summaryrefslogtreecommitdiffstats
path: root/nova/compute
diff options
context:
space:
mode:
authorKen'ichi Ohmichi <oomichi@mxs.nes.nec.co.jp>2012-11-20 01:24:48 +0000
committerKen'ichi Ohmichi <oomichi@mxs.nes.nec.co.jp>2012-11-20 01:52:23 +0000
commita19d64808f3c4ab1cc3306ac3678701d0fff3e87 (patch)
tree9d8a240813fe06926bc563f765aea6f132edd512 /nova/compute
parente60d593b5ec254bb74fca39db7164f57db90be47 (diff)
Return an error response if the specified flavor does not exists. (v4)
'nova list --flavor <id>' command outputs empty list, if there is not any instance or flavor. A user cannot know the reason of empty list easily. This patch changes a response to error if the specified flavor-id does not exist instead of empty list. Example: $ nova flavor-list +----+-----------+-----------+------+-----------+------+-------+-------------+-----------+-------------+ | ID | Name | Memory_MB | Disk | Ephemeral | Swap | VCPUs | RXTX_Factor | Is_Public | extra_specs | +----+-----------+-----------+------+-----------+------+-------+-------------+-----------+-------------+ | 1 | m1.tiny | 512 | 0 | 0 | | 1 | 1.0 | True | {} | | 2 | m1.small | 2048 | 20 | 0 | | 1 | 1.0 | True | {} | | 3 | m1.medium | 4096 | 40 | 0 | | 2 | 1.0 | True | {} | | 4 | m1.large | 8192 | 80 | 0 | | 4 | 1.0 | True | {} | | 5 | m1.xlarge | 16384 | 160 | 0 | | 8 | 1.0 | True | {} | +----+-----------+-----------+------+-----------+------+-------+-------------+-----------+-------------+ Before applying this patch: $ nova list --flavor 10 $ After applying this patch: $ nova list --flavor 10 ERROR: Flavor could not be found (HTTP 422) (Request-ID: req-003d4bbc-f338-4361-9eeb-1cf18073a5a8) $ Changelog of v4: * Change a response code of NotFoundFlavor from 404 to 422. Changelog of v3: * Merge patchset2(change a response of test_get_all_by_flavor) into one patch. * Change a response code of NotFoundFlavor from 400 to 404. Fixes bug 1076863 Change-Id: I45f35ae6a4bf1de734c258ef819fb9b4d7f9681e
Diffstat (limited to 'nova/compute')
-rw-r--r--nova/compute/api.py7
1 files changed, 2 insertions, 5 deletions
diff --git a/nova/compute/api.py b/nova/compute/api.py
index 6da04c97b..948cf3fea 100644
--- a/nova/compute/api.py
+++ b/nova/compute/api.py
@@ -1122,11 +1122,8 @@ class API(base.Base):
filters = {}
def _remap_flavor_filter(flavor_id):
- try:
- instance_type = instance_types.get_instance_type_by_flavor_id(
- flavor_id)
- except exception.FlavorNotFound:
- raise ValueError()
+ instance_type = instance_types.get_instance_type_by_flavor_id(
+ flavor_id)
filters['instance_type_id'] = instance_type['id']