Add maintenance mode commands

baremetal node maintenance set
baremetal node maintenance unset

Change-Id: Idbb451b90dbe8ad6ee410b06a18592ba74d29514
Partial-Bug: #1526479
This commit is contained in:
Brad P. Crochet 2015-08-24 15:46:12 -04:00
parent 77e543779f
commit b9b6e93f80
4 changed files with 124 additions and 0 deletions

View File

@ -395,6 +395,64 @@ class ListBaremetal(ListBaremetalNode):
return super(ListBaremetal, self).take_action(parsed_args) return super(ListBaremetal, self).take_action(parsed_args)
class MaintenanceSetBaremetalNode(command.Command):
"""Set baremetal node to maintenance mode"""
log = logging.getLogger(__name__ + ".MaintenanceSetBaremetalNode")
def get_parser(self, prog_name):
parser = super(MaintenanceSetBaremetalNode, self).get_parser(prog_name)
parser.add_argument(
'node',
metavar='<node>',
help="Name or UUID of the node."
)
parser.add_argument(
'--reason',
metavar='<reason>',
default=None,
help=("Reason for setting maintenance mode."))
return parser
def take_action(self, parsed_args):
self.log.debug("take_action(%s)", parsed_args)
baremetal_client = self.app.client_manager.baremetal
baremetal_client.node.set_maintenance(
parsed_args.node,
True,
maint_reason=parsed_args.reason)
class MaintenanceUnsetBaremetalNode(command.Command):
"""Unset baremetal node from maintenance mode"""
log = logging.getLogger(__name__ + ".MaintenanceUnsetBaremetalNode")
def get_parser(self, prog_name):
parser = super(MaintenanceUnsetBaremetalNode,
self).get_parser(prog_name)
parser.add_argument(
'node',
metavar='<node>',
help="Name or UUID of the node."
)
return parser
def take_action(self, parsed_args):
self.log.debug("take_action(%s)", parsed_args)
baremetal_client = self.app.client_manager.baremetal
baremetal_client.node.set_maintenance(
parsed_args.node,
False)
class ManageBaremetalNode(ProvisionStateBaremetalNode): class ManageBaremetalNode(ProvisionStateBaremetalNode):
"""Set provision state of baremetal node to 'manage'""" """Set provision state of baremetal node to 'manage'"""

View File

@ -495,6 +495,68 @@ class TestBaremetalList(TestBaremetal):
self.cmd, arglist, verifylist) self.cmd, arglist, verifylist)
class TestBaremetalMaintenanceSet(TestBaremetal):
def setUp(self):
super(TestBaremetalMaintenanceSet, self).setUp()
# Get the command object to test
self.cmd = baremetal_node.MaintenanceSetBaremetalNode(self.app, None)
def test_baremetal_maintenance_on(self):
arglist = ['node_uuid',
'--reason', 'maintenance reason']
verifylist = [
('node', 'node_uuid'),
('reason', 'maintenance reason'),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.cmd.take_action(parsed_args)
self.baremetal_mock.node.set_maintenance.assert_called_once_with(
'node_uuid',
True,
maint_reason='maintenance reason'
)
def test_baremetal_maintenance_on_no_reason(self):
arglist = ['node_uuid']
verifylist = [
('node', 'node_uuid'),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.cmd.take_action(parsed_args)
self.baremetal_mock.node.set_maintenance.assert_called_once_with(
'node_uuid',
True,
maint_reason=None
)
class TestBaremetalMaintenanceUnset(TestBaremetal):
def setUp(self):
super(TestBaremetalMaintenanceUnset, self).setUp()
# Get the command object to test
self.cmd = baremetal_node.MaintenanceUnsetBaremetalNode(self.app, None)
def test_baremetal_maintenance_off(self):
arglist = ['node_uuid']
verifylist = [('node', 'node_uuid')]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.cmd.take_action(parsed_args)
self.baremetal_mock.node.set_maintenance.assert_called_once_with(
'node_uuid',
False)
class TestBaremetalPower(TestBaremetal): class TestBaremetalPower(TestBaremetal):
def setUp(self): def setUp(self):
super(TestBaremetalPower, self).setUp() super(TestBaremetalPower, self).setUp()

View File

@ -10,6 +10,8 @@ features:
* openstack baremetal node deploy * openstack baremetal node deploy
* openstack baremetal node inspect * openstack baremetal node inspect
* openstack baremetal node list * openstack baremetal node list
* openstack baremetal node maintenance set
* opnestack baremetal node maintenance unset
* openstack baremetal node manage * openstack baremetal node manage
* openstack baremetal node power * openstack baremetal node power
* openstack baremetal node provide * openstack baremetal node provide

View File

@ -38,6 +38,8 @@ openstack.baremetal.v1 =
baremetal_node_deploy = ironicclient.osc.v1.baremetal_node:DeployBaremetalNode baremetal_node_deploy = ironicclient.osc.v1.baremetal_node:DeployBaremetalNode
baremetal_node_inspect = ironicclient.osc.v1.baremetal_node:InspectBaremetalNode baremetal_node_inspect = ironicclient.osc.v1.baremetal_node:InspectBaremetalNode
baremetal_node_list = ironicclient.osc.v1.baremetal_node:ListBaremetalNode baremetal_node_list = ironicclient.osc.v1.baremetal_node:ListBaremetalNode
baremetal_node_maintenance_set = ironicclient.osc.v1.baremetal_node:MaintenanceSetBaremetalNode
baremetal_node_maintenance_unset = ironicclient.osc.v1.baremetal_node:MaintenanceUnsetBaremetalNode
baremetal_node_manage = ironicclient.osc.v1.baremetal_node:ManageBaremetalNode baremetal_node_manage = ironicclient.osc.v1.baremetal_node:ManageBaremetalNode
baremetal_node_power = ironicclient.osc.v1.baremetal_node:PowerBaremetalNode baremetal_node_power = ironicclient.osc.v1.baremetal_node:PowerBaremetalNode
baremetal_node_provide = ironicclient.osc.v1.baremetal_node:ProvideBaremetalNode baremetal_node_provide = ironicclient.osc.v1.baremetal_node:ProvideBaremetalNode