Add soft off/reboot support
As ironic has supported soft power off and reboot for a while, we should add these as well. Note: ssh driver does not support this. Change-Id: I41fb159ca584ebe0ad23fe4a5fbd8be14295b9b8
This commit is contained in:
parent
374de173c7
commit
3036689e2d
|
@ -250,7 +250,8 @@ power_state:
|
|||
type: string
|
||||
power_state_target:
|
||||
description: |
|
||||
This field represents the requested state either "on", "off", or "reboot".
|
||||
This field represents the requested state either "on", "off", "soft_off",
|
||||
"reboot", or "soft_reboot".
|
||||
in: body
|
||||
required: true
|
||||
type: string
|
||||
|
|
|
@ -110,7 +110,7 @@ class InstanceStatesController(InstanceControllerBase):
|
|||
state is not valid or if the instance is in CLEANING state.
|
||||
|
||||
"""
|
||||
if target not in ["on", "off", "reboot"]:
|
||||
if target not in ["on", "off", "reboot", "soft_off", "soft_reboot"]:
|
||||
# ironic will throw InvalidStateRequested
|
||||
raise exception.InvalidActionParameterValue(
|
||||
value=target, action="power",
|
||||
|
|
|
@ -97,9 +97,15 @@ instance_policies = [
|
|||
policy.RuleDefault('mogan:instance:set_power_state:off',
|
||||
'rule:default',
|
||||
description='Stop an instance'),
|
||||
policy.RuleDefault('mogan:instance:set_power_state:soft_off',
|
||||
'rule:default',
|
||||
description='Soft stop an instance'),
|
||||
policy.RuleDefault('mogan:instance:set_power_state:reboot',
|
||||
'rule:default',
|
||||
description='Reboot an instance'),
|
||||
policy.RuleDefault('mogan:instance:set_power_state:soft_reboot',
|
||||
'rule:default',
|
||||
description='Soft reboot an instance'),
|
||||
policy.RuleDefault('mogan:instance:get_networks',
|
||||
'rule:default',
|
||||
description='Get Instance network information'),
|
||||
|
|
|
@ -43,7 +43,9 @@ NOSTATE = None
|
|||
POWER_ACTION_MAP = {
|
||||
'on': 'start',
|
||||
'off': 'stop',
|
||||
'soft_off': 'soft_stop',
|
||||
'reboot': 'reboot',
|
||||
'soft_reboot': 'soft_reboot',
|
||||
}
|
||||
|
||||
|
||||
|
@ -80,9 +82,15 @@ POWERING_ON = 'powering-on'
|
|||
POWERING_OFF = 'powering-off'
|
||||
""" The server is in powering off """
|
||||
|
||||
SOFT_POWERING_OFF = 'soft-powering-off'
|
||||
""" The server is in soft powering off """
|
||||
|
||||
REBOOTING = 'rebooting'
|
||||
""" The server is in rebooting """
|
||||
|
||||
SOFT_REBOOTING = 'soft-rebooting'
|
||||
""" The server is in soft rebooting """
|
||||
|
||||
STOPPED = 'stopped'
|
||||
""" The server is powered off """
|
||||
|
||||
|
@ -92,7 +100,8 @@ REBUILDING = 'rebuilding'
|
|||
STABLE_STATES = (ACTIVE, ERROR, DELETED, STOPPED)
|
||||
"""States that will not transition unless receiving a request."""
|
||||
|
||||
UNSTABLE_STATES = (BUILDING, DELETING, POWERING_ON, POWERING_OFF, REBOOTING,
|
||||
UNSTABLE_STATES = (BUILDING, DELETING, POWERING_ON, POWERING_OFF,
|
||||
SOFT_POWERING_OFF, REBOOTING, SOFT_REBOOTING,
|
||||
REBUILDING)
|
||||
"""States that can be changed without external request."""
|
||||
|
||||
|
@ -136,15 +145,19 @@ machine.add_state(POWERING_ON, target=ACTIVE, **watchers)
|
|||
|
||||
# Add power off* states
|
||||
machine.add_state(POWERING_OFF, target=STOPPED, **watchers)
|
||||
machine.add_state(SOFT_POWERING_OFF, target=STOPPED, **watchers)
|
||||
|
||||
# Add reboot* states
|
||||
machine.add_state(REBOOTING, target=ACTIVE, **watchers)
|
||||
machine.add_state(SOFT_REBOOTING, target=ACTIVE, **watchers)
|
||||
|
||||
|
||||
# from active* states
|
||||
machine.add_transition(ACTIVE, REBUILDING, 'rebuild')
|
||||
machine.add_transition(ACTIVE, POWERING_OFF, 'stop')
|
||||
machine.add_transition(ACTIVE, SOFT_POWERING_OFF, 'soft_stop')
|
||||
machine.add_transition(ACTIVE, REBOOTING, 'reboot')
|
||||
machine.add_transition(ACTIVE, SOFT_REBOOTING, 'soft_reboot')
|
||||
machine.add_transition(ACTIVE, DELETING, 'delete')
|
||||
|
||||
# from stopped* states
|
||||
|
@ -161,7 +174,9 @@ machine.add_transition(DELETING, DELETED, 'done')
|
|||
machine.add_transition(REBUILDING, ACTIVE, 'done')
|
||||
machine.add_transition(POWERING_ON, ACTIVE, 'done')
|
||||
machine.add_transition(POWERING_OFF, STOPPED, 'done')
|
||||
machine.add_transition(SOFT_POWERING_OFF, STOPPED, 'done')
|
||||
machine.add_transition(REBOOTING, ACTIVE, 'done')
|
||||
machine.add_transition(SOFT_REBOOTING, ACTIVE, 'done')
|
||||
|
||||
# All unstable states are allowed to transition to ERROR and DELETING
|
||||
for state in UNSTABLE_STATES:
|
||||
|
|
|
@ -187,4 +187,11 @@ def get_portgroup_list(ironicclient, **kwargs):
|
|||
|
||||
|
||||
def set_power_state(ironicclient, node_uuid, state):
|
||||
ironicclient.call("node.set_power_state", node_uuid, state)
|
||||
if state == "soft_off":
|
||||
ironicclient.call("node.set_power_state",
|
||||
node_uuid, "off", soft=True)
|
||||
elif state == "soft_reboot":
|
||||
ironicclient.call("node.set_power_state",
|
||||
node_uuid, "reboot", soft=True)
|
||||
else:
|
||||
ironicclient.call("node.set_power_state", node_uuid, state)
|
||||
|
|
|
@ -145,6 +145,12 @@ POWER_OFF = 'power off'
|
|||
REBOOT = 'rebooting'
|
||||
""" Node is rebooting. """
|
||||
|
||||
SOFT_REBOOT = 'soft rebooting'
|
||||
""" Node is rebooting gracefully. """
|
||||
|
||||
SOFT_POWER_OFF = 'soft power off'
|
||||
""" Node is in the process of soft power off. """
|
||||
|
||||
##################
|
||||
# Helper constants
|
||||
##################
|
||||
|
|
Loading…
Reference in New Issue