Create Flavors without Optional Arguments

fixes Bug #1056910

Allows the user to create a flavor without optional arguments.
The variable, ephemeral, is not currently set to a default value.
This none type value causes exceptions in subsequent code, which
occurs when specifying only mandatory parameters.

Change-Id: Ic440136b000dc296bef3bb6f8b0856ff5e7e4e79
This commit is contained in:
Sathish Nagappan
2012-10-18 05:00:47 -07:00
parent 254b479bf0
commit 38aa742551
2 changed files with 25 additions and 1 deletions

View File

@@ -832,7 +832,7 @@ class InstanceTypeCommands(object):
help='rxtx_factor')
@args('--is_public', dest="is_public", metavar='<is_public>',
help='Make flavor accessible to the public')
def create(self, name, memory, vcpus, root_gb, ephemeral_gb, flavorid=None,
def create(self, name, memory, vcpus, root_gb, ephemeral_gb=0, flavorid=None,
swap=0, rxtx_factor=1, is_public=True):
"""Creates instance types / flavors"""
try:

View File

@@ -56,6 +56,30 @@ class InstanceTypeTestCase(test.TestCase):
"""return first instance type name"""
return instance_types.get_all_types().keys()[0]
def test_instance_type_create(self):
"""Ensure instance types can be created"""
name = 'Instance create test'
flavor_id = '512'
original_list = instance_types.get_all_types()
# create new type and make sure values stick
inst_type = instance_types.create(name, 256, 1, 120,
flavorid=flavor_id)
self.assertEqual(inst_type['flavorid'], flavor_id)
self.assertEqual(inst_type['name'], name)
self.assertEqual(inst_type['memory_mb'], 256)
self.assertEqual(inst_type['vcpus'], 1)
self.assertEqual(inst_type['root_gb'], 120)
self.assertEqual(inst_type['ephemeral_gb'], 0)
self.assertEqual(inst_type['swap'], 0)
self.assertEqual(inst_type['rxtx_factor'], 1)
# make sure new type shows up in list
new_list = instance_types.get_all_types()
self.assertNotEqual(len(original_list), len(new_list),
'instance type was not created')
def test_instance_type_create_then_delete(self):
"""Ensure instance types can be created"""
name = 'Small Flavor'