diff options
author | Hans Lindgren <hanlind@kth.se> | 2015-11-09 19:29:20 +0100 |
---|---|---|
committer | Hans Lindgren <hanlind@kth.se> | 2016-05-19 16:05:19 +0200 |
commit | 43e6a067184127c7f5ab9bfb67c07430f2c7fd14 (patch) | |
tree | 2a94d6995b712248245116327cf68ea4cfbfaf0c /nova/compute/flavors.py | |
parent | fe8a119e8d80de35d7f99e0c1d9a9e5095840146 (diff) | |
download | nova-43e6a067184127c7f5ab9bfb67c07430f2c7fd14.tar.gz |
Make flavor-manage api call destroy with Flavor object
The flavor-manage api delete command currently need 3 separate db calls
to remove a flavor from the db. This is due to the use of flavor name to
identify the db flavor when the api command itself take flavorid as
input.
This change reworks this to only issue a single db call that now use
flavorid all way through to the db. It also gets rid of the in between
flavors module by calling destroy on a Flavor object right from the api.
Additional test changes are made to similarily bypass the flavors module
and instead call destroy() directly on the Flavor objects so the flavors
method becomes unused and thus can be removed.
Change-Id: I62bc11887283201be0bcdcfe9fa58b3f6156c754
Diffstat (limited to 'nova/compute/flavors.py')
-rw-r--r-- | nova/compute/flavors.py | 16 |
1 files changed, 0 insertions, 16 deletions
diff --git a/nova/compute/flavors.py b/nova/compute/flavors.py index ded0e35055..660923da76 100644 --- a/nova/compute/flavors.py +++ b/nova/compute/flavors.py @@ -21,7 +21,6 @@ import re import uuid -from oslo_log import log as logging from oslo_utils import strutils import six @@ -31,14 +30,11 @@ from nova import context from nova import db from nova import exception from nova.i18n import _ -from nova.i18n import _LE from nova import objects from nova import utils CONF = nova.conf.CONF -LOG = logging.getLogger(__name__) - # NOTE(luisg): Flavor names can include non-ascii characters so that users can # create flavor names in locales that use them, however flavor IDs are limited # to ascii characters. @@ -168,18 +164,6 @@ def create(name, memory, vcpus, root_gb, ephemeral_gb=0, flavorid=None, return flavor -def destroy(name): - """Marks flavor as deleted.""" - try: - if not name: - raise ValueError() - flavor = objects.Flavor(context=context.get_admin_context(), name=name) - flavor.destroy() - except (ValueError, exception.NotFound): - LOG.exception(_LE('Instance type %s not found for deletion'), name) - raise exception.FlavorNotFoundByName(flavor_name=name) - - def get_all_flavors_sorted_list(ctxt=None, filters=None, sort_key='flavorid', sort_dir='asc', limit=None, marker=None): """Get all non-deleted flavors as a sorted list. |