Adds 'openstack baremetal node console' commands
Adds the following console-related commands to the OpenStackClient plugin: openstack baremetal node console disable openstack baremetal node console enable openstack baremetal node console show Change-Id: I060531baf84907cdf3763369a43469ec1c860e4d Partial-Bug: #1526479
This commit is contained in:
parent
9ded4d2b7d
commit
fd54fd076f
@ -110,6 +110,73 @@ class CleanBaremetalNode(ProvisionStateBaremetalNode):
|
|||||||
cleansteps=clean_steps)
|
cleansteps=clean_steps)
|
||||||
|
|
||||||
|
|
||||||
|
class ConsoleDisableBaremetalNode(command.Command):
|
||||||
|
"""Disable console access for a node"""
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__ + ".ConsoleDisableBaremetalNode")
|
||||||
|
|
||||||
|
def get_parser(self, prog_name):
|
||||||
|
parser = super(ConsoleDisableBaremetalNode, 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_console_mode(parsed_args.node, False)
|
||||||
|
|
||||||
|
|
||||||
|
class ConsoleEnableBaremetalNode(command.Command):
|
||||||
|
"""Enable console access for a node"""
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__ + ".ConsoleEnableBaremetalNode")
|
||||||
|
|
||||||
|
def get_parser(self, prog_name):
|
||||||
|
parser = super(ConsoleEnableBaremetalNode, 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_console_mode(parsed_args.node, True)
|
||||||
|
|
||||||
|
|
||||||
|
class ConsoleShowBaremetalNode(command.ShowOne):
|
||||||
|
"""Show console information for a node"""
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__ + ".ConsoleShowBaremetalNode")
|
||||||
|
|
||||||
|
def get_parser(self, prog_name):
|
||||||
|
parser = super(ConsoleShowBaremetalNode, 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
|
||||||
|
info = baremetal_client.node.get_console(parsed_args.node)
|
||||||
|
return zip(*sorted(info.items()))
|
||||||
|
|
||||||
|
|
||||||
class CreateBaremetalNode(command.ShowOne):
|
class CreateBaremetalNode(command.ShowOne):
|
||||||
"""Register a new node with the baremetal service"""
|
"""Register a new node with the baremetal service"""
|
||||||
|
|
||||||
|
@ -56,6 +56,66 @@ class TestAdopt(TestBaremetal):
|
|||||||
'node_uuid', 'adopt')
|
'node_uuid', 'adopt')
|
||||||
|
|
||||||
|
|
||||||
|
class TestConsoleDisable(TestBaremetal):
|
||||||
|
def setUp(self):
|
||||||
|
super(TestConsoleDisable, self).setUp()
|
||||||
|
|
||||||
|
# Get the command object to test
|
||||||
|
self.cmd = baremetal_node.ConsoleDisableBaremetalNode(self.app, None)
|
||||||
|
|
||||||
|
def test_console_disable(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_console_mode.assert_called_once_with(
|
||||||
|
'node_uuid', False)
|
||||||
|
|
||||||
|
|
||||||
|
class TestConsoleEnable(TestBaremetal):
|
||||||
|
def setUp(self):
|
||||||
|
super(TestConsoleEnable, self).setUp()
|
||||||
|
|
||||||
|
# Get the command object to test
|
||||||
|
self.cmd = baremetal_node.ConsoleEnableBaremetalNode(self.app, None)
|
||||||
|
|
||||||
|
def test_console_enable(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_console_mode.assert_called_once_with(
|
||||||
|
'node_uuid', True)
|
||||||
|
|
||||||
|
|
||||||
|
class TestConsoleShow(TestBaremetal):
|
||||||
|
def setUp(self):
|
||||||
|
super(TestConsoleShow, self).setUp()
|
||||||
|
|
||||||
|
# Get the command object to test
|
||||||
|
self.cmd = baremetal_node.ConsoleShowBaremetalNode(self.app, None)
|
||||||
|
|
||||||
|
self.baremetal_mock.node.get_console.return_value = {
|
||||||
|
"console_enabled": False, "console_info": None}
|
||||||
|
|
||||||
|
def test_console_show(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.get_console.assert_called_once_with(
|
||||||
|
'node_uuid')
|
||||||
|
|
||||||
|
|
||||||
class TestBaremetalCreate(TestBaremetal):
|
class TestBaremetalCreate(TestBaremetal):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestBaremetalCreate, self).setUp()
|
super(TestBaremetalCreate, self).setUp()
|
||||||
|
@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
Extends the OpenStackClient plug-in with new commands:
|
||||||
|
|
||||||
|
* openstack baremetal node console disable
|
||||||
|
* openstack baremetal node console enable
|
||||||
|
* openstack baremetal node console show
|
@ -35,6 +35,9 @@ openstack.baremetal.v1 =
|
|||||||
baremetal_node_abort = ironicclient.osc.v1.baremetal_node:AbortBaremetalNode
|
baremetal_node_abort = ironicclient.osc.v1.baremetal_node:AbortBaremetalNode
|
||||||
baremetal_node_adopt = ironicclient.osc.v1.baremetal_node:AdoptBaremetalNode
|
baremetal_node_adopt = ironicclient.osc.v1.baremetal_node:AdoptBaremetalNode
|
||||||
baremetal_node_clean = ironicclient.osc.v1.baremetal_node:CleanBaremetalNode
|
baremetal_node_clean = ironicclient.osc.v1.baremetal_node:CleanBaremetalNode
|
||||||
|
baremetal_node_console_disable = ironicclient.osc.v1.baremetal_node:ConsoleDisableBaremetalNode
|
||||||
|
baremetal_node_console_enable = ironicclient.osc.v1.baremetal_node:ConsoleEnableBaremetalNode
|
||||||
|
baremetal_node_console_show = ironicclient.osc.v1.baremetal_node:ConsoleShowBaremetalNode
|
||||||
baremetal_node_create = ironicclient.osc.v1.baremetal_node:CreateBaremetalNode
|
baremetal_node_create = ironicclient.osc.v1.baremetal_node:CreateBaremetalNode
|
||||||
baremetal_node_delete = ironicclient.osc.v1.baremetal_node:DeleteBaremetalNode
|
baremetal_node_delete = ironicclient.osc.v1.baremetal_node:DeleteBaremetalNode
|
||||||
baremetal_node_deploy = ironicclient.osc.v1.baremetal_node:DeployBaremetalNode
|
baremetal_node_deploy = ironicclient.osc.v1.baremetal_node:DeployBaremetalNode
|
||||||
|
Loading…
Reference in New Issue
Block a user