summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ironicclient/osc/v1/baremetal_node.py39
-rw-r--r--ironicclient/tests/unit/osc/v1/test_baremetal_node.py113
-rw-r--r--releasenotes/notes/osc-soft-reboot-poweroff-121b8043567f54a9.yaml4
3 files changed, 147 insertions, 9 deletions
diff --git a/ironicclient/osc/v1/baremetal_node.py b/ironicclient/osc/v1/baremetal_node.py
index b5a611f..3495437 100644
--- a/ironicclient/osc/v1/baremetal_node.py
+++ b/ironicclient/osc/v1/baremetal_node.py
@@ -714,6 +714,21 @@ class PowerBaremetalNode(command.Command):
metavar='<node>',
help="Name or UUID of the node."
)
+ parser.add_argument(
+ '--soft',
+ dest='soft',
+ action='store_true',
+ default=False,
+ help=_("Request graceful power-off.")
+ )
+ parser.add_argument(
+ '--power-timeout',
+ metavar='<power-timeout>',
+ default=None,
+ type=int,
+ help=_("Timeout (in seconds, positive integer) to wait for the "
+ "target power state before erroring out.")
+ )
return parser
def take_action(self, parsed_args):
@@ -722,7 +737,8 @@ class PowerBaremetalNode(command.Command):
baremetal_client = self.app.client_manager.baremetal
baremetal_client.node.set_power_state(
- parsed_args.node, parsed_args.power_state)
+ parsed_args.node, parsed_args.power_state, parsed_args.soft,
+ timeout=parsed_args.power_timeout)
class ProvideBaremetalNode(ProvisionStateBaremetalNode):
@@ -743,7 +759,23 @@ class RebootBaremetalNode(command.Command):
parser.add_argument(
'node',
metavar='<node>',
- help="Name or UUID of the node.")
+ help="Name or UUID of the node."
+ )
+ parser.add_argument(
+ '--soft',
+ dest='soft',
+ action='store_true',
+ default=False,
+ help=_("Request Graceful reboot.")
+ )
+ parser.add_argument(
+ '--power-timeout',
+ metavar='<power-timeout>',
+ default=None,
+ type=int,
+ help=_("Timeout (in seconds, positive integer) to wait for the "
+ "target power state before erroring out.")
+ )
return parser
@@ -753,7 +785,8 @@ class RebootBaremetalNode(command.Command):
baremetal_client = self.app.client_manager.baremetal
baremetal_client.node.set_power_state(
- parsed_args.node, 'reboot')
+ parsed_args.node, 'reboot', parsed_args.soft,
+ timeout=parsed_args.power_timeout)
class RebuildBaremetalNode(ProvisionStateBaremetalNode):
diff --git a/ironicclient/tests/unit/osc/v1/test_baremetal_node.py b/ironicclient/tests/unit/osc/v1/test_baremetal_node.py
index f519f0b..942e9e8 100644
--- a/ironicclient/tests/unit/osc/v1/test_baremetal_node.py
+++ b/ironicclient/tests/unit/osc/v1/test_baremetal_node.py
@@ -893,26 +893,86 @@ class TestBaremetalPower(TestBaremetal):
def test_baremetal_power_on(self):
arglist = ['on', 'node_uuid']
verifylist = [('power_state', 'on'),
- ('node', 'node_uuid')]
+ ('node', 'node_uuid'),
+ ('soft', False),
+ ('power_timeout', None)]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.cmd.take_action(parsed_args)
self.baremetal_mock.node.set_power_state.assert_called_once_with(
- 'node_uuid', 'on')
+ 'node_uuid', 'on', False, timeout=None)
+
+ def test_baremetal_power_on_timeout(self):
+ arglist = ['on', 'node_uuid', '--power-timeout', '2']
+ verifylist = [('power_state', 'on'),
+ ('node', 'node_uuid'),
+ ('soft', False),
+ ('power_timeout', 2)]
+
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
+
+ self.cmd.take_action(parsed_args)
+
+ self.baremetal_mock.node.set_power_state.assert_called_once_with(
+ 'node_uuid', 'on', False, timeout=2)
def test_baremetal_power_off(self):
arglist = ['off', 'node_uuid']
verifylist = [('power_state', 'off'),
- ('node', 'node_uuid')]
+ ('node', 'node_uuid'),
+ ('soft', False),
+ ('power_timeout', None)]
+
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
+
+ self.cmd.take_action(parsed_args)
+
+ self.baremetal_mock.node.set_power_state.assert_called_once_with(
+ 'node_uuid', 'off', False, timeout=None)
+
+ def test_baremetal_power_off_timeout(self):
+ arglist = ['off', 'node_uuid', '--power-timeout', '2']
+ verifylist = [('power_state', 'off'),
+ ('node', 'node_uuid'),
+ ('soft', False),
+ ('power_timeout', 2)]
+
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
+
+ self.cmd.take_action(parsed_args)
+
+ self.baremetal_mock.node.set_power_state.assert_called_once_with(
+ 'node_uuid', 'off', False, timeout=2)
+
+ def test_baremetal_soft_power_off(self):
+ arglist = ['off', 'node_uuid', '--soft']
+ verifylist = [('power_state', 'off'),
+ ('node', 'node_uuid'),
+ ('soft', True),
+ ('power_timeout', None)]
+
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
+
+ self.cmd.take_action(parsed_args)
+
+ self.baremetal_mock.node.set_power_state.assert_called_once_with(
+ 'node_uuid', 'off', True, timeout=None)
+
+ def test_baremetal_soft_power_off_timeout(self):
+ arglist = ['off', 'node_uuid', '--soft', '--power-timeout', '2']
+ verifylist = [('power_state', 'off'),
+ ('node', 'node_uuid'),
+ ('soft', True),
+ ('power_timeout', 2)]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.cmd.take_action(parsed_args)
self.baremetal_mock.node.set_power_state.assert_called_once_with(
- 'node_uuid', 'off')
+ 'node_uuid', 'off', True, timeout=2)
class TestDeployBaremetalProvisionState(TestBaremetal):
@@ -969,14 +1029,55 @@ class TestBaremetalReboot(TestBaremetal):
def test_baremetal_reboot_uuid_only(self):
arglist = ['node_uuid']
- verifylist = [('node', 'node_uuid')]
+ verifylist = [('node', 'node_uuid'),
+ ('soft', False),
+ ('power_timeout', None)]
+
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
+
+ self.cmd.take_action(parsed_args)
+
+ self.baremetal_mock.node.set_power_state.assert_called_once_with(
+ 'node_uuid', 'reboot', False, timeout=None)
+
+ def test_baremetal_reboot_timeout(self):
+ arglist = ['node_uuid', '--power-timeout', '2']
+ verifylist = [('node', 'node_uuid'),
+ ('soft', False),
+ ('power_timeout', 2)]
+
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
+
+ self.cmd.take_action(parsed_args)
+
+ self.baremetal_mock.node.set_power_state.assert_called_once_with(
+ 'node_uuid', 'reboot', False, timeout=2)
+
+ def test_baremetal_soft_reboot(self):
+ arglist = ['node_uuid', '--soft']
+ verifylist = [('node', 'node_uuid'),
+ ('soft', True),
+ ('power_timeout', None)]
+
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
+
+ self.cmd.take_action(parsed_args)
+
+ self.baremetal_mock.node.set_power_state.assert_called_once_with(
+ 'node_uuid', 'reboot', True, timeout=None)
+
+ def test_baremetal_soft_reboot_timeout(self):
+ arglist = ['node_uuid', '--soft', '--power-timeout', '2']
+ verifylist = [('node', 'node_uuid'),
+ ('soft', True),
+ ('power_timeout', 2)]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.cmd.take_action(parsed_args)
self.baremetal_mock.node.set_power_state.assert_called_once_with(
- 'node_uuid', 'reboot')
+ 'node_uuid', 'reboot', True, timeout=2)
class TestBaremetalSet(TestBaremetal):
diff --git a/releasenotes/notes/osc-soft-reboot-poweroff-121b8043567f54a9.yaml b/releasenotes/notes/osc-soft-reboot-poweroff-121b8043567f54a9.yaml
new file mode 100644
index 0000000..ab38a15
--- /dev/null
+++ b/releasenotes/notes/osc-soft-reboot-poweroff-121b8043567f54a9.yaml
@@ -0,0 +1,4 @@
+---
+features:
+ - Enhances OSC to support soft reboot and soft power off with
+ power control timeout option.