]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
hammer: added checking vagrant version, removed hammer from EXTRA_DIST
authorMichal Nowikowski <godfryd@isc.org>
Mon, 4 Mar 2019 10:36:57 +0000 (11:36 +0100)
committerMichal Nowikowski <godfryd@isc.org>
Tue, 5 Mar 2019 05:32:00 +0000 (06:32 +0100)
Makefile.am
hammer.py

index 4f364e7672727662c24b63f65b6be545e9c412af..3adb68f82ed730611c6723bdf5a93e2d609bcde9 100644 (file)
@@ -157,9 +157,6 @@ EXTRA_DIST += tools/mk_cfgrpt.sh
 #### include external sources in the distributed tarball:
 EXTRA_DIST += ext/coroutine/coroutine.hpp
 
-# Add Hammer
-EXTRA_DIST += hammer.py
-
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = dns++.pc
 
index 41f417508036fca517a03cfd66b5a31ea69842f1..1604e10d46ada827bf31b44011d011e8a1daf666 100755 (executable)
--- a/hammer.py
+++ b/hammer.py
@@ -9,6 +9,7 @@
 
 from __future__ import print_function
 import os
+import re
 import sys
 import glob
 import time
@@ -1204,27 +1205,46 @@ def ssh(provider, system, revision):
     ve.ssh()
 
 
-def ensure_hammer_deps():
-    """Install Hammer dependencies onto current, host system."""
+def _install_vagrant(ver='2.2.4', upgrade=False):
     system, _ = get_system_revision()
+    if system in ['fedora', 'centos', 'rhel']:
+        if upgrade:
+            execute('sudo rpm -e vagrant')
+        rpm = 'vagrant_%s_x86_64.rpm' % ver
+        cmd = 'wget --no-verbose -O /tmp/%s ' % rpm
+        cmd += 'https://releases.hashicorp.com/vagrant/%s/%s' % (ver, rpm)
+        execute(cmd)
+        execute('sudo rpm -i /tmp/%s' % rpm)
+        os.unlink('/tmp/%s' % rpm)
+    elif system in ['debian', 'ubuntu']:
+        if upgrade:
+            execute('sudo dpkg --purge vagrant')
+        deb = 'vagrant_%s_x86_64.deb' % ver
+        cmd = 'wget --no-verbose -O /tmp/%s ' % deb
+        cmd += 'https://releases.hashicorp.com/vagrant/%s/%s' % (ver, deb)
+        execute(cmd)
+        execute('sudo dpkg -i /tmp/%s' % deb)
+        os.unlink('/tmp/%s' % deb)
+    else:
+        # TODO: check for packages here: https://www.vagrantup.com/downloads.html
+        raise NotImplementedError
+
 
-    exitcode = execute('vagrant version', raise_error=False)
+def ensure_hammer_deps():
+    """Install Hammer dependencies onto current, host system."""
+    exitcode, out = execute('vagrant version', raise_error=False, capture=True)
     if exitcode != 0:
-        if system in ['fedora', 'centos', 'rhel']:
-            cmd = 'wget --no-verbose -O /tmp/vagrant_2.2.2_x86_64.rpm '
-            cmd += 'https://releases.hashicorp.com/vagrant/2.2.2/vagrant_2.2.2_x86_64.rpm'
-            execute(cmd)
-            execute('sudo rpm -i /tmp/vagrant_2.2.2_x86_64.rpm')
-            os.unlink('/tmp/vagrant_2.2.2_x86_64.rpm')
-        elif system in ['debian', 'ubuntu']:
-            cmd = 'wget --no-verbose -O /tmp/vagrant_2.2.2_x86_64.deb '
-            cmd += 'https://releases.hashicorp.com/vagrant/2.2.2/vagrant_2.2.2_x86_64.deb'
-            execute(cmd)
-            execute('sudo dpkg -i /tmp/vagrant_2.2.2_x86_64.deb')
-            os.unlink('/tmp/vagrant_2.2.2_x86_64.deb')
-        else:
-            # TODO: check for packages here: https://www.vagrantup.com/downloads.html
-            raise NotImplementedError
+        _install_vagrant()
+    else:
+        m = re.search('Installed Version: ([\d\.]+)', out, re.I)
+        ver = m.group(1)
+        major, minor, patch = [int(v) for v in ver.split('.')]
+        # if ver < 2.2.3
+        if major < 2 or (major == 2 and (minor < 2 or (minor == 2 and patch < 3))):
+            m = re.search('Latest Version: ([\d\.]+)', out, re.I)
+            ver = m.group(1)
+            _install_vagrant(ver, upgrade=True)
+
 
     exitcode = execute('vagrant plugin list | grep vagrant-lxc', raise_error=False)
     if exitcode != 0: