defget_supported_power_states(self,task):"""Get a list of the supported power states. :param task: A TaskManager instance containing the node to act on. :returns: A list of the supported power states defined in :mod:`ironic.common.states`. """return[states.POWER_ON,states.POWER_OFF,states.REBOOT]
@abc.abstractmethoddefset_power_state(self,task,power_state,timeout=None):"""Set the power state of the task's node. :param task: a TaskManager instance containing the node to act on. :param power_state: Any power state from :mod:`ironic.common.states`. :param timeout: timeout positive integer (> 0) for any power state. ``None`` indicates to use default timeout which depends on ``power_state``[*]_ and driver. :raises: MissingParameterValue if a required parameter is missing. """
defget_supported_power_states(self,task):"""Get a list of the supported power states. :param task: A TaskManager instance containing the node to act on. currently not used. :returns: A list of the supported power states defined in :mod:`ironic.common.states`. """return[states.POWER_ON,states.POWER_OFF,states.REBOOT,states.SOFT_REBOOT,states.SOFT_POWER_OFF]
@abc.abstractmethoddefinject_nmi(self,task):"""Inject NMI, Non Maskable Interrupt. :param task: A TaskManager instance containing the node to act on. :returns: None """
将 SOFT_REBOOT 和 SOFT_POWER_OFF 的支持添加到以下 API 的 target 参数中
PUT /v1/nodes/(node_ident)/states/power
The target parameter supports the following JSON data respectively.
``timeout`` is an optional parameter for any ``target`` parameter.
In case of "soft reboot" and "soft power off", ``timeout`` overrides
``soft_power_off_timeout`` in the in the Ironic configuration file,
typically /etc/ironic/ironic.conf.
Examples
{"target": "soft reboot",
"timeout": 900}
{"target": "soft power off",
"timeout": 600}
添加一个新的管理 API 以支持注入 NMI
PUT/v1/nodes/(node_ident)/management/inject_nmiRequestdoesn't take any parameter.
usage: ironic node-set-power-state <node> <power-state>
[--soft] [--timeout <timeout>]
Power a node on/off/reboot, power graceful off/reboot to a node.
Positional arguments
<node>
Name or UUID of the node.
<power-state>
'on', 'off', 'reboot'
Optional arguments:
--soft
power graceful off/reboot.
--timeout <timeout>
timeout positive integer value(> 0) for any ``power-state``.
If ``--soft`` option is also specified, it overrides
``soft_power_off_timeout`` in the in the Ironic configuration
file, typically /etc/ironic/ironic.conf.