Merge "Add missing properties to image set command"

This commit is contained in:
Jenkins 2015-05-26 22:43:49 +00:00 committed by Gerrit Code Review
commit aed5af47a1
3 changed files with 51 additions and 1 deletions

View File

@ -205,6 +205,9 @@ Set image properties
[--owner <project>]
[--min-disk <disk-gb>]
[--min-ram <disk-ram>]
[--container-format <container-format>]
[--disk-format <disk-format>]
[--size <size>]
[--protected | --unprotected]
[--public | --private]
[--property <key=value> [...] ]
@ -226,6 +229,21 @@ Set image properties
Minimum RAM size needed to boot image, in megabytes
.. option:: --container-format <container-format>
Container format of image.
Acceptable formats: ['ami', 'ari', 'aki', 'bare', 'ovf']
.. option:: --disk-format <disk-format>
Disk format of image.
Acceptable formats: ['ami', 'ari', 'aki', 'vhd', 'vmdk', 'raw', 'qcow2',
'vdi', 'iso']
.. option:: --size <size>
Size of image data (in bytes)
.. option:: --protected
Prevent image from being deleted

View File

@ -508,6 +508,28 @@ class SetImage(show.ShowOne):
type=int,
help="Minimum RAM size needed to boot image, in megabytes",
)
container_choices = ["ami", "ari", "aki", "bare", "ovf"]
parser.add_argument(
"--container-format",
metavar="<container-format>",
help=("Container format of image. Acceptable formats: %s" %
container_choices),
choices=container_choices
)
disk_choices = ["ami", "ari", "aki", "vhd", "vmdk", "raw", "qcow2",
"vdi", "iso"]
parser.add_argument(
"--disk-format",
metavar="<disk-format>",
help="Disk format of image. Acceptable formats: %s" % disk_choices,
choices=disk_choices
)
parser.add_argument(
"--size",
metavar="<size>",
type=int,
help="Size of image data (in bytes)"
)
protected_group = parser.add_mutually_exclusive_group()
protected_group.add_argument(
"--protected",
@ -545,7 +567,8 @@ class SetImage(show.ShowOne):
image_client = self.app.client_manager.image
kwargs = {}
copy_attrs = ('name', 'owner', 'min_disk', 'min_ram', 'properties')
copy_attrs = ('name', 'owner', 'min_disk', 'min_ram', 'properties',
'container_format', 'disk_format', 'size')
for attr in copy_attrs:
if attr in parsed_args:
val = getattr(parsed_args, attr, None)

View File

@ -547,6 +547,9 @@ class TestImageSet(TestImage):
'--owner', 'new-owner',
'--min-disk', '2',
'--min-ram', '4',
'--container-format', 'ovf',
'--disk-format', 'vmdk',
'--size', '35165824',
image_fakes.image_name,
]
verifylist = [
@ -554,6 +557,9 @@ class TestImageSet(TestImage):
('owner', 'new-owner'),
('min_disk', 2),
('min_ram', 4),
('container_format', 'ovf'),
('disk_format', 'vmdk'),
('size', 35165824),
('image', image_fakes.image_name),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@ -566,6 +572,9 @@ class TestImageSet(TestImage):
'owner': 'new-owner',
'min_disk': 2,
'min_ram': 4,
'container_format': 'ovf',
'disk_format': 'vmdk',
'size': 35165824
}
# ImageManager.update(image, **kwargs)
self.images_mock.update.assert_called_with(