mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
get valid properties for image_show() from the schema for "image"
This commit is contained in:
parent
0c6a61173a
commit
19a20bf228
1 changed files with 29 additions and 16 deletions
|
@ -184,7 +184,7 @@ def image_create(name, location, profile=None, visibility='public',
|
|||
'of the following: {0}'.format(', '.join(df_list)))
|
||||
g_client = _auth(profile)
|
||||
|
||||
image = g_client.images.create(name=name, Location=location)
|
||||
image = g_client.images.create(name=name, location=location)
|
||||
# Icehouse glanceclient doesn't have add_location()
|
||||
#if 'add_location' in dir(g_client.images):
|
||||
# g_client.images.add_location(image.id, location)
|
||||
|
@ -246,21 +246,11 @@ def image_show(id=None, name=None, profile=None): # pylint: disable=C0103
|
|||
log.debug('Properties of image {0}:\n{1}'.format(
|
||||
image.name, pformat(image)))
|
||||
# TODO: Get rid of the wrapping dict, see #24568
|
||||
ret[image.name] = {
|
||||
'id': image.id,
|
||||
'name': image.name,
|
||||
'created_at': image.created_at,
|
||||
'file': image.file,
|
||||
'min_disk': image.min_disk,
|
||||
'min_ram': image.min_ram,
|
||||
'owner': image.owner,
|
||||
'protected': image.protected,
|
||||
'status': image.status,
|
||||
'tags': image.tags,
|
||||
'updated_at': image.updated_at,
|
||||
'visibility': image.visibility,
|
||||
}
|
||||
for key in ['container_format', 'location', 'disk_format', 'size']:
|
||||
ret[image.name] = {}
|
||||
schema = image_schema(profile=profile)
|
||||
if len(schema.keys()) == 1:
|
||||
schema = schema['image']
|
||||
for key in schema.keys():
|
||||
if image.has_key(key):
|
||||
ret[image.name][key] = image[key]
|
||||
return ret
|
||||
|
@ -312,6 +302,29 @@ def image_list(id=None, profile=None): # pylint: disable=C0103
|
|||
return ret[image.name]
|
||||
return ret
|
||||
|
||||
def image_schema(profile=None):
|
||||
'''
|
||||
Returns names and descriptions of the schema "image"'s
|
||||
properties for this profile's instance of glance
|
||||
'''
|
||||
return schema_get('image', profile)
|
||||
|
||||
def schema_get(name, profile=None):
|
||||
'''
|
||||
Known valid names of schemas are:
|
||||
- image
|
||||
- images
|
||||
- member
|
||||
- members
|
||||
'''
|
||||
g_client = _auth(profile)
|
||||
pformat = pprint.PrettyPrinter(indent=4).pformat
|
||||
schema_props = {}
|
||||
for prop in g_client.schemas.get(name).properties:
|
||||
schema_props[prop.name] = prop.description
|
||||
log.debug('Properties of schema {0}:\n{1}'.format(
|
||||
name, pformat(schema_props)))
|
||||
return {name: schema_props}
|
||||
|
||||
def _item_list(profile=None):
|
||||
'''
|
||||
|
|
Loading…
Add table
Reference in a new issue