Merge pull request #144 from jstraw/master
Add parent server information to the shell output of image-list Rushed through for gerrit move
This commit is contained in:
commit
464fbbcb60
@ -20,6 +20,7 @@ def pretty_choice_list(l):
|
||||
|
||||
|
||||
def print_list(objs, fields, formatters={}):
|
||||
mixed_case_fields = ['serverId']
|
||||
pt = prettytable.PrettyTable([f for f in fields], caching=False)
|
||||
pt.aligns = ['l' for f in fields]
|
||||
|
||||
@ -29,7 +30,10 @@ def print_list(objs, fields, formatters={}):
|
||||
if field in formatters:
|
||||
row.append(formatters[field](o))
|
||||
else:
|
||||
field_name = field.lower().replace(' ', '_')
|
||||
if field in mixed_case_fields:
|
||||
field_name = field.replace(' ', '_')
|
||||
else:
|
||||
field_name = field.lower().replace(' ', '_')
|
||||
data = getattr(o, field_name, '')
|
||||
row.append(data)
|
||||
pt.add_row(row)
|
||||
|
@ -350,7 +350,15 @@ def do_flavor_list(cs, args):
|
||||
|
||||
def do_image_list(cs, args):
|
||||
"""Print a list of available images to boot from."""
|
||||
utils.print_list(cs.images.list(), ['ID', 'Name', 'Status'])
|
||||
server_list = {}
|
||||
for server in cs.servers.list():
|
||||
server_list[server.id] = server.name
|
||||
image_list = cs.images.list()
|
||||
for i in range(len(image_list)):
|
||||
if hasattr(image_list[i], 'serverId'):
|
||||
image_list[i].serverId = server_list[image_list[i].serverId] + \
|
||||
' (' + str(image_list[i].serverId) + ')'
|
||||
utils.print_list(image_list, ['ID', 'Name', 'serverId','Status'])
|
||||
|
||||
|
||||
@utils.arg('server', metavar='<server>', help='Name or ID of server.')
|
||||
|
@ -315,7 +315,15 @@ def do_flavor_list(cs, args):
|
||||
|
||||
def do_image_list(cs, args):
|
||||
"""Print a list of available images to boot from."""
|
||||
utils.print_list(cs.images.list(), ['ID', 'Name', 'Status'])
|
||||
server_list = {}
|
||||
for server in cs.servers.list():
|
||||
server_list[server.id] = server.name
|
||||
image_list = cs.images.list()
|
||||
for i in range(len(image_list)):
|
||||
if hasattr(image_list[i], 'serverId'):
|
||||
image_list[i].serverId = server_list[image_list[i].serverId] + \
|
||||
' (' + str(image_list[i].serverId) + ')'
|
||||
utils.print_list(cs.images.list(), ['ID', 'Name', 'serverId', 'Status'])
|
||||
|
||||
|
||||
@utils.arg('image',
|
||||
|
@ -287,7 +287,7 @@ class FakeHTTPClient(base_client.HTTPClient):
|
||||
{
|
||||
"id": 743,
|
||||
"name": "My Server Backup",
|
||||
"serverId": 12,
|
||||
"serverId": 1234,
|
||||
"updated": "2010-10-10T12:00:00Z",
|
||||
"created": "2010-08-10T12:00:00Z",
|
||||
"status": "SAVING",
|
||||
|
@ -359,7 +359,7 @@ class FakeHTTPClient(base_client.HTTPClient):
|
||||
{
|
||||
"id": 743,
|
||||
"name": "My Server Backup",
|
||||
"serverId": 12,
|
||||
"serverId": 1234,
|
||||
"updated": "2010-10-10T12:00:00Z",
|
||||
"created": "2010-08-10T12:00:00Z",
|
||||
"status": "SAVING",
|
||||
|
Loading…
Reference in New Issue
Block a user