Skip to content

Commit

Permalink
Clean up image-show
Browse files Browse the repository at this point in the history
- parse server entity to just an id
- parse metadata out into separate rows

Change-Id: I8927b148714a7f5ed64bbb74bd79193e258cb34d
  • Loading branch information
Brian Waldon committed Dec 7, 2011
1 parent 9067f26 commit f866c6e
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion novaclient/v1_1/shell.py
Expand Up @@ -360,9 +360,27 @@ def do_image_meta(cs, args):


def _print_image(image):
links = image.links
info = image._info.copy()

# ignore links, we don't need to present those
info.pop('links')

# try to replace a server entity to just an id
server = info.pop('server', None)
try:
info['server'] = server['id']
except (KeyError, TypeError):
pass

# break up metadata and display each on its own row
metadata = info.pop('metadata', {})
try:
for key, value in metadata.items():
_key = 'metadata %s' % key
info[_key] = value
except AttributeError:
pass

utils.print_dict(info)


Expand Down

0 comments on commit f866c6e

Please sign in to comment.