From: Royce Lv <lvroyce(a)linux.vnet.ibm.com>
Add model test to validate cdrom create, get list,
and get detailed attribute.
Signed-off-by: Royce Lv <lvroyce(a)linux.vnet.ibm.com>
---
tests/test_model.py | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/tests/test_model.py b/tests/test_model.py
index c689bcc..06ffb3e 100644
--- a/tests/test_model.py
+++ b/tests/test_model.py
@@ -71,6 +71,35 @@ class ModelTests(unittest.TestCase):
self.assertRaises(NotFoundError, inst.vm_lookup, 'nosuchvm')
@unittest.skipUnless(utils.running_as_root(), 'Must be run as root')
+ def test_vm_cdrom(self):
+ inst = kimchi.model.Model(objstore_loc=self.tmp_store)
+
+ with RollbackContext() as rollback:
+ params = {'name': 'test', 'disks': []}
+ inst.templates_create(params)
+ rollback.prependDefer(inst.template_delete, 'test')
+
+ params = {'name': 'kimchi-vm', 'template':
'/templates/test'}
+ inst.vms_create(params)
+ rollback.prependDefer(inst.vm_delete, 'kimchi-vm')
+
+ vms = inst.vms_get_list()
+ self.assertTrue('kimchi-vm' in vms)
+
+ path = '/tmp/kimchi-images/tmpdir'
+ if not os.path.exists(path):
+ os.makedirs(path)
+
+ iso = '/tmp/kimchi-images/tmpdir/ubuntu12.04.iso'
+ iso_gen.construct_fake_iso(iso, True, '12.04', 'ubuntu')
+ param = dict(name='hde', path=iso)
+ inst.cdroms_create('kimchi-vm', dict(name='hde', path=iso))
+ info = inst.cdroms_get_list('kimchi-vm')
+ self.assertIn('hde', info)
+ info = inst.cdrom_lookup('kimchi-vm', 'hde')
+ self.assertEqual(info['path'], iso)
+
+ @unittest.skipUnless(utils.running_as_root(), 'Must be run as root')
def test_vm_lifecycle(self):
inst = kimchi.model.Model(objstore_loc=self.tmp_store)
--
1.8.1.2