summaryrefslogtreecommitdiffstats
path: root/hammer.py
diff options
context:
space:
mode:
authorMichal Nowikowski <godfryd@isc.org>2019-04-14 07:26:50 +0200
committerMichal Nowikowski <godfryd@isc.org>2019-05-16 12:53:29 +0200
commitbe42fe414fccbf4e020138a52d0763c466fbcb9a (patch)
tree04faa4125129fa212cda9dbbe9b2646c3179897e /hammer.py
parentimproved support for building native packages: rpm and deb (diff)
downloadkea-be42fe414fccbf4e020138a52d0763c466fbcb9a.tar.xz
kea-be42fe414fccbf4e020138a52d0763c466fbcb9a.zip
fixed bringing up lxc container when there is conflicting one present
Diffstat (limited to 'hammer.py')
-rwxr-xr-xhammer.py21
1 files changed, 18 insertions, 3 deletions
diff --git a/hammer.py b/hammer.py
index 66518e6566..6718862084 100755
--- a/hammer.py
+++ b/hammer.py
@@ -52,7 +52,7 @@ SYSTEMS = {
IMAGE_TEMPLATES = {
'fedora-27-lxc': {'bare': 'lxc-fedora-27', 'kea': 'godfryd/kea-fedora-27'},
'fedora-27-virtualbox': {'bare': 'generic/fedora27', 'kea': 'godfryd/kea-fedora-27'},
- 'fedora-28-lxc': {'bare': 'lxc-fedora-28', 'kea': 'godfryd/kea-fedora-28'},
+ 'fedora-28-lxc': {'bare': 'godfryd/lxc-fedora-28', 'kea': 'godfryd/kea-fedora-28'},
'fedora-28-virtualbox': {'bare': 'generic/fedora28', 'kea': 'godfryd/kea-fedora-28'},
'fedora-29-lxc': {'bare': 'godfryd/lxc-fedora-29', 'kea': 'godfryd/kea-fedora-29'},
'fedora-29-virtualbox': {'bare': 'generic/fedora29', 'kea': 'godfryd/kea-fedora-29'},
@@ -446,8 +446,23 @@ class VagrantEnv(object):
def up(self):
"""Do Vagrant up."""
- execute("vagrant up --no-provision --provider %s" % self.provider,
- cwd=self.vagrant_dir, timeout=15 * 60, dry_run=self.dry_run)
+ exitcode, out = execute("vagrant up --no-provision --provider %s" % self.provider,
+ cwd=self.vagrant_dir, timeout=15 * 60, dry_run=self.dry_run,
+ capture=True, raise_error=False)
+ if exitcode != 0:
+ if 'There is container on your system' in out and 'lxc-destroy' in out:
+ m = re.search('`lxc-destroy.*?`', out)
+ if m:
+ # destroy some old container
+ cmd = m.group(0)[1:-1]
+ cmd = 'sudo ' + cmd + ' -f'
+ execute(cmd, timeout=60)
+
+ # try again spinning up new
+ execute("vagrant up --no-provision --provider %s" % self.provider,
+ cwd=self.vagrant_dir, timeout=15 * 60, dry_run=self.dry_run)
+ return
+ raise ExecutionError('There is a problem with putting up a system')
def _get_cloud_meta(self, image_tpl=None):
if '/' not in self.image_tpl: