Fix mac address and task_state in baremetal-node-list

Currently nova baremetal-node-list doesn't display the
list of MAC addresses for each node because this is part
of the interfaces object, and not a top level field.

It also doesn't display the task state, which is very useful
when trying to find which nodes have failed to build.

This change fixes both issues

Change-Id: If7a3bcab1220be400519ac811bd727ca8ff85827
Closes-Bug: #1308147
This commit is contained in:
Phil Day 2014-04-15 17:46:01 +00:00
parent 5ff5e05fac
commit a4db0feab4

View File

@ -219,10 +219,22 @@ def _translate_baremetal_node_keys(collection):
def _print_baremetal_nodes_list(nodes): def _print_baremetal_nodes_list(nodes):
"""Print the list of baremetal nodes.""" """Print the list of baremetal nodes."""
def _parse_address(fields):
macs = []
for interface in fields.interfaces:
macs.append(interface['address'])
return ', '.join("%s" % i for i in macs)
formatters = {
'MAC Address': _parse_address
}
_translate_baremetal_node_keys(nodes) _translate_baremetal_node_keys(nodes)
utils.print_list(nodes, [ utils.print_list(nodes, [
'ID', 'ID',
'Host', 'Host',
'Task State',
'CPUs', 'CPUs',
'Memory_MB', 'Memory_MB',
'Disk_GB', 'Disk_GB',
@ -231,7 +243,7 @@ def _print_baremetal_nodes_list(nodes):
'PM Username', 'PM Username',
'PM Password', 'PM Password',
'Terminal Port', 'Terminal Port',
]) ], formatters=formatters)
def do_baremetal_node_list(cs, _args): def do_baremetal_node_list(cs, _args):