Rewrite link parsing for finding v2 schemas

What we called 'links' are no longer returned in a container of
objects, they are top-level entity attribtues. This fixes the
parsing of the entities to look in the correct place when trying
to locate a specific schema.

Add a helper for printing to stderr and exiting with a non-zero
exit code.

Map 'name' to 'Attribute' when explaining a schema.

Related to bp glance-client-v2

Change-Id: Ib98e912a7af0bb570b4fd738733edd9b837d1a05
This commit is contained in:
Brian Waldon
2012-07-13 22:03:22 +00:00
parent 53acf1a0ca
commit f0445a1b44
4 changed files with 26 additions and 13 deletions
+10 -4
View File
@@ -14,6 +14,7 @@
# under the License.
from glanceclient.common import utils
from glanceclient import exc
def do_image_list(gc, args):
@@ -23,9 +24,14 @@ def do_image_list(gc, args):
utils.print_list(images, columns)
@utils.arg('name', metavar='<NAME>', help='Name of model to describe.')
@utils.arg('model', metavar='<MODEL>', help='Name of model to describe.')
def do_explain(gc, args):
"""Describe a specific model."""
schema = gc.schemas.get(args.name)
columns = ['Name', 'Description']
utils.print_list(schema.properties, columns)
try:
schema = gc.schemas.get(args.model)
except exc.SchemaNotFound:
utils.exit('Unable to find requested model \'%s\'' % args.model)
else:
formatters = {'Attribute': lambda m: m.name}
columns = ['Attribute', 'Description']
utils.print_list(schema.properties, columns, formatters)