summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorBob Ball <bob.ball@citrix.com>2013-03-19 14:12:29 +0000
committerBob Ball <bob.ball@citrix.com>2013-03-25 09:39:33 +0000
commit90cda3512ae509d548bf2b4343ce0d8b8b9bfb43 (patch)
treebd567c209717b9061c0794dca44d4c531fdc8eac /nova/tests
parentdb8dfce9516957c445583015bb983ae4ebbc6d9d (diff)
xenapi: Retrieve VM uuid from xenstore.
Fall back to retrieving the uuid from xenstore if /sys/hypervisor/uuid isn't accessible. Change-Id: I409079068d3102ff86a71431b29c1ce2e6fe8857 Fixes: bug #1157211
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/virt/xenapi/test_vm_utils.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/nova/tests/virt/xenapi/test_vm_utils.py b/nova/tests/virt/xenapi/test_vm_utils.py
index f757a57ad..d42ed7629 100644
--- a/nova/tests/virt/xenapi/test_vm_utils.py
+++ b/nova/tests/virt/xenapi/test_vm_utils.py
@@ -85,3 +85,33 @@ class GenerateConfigDriveTestCase(test.TestCase):
# And the actual call we're testing
vm_utils.generate_configdrive('session', instance, 'vm_ref',
'userdevice')
+
+
+class XenAPIGetUUID(test.TestCase):
+ def test_get_this_vm_uuid_new_kernel(self):
+ self.mox.StubOutWithMock(vm_utils, '_get_sys_hypervisor_uuid')
+
+ vm_utils._get_sys_hypervisor_uuid().AndReturn(
+ '2f46f0f5-f14c-ef1b-1fac-9eeca0888a3f')
+
+ self.mox.ReplayAll()
+ self.assertEquals('2f46f0f5-f14c-ef1b-1fac-9eeca0888a3f',
+ vm_utils.get_this_vm_uuid())
+ self.mox.VerifyAll()
+
+ def test_get_this_vm_uuid_old_kernel_reboot(self):
+ self.mox.StubOutWithMock(vm_utils, '_get_sys_hypervisor_uuid')
+ self.mox.StubOutWithMock(utils, 'execute')
+
+ vm_utils._get_sys_hypervisor_uuid().AndRaise(
+ IOError(13, 'Permission denied'))
+ utils.execute('xenstore-read', 'domid', run_as_root=True).AndReturn(
+ ('27', ''))
+ utils.execute('xenstore-read', '/local/domain/27/vm',
+ run_as_root=True).AndReturn(
+ ('/vm/2f46f0f5-f14c-ef1b-1fac-9eeca0888a3f', ''))
+
+ self.mox.ReplayAll()
+ self.assertEquals('2f46f0f5-f14c-ef1b-1fac-9eeca0888a3f',
+ vm_utils.get_this_vm_uuid())
+ self.mox.VerifyAll()