"vbmc list" to sort the result by domain name
This patch is making the result of "vbmc list" command to sort the table by the domain name, that's visually easier to follow. This patch also makes use of the PrettyTable's get_string() method when printing a table for the "list" and "show" commands. Change-Id: I6bd6d0d9f5a9d2eeaa791d1e9d56bb3dc4131da2
This commit is contained in:
parent
b14ae0b9ee
commit
03cda5571a
@ -132,18 +132,19 @@ def main():
|
||||
manager.stop(domain)
|
||||
|
||||
elif args.command == 'list':
|
||||
ptable = PrettyTable(['Domain name', 'Status', 'Address', 'Port'])
|
||||
fields = ('Domain name', 'Status', 'Address', 'Port')
|
||||
ptable = PrettyTable(fields)
|
||||
for bmc in manager.list():
|
||||
ptable.add_row([bmc['domain_name'], bmc['status'],
|
||||
bmc['address'], bmc['port']])
|
||||
print(ptable)
|
||||
print(ptable.get_string(sortby=fields[0]))
|
||||
|
||||
elif args.command == 'show':
|
||||
ptable = PrettyTable(['Property', 'Value'])
|
||||
bmc = manager.show(args.domain_name)
|
||||
for key, val in sorted(bmc.items()):
|
||||
ptable.add_row([key, val])
|
||||
print(ptable)
|
||||
print(ptable.get_string())
|
||||
|
||||
except exception.VirtualBMCError as e:
|
||||
print(e, file=sys.stderr)
|
||||
|
@ -108,8 +108,8 @@ class VBMCTestCase(base.TestCase):
|
||||
+-------------+---------+---------+------+
|
||||
| Domain name | Status | Address | Port |
|
||||
+-------------+---------+---------+------+
|
||||
| node-1 | running | :: | 321 |
|
||||
| node-0 | running | :: | 123 |
|
||||
| node-1 | running | :: | 321 |
|
||||
+-------------+---------+---------+------+
|
||||
"""
|
||||
self.assertEqual(expected_output, out)
|
||||
|
Loading…
x
Reference in New Issue
Block a user