Add 'suspended' lifecycle event
Hyper-V can emit events signaling that an instance was suspended. The issue is that at the moment, there is no lifecycle event defined for this instance state in nova.virt.event. This patch adds this lifecycle event and ensures that the manager will properly handle it. Partially fixes bug: #1428505 Change-Id: I0fad28025785e77ef32b88ff813f39000d9f9e35
This commit is contained in:
parent
430c92e3cd
commit
4720be6f29
|
@ -1184,6 +1184,8 @@ class ComputeManager(manager.Manager):
|
|||
vm_power_state = power_state.PAUSED
|
||||
elif event.get_transition() == virtevent.EVENT_LIFECYCLE_RESUMED:
|
||||
vm_power_state = power_state.RUNNING
|
||||
elif event.get_transition() == virtevent.EVENT_LIFECYCLE_SUSPENDED:
|
||||
vm_power_state = power_state.SUSPENDED
|
||||
else:
|
||||
LOG.warning(_LW("Unexpected power state %d"),
|
||||
event.get_transition())
|
||||
|
|
|
@ -72,7 +72,10 @@ class ComputeManagerUnitTestCase(test.NoDBTestCase):
|
|||
event_map = {virtevent.EVENT_LIFECYCLE_STOPPED: power_state.SHUTDOWN,
|
||||
virtevent.EVENT_LIFECYCLE_STARTED: power_state.RUNNING,
|
||||
virtevent.EVENT_LIFECYCLE_PAUSED: power_state.PAUSED,
|
||||
virtevent.EVENT_LIFECYCLE_RESUMED: power_state.RUNNING}
|
||||
virtevent.EVENT_LIFECYCLE_RESUMED: power_state.RUNNING,
|
||||
virtevent.EVENT_LIFECYCLE_SUSPENDED:
|
||||
power_state.SUSPENDED,
|
||||
}
|
||||
event = mock.Mock()
|
||||
event.get_instance_uuid.return_value = mock.sentinel.uuid
|
||||
for transition, pwr_state in event_map.iteritems():
|
||||
|
|
|
@ -28,12 +28,14 @@ EVENT_LIFECYCLE_STARTED = 0
|
|||
EVENT_LIFECYCLE_STOPPED = 1
|
||||
EVENT_LIFECYCLE_PAUSED = 2
|
||||
EVENT_LIFECYCLE_RESUMED = 3
|
||||
EVENT_LIFECYCLE_SUSPENDED = 4
|
||||
|
||||
NAMES = {
|
||||
EVENT_LIFECYCLE_STARTED: _('Started'),
|
||||
EVENT_LIFECYCLE_STOPPED: _('Stopped'),
|
||||
EVENT_LIFECYCLE_PAUSED: _('Paused'),
|
||||
EVENT_LIFECYCLE_RESUMED: _('Resumed')
|
||||
EVENT_LIFECYCLE_RESUMED: _('Resumed'),
|
||||
EVENT_LIFECYCLE_SUSPENDED: _('Suspended'),
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue