def test_wait_for_instance_to_start(self): instance = {"uuid": "uuid"} vm_ref = "vm_ref" self.mox.StubOutWithMock(vm_utils, "get_power_state") self.mox.StubOutWithMock(greenthread, "sleep") vm_utils.get_power_state(self._session, vm_ref).AndReturn(power_state.SHUTDOWN) greenthread.sleep(0.5) vm_utils.get_power_state(self._session, vm_ref).AndReturn(power_state.RUNNING) self.mox.ReplayAll() self.vmops._wait_for_instance_to_start(instance, vm_ref)
def test_wait_for_instance_to_start(self): instance = {"uuid": "uuid"} vm_ref = "vm_ref" self.mox.StubOutWithMock(vm_utils, 'get_power_state') self.mox.StubOutWithMock(greenthread, 'sleep') vm_utils.get_power_state(self._session, vm_ref).AndReturn(power_state.SHUTDOWN) greenthread.sleep(0.5) vm_utils.get_power_state(self._session, vm_ref).AndReturn(power_state.RUNNING) self.mox.ReplayAll() self.vmops._wait_for_instance_to_start(instance, vm_ref)
def hot_unplug(self, vif, instance, vm_ref, vif_ref): # hot unplug vif only when VM's power state is running LOG.debug("Hot unplug vif, vif: %s", vif, instance=instance) state = vm_utils.get_power_state(self._session, vm_ref) if state != power_state.RUNNING: LOG.debug("Skip hot unplug VIF, VM is not running, vif: %s", vif, instance=instance) return self._session.VIF.unplug(vif_ref)
def hot_unplug(self, vif, instance, vm_ref, vif_ref): # hot unplug vif only when VM's power state is running LOG.debug("Hot unplug vif, vif: %s", vif, instance=instance) state = vm_utils.get_power_state(self._session, vm_ref) if state != power_state.RUNNING: LOG.debug("Skip hot unplug VIF, VM is not running, vif: %s", vif, instance=instance) return self._session.VIF.unplug(vif_ref)