summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorRick Harris <rconradharris@gmail.com>2013-05-14 01:01:33 +0000
committerRick Harris <rconradharris@gmail.com>2013-05-14 05:10:24 +0000
commit6f89e26d01b33942398165cdd7ccd168533170c4 (patch)
treeea11ac4ed35bf3e6116def5a523e86c84598ab6a /nova/api
parent87afef9121a6299f92a3b24059009c1c7a966d39 (diff)
Cleanups for create-flavor
Instead of setting defaults values to None in the signature and then setting the *real* default in the function body, it's more concise/readable to set the value in the signature itself (when dealing with immutable types). Along with this, the handling of `memory_mb` and `vcpus` was detangled so the attributes were handled in one place and not across both the non-negative and positive int checks. Change-Id: I1c06768c2fd076adc8c0a647a492dabb67b7bf79
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/openstack/compute/contrib/flavormanage.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/nova/api/openstack/compute/contrib/flavormanage.py b/nova/api/openstack/compute/contrib/flavormanage.py
index c36b40125..086c541dc 100644
--- a/nova/api/openstack/compute/contrib/flavormanage.py
+++ b/nova/api/openstack/compute/contrib/flavormanage.py
@@ -58,18 +58,20 @@ class FlavorManageController(wsgi.Controller):
vals = body['flavor']
name = vals['name']
flavorid = vals.get('id')
- memory_mb = vals.get('ram')
+ memory = vals.get('ram')
vcpus = vals.get('vcpus')
root_gb = vals.get('disk')
- ephemeral_gb = vals.get('OS-FLV-EXT-DATA:ephemeral')
- swap = vals.get('swap')
- rxtx_factor = vals.get('rxtx_factor')
+ ephemeral_gb = vals.get('OS-FLV-EXT-DATA:ephemeral', 0)
+ swap = vals.get('swap', 0)
+ rxtx_factor = vals.get('rxtx_factor', 1.0)
is_public = vals.get('os-flavor-access:is_public', True)
try:
- flavor = flavors.create(name, memory_mb, vcpus,
- root_gb, ephemeral_gb, flavorid,
- swap, rxtx_factor, is_public)
+ flavor = flavors.create(name, memory, vcpus, root_gb,
+ ephemeral_gb=ephemeral_gb,
+ flavorid=flavorid, swap=swap,
+ rxtx_factor=rxtx_factor,
+ is_public=is_public)
req.cache_db_flavor(flavor)
except (exception.InstanceTypeExists,
exception.InstanceTypeIdExists) as err: