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_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()
def _create_slave_info(self): """XenServer specific info needed to join the hypervisor pool.""" # replace the address from the xenapi connection url # because this might be 169.254.0.1, i.e. xenapi # NOTE: password in clear is not great, but it'll do for now sender_url = swap_xapi_host(CONF.xenserver.connection_url, self._host_addr) return { "url": sender_url, "user": CONF.xenserver.connection_username, "passwd": CONF.xenserver.connection_password, "compute_uuid": vm_utils.get_this_vm_uuid(None), "xenhost_uuid": self._host_uuid, }
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()
def forward_request(context, request_type, master, aggregate_id, slave_compute, slave_address, slave_uuid): """Casts add/remove requests to the pool master.""" # replace the address from the xenapi connection url # because this might be 169.254.0.1, i.e. xenapi # NOTE: password in clear is not great, but it'll do for now sender_url = swap_xapi_host(FLAGS.xenapi_connection_url, slave_address) rpc.cast(context, rpc.queue_get_for(context, FLAGS.compute_topic, master), {"method": request_type, "args": {"aggregate_id": aggregate_id, "host": slave_compute, "url": sender_url, "user": FLAGS.xenapi_connection_username, "passwd": FLAGS.xenapi_connection_password, "compute_uuid": vm_utils.get_this_vm_uuid(), "xenhost_uuid": slave_uuid, }, })