Convert passed integer values into int in v1 shell
Add the type to the parameters that require an integer in the V1 shell to avoid sending an improper request. Change-Id: Idb1ed39b11ca737fdd42d24e297c142f28dce35c
This commit is contained in:
parent
dbefc1a3b1
commit
04fb3c2624
@ -44,9 +44,9 @@ DISK_FORMATS = ('Acceptable formats: ami, ari, aki, vhd, vmdk, raw, '
|
||||
@utils.arg('--disk-format', metavar='<DISK_FORMAT>',
|
||||
help='Filter images to those that have this disk format. '
|
||||
+ DISK_FORMATS)
|
||||
@utils.arg('--size-min', metavar='<SIZE>',
|
||||
@utils.arg('--size-min', metavar='<SIZE>', type=int,
|
||||
help='Filter images to those with a size greater than this.')
|
||||
@utils.arg('--size-max', metavar='<SIZE>',
|
||||
@utils.arg('--size-max', metavar='<SIZE>', type=int,
|
||||
help='Filter images to those with a size less than this.')
|
||||
@utils.arg('--property-filter', metavar='<KEY=VALUE>',
|
||||
help="Filter images by a user-defined image property.",
|
||||
@ -167,12 +167,12 @@ def do_image_download(gc, args):
|
||||
help='Container format of image. ' + CONTAINER_FORMATS)
|
||||
@utils.arg('--owner', metavar='<TENANT_ID>',
|
||||
help='Tenant who should own image.')
|
||||
@utils.arg('--size', metavar='<SIZE>',
|
||||
@utils.arg('--size', metavar='<SIZE>', type=int,
|
||||
help=('Size of image data (in bytes). Only used with'
|
||||
' \'--location\' and \'--copy-from\'.'))
|
||||
@utils.arg('--min-disk', metavar='<DISK_GB>',
|
||||
' \'--location\' and \'--copy_from\'.'))
|
||||
@utils.arg('--min-disk', metavar='<DISK_GB>', type=int,
|
||||
help='Minimum size of disk needed to boot image (in gigabytes).')
|
||||
@utils.arg('--min-ram', metavar='<DISK_RAM>',
|
||||
@utils.arg('--min-ram', metavar='<DISK_RAM>', type=int,
|
||||
help='Minimum amount of ram needed to boot image (in megabytes).')
|
||||
@utils.arg('--location', metavar='<IMAGE_URL>',
|
||||
help=('URL where the data for this image already resides. For '
|
||||
@ -248,11 +248,11 @@ def do_image_create(gc, args):
|
||||
help='Container format of image. ' + CONTAINER_FORMATS)
|
||||
@utils.arg('--owner', metavar='<TENANT_ID>',
|
||||
help='Tenant who should own image.')
|
||||
@utils.arg('--size', metavar='<SIZE>',
|
||||
@utils.arg('--size', metavar='<SIZE>', type=int,
|
||||
help='Size of image data (in bytes).')
|
||||
@utils.arg('--min-disk', metavar='<DISK_GB>',
|
||||
@utils.arg('--min-disk', metavar='<DISK_GB>', type=int,
|
||||
help='Minimum size of disk needed to boot image (in gigabytes).')
|
||||
@utils.arg('--min-ram', metavar='<DISK_RAM>',
|
||||
@utils.arg('--min-ram', metavar='<DISK_RAM>', type=int,
|
||||
help='Minimum amount of ram needed to boot image (in megabytes).')
|
||||
@utils.arg('--location', metavar='<IMAGE_URL>',
|
||||
help=('URL where the data for this image already resides. For '
|
||||
|
@ -189,12 +189,12 @@ fixtures = {
|
||||
}
|
||||
|
||||
|
||||
class ShellInvalidEndpointTest(utils.TestCase):
|
||||
class ShellInvalidEndpointandParameterTest(utils.TestCase):
|
||||
|
||||
# Patch os.environ to avoid required auth info.
|
||||
def setUp(self):
|
||||
"""Run before each test."""
|
||||
super(ShellInvalidEndpointTest, self).setUp()
|
||||
super(ShellInvalidEndpointandParameterTest, self).setUp()
|
||||
self.old_environment = os.environ.copy()
|
||||
os.environ = {
|
||||
'OS_USERNAME': 'username',
|
||||
@ -210,7 +210,7 @@ class ShellInvalidEndpointTest(utils.TestCase):
|
||||
self.shell = shell.OpenStackImagesShell()
|
||||
|
||||
def tearDown(self):
|
||||
super(ShellInvalidEndpointTest, self).tearDown()
|
||||
super(ShellInvalidEndpointandParameterTest, self).tearDown()
|
||||
os.environ = self.old_environment
|
||||
|
||||
def run_command(self, cmd):
|
||||
@ -302,6 +302,46 @@ class ShellInvalidEndpointTest(utils.TestCase):
|
||||
self.run_command,
|
||||
'member-add <IMAGE_ID> <TENANT_ID>')
|
||||
|
||||
def test_image_create_invalid_size_parameter(self):
|
||||
self.assertRaises(
|
||||
SystemExit,
|
||||
self.run_command, 'image-create --size 10gb')
|
||||
|
||||
def test_image_create_invalid_ram_parameter(self):
|
||||
self.assertRaises(
|
||||
SystemExit,
|
||||
self.run_command, 'image-create --min-ram 10gb')
|
||||
|
||||
def test_image_create_invalid_min_disk_parameter(self):
|
||||
self.assertRaises(
|
||||
SystemExit,
|
||||
self.run_command, 'image-create --min-disk 10gb')
|
||||
|
||||
def test_image_update_invalid_size_parameter(self):
|
||||
self.assertRaises(
|
||||
SystemExit,
|
||||
self.run_command, 'image-update --size 10gb')
|
||||
|
||||
def test_image_update_invalid_min_disk_parameter(self):
|
||||
self.assertRaises(
|
||||
SystemExit,
|
||||
self.run_command, 'image-update --min-disk 10gb')
|
||||
|
||||
def test_image_update_invalid_ram_parameter(self):
|
||||
self.assertRaises(
|
||||
SystemExit,
|
||||
self.run_command, 'image-update --min-ram 10gb')
|
||||
|
||||
def test_image_list_invalid_min_size_parameter(self):
|
||||
self.assertRaises(
|
||||
SystemExit,
|
||||
self.run_command, 'image-list --size-min 10gb')
|
||||
|
||||
def test_image_list_invalid_max_size_parameter(self):
|
||||
self.assertRaises(
|
||||
SystemExit,
|
||||
self.run_command, 'image-list --size-max 10gb')
|
||||
|
||||
|
||||
class ShellStdinHandlingTests(testtools.TestCase):
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user