diff options
| author | Rick Harris <rconradharris@gmail.com> | 2012-05-29 22:28:17 +0000 |
|---|---|---|
| committer | Rick Harris <rconradharris@gmail.com> | 2012-06-05 14:52:38 -0500 |
| commit | f371198b843ba17ad6a6e4bc77a58afb006ab677 (patch) | |
| tree | 932df1706d76c516ad65ea20129bb392e0480c8d /nova/api | |
| parent | 9a020a6ecf5d0ec1a49e8f52ce1c8908ae51e2b5 (diff) | |
| download | nova-f371198b843ba17ad6a6e4bc77a58afb006ab677.tar.gz nova-f371198b843ba17ad6a6e4bc77a58afb006ab677.tar.xz nova-f371198b843ba17ad6a6e4bc77a58afb006ab677.zip | |
Adds `disabled` field for instance-types.
The `disabled` field is intended to be used when phasing out
instance-types. In this case, a delete wouldn't work because the
instance-type needs to still be available for live instances using that
type, but we don't want to allow *new* instances created from that type.
In addition, we don't want to list hidden instance-types for regular
users, but we *do* want to list them for admin-users to ensure they have
a complete view of what's going on in the system.
Once all references to the phased-out instance-type have been dropped,
it would be safe to mark the instance-type as `deleted=True`.
Change-Id: I2af1c027f4d8114aee31353007dfdd3d0bb679ed
Diffstat (limited to 'nova/api')
| -rw-r--r-- | nova/api/openstack/compute/contrib/flavorextradata.py | 3 | ||||
| -rw-r--r-- | nova/api/openstack/compute/flavors.py | 5 | ||||
| -rw-r--r-- | nova/api/openstack/compute/servers.py | 2 | ||||
| -rw-r--r-- | nova/api/openstack/compute/views/flavors.py | 10 |
4 files changed, 18 insertions, 2 deletions
diff --git a/nova/api/openstack/compute/contrib/flavorextradata.py b/nova/api/openstack/compute/contrib/flavorextradata.py index 2864ada5e..d50734817 100644 --- a/nova/api/openstack/compute/contrib/flavorextradata.py +++ b/nova/api/openstack/compute/contrib/flavorextradata.py @@ -37,7 +37,8 @@ authorize = extensions.soft_extension_authorizer('compute', 'flavorextradata') class FlavorextradataController(wsgi.Controller): def _get_flavor_refs(self): """Return a dictionary mapping flavorid to flavor_ref.""" - flavor_refs = instance_types.get_all_types(True) + + flavor_refs = instance_types.get_all_types(inactive=True) rval = {} for name, obj in flavor_refs.iteritems(): rval[obj['flavorid']] = obj diff --git a/nova/api/openstack/compute/flavors.py b/nova/api/openstack/compute/flavors.py index 23c918924..56b2e18ab 100644 --- a/nova/api/openstack/compute/flavors.py +++ b/nova/api/openstack/compute/flavors.py @@ -94,6 +94,11 @@ class Controller(wsgi.Controller): def _get_flavors(self, req): """Helper function that returns a list of flavor dicts.""" filters = {} + + context = req.environ['nova.context'] + if not context.is_admin: + filters['disabled'] = False + if 'minRam' in req.params: try: filters['min_memory_mb'] = int(req.params['minRam']) diff --git a/nova/api/openstack/compute/servers.py b/nova/api/openstack/compute/servers.py index 7bf3d59d0..64af7222f 100644 --- a/nova/api/openstack/compute/servers.py +++ b/nova/api/openstack/compute/servers.py @@ -704,6 +704,8 @@ class Controller(wsgi.Controller): headers={'Retry-After': 0}) except exception.InstanceTypeMemoryTooSmall as error: raise exc.HTTPBadRequest(explanation=unicode(error)) + except exception.InstanceTypeNotFound as error: + raise exc.HTTPBadRequest(explanation=unicode(error)) except exception.InstanceTypeDiskTooSmall as error: raise exc.HTTPBadRequest(explanation=unicode(error)) except exception.InvalidMetadata as error: diff --git a/nova/api/openstack/compute/views/flavors.py b/nova/api/openstack/compute/views/flavors.py index 7406e8066..c299170b0 100644 --- a/nova/api/openstack/compute/views/flavors.py +++ b/nova/api/openstack/compute/views/flavors.py @@ -34,7 +34,7 @@ class ViewBuilder(common.ViewBuilder): } def show(self, request, flavor): - return { + flavor_dict = { "flavor": { "id": flavor["flavorid"], "name": flavor["name"], @@ -49,6 +49,14 @@ class ViewBuilder(common.ViewBuilder): }, } + # NOTE(sirp): disabled attribute is namespaced for now for + # compatability with the OpenStack API. This should ultimately be made + # a first class attribute. + flavor_dict["flavor"]["OS-FLV-DISABLED:disabled"] =\ + flavor.get("disabled", "") + + return flavor_dict + def index(self, request, flavors): """Return the 'index' view of flavors.""" return self._list_view(self.basic, request, flavors) |
