Auto-Assign Flavor ID

Auto-assign a flavor ID if the user enters "auto" for the ID.

Change-Id: I745744b9ca44668477635c20df5e2ece6cbf1c27
This commit is contained in:
sathish-nagappan 2012-10-29 14:26:32 -07:00
parent 05bbe0fa0e
commit 67d4d7e0fd
3 changed files with 3 additions and 11 deletions

View File

@ -133,10 +133,8 @@ class FlavorManager(base.ManagerWithFind):
except:
raise exceptions.CommandError("Disk must be an integer.")
try:
flavorid = int(flavorid)
except:
raise exceptions.CommandError("Flavor ID must be an integer.")
if flavorid == "auto":
flavorid = None
try:
swap = int(swap)
@ -159,7 +157,7 @@ class FlavorManager(base.ManagerWithFind):
"ram": int(ram),
"vcpus": int(vcpus),
"disk": int(disk),
"id": int(flavorid),
"id": flavorid,
"swap": int(swap),
"OS-FLV-EXT-DATA:ephemeral": int(ephemeral),
"rxtx_factor": int(rxtx_factor),

View File

@ -341,9 +341,6 @@ def _print_flavor_list(cs, flavors):
def do_flavor_list(cs, _args):
"""Print a list of available 'flavors' (sizes of servers)."""
flavors = cs.flavors.list()
for flavor in flavors:
# int needed for numerical sort
flavor.id = int(flavor.id)
_print_flavor_list(cs, flavors)

View File

@ -98,9 +98,6 @@ class FlavorsTest(utils.TestCase):
self.assertRaises(exceptions.CommandError, cs.flavors.create,
"flavorcreate", 512, 1, "invalid", 1234, swap=0,
ephemeral=0, rxtx_factor=1, is_public=True)
self.assertRaises(exceptions.CommandError, cs.flavors.create,
"flavorcreate", 512, 1, 10, "invalid", swap=0,
ephemeral=0, rxtx_factor=1, is_public=True)
self.assertRaises(exceptions.CommandError, cs.flavors.create,
"flavorcreate", 512, 1, 10, 1234, swap="invalid",
ephemeral=0, rxtx_factor=1, is_public=True)