Include BIOS registry fields in bios setting list command
Add new params to the 'baremetal node bios setting list' command to include support for the BIOS registry. The '--long' option will retrieve and display the additonal BIOS registry fields, the '--fields' option will retrieve and display selected fields. The header names when the '--long' or '--fields' options are not used match the existing functionality. Note that the 'baremetal node bios setting show' includes these fields by default with no changes. Change-Id: I9d6d2e42879e12cce8e1f2111be1a27f1a251de2
This commit is contained in:
parent
2d813b3c70
commit
f12e1a5791
@ -1978,15 +1978,52 @@ class ListBIOSSettingBaremetalNode(command.Lister):
|
||||
metavar='<node>',
|
||||
help=_("Name or UUID of the node")
|
||||
)
|
||||
display_group = parser.add_mutually_exclusive_group(required=False)
|
||||
display_group.add_argument(
|
||||
'--long',
|
||||
default=False,
|
||||
help=_("Show detailed information about the BIOS settings."),
|
||||
action='store_true')
|
||||
display_group.add_argument(
|
||||
'--fields',
|
||||
nargs='+',
|
||||
dest='fields',
|
||||
metavar='<field>',
|
||||
action='append',
|
||||
default=[],
|
||||
choices=res_fields.BIOS_DETAILED_RESOURCE.fields,
|
||||
help=_("One or more node fields. Only these fields will be "
|
||||
"fetched from the server. Can not be used when '--long' "
|
||||
"is specified."))
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
self.log.debug("take_action(%s)", parsed_args)
|
||||
|
||||
labels = res_fields.BIOS_RESOURCE.labels
|
||||
fields = res_fields.BIOS_RESOURCE.fields
|
||||
|
||||
params = {}
|
||||
if parsed_args.long:
|
||||
params['detail'] = parsed_args.long
|
||||
fields = res_fields.BIOS_DETAILED_RESOURCE.fields
|
||||
labels = res_fields.BIOS_DETAILED_RESOURCE.labels
|
||||
elif parsed_args.fields:
|
||||
params['detail'] = False
|
||||
fields = itertools.chain.from_iterable(parsed_args.fields)
|
||||
resource = res_fields.Resource(list(fields))
|
||||
fields = resource.fields
|
||||
labels = resource.labels
|
||||
params['fields'] = fields
|
||||
|
||||
self.log.debug("params(%s)", params)
|
||||
|
||||
baremetal_client = self.app.client_manager.baremetal
|
||||
settings = baremetal_client.node.list_bios_settings(parsed_args.node)
|
||||
return (labels, [[s['name'], s['value']] for s in settings])
|
||||
settings = baremetal_client.node.list_bios_settings(parsed_args.node,
|
||||
**params)
|
||||
|
||||
return (labels,
|
||||
(oscutils.get_dict_properties(s, fields) for s in settings))
|
||||
|
||||
|
||||
class BIOSSettingShowBaremetalNode(command.ShowOne):
|
||||
|
@ -152,6 +152,16 @@ TRAITS = ['CUSTOM_FOO', 'CUSTOM_BAR']
|
||||
BIOS_SETTINGS = [{'name': 'bios_name_1', 'value': 'bios_value_1', 'links': []},
|
||||
{'name': 'bios_name_2', 'value': 'bios_value_2', 'links': []}]
|
||||
|
||||
BIOS_DETAILED_SETTINGS = [{'name': 'SysName', 'value': 'my-system',
|
||||
'links': [], 'attribute_type': 'String',
|
||||
'min_length': '1', 'max_length': '16'},
|
||||
{'name': 'NumCores', 'value': '10',
|
||||
'links': [], 'attribute_type': 'Integer',
|
||||
'lower_bound': '10', 'upper_bound': '20'},
|
||||
{'name': 'ProcVirtualization', 'value': 'Enabled',
|
||||
'links': [], 'attribute_type': 'Enumeration',
|
||||
'allowable_values': ['Enabled', 'Disabled']}]
|
||||
|
||||
baremetal_volume_connector_uuid = 'vvv-cccccc-vvvv'
|
||||
baremetal_volume_connector_type = 'iqn'
|
||||
baremetal_volume_connector_connector_id = 'iqn.2017-01.connector'
|
||||
|
@ -4031,14 +4031,76 @@ class TestListBIOSSetting(TestBaremetal):
|
||||
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
data = self.cmd.take_action(parsed_args)
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
|
||||
self.baremetal_mock.node.list_bios_settings.assert_called_once_with(
|
||||
'node_uuid')
|
||||
expected_data = (('BIOS setting name', 'BIOS setting value'),
|
||||
[[s['name'], s['value']]
|
||||
expected_columns = ('BIOS setting name', 'BIOS setting value')
|
||||
self.assertEqual(expected_columns, columns)
|
||||
|
||||
expected_data = ([(s['name'], s['value'])
|
||||
for s in baremetal_fakes.BIOS_SETTINGS])
|
||||
self.assertEqual(expected_data, data)
|
||||
self.assertEqual(tuple(expected_data), tuple(data))
|
||||
|
||||
def test_baremetal_list_bios_setting_long(self):
|
||||
verifylist = [
|
||||
('long', True),
|
||||
]
|
||||
|
||||
arglist = ['node_uuid', '--long']
|
||||
verifylist = [('node', 'node_uuid'), ('long', True)]
|
||||
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
self.baremetal_mock.node.list_bios_settings.return_value = (
|
||||
baremetal_fakes.BIOS_DETAILED_SETTINGS)
|
||||
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
|
||||
kwargs = {
|
||||
'detail': True,
|
||||
}
|
||||
|
||||
self.baremetal_mock.node.list_bios_settings.assert_called_once_with(
|
||||
'node_uuid', **kwargs)
|
||||
expected_columns = ('Name', 'Value', 'Attribute Type',
|
||||
'Allowable Values', 'Lower Bound',
|
||||
'Minimum Length', 'Maximum Length', 'Read Only',
|
||||
'Reset Required', 'Unique', 'Upper Bound')
|
||||
self.assertEqual(expected_columns, columns)
|
||||
|
||||
expected_data = (('SysName', 'my-system', 'String', '', '', '1', '16',
|
||||
'', '', '', ''),
|
||||
('NumCores', '10', 'Integer', '', '10', '', '', '',
|
||||
'', '', '20'),
|
||||
('ProcVirtualization', 'Enabled',
|
||||
'Enumeration', ['Enabled', 'Disabled'], '', '', '',
|
||||
'', '', '', ''))
|
||||
self.assertEqual(expected_data, tuple(data))
|
||||
|
||||
def test_baremetal_list_bios_setting_fields(self):
|
||||
|
||||
arglist = ['node_uuid', '--fields', 'name', 'attribute_type']
|
||||
verifylist = [
|
||||
('fields', [['name', 'attribute_type']]),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
self.baremetal_mock.node.list_bios_settings.return_value = (
|
||||
baremetal_fakes.BIOS_DETAILED_SETTINGS)
|
||||
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
self.assertNotIn('Value', columns)
|
||||
self.assertIn('Name', columns)
|
||||
self.assertIn('Attribute Type', columns)
|
||||
|
||||
kwargs = {
|
||||
'detail': False,
|
||||
'fields': ('name', 'attribute_type'),
|
||||
}
|
||||
|
||||
self.baremetal_mock.node.list_bios_settings.assert_called_with(
|
||||
'node_uuid', **kwargs)
|
||||
|
||||
|
||||
class TestBIOSSettingShow(TestBaremetal):
|
||||
|
@ -847,8 +847,8 @@ class NodeManager(base.CreateManager):
|
||||
path, os_ironic_api_version=os_ironic_api_version,
|
||||
global_request_id=global_request_id).get(name)
|
||||
|
||||
def list_bios_settings(self, node_ident, os_ironic_api_version=None,
|
||||
global_request_id=None):
|
||||
def list_bios_settings(self, node_ident, detail=False, fields=None,
|
||||
os_ironic_api_version=None, global_request_id=None):
|
||||
"""List all BIOS settings from a node.
|
||||
|
||||
:param node_ident: node UUID or name.
|
||||
@ -856,8 +856,23 @@ class NodeManager(base.CreateManager):
|
||||
the request. If not specified, the client's default is used.
|
||||
:param global_request_id: String containing global request ID header
|
||||
value (in form "req-<UUID>") to use for the request.
|
||||
:param detail: Optional, boolean whether to return detailed information
|
||||
about bios settings.
|
||||
:param fields: Optional, a list with a specified set of fields
|
||||
of the resource to be returned. Can not be used
|
||||
when 'detail' is set.
|
||||
|
||||
"""
|
||||
if detail and fields:
|
||||
raise exc.InvalidAttribute(_("Can't fetch a subset of fields "
|
||||
"with 'detail' set"))
|
||||
|
||||
filters = utils.common_filters(detail=detail, fields=fields)
|
||||
path = "%s/bios" % node_ident
|
||||
|
||||
if filters:
|
||||
path += '?' + '&'.join(filters)
|
||||
|
||||
return self._list_primitives(
|
||||
self._path(path), 'bios',
|
||||
os_ironic_api_version=os_ironic_api_version,
|
||||
|
@ -34,11 +34,11 @@ class Resource(object):
|
||||
'address': 'Address',
|
||||
'alive': 'Alive',
|
||||
'allocation_uuid': 'Allocation UUID',
|
||||
'allowable_values': 'Allowable Values',
|
||||
'async': 'Async',
|
||||
'attribute_type': 'Attribute Type',
|
||||
'automated_clean': 'Automated Clean',
|
||||
'attach': 'Response is attachment',
|
||||
'bios_name': 'BIOS setting name',
|
||||
'bios_value': 'BIOS setting value',
|
||||
'boot_index': 'Boot Index',
|
||||
'boot_mode': 'Boot Mode',
|
||||
'candidate_nodes': 'Candidate Nodes',
|
||||
@ -89,9 +89,12 @@ class Resource(object):
|
||||
'internal_info': 'Internal Info',
|
||||
'last_error': 'Last Error',
|
||||
'lessee': 'Lessee',
|
||||
'lower_bound': 'Lower Bound',
|
||||
'maintenance': 'Maintenance',
|
||||
'maintenance_reason': 'Maintenance Reason',
|
||||
'max_length': 'Maximum Length',
|
||||
'fault': 'Fault',
|
||||
'min_length': 'Minimum Length',
|
||||
'mode': 'Mode',
|
||||
'name': 'Name',
|
||||
'network_data': 'Network Configuration',
|
||||
@ -104,6 +107,8 @@ class Resource(object):
|
||||
'provision_state': 'Provisioning State',
|
||||
'provision_updated_at': 'Provision Updated At',
|
||||
'raid_config': 'Current RAID configuration',
|
||||
'read_only': 'Read Only',
|
||||
'reset_required': 'Reset Required',
|
||||
'reservation': 'Reservation',
|
||||
'resource_class': 'Resource Class',
|
||||
'retired': 'Retired',
|
||||
@ -118,6 +123,7 @@ class Resource(object):
|
||||
'type': 'Type',
|
||||
'updated_at': 'Updated At',
|
||||
'uuid': 'UUID',
|
||||
'value': 'Value',
|
||||
'volume_id': 'Volume ID',
|
||||
'volume_type': 'Driver Volume Type',
|
||||
'local_link_connection': 'Local Link Connection',
|
||||
@ -134,6 +140,8 @@ class Resource(object):
|
||||
'raid_interface': 'RAID Interface',
|
||||
'rescue_interface': 'Rescue Interface',
|
||||
'storage_interface': 'Storage Interface',
|
||||
'unique': 'Unique',
|
||||
'upper_bound': 'Upper Bound',
|
||||
'vendor_interface': 'Vendor Interface',
|
||||
'standalone_ports_supported': 'Standalone Ports Supported',
|
||||
'physical_network': 'Physical Network',
|
||||
@ -381,7 +389,24 @@ TRAIT_RESOURCE = Resource(
|
||||
)
|
||||
|
||||
BIOS_RESOURCE = Resource(
|
||||
['bios_name', 'bios_value'],
|
||||
['name', 'value'],
|
||||
override_labels={'name': 'BIOS setting name',
|
||||
'value': 'BIOS setting value'}
|
||||
)
|
||||
|
||||
BIOS_DETAILED_RESOURCE = Resource(
|
||||
['name',
|
||||
'value',
|
||||
'attribute_type',
|
||||
'allowable_values',
|
||||
'lower_bound',
|
||||
'min_length',
|
||||
'max_length',
|
||||
'read_only',
|
||||
'reset_required',
|
||||
'unique',
|
||||
'upper_bound'
|
||||
],
|
||||
)
|
||||
|
||||
# Drivers
|
||||
|
@ -0,0 +1,8 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
Adds new params to the ``baremetal node bios setting list`` command to
|
||||
include support for the BIOS registry. The ``--long`` option will
|
||||
retrieve and display the additonal BIOS registry fields, the ``--fields``
|
||||
option will retrieve and display selected fields. The ``baremetal node
|
||||
bios setting show`` includes these fields by default with no changes.
|
Loading…
Reference in New Issue
Block a user