Ejemplo n.º 1
0
    def _execute(self):
        """See `NodeAction.execute`."""
        try:
            self.node.start(self.user)
        except StaticIPAddressExhaustion:
            raise NodeActionError(
                "%s: Failed to start, static IP addresses are exhausted." %
                self.node.hostname)
        except RPC_EXCEPTIONS + (ExternalProcessError, ) as exception:
            raise NodeActionError(exception)


FAILED_STATUSES = [
    status for status in map_enum(NODE_STATUS).values()
    if is_failed_status(status)
]


class PowerOff(NodeAction):
    """Power off a node."""
    name = "off"
    display = "Power off..."
    display_sentence = "powered off"
    # Let a user power off a node in any non-active status.
    actionable_statuses = NON_MONITORED_STATUSES
    permission = NodePermission.edit
    for_type = {NODE_TYPE.MACHINE, NODE_TYPE.RACK_CONTROLLER}
    action_type = NODE_ACTION_TYPE.POWER
    audit_description = "Powered off '%s'."
Ejemplo n.º 2
0
        try:
            self.node.start(self.user)
        except StaticIPAddressExhaustion:
            raise NodeActionError(
                "%s: Failed to start, static IP addresses are exhausted."
                % self.node.hostname)
        except RPC_EXCEPTIONS + (ExternalProcessError,) as exception:
            raise NodeActionError(exception)
        else:
            return "This node has been asked to start up."


FAILED_STATUSES = [
    status for status in map_enum(NODE_STATUS).values()
    if is_failed_status(status)
]


class StopNode(NodeAction):
    """Stop a node."""
    name = "stop"
    display = "Stop node"
    display_bulk = "Stop selected nodes"
    actionable_statuses = (
        [NODE_STATUS.DEPLOYED, NODE_STATUS.READY] +
        # Also let a user ask a failed node to shutdown: this
        # is useful to try to recover from power failures.
        FAILED_STATUSES
    )
    permission = NODE_PERMISSION.EDIT