[Kimchi-devel] [PATCH v3] Does not list non-bootable images

Ramon Medeiros ramonn at linux.vnet.ibm.com
Mon Jun 1 17:29:59 UTC 2015


Also fix tests that were using non-bootable isos.

Signed-off-by: Ramon Medeiros <ramonn at linux.vnet.ibm.com>

Changes:

v3:
Fix errors listed by make check-local

v2:
Fix tests that were listing non-bootable isos


---
 src/kimchi/model/storagevolumes.py |  2 +-
 tests/test_rest.py                 | 13 ++++++++-----
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/src/kimchi/model/storagevolumes.py b/src/kimchi/model/storagevolumes.py
index 9165946..4cc3a0d 100644
--- a/src/kimchi/model/storagevolumes.py
+++ b/src/kimchi/model/storagevolumes.py
@@ -527,7 +527,7 @@ class IsoVolumesModel(object):
             for volume in volumes:
                 res = self.storagevolume.lookup(pool_name,
                                                 volume.decode("utf-8"))
-                if res['format'] == 'iso':
+                if res['format'] == 'iso' and res['bootable']:
                     res['name'] = '%s' % volume
                     iso_volumes.append(res)
         return iso_volumes
diff --git a/tests/test_rest.py b/tests/test_rest.py
index 72ff14f..7fe6831 100644
--- a/tests/test_rest.py
+++ b/tests/test_rest.py
@@ -61,12 +61,15 @@ def setUpModule():
 
     # Create fake ISO to do the tests
     iso_gen.construct_fake_iso(fake_iso, True, '12.04', 'ubuntu')
+    iso_gen.construct_fake_iso("/var/lib/libvirt/images/fedora.iso", True,
+                               "17", "fedora")
 
 
 def tearDownModule():
     test_server.stop()
     os.unlink('/tmp/obj-store-test')
     os.unlink(fake_iso)
+    os.unlink("/var/lib/libvirt/images/fedora.iso")
 
 
 class RestTests(unittest.TestCase):
@@ -928,9 +931,9 @@ class RestTests(unittest.TestCase):
                           storagevolume['path'])
         self.assertEquals(1073741824, storagevolume['capacity'])  # 1 GiB
         self.assertEquals(0, storagevolume['allocation'])
-        self.assertEquals('unknown', storagevolume['os_version'])
-        self.assertEquals('unknown', storagevolume['os_distro'])
-        self.assertEquals(False, storagevolume['bootable'])
+        self.assertEquals('17', storagevolume['os_version'])
+        self.assertEquals('fedora', storagevolume['os_distro'])
+        self.assertEquals(True, storagevolume['bootable'])
 
         # Create a template
         # In real model os distro/version can be omitted
@@ -945,8 +948,8 @@ class RestTests(unittest.TestCase):
         # Verify the template
         t = json.loads(self.request('/templates/test').read())
         self.assertEquals('test', t['name'])
-        self.assertEquals('unknown', t['os_distro'])
-        self.assertEquals('unknown', t['os_version'])
+        self.assertEquals('fedora', t['os_distro'])
+        self.assertEquals('17', t['os_version'])
         self.assertEquals(get_template_default('old', 'memory'), t['memory'])
 
         # Deactivate or destroy scan pool return 405
-- 
2.1.0




More information about the Kimchi-devel mailing list