summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2022-10-23 00:57:27 +0000
committerGerrit Code Review <review@openstack.org>2022-10-23 00:57:27 +0000
commit794472df8e020a1d480da0ae835ff5ed2e13c962 (patch)
tree416185a4812214bed88672fd226a4d730950b00e
parentfade123b22d0c0bdc04a2f8bff53c7b6e5ca80d9 (diff)
parent01afd1ba70c207932a6574c9ab13036d40abe3fe (diff)
downloadhorizon-794472df8e020a1d480da0ae835ff5ed2e13c962.tar.gz
Merge "Handle empty image_type in launch-instance workflow"
-rw-r--r--openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/launch-instance-model.service.js15
-rw-r--r--openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/launch-instance-model.service.spec.js5
2 files changed, 14 insertions, 6 deletions
diff --git a/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/launch-instance-model.service.js b/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/launch-instance-model.service.js
index 26086bc14..c38d75bc4 100644
--- a/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/launch-instance-model.service.js
+++ b/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/launch-instance-model.service.js
@@ -676,14 +676,17 @@
}
function getImageType(image) {
- if (image === null || !angular.isDefined(image.properties) ||
- !(angular.isDefined(image.properties.image_type) ||
- angular.isDefined(image.properties.block_device_mapping))) {
+ if (image === null || !image.properties) {
return 'image';
}
- return image.properties.image_type ||
- angular.fromJson(image.properties.block_device_mapping)[0].source_type ||
- 'image';
+ if (image.properties.image_type) {
+ return image.properties.image_type;
+ }
+ var bdm = angular.fromJson(image.properties.block_device_mapping || "[]");
+ if (bdm[0] && bdm[0].source_type) {
+ return bdm[0].source_type;
+ }
+ return 'image';
}
function isValidImage(image) {
diff --git a/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/launch-instance-model.service.spec.js b/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/launch-instance-model.service.spec.js
index fa15af910..27a580698 100644
--- a/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/launch-instance-model.service.spec.js
+++ b/openstack_dashboard/dashboards/project/static/dashboard/project/workflow/launch-instance/launch-instance-model.service.spec.js
@@ -151,6 +151,8 @@
{id: '4', container_format: 'raw', properties: {}, name: 'raw_image'},
{id: '5', container_format: 'ami', properties: {image_type: 'image'}},
{id: '6', container_format: 'raw', properties: {image_type: 'image'}},
+ {id: '11', container_format: 'raw', properties: {image_type: ''}},
+ {id: '12', container_format: 'raw', properties: {block_device_mapping: '[]'}},
// The following images are considered as "snapshot" sources.
{id: '7', container_format: 'ami',
properties: {block_device_mapping: '[{"source_type": "snapshot"}]'}},
@@ -393,6 +395,9 @@
name_or_id: 'raw_image'},
{id: '5', container_format: 'ami', properties: {image_type: 'image'}, name_or_id: '5'},
{id: '6', container_format: 'raw', properties: {image_type: 'image'}, name_or_id: '6'},
+ {id: '11', container_format: 'raw', properties: {image_type: ''}, name_or_id: '11'},
+ {id: '12', container_format: 'raw', properties: {block_device_mapping: '[]'},
+ name_or_id: '12'},
{id: '10', container_format: 'raw', properties: {image_type: 'image'}, name_or_id: '10',
visibility: 'community'},
];