Add an API extension for creating+deleting flavors

This extension is a step towards deprecating openstackx for horizon.
Most of the extension code is based on the equivalent in openstackx.

v2:
    s/lifecycle/manage/ for all bits
    Address Pádraig style issues
    Drop purge API option
    Adjust now inaccurate comment in DB api
    Make extension admin_only
    Extend existing /flavors namespace rather than os-flavor-lifecycle
    Only allow API access from admin user

v3:
    Some pep8 fixes

v4:
    Adjust to root_gb, ephemeral_gb changes
    Drop admin_only (it's on the way out AIUI)

Change-Id: I3fdfccdd8e7337e1759f5875c3b15fa9954371ef
This commit is contained in:
Cole Robinson 2012-01-19 18:39:11 -05:00
parent 2a2d42277e
commit d8363ae3e1

@ -3340,13 +3340,13 @@ def instance_type_create(context, values):
instance_type_ref.save()
except Exception, e:
raise exception.DBError(e)
return instance_type_ref
return _dict_with_extra_specs(instance_type_ref)
def _dict_with_extra_specs(inst_type_query):
"""Takes an instance OR volume type query returned by sqlalchemy
and returns it as a dictionary, converting the extra_specs
entry from a list of dicts:
"""Takes an instance, volume, or instance type query returned
by sqlalchemy and returns it as a dictionary, converting the
extra_specs entry from a list of dicts:
'extra_specs' : [{'key': 'k1', 'value': 'v1', ...}, ...]