Validate that rxtx_factor is a float.
Nova stores rxtx_factor as a float internally and as such novaclient should validate that a float is specified when creating a flavor. Fixes LP Bug #1083651. Change-Id: I75f9440d3fe2a0e72ea592f2259640623400ae73
This commit is contained in:
parent
b9d60c1fd2
commit
27d7ad9d86
|
@ -105,7 +105,7 @@ class FlavorManager(base.ManagerWithFind):
|
|||
self._delete("/flavors/%s" % base.getid(flavor))
|
||||
|
||||
def create(self, name, ram, vcpus, disk, flavorid=None,
|
||||
ephemeral=0, swap=0, rxtx_factor=1, is_public=True):
|
||||
ephemeral=0, swap=0, rxtx_factor=1.0, is_public=True):
|
||||
"""
|
||||
Create (allocate) a floating ip for a tenant
|
||||
|
||||
|
@ -150,9 +150,9 @@ class FlavorManager(base.ManagerWithFind):
|
|||
raise exceptions.CommandError("Ephemeral must be an integer.")
|
||||
|
||||
try:
|
||||
rxtx_factor = int(rxtx_factor)
|
||||
rxtx_factor = float(rxtx_factor)
|
||||
except:
|
||||
raise exceptions.CommandError("rxtx_factor must be an integer.")
|
||||
raise exceptions.CommandError("rxtx_factor must be a float.")
|
||||
|
||||
try:
|
||||
is_public = utils.bool_from_str(is_public)
|
||||
|
@ -168,7 +168,7 @@ class FlavorManager(base.ManagerWithFind):
|
|||
"id": flavorid,
|
||||
"swap": int(swap),
|
||||
"OS-FLV-EXT-DATA:ephemeral": int(ephemeral),
|
||||
"rxtx_factor": int(rxtx_factor),
|
||||
"rxtx_factor": float(rxtx_factor),
|
||||
"os-flavor-access:is_public": bool(is_public),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -394,7 +394,7 @@ def do_flavor_show(cs, args):
|
|||
@utils.arg('--rxtx-factor',
|
||||
metavar='<factor>',
|
||||
help="RX/TX factor (default 1)",
|
||||
default=1)
|
||||
default=1.0)
|
||||
@utils.arg('--is-public',
|
||||
metavar='<is-public>',
|
||||
help="Make flavor accessible to the public (default true)",
|
||||
|
|
|
@ -60,7 +60,7 @@ class FlavorsTest(utils.TestCase):
|
|||
"OS-FLV-EXT-DATA:ephemeral": 10,
|
||||
"id": 1234,
|
||||
"swap": 0,
|
||||
"rxtx_factor": 1,
|
||||
"rxtx_factor": 1.0,
|
||||
"os-flavor-access:is_public": False,
|
||||
}
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ class FlavorsTest(utils.TestCase):
|
|||
"OS-FLV-EXT-DATA:ephemeral": 0,
|
||||
"id": 1234,
|
||||
"swap": 0,
|
||||
"rxtx_factor": 1,
|
||||
"rxtx_factor": 1.0,
|
||||
"os-flavor-access:is_public": True,
|
||||
}
|
||||
}
|
||||
|
@ -91,25 +91,25 @@ class FlavorsTest(utils.TestCase):
|
|||
def test_invalid_parameters_create(self):
|
||||
self.assertRaises(exceptions.CommandError, cs.flavors.create,
|
||||
"flavorcreate", "invalid", 1, 10, 1234, swap=0,
|
||||
ephemeral=0, rxtx_factor=1, is_public=True)
|
||||
ephemeral=0, rxtx_factor=1.0, is_public=True)
|
||||
self.assertRaises(exceptions.CommandError, cs.flavors.create,
|
||||
"flavorcreate", 512, "invalid", 10, 1234, swap=0,
|
||||
ephemeral=0, rxtx_factor=1, is_public=True)
|
||||
ephemeral=0, rxtx_factor=1.0, is_public=True)
|
||||
self.assertRaises(exceptions.CommandError, cs.flavors.create,
|
||||
"flavorcreate", 512, 1, "invalid", 1234, swap=0,
|
||||
ephemeral=0, rxtx_factor=1, is_public=True)
|
||||
ephemeral=0, rxtx_factor=1.0, 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)
|
||||
ephemeral=0, rxtx_factor=1.0, is_public=True)
|
||||
self.assertRaises(exceptions.CommandError, cs.flavors.create,
|
||||
"flavorcreate", 512, 1, 10, 1234, swap=0,
|
||||
ephemeral="invalid", rxtx_factor=1, is_public=True)
|
||||
ephemeral="invalid", rxtx_factor=1.0, is_public=True)
|
||||
self.assertRaises(exceptions.CommandError, cs.flavors.create,
|
||||
"flavorcreate", 512, 1, 10, 1234, swap=0,
|
||||
ephemeral=0, rxtx_factor="invalid", is_public=True)
|
||||
self.assertRaises(exceptions.CommandError, cs.flavors.create,
|
||||
"flavorcreate", 512, 1, 10, 1234, swap=0,
|
||||
ephemeral=0, rxtx_factor=1, is_public='invalid')
|
||||
ephemeral=0, rxtx_factor=1.0, is_public='invalid')
|
||||
|
||||
def test_delete(self):
|
||||
cs.flavors.delete("flavordelete")
|
||||
|
|
Loading…
Reference in New Issue