summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKen Pepple <ken.pepple@gmail.com>2011-02-09 11:36:45 -0800
committerKen Pepple <ken.pepple@gmail.com>2011-02-09 11:36:45 -0800
commit99a02a7d68416c72675f7b6c554df9b682771e04 (patch)
treea7482901c61f93ecac4d485356efa24f156075d9
parentdd2544345e1686ee1ed020fd8f14607d10d8b3d1 (diff)
added support to pull list of ALL instance types even those that are marked deleted
-rw-r--r--nova/compute/instance_types.py14
-rw-r--r--nova/db/api.py4
-rw-r--r--nova/db/sqlalchemy/api.py6
3 files changed, 13 insertions, 11 deletions
diff --git a/nova/compute/instance_types.py b/nova/compute/instance_types.py
index b97a0da25..b13ccda43 100644
--- a/nova/compute/instance_types.py
+++ b/nova/compute/instance_types.py
@@ -55,13 +55,15 @@ def destroy(name):
return records
-def get_all_types():
- """retrieves all instance_types"""
- return db.instance_type_get_all(context.get_admin_context())
+def get_all_types(inactive=0):
+ """Retrieves non-deleted instance_types.
+ Pass true as argument if you want deleted instance types returned also."""
+ return db.instance_type_get_all(context.get_admin_context(), inactive)
def get_all_flavors():
- """retrieves all flavors. alias for instance_types.get_all_types()"""
+ """retrieves non-deleted flavors. alias for instance_types.get_all_types().
+ Pass true as argument if you want deleted instance types returned also."""
return get_all_types(context.get_admin_context())
@@ -79,7 +81,7 @@ def get_instance_type(name):
def get_by_type(instance_type):
- """retrieve instance_type details"""
+ """retrieve instance type name"""
if instance_type is None:
return FLAGS.default_instance_type
try:
@@ -92,7 +94,7 @@ def get_by_type(instance_type):
def get_by_flavor_id(flavor_id):
- """retrieve instance_type's name by flavor_id"""
+ """retrieve instance type's name by flavor_id"""
if flavor_id is None:
return FLAGS.default_instance_type
try:
diff --git a/nova/db/api.py b/nova/db/api.py
index 2f1903ade..69f577764 100644
--- a/nova/db/api.py
+++ b/nova/db/api.py
@@ -995,9 +995,9 @@ def instance_type_create(context, values):
return IMPL.instance_type_create(context, values)
-def instance_type_get_all(context):
+def instance_type_get_all(context, inactive=0):
"""Get all instance types"""
- return IMPL.instance_type_get_all(context)
+ return IMPL.instance_type_get_all(context, inactive)
def instance_type_get_by_name(context, name):
diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py
index e5afb8eac..1e13e4d2d 100644
--- a/nova/db/sqlalchemy/api.py
+++ b/nova/db/sqlalchemy/api.py
@@ -2035,16 +2035,16 @@ def instance_type_create(context, values):
@require_context
-def instance_type_get_all(context):
+def instance_type_get_all(context, inactive=0):
"""
- Returns a dict describing all instance_types with name as key:
+ Returns a dict describing all non-deleted instance_types with name as key:
{'m1.tiny': dict(memory_mb=512, vcpus=1, local_gb=0, flavorid=1),
'm1.small': dict(memory_mb=2048, vcpus=1, local_gb=20, flavorid=2),
'm1.medium': dict(memory_mb=4096, vcpus=2, local_gb=40, flavorid=3)}
"""
session = get_session()
inst_types = session.query(models.InstanceTypes).\
- filter_by(deleted=0).\
+ filter_by(deleted=inactive).\
order_by("name").\
all()
if inst_types: