Add OSC 'baremetal driver property list' command
Extends OSC plugin with the new command: openstack baremetal driver property list <driver> This returns a list of the names of a driver's properties along with their descriptions. Change-Id: I4419daa68928a479971dab80806f0dfac37224a4 Closes-Bug: 1619053 Co-Authored-By: Ruby Loo <ruby.loo@intel.com>
This commit is contained in:
parent
725b45376a
commit
58fe82082b
@ -71,6 +71,29 @@ class ListBaremetalDriver(command.Lister):
|
||||
(oscutils.get_dict_properties(s, columns) for s in data))
|
||||
|
||||
|
||||
class ListBaremetalDriverProperty(command.Lister):
|
||||
"""List the driver properties."""
|
||||
|
||||
log = logging.getLogger(__name__ + ".ListBaremetalDriverProperty")
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super(ListBaremetalDriverProperty, self).get_parser(prog_name)
|
||||
parser.add_argument(
|
||||
'driver',
|
||||
metavar='<driver>',
|
||||
help='Name of the driver.')
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
self.log.debug("take_action(%s)", parsed_args)
|
||||
baremetal_client = self.app.client_manager.baremetal
|
||||
|
||||
driver_properties = baremetal_client.driver.properties(
|
||||
parsed_args.driver)
|
||||
labels = ['Property', 'Description']
|
||||
return labels, sorted(driver_properties.items())
|
||||
|
||||
|
||||
class PassthruCallBaremetalDriver(command.ShowOne):
|
||||
"""Call a vendor passthru method for a driver."""
|
||||
|
||||
|
@ -135,6 +135,39 @@ class TestListBaremetalDriver(TestBaremetalDriver):
|
||||
self.assertEqual(datalist, tuple(data))
|
||||
|
||||
|
||||
class TestListBaremetalDriverProperty(TestBaremetalDriver):
|
||||
|
||||
def setUp(self):
|
||||
super(TestListBaremetalDriverProperty, self).setUp()
|
||||
|
||||
self.baremetal_mock.driver.properties.return_value = {
|
||||
'property1': 'description1', 'property2': 'description2'}
|
||||
self.cmd = baremetal_driver.ListBaremetalDriverProperty(
|
||||
self.app, None)
|
||||
|
||||
def test_baremetal_driver_property_list(self):
|
||||
arglist = ['fakedrivername']
|
||||
verifylist = []
|
||||
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
self.baremetal_mock.driver.properties.assert_called_with(*arglist)
|
||||
|
||||
collist = ['Property', 'Description']
|
||||
self.assertEqual(collist, columns)
|
||||
expected_data = [('property1', 'description1'),
|
||||
('property2', 'description2')]
|
||||
self.assertEqual(expected_data, data)
|
||||
|
||||
def test_baremetal_driver_list_no_arg(self):
|
||||
arglist = []
|
||||
verifylist = []
|
||||
|
||||
self.assertRaises(oscutils.ParserException,
|
||||
self.check_parser,
|
||||
self.cmd, arglist, verifylist)
|
||||
|
||||
|
||||
class TestPassthruCallBaremetalDriver(TestBaremetalDriver):
|
||||
|
||||
def setUp(self):
|
||||
|
@ -0,0 +1,6 @@
|
||||
---
|
||||
features:
|
||||
- Adds the ``openstack baremetal driver property list <driver>`` command.
|
||||
For the specified driver, this returns a list of its properties, along
|
||||
with descriptions for each property. (The values of these properties
|
||||
are specified in a node's driver_info.)
|
@ -40,6 +40,7 @@ openstack.baremetal.v1 =
|
||||
baremetal_driver_list = ironicclient.osc.v1.baremetal_driver:ListBaremetalDriver
|
||||
baremetal_driver_passthru_call = ironicclient.osc.v1.baremetal_driver:PassthruCallBaremetalDriver
|
||||
baremetal_driver_passthru_list = ironicclient.osc.v1.baremetal_driver:PassthruListBaremetalDriver
|
||||
baremetal_driver_property_list = ironicclient.osc.v1.baremetal_driver:ListBaremetalDriverProperty
|
||||
baremetal_driver_show = ironicclient.osc.v1.baremetal_driver:ShowBaremetalDriver
|
||||
baremetal_list = ironicclient.osc.v1.baremetal_node:ListBaremetal
|
||||
baremetal_node_abort = ironicclient.osc.v1.baremetal_node:AbortBaremetalNode
|
||||
|
Loading…
Reference in New Issue
Block a user