Skip to content

Commit aed5af4

Browse files
Jenkinsopenstack-gerrit
authored andcommitted
Merge "Add missing properties to image set command"
2 parents e72d350 + ba21d46 commit aed5af4

3 files changed

Lines changed: 51 additions & 1 deletion

File tree

‎doc/source/command-objects/image.rst‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,9 @@ Set image properties
205205
[--owner <project>]
206206
[--min-disk <disk-gb>]
207207
[--min-ram <disk-ram>]
208+
[--container-format <container-format>]
209+
[--disk-format <disk-format>]
210+
[--size <size>]
208211
[--protected | --unprotected]
209212
[--public | --private]
210213
[--property <key=value> [...] ]
@@ -226,6 +229,21 @@ Set image properties
226229
227230
Minimum RAM size needed to boot image, in megabytes
228231
232+
.. option:: --container-format <container-format>
233+
234+
Container format of image.
235+
Acceptable formats: ['ami', 'ari', 'aki', 'bare', 'ovf']
236+
237+
.. option:: --disk-format <disk-format>
238+
239+
Disk format of image.
240+
Acceptable formats: ['ami', 'ari', 'aki', 'vhd', 'vmdk', 'raw', 'qcow2',
241+
'vdi', 'iso']
242+
243+
.. option:: --size <size>
244+
245+
Size of image data (in bytes)
246+
229247
.. option:: --protected
230248
231249
Prevent image from being deleted

‎openstackclient/image/v1/image.py‎

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,28 @@ def get_parser(self, prog_name):
508508
type=int,
509509
help="Minimum RAM size needed to boot image, in megabytes",
510510
)
511+
container_choices = ["ami", "ari", "aki", "bare", "ovf"]
512+
parser.add_argument(
513+
"--container-format",
514+
metavar="<container-format>",
515+
help=("Container format of image. Acceptable formats: %s" %
516+
container_choices),
517+
choices=container_choices
518+
)
519+
disk_choices = ["ami", "ari", "aki", "vhd", "vmdk", "raw", "qcow2",
520+
"vdi", "iso"]
521+
parser.add_argument(
522+
"--disk-format",
523+
metavar="<disk-format>",
524+
help="Disk format of image. Acceptable formats: %s" % disk_choices,
525+
choices=disk_choices
526+
)
527+
parser.add_argument(
528+
"--size",
529+
metavar="<size>",
530+
type=int,
531+
help="Size of image data (in bytes)"
532+
)
511533
protected_group = parser.add_mutually_exclusive_group()
512534
protected_group.add_argument(
513535
"--protected",
@@ -545,7 +567,8 @@ def take_action(self, parsed_args):
545567
image_client = self.app.client_manager.image
546568

547569
kwargs = {}
548-
copy_attrs = ('name', 'owner', 'min_disk', 'min_ram', 'properties')
570+
copy_attrs = ('name', 'owner', 'min_disk', 'min_ram', 'properties',
571+
'container_format', 'disk_format', 'size')
549572
for attr in copy_attrs:
550573
if attr in parsed_args:
551574
val = getattr(parsed_args, attr, None)

‎openstackclient/tests/image/v1/test_image.py‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,13 +547,19 @@ def test_image_set_options(self):
547547
'--owner', 'new-owner',
548548
'--min-disk', '2',
549549
'--min-ram', '4',
550+
'--container-format', 'ovf',
551+
'--disk-format', 'vmdk',
552+
'--size', '35165824',
550553
image_fakes.image_name,
551554
]
552555
verifylist = [
553556
('name', 'new-name'),
554557
('owner', 'new-owner'),
555558
('min_disk', 2),
556559
('min_ram', 4),
560+
('container_format', 'ovf'),
561+
('disk_format', 'vmdk'),
562+
('size', 35165824),
557563
('image', image_fakes.image_name),
558564
]
559565
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -566,6 +572,9 @@ def test_image_set_options(self):
566572
'owner': 'new-owner',
567573
'min_disk': 2,
568574
'min_ram': 4,
575+
'container_format': 'ovf',
576+
'disk_format': 'vmdk',
577+
'size': 35165824
569578
}
570579
# ImageManager.update(image, **kwargs)
571580
self.images_mock.update.assert_called_with(

0 commit comments

Comments
 (0)