[Kimchi-devel] [PATCH V4 2/7] template supports networks: fix test case
shaohef at linux.vnet.ibm.com
shaohef at linux.vnet.ibm.com
Tue Dec 31 12:49:34 UTC 2013
From: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
after template supports networks, we should change the test case accordingly
Signed-off-by: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
---
src/kimchi/model.py | 19 +++++++++----------
tests/test_osinfo.py | 2 +-
tests/test_vmtemplate.py | 6 +++---
3 files changed, 13 insertions(+), 14 deletions(-)
diff --git a/src/kimchi/model.py b/src/kimchi/model.py
index a6790b8..572b316 100644
--- a/src/kimchi/model.py
+++ b/src/kimchi/model.py
@@ -1374,16 +1374,15 @@ class LibvirtVMTemplate(VMTemplate):
return pool
def _network_validate(self):
- name = self.info['network']
- try:
- conn = self.conn.get()
- network = conn.networkLookupByName(name)
- except libvirt.libvirtError:
- raise InvalidParameter('Network specified by template does not exist')
- if not network.isActive():
- raise InvalidParameter('Storage specified by template is not active')
-
- return network
+ names = self.info['networks']
+ for name in names:
+ try:
+ conn = self.conn.get()
+ network = conn.networkLookupByName(name)
+ except libvirt.libvirtError:
+ raise InvalidParameter('Network specified by template does not exist')
+ if not network.isActive():
+ raise InvalidParameter('Network specified by template is not active')
def _get_storage_path(self):
pool = self._storage_validate()
diff --git a/tests/test_osinfo.py b/tests/test_osinfo.py
index fda8ada..69fdaf9 100644
--- a/tests/test_osinfo.py
+++ b/tests/test_osinfo.py
@@ -32,7 +32,7 @@ class OSInfoTests(unittest.TestCase):
self.assertEquals(name, 'unknown')
self.assertEquals('unknown', entry['os_distro'])
self.assertEquals('unknown', entry['os_version'])
- self.assertEquals('default', entry['network'])
+ self.assertEquals(['default'], entry['networks'])
def test_fedora_lookup(self):
cd = 'http://fedora.mirrors.tds.net/pub/fedora/releases/17/Live/x86_64/Fedora-17-x86_64-Live-Desktop.iso'
diff --git a/tests/test_vmtemplate.py b/tests/test_vmtemplate.py
index 7f032e7..dc9c0ef 100644
--- a/tests/test_vmtemplate.py
+++ b/tests/test_vmtemplate.py
@@ -32,7 +32,7 @@ class VMTemplateTests(unittest.TestCase):
def test_minimal_construct(self):
fields = (('name', 'test'), ('os_distro', 'unknown'),
('os_version', 'unknown'), ('cpus', 1),
- ('memory', 1024), ('cdrom', ''), ('network', 'default'),
+ ('memory', 1024), ('cdrom', ''), ('networks', ['default']),
('disk_bus', 'ide'), ('nic_model', 'e1000'))
args = {'name': 'test'}
@@ -58,10 +58,10 @@ class VMTemplateTests(unittest.TestCase):
provided parameters.
"""
args = {'name': 'test', 'os_distro': 'opensuse', 'os_version': '12.3',
- 'cpus': 2, 'memory': 2048, 'network': 'foo',
+ 'cpus': 2, 'memory': 2048, 'networks': ['foo'],
'cdrom': '/cd.iso'}
t = VMTemplate(args)
self.assertEquals(2, t.info.get('cpus'))
self.assertEquals(2048, t.info.get('memory'))
- self.assertEquals('foo', t.info.get('network'))
+ self.assertEquals(['foo'], t.info.get('networks'))
self.assertEquals('/cd.iso', t.info.get('cdrom'))
--
1.8.4.2
More information about the Kimchi-devel
mailing list