summaryrefslogtreecommitdiffstats
path: root/nova/db
diff options
context:
space:
mode:
authorKen Pepple <ken.pepple@gmail.com>2011-02-08 11:24:05 -0800
committerKen Pepple <ken.pepple@gmail.com>2011-02-08 11:24:05 -0800
commitffc788fb41bf5a4bcb85cfa80b3437ed94d46291 (patch)
treed8c0f161806ad224ba7213048f6d7a45b57dc0b2 /nova/db
parentbb2a379e2827ceccc5b46b0a9936e6dcedc6499e (diff)
additional error checking for nova-manage instance_type
Diffstat (limited to 'nova/db')
-rw-r--r--nova/db/sqlalchemy/api.py26
1 files changed, 19 insertions, 7 deletions
diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py
index 6065af9ca..f084423e1 100644
--- a/nova/db/sqlalchemy/api.py
+++ b/nova/db/sqlalchemy/api.py
@@ -2044,10 +2044,13 @@ def instance_type_get_all(context):
filter_by(deleted=0).\
order_by("name").\
all()
- inst_dict = {}
- for i in inst_types:
- inst_dict[i['name']] = dict(i)
- return inst_dict
+ if inst_types:
+ inst_dict = {}
+ for i in inst_types:
+ inst_dict[i['name']] = dict(i)
+ return inst_dict
+ else:
+ raise exception.NotFound
@require_context
@@ -2057,7 +2060,10 @@ def instance_type_get_by_name(context, name):
inst_type = session.query(models.InstanceTypes).\
filter_by(name=name).\
first()
- return dict(inst_type)
+ if not inst_type:
+ raise exception.NotFound(_("No instance type with name %s") % name)
+ else:
+ return dict(inst_type)
@require_context
@@ -2067,7 +2073,10 @@ def instance_type_get_by_flavor_id(context, id):
inst_type = session.query(models.InstanceTypes).\
filter_by(flavorid=int(id)).\
first()
- return dict(inst_type)
+ if not inst_type:
+ raise exception.NotFound(_("No flavor with name %s") % id)
+ else:
+ return dict(inst_type)
@require_admin_context
@@ -2077,4 +2086,7 @@ def instance_type_destroy(context, name):
instance_type_ref = session.query(models.InstanceTypes).\
filter_by(name=name)
rows = instance_type_ref.update(dict(deleted=1))
- return rows
+ if not rows:
+ raise exception.NotFound(_("Couldn't delete instance type %s") % name)
+ else:
+ return rows