From 7ef981e91928db3e74b7fa8363af4122a3231e6f Mon Sep 17 00:00:00 2001 From: Jan Scotka Date: Thu, 19 Mar 2015 14:57:09 +0100 Subject: [PATCH 1/4] better image table handling --- virtdeploy/drivers/libvirt.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) mode change 100644 => 100755 virtdeploy/drivers/libvirt.py diff --git a/virtdeploy/drivers/libvirt.py b/virtdeploy/drivers/libvirt.py old mode 100644 new mode 100755 index 74c48d0..55338ed --- a/virtdeploy/drivers/libvirt.py +++ b/virtdeploy/drivers/libvirt.py @@ -245,10 +245,16 @@ def instance_delete(self, vmid): def _get_image_os(image): - try: + if image in _IMAGE_OS_TABLE: return _IMAGE_OS_TABLE[image] - except KeyError: + stdout, _ = execute(('osinfo-query', '--fields=short-id', 'os'), stdout=subprocess.PIPE) + stdtable=stdout.split() + if image.replace('-', '') in stdtable: return image.replace('-', '') + if image in stdtable: + return image + else + return "fedora20" def _create_base(template, arch, repository): From 109d89eeb3be6011147169c34336e57c7ba38cd5 Mon Sep 17 00:00:00 2001 From: Jan Scotka Date: Thu, 19 Mar 2015 15:25:08 +0100 Subject: [PATCH 2/4] missing : after else --- virtdeploy/drivers/libvirt.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virtdeploy/drivers/libvirt.py b/virtdeploy/drivers/libvirt.py index 55338ed..a17c6f8 100755 --- a/virtdeploy/drivers/libvirt.py +++ b/virtdeploy/drivers/libvirt.py @@ -253,7 +253,7 @@ def _get_image_os(image): return image.replace('-', '') if image in stdtable: return image - else + else: return "fedora20" From 2e41e5110ff10c08c6ddad4dbe61cbdf1e5705dc Mon Sep 17 00:00:00 2001 From: Jan Scotka Date: Thu, 19 Mar 2015 15:28:03 +0100 Subject: [PATCH 3/4] cleaning against https://travis-ci.org/simon3z/virt-deploy/jobs/55027342 --- virtdeploy/drivers/libvirt.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/virtdeploy/drivers/libvirt.py b/virtdeploy/drivers/libvirt.py index a17c6f8..5d348e6 100755 --- a/virtdeploy/drivers/libvirt.py +++ b/virtdeploy/drivers/libvirt.py @@ -247,7 +247,8 @@ def instance_delete(self, vmid): def _get_image_os(image): if image in _IMAGE_OS_TABLE: return _IMAGE_OS_TABLE[image] - stdout, _ = execute(('osinfo-query', '--fields=short-id', 'os'), stdout=subprocess.PIPE) + stdout, _ = execute(('osinfo-query', '--fields=short-id', 'os'), + stdout=subprocess.PIPE) stdtable=stdout.split() if image.replace('-', '') in stdtable: return image.replace('-', '') From b593fc025f2c3a3fa97836af1908eb66ab228d82 Mon Sep 17 00:00:00 2001 From: Jan Scotka Date: Thu, 19 Mar 2015 15:34:57 +0100 Subject: [PATCH 4/4] added dependency to .tox file --- tox.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/tox.ini b/tox.ini index 4e8030f..4e7f05b 100644 --- a/tox.ini +++ b/tox.ini @@ -7,6 +7,7 @@ deps = lxml mock netaddr + libosinfo commands = python -m unittest discover