From 6f89e26d01b33942398165cdd7ccd168533170c4 Mon Sep 17 00:00:00 2001 From: Rick Harris Date: Tue, 14 May 2013 01:01:33 +0000 Subject: 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 --- nova/api/openstack/compute/contrib/flavormanage.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'nova/api') 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: -- cgit