diff --git a/ironicclient/osc/v1/baremetal_driver.py b/ironicclient/osc/v1/baremetal_driver.py index 83b3d0645..9c3323c12 100644 --- a/ironicclient/osc/v1/baremetal_driver.py +++ b/ironicclient/osc/v1/baremetal_driver.py @@ -94,6 +94,30 @@ class ListBaremetalDriverProperty(command.Lister): return labels, sorted(driver_properties.items()) +class ListBaremetalDriverRaidProperty(command.Lister): + """List a driver's RAID logical disk properties.""" + + log = logging.getLogger(__name__ + ".ListBaremetalDriverRaidProperty") + + def get_parser(self, prog_name): + parser = super(ListBaremetalDriverRaidProperty, self).get_parser( + prog_name) + parser.add_argument( + 'driver', + metavar='', + 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 + + raid_props = baremetal_client.driver.raid_logical_disk_properties( + parsed_args.driver) + labels = ['Property', 'Description'] + return labels, sorted(raid_props.items()) + + class PassthruCallBaremetalDriver(command.ShowOne): """Call a vendor passthru method for a driver.""" diff --git a/ironicclient/tests/unit/osc/v1/test_baremetal_driver.py b/ironicclient/tests/unit/osc/v1/test_baremetal_driver.py index 1bf7ed29e..6988d8795 100644 --- a/ironicclient/tests/unit/osc/v1/test_baremetal_driver.py +++ b/ironicclient/tests/unit/osc/v1/test_baremetal_driver.py @@ -168,6 +168,47 @@ class TestListBaremetalDriverProperty(TestBaremetalDriver): self.cmd, arglist, verifylist) +class TestListBaremetalDriverRaidProperty(TestBaremetalDriver): + + def setUp(self): + super(TestListBaremetalDriverRaidProperty, self).setUp() + + (self.baremetal_mock.driver. + raid_logical_disk_properties.return_value) = { + 'RAIDProperty1': 'driver_raid_property1', + 'RAIDProperty2': 'driver_raid_property2', + } + + self.cmd = ( + baremetal_driver.ListBaremetalDriverRaidProperty( + self.app, None)) + + def test_baremetal_driver_raid_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. + raid_logical_disk_properties.assert_called_with(*arglist)) + + collist = ('Property', 'Description') + self.assertEqual(collist, tuple(columns)) + + expected_data = [('RAIDProperty1', 'driver_raid_property1'), + ('RAIDProperty2', 'driver_raid_property2')] + self.assertEqual(expected_data, data) + + def test_baremetal_driver_raid_property_list_no_arg(self): + arglist = [] + verifylist = [] + + self.assertRaises(oscutils.ParserException, + self.check_parser, + self.cmd, arglist, verifylist) + + class TestPassthruCallBaremetalDriver(TestBaremetalDriver): def setUp(self): diff --git a/releasenotes/notes/osc-baremetal-driver-raid-properties-159bd57058c0fc0e.yaml b/releasenotes/notes/osc-baremetal-driver-raid-properties-159bd57058c0fc0e.yaml new file mode 100644 index 000000000..d14013d93 --- /dev/null +++ b/releasenotes/notes/osc-baremetal-driver-raid-properties-159bd57058c0fc0e.yaml @@ -0,0 +1,7 @@ +--- +features: + - Adds the ``openstack baremetal driver raid property list `` + command. For a specified driver, this returns a list of the + RAID logical disk properties that can be specified, along with + a description for each property. (The values of these properties + are specified in a node's ``target_raid_config`` field.) diff --git a/setup.cfg b/setup.cfg index d0c5501e1..43a749fc2 100644 --- a/setup.cfg +++ b/setup.cfg @@ -40,6 +40,7 @@ openstack.baremetal.v1 = 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_raid_property_list = ironicclient.osc.v1.baremetal_driver:ListBaremetalDriverRaidProperty 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