summaryrefslogtreecommitdiff
path: root/glanceclient/common/utils.py
diff options
context:
space:
mode:
authorBrian Waldon <bcwaldon@gmail.com>2012-07-13 22:03:22 +0000
committerBrian Waldon <bcwaldon@gmail.com>2012-07-13 18:38:40 -0700
commitf0445a1b443182cf77e27038cc5f90c424e00c62 (patch)
tree8c88d0fda0bfdaa5267198e38442f9fdc718bb50 /glanceclient/common/utils.py
parent53acf1a0ca70c900267286a249e476fffe078a9f (diff)
downloadpython-glanceclient-f0445a1b443182cf77e27038cc5f90c424e00c62.tar.gz
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
Diffstat (limited to 'glanceclient/common/utils.py')
-rw-r--r--glanceclient/common/utils.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/glanceclient/common/utils.py b/glanceclient/common/utils.py
index 8bbb7ac..07e77a1 100644
--- a/glanceclient/common/utils.py
+++ b/glanceclient/common/utils.py
@@ -14,6 +14,7 @@
# under the License.
import os
+import sys
import uuid
import prettytable
@@ -47,7 +48,7 @@ def print_list(objs, fields, formatters={}):
row.append(formatters[field](o))
else:
field_name = field.lower().replace(' ', '_')
- data = getattr(o, field_name, '')
+ data = getattr(o, field_name, None) or ''
row.append(data)
pt.add_row(row)
@@ -123,3 +124,9 @@ def import_versioned_module(version, submodule=None):
if submodule:
module = '.'.join((module, submodule))
return importutils.import_module(module)
+
+
+def exit(msg=''):
+ if msg:
+ print >> sys.stderr, msg
+ sys.exit(1)