summaryrefslogtreecommitdiff
path: root/nova/db
diff options
context:
space:
mode:
authorHans Lindgren <hanlind@kth.se>2015-11-09 19:29:20 +0100
committerHans Lindgren <hanlind@kth.se>2016-05-19 16:05:19 +0200
commit43e6a067184127c7f5ab9bfb67c07430f2c7fd14 (patch)
tree2a94d6995b712248245116327cf68ea4cfbfaf0c /nova/db
parentfe8a119e8d80de35d7f99e0c1d9a9e5095840146 (diff)
downloadnova-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/db')
-rw-r--r--nova/db/api.py4
-rw-r--r--nova/db/sqlalchemy/api.py6
2 files changed, 5 insertions, 5 deletions
diff --git a/nova/db/api.py b/nova/db/api.py
index a5bc8fe167..0036829872 100644
--- a/nova/db/api.py
+++ b/nova/db/api.py
@@ -1527,9 +1527,9 @@ def flavor_get_by_flavor_id(context, id, read_deleted=None):
return IMPL.flavor_get_by_flavor_id(context, id, read_deleted)
-def flavor_destroy(context, name):
+def flavor_destroy(context, flavor_id):
"""Delete an instance type."""
- return IMPL.flavor_destroy(context, name)
+ return IMPL.flavor_destroy(context, flavor_id)
def flavor_access_get_by_flavor_id(context, flavor_id):
diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py
index 416fad8b10..0407e62ff0 100644
--- a/nova/db/sqlalchemy/api.py
+++ b/nova/db/sqlalchemy/api.py
@@ -5204,13 +5204,13 @@ def flavor_get_by_flavor_id(context, flavor_id, read_deleted):
@main_context_manager.writer
-def flavor_destroy(context, name):
+def flavor_destroy(context, flavor_id):
"""Marks specific flavor as deleted."""
ref = model_query(context, models.InstanceTypes, read_deleted="no").\
- filter_by(name=name).\
+ filter_by(flavorid=flavor_id).\
first()
if not ref:
- raise exception.FlavorNotFoundByName(flavor_name=name)
+ raise exception.FlavorNotFound(flavor_id=flavor_id)
ref.soft_delete(context.session)
model_query(context, models.InstanceTypeExtraSpecs, read_deleted="no").\