Always define properties for image even if empty

This re-factor allows us to set default properties very simply.  It does
add empty properties on images that otherwise didn't have them but this
should be safe[1]

[1] famous last words

Blueprint: multiarch-support
Change-Id: I136ae6c59bb4a4b3e12eb6a96bfbce732554bb4c
This commit is contained in:
Tony Breeds
2018-01-11 14:17:41 +11:00
parent 9db478bf0f
commit 8d05757bcf
2 changed files with 18 additions and 7 deletions

View File

@@ -282,11 +282,13 @@ class TestUploadOvercloudImage(TestPluginV1):
self.app.client_manager.image.images.create.call_count
)
self.assertEqual(
[mock.call(data=b'IMGDATA',
[mock.call(properties={},
data=b'IMGDATA',
name='overcloud-full-vmlinuz',
disk_format='aki',
is_public=True),
mock.call(data=b'IMGDATA',
mock.call(properties={},
data=b'IMGDATA',
name='overcloud-full-initrd',
disk_format='ari',
is_public=True),
@@ -296,11 +298,13 @@ class TestUploadOvercloudImage(TestPluginV1):
container_format='bare',
disk_format='qcow2',
is_public=True),
mock.call(data=b'IMGDATA',
mock.call(properties={},
data=b'IMGDATA',
name='bm-deploy-kernel',
disk_format='aki',
is_public=True),
mock.call(data=b'IMGDATA',
mock.call(properties={},
data=b'IMGDATA',
name='bm-deploy-ramdisk',
disk_format='ari',
is_public=True)

View File

@@ -305,6 +305,8 @@ class UploadOvercloudImage(command.Command):
self.log.debug("uploading %s overcloud images to glance" %
overcloud_image_type)
properties = {}
# vmlinuz and initrd only need to be uploaded for a partition image
if not parsed_args.whole_disk:
(oc_vmlinuz_name,
@@ -319,6 +321,7 @@ class UploadOvercloudImage(command.Command):
name=oc_vmlinuz_name,
is_public=True,
disk_format='aki',
properties=properties,
data=self._read_image_file_pointer(
parsed_args.image_path, oc_vmlinuz_file)
))
@@ -335,6 +338,7 @@ class UploadOvercloudImage(command.Command):
name=oc_initrd_name,
is_public=True,
disk_format='ari',
properties=properties,
data=self._read_image_file_pointer(
parsed_args.image_path, oc_initrd_file)
))
@@ -351,8 +355,9 @@ class UploadOvercloudImage(command.Command):
is_public=True,
disk_format='qcow2',
container_format='bare',
properties={'kernel_id': kernel.id,
'ramdisk_id': ramdisk.id},
properties=dict({'kernel_id': kernel.id,
'ramdisk_id': ramdisk.id},
**properties),
data=self._read_image_file_pointer(
parsed_args.image_path, oc_file)
))
@@ -380,7 +385,7 @@ class UploadOvercloudImage(command.Command):
is_public=True,
disk_format='qcow2',
container_format='bare',
properties={},
properties=properties,
data=self._read_image_file_pointer(
parsed_args.image_path, oc_file)
))
@@ -398,6 +403,7 @@ class UploadOvercloudImage(command.Command):
name=deploy_kernel_name,
is_public=True,
disk_format='aki',
properties=properties,
data=self._read_image_file_pointer(
parsed_args.image_path,
deploy_kernel_file))
@@ -413,6 +419,7 @@ class UploadOvercloudImage(command.Command):
name=deploy_ramdisk_name,
is_public=True,
disk_format='ari',
properties=properties,
data=self._read_image_file_pointer(parsed_args.image_path,
deploy_ramdisk_file))