def test_resume_state_on_host_boot_no_reboot_2(self): """Don't call reboot on instance which is suspended.""" self._create_vm() self.mox.StubOutWithMock(vm_util, "get_vm_state_from_name") self.mox.StubOutWithMock(self.conn, "reboot") vm_util.get_vm_state_from_name(mox.IgnoreArg(), self.instance["uuid"]).AndReturn("suspended") self.mox.ReplayAll() self.conn.resume_state_on_host_boot(self.context, self.instance, "network_info")
def test_resume_state_on_host_boot(self): self._create_vm() self.mox.StubOutWithMock(vm_util, "get_vm_state_from_name") self.mox.StubOutWithMock(self.conn, "reboot") vm_util.get_vm_state_from_name(mox.IgnoreArg(), self.instance["uuid"]).AndReturn("poweredOff") self.conn.reboot(self.context, self.instance, "network_info", "hard", None) self.mox.ReplayAll() self.conn.resume_state_on_host_boot(self.context, self.instance, "network_info")
def test_resume_state_on_host_boot_no_reboot_1(self): """Don't call reboot on instance which is poweredon.""" self._create_vm() self.mox.StubOutWithMock(vm_util, 'get_vm_state_from_name') self.mox.StubOutWithMock(self.conn, 'reboot') vm_util.get_vm_state_from_name(mox.IgnoreArg(), self.instance['uuid']).AndReturn("poweredOn") self.mox.ReplayAll() self.conn.resume_state_on_host_boot(self.context, self.instance, 'network_info')
def resume_state_on_host_boot(self, context, instance, network_info, block_device_info=None): """resume guest state when a host is booted.""" # Check if the instance is running already and avoid doing # anything if it is. instances = self.list_instances() if instance["uuid"] not in instances: LOG.warn(_("Instance cannot be found in host, or in an unknown" "state."), instance=instance) else: state = vm_util.get_vm_state_from_name(self._session, instance["uuid"]) ignored_states = ["poweredon", "suspended"] if state.lower() in ignored_states: return # Instance is not up and could be in an unknown state. # Be as absolute as possible about getting it back into # a known and running state. self.reboot(context, instance, network_info, "hard", block_device_info)
def resume_state_on_host_boot(self, context, instance, network_info, block_device_info=None): """resume guest state when a host is booted.""" # Check if the instance is running already and avoid doing # anything if it is. instances = self.list_instances() if instance['uuid'] not in instances: LOG.warn(_LW('Instance cannot be found in host, or in an unknown' 'state.'), instance=instance) else: state = vm_util.get_vm_state_from_name(self._session, instance['uuid']) ignored_states = ['poweredon', 'suspended'] if state.lower() in ignored_states: return # Instance is not up and could be in an unknown state. # Be as absolute as possible about getting it back into # a known and running state. self.reboot(context, instance, network_info, 'hard', block_device_info)