2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-07-10 06:41:31 +00:00
Files
build-utils
docs
java-xCAT
perl-xCAT
src
xCAT
xCAT-IBMhpc
xCAT-OpenStack
xCAT-OpenStack-baremetal
xCAT-OpenStack-ironic
xCAT-SoftLayer
xCAT-UI
xCAT-buildkit
xCAT-client
xCAT-confluent
xCAT-csm
xCAT-genesis-builder
xCAT-genesis-scripts
xCAT-openbmc-py
xCAT-probe
xCAT-rmc
xCAT-server
xCAT-test
xCAT-vlan
xCATsn
.gitignore
.mailmap
.travis.yml
README.rst
Release
Version
build-python-deb
build-ubunturepo
buildcore.sh
builddep.sh
buildlocal.sh
comps.xml
create_man_pages.py
makerpm
makerpm-genesisbuilder
travis.pl
xcat-core/xCAT-openbmc-py/lib/python/agent/hwctl/power.py
2018-02-05 16:39:25 +08:00

60 lines
2.1 KiB
Python

#!/usr/bin/env python
###############################################################################
# IBM(c) 2018 EPL license http://www.eclipse.org/legal/epl-v10.html
###############################################################################
# -*- coding: utf-8 -*-
#
class PowerInterface(object):
"""Interface for power-related actions."""
interface_type = 'power'
version = '1.0'
def get_power_state(self, task):
"""Return the power state of the task's nodes.
:param task: a Task instance containing the nodes to act on.
:returns: a power state.
"""
return task.run('get_state')
def set_power_state(self, task, power_state, timeout=None):
"""Set the power state of the task's nodes.
:param task: a Task instance containing the nodes to act on.
:param power_state: Any supported power state.
:param timeout: timeout (in seconds) positive integer (> 0) for any
power state. ``None`` indicates to use default timeout.
"""
return task.run('set_state', power_state, timeout=timeout)
def reboot(self, task, optype='boot', timeout=None):
"""Perform a hard reboot of the task's nodes.
:param task: a Task instance containing the node to act on.
:param timeout: timeout (in seconds) positive integer (> 0) for any
power state. ``None`` indicates to use default timeout.
"""
return task.run('reboot', optype, timeout=timeout)
def get_bmc_state(self, task):
"""Return the bmc state of the task's nodes.
:param task: a Task instance containing the nodes to act on.
:returns: a bmc state.
"""
return task.run('get_bmcstate')
def reboot_bmc(self, task, optype='warm'):
"""Set the BMC state of the task's nodes.
:param task: a Task instance containing the nodes to act on.
:returns: a power state.
"""
return task.run('reboot_bmc', optype)
class DefaultPowerManager(PowerInterface):
"""Interface for power-related actions."""
pass