diff options
author | Jenkins <jenkins@review.openstack.org> | 2016-12-08 09:47:29 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2016-12-08 09:47:29 +0000 |
commit | 9a460aad76c05c411765af2b2d85b075a5f7004e (patch) | |
tree | 36b441755bb3694217a944dfd4df1edfd7570b4b | |
parent | cad2ac79d008df94f62f8e4dc1e1a7e88a843df4 (diff) | |
parent | d4ac1d28c3808575a9bbef4b67389da0593956d1 (diff) | |
download | horizon-9.1.1.tar.gz |
Merge "Validate minimum RAM for snapshot source" into stable/mitaka9.1.1
3 files changed, 26 insertions, 19 deletions
diff --git a/horizon/static/horizon/js/horizon.instances.js b/horizon/static/horizon/js/horizon.instances.js index 43413661f..73eaba92b 100644 --- a/horizon/static/horizon/js/horizon.instances.js +++ b/horizon/static/horizon/js/horizon.instances.js @@ -212,16 +212,18 @@ horizon.addInitFunction(horizon.instances.init = function () { Update the device size value to reflect minimum allowed for selected image and flavor */ - function update_device_size() { + function update_device_size(source_type) { var volume_size = horizon.Quota.getSelectedFlavor().disk; - var image = horizon.Quota.getSelectedImage(); var size_field = $("#id_volume_size"); - if (image !== undefined && image.min_disk > volume_size) { - volume_size = image.min_disk; - } - if (image !== undefined && image.size > volume_size) { - volume_size = image.size; + if (source_type === 'image') { + var image = horizon.Quota.getSelectedImageOrSnapshot(source_type); + if (image !== undefined && image.min_disk > volume_size) { + volume_size = image.min_disk; + } + if (image !== undefined && image.size > volume_size) { + volume_size = image.size; + } } // If the user has manually changed the volume size, do not override @@ -246,7 +248,7 @@ horizon.addInitFunction(horizon.instances.init = function () { }); $document.on('change', '.workflow #id_image_id', function () { - update_device_size(); + update_device_size('image'); }); $document.on('input', '.workflow #id_volume_size', function () { diff --git a/horizon/static/horizon/js/horizon.quota.js b/horizon/static/horizon/js/horizon.quota.js index 2bd630210..09d6c660b 100644 --- a/horizon/static/horizon/js/horizon.quota.js +++ b/horizon/static/horizon/js/horizon.quota.js @@ -134,25 +134,25 @@ horizon.Quota = { }, /* - Return an image Object based on which image ID is selected + Return an image/snapshot Object based on which image/snapshot ID is selected */ - getSelectedImage: function() { - var selected = $('#id_image_id option:selected').val(); + getSelectedImageOrSnapshot: function(source_type) { + var selected = $('#id_' + source_type + '_id option:selected').val(); return horizon.Quota.findImageById(selected); }, /* - Disable any flavors for a given image that do not meet + Disable any flavors for a given image/snapshot that do not meet its minimum RAM or disk requirements. */ - disableFlavorsForImage: function(image) { - image = horizon.Quota.getSelectedImage(); + disableFlavorsForImage: function(source_type) { + var source = horizon.Quota.getSelectedImageOrSnapshot(source_type); var to_disable = []; // an array of flavor names to disable horizon.Quota.resetFlavors(); // clear any previous messages $.each(horizon.Quota.flavors, function(i, flavor) { - if (!horizon.Quota.imageFitsFlavor(image, flavor)) { + if (!horizon.Quota.imageFitsFlavor(source, flavor)) { to_disable.push(flavor.name); } }); @@ -192,7 +192,7 @@ horizon.Quota = { this.disabledFlavorMessage = disabledMessage; this.allFlavorsDisabledMessage = allDisabledMessage; // Check if the image is pre-selected - horizon.Quota.disableFlavorsForImage(); + horizon.Quota.disableFlavorsForImage('image'); }, /* @@ -397,12 +397,17 @@ horizon.Quota = { }; var imageChangeCallback = function() { - scope.disableFlavorsForImage(); + scope.disableFlavorsForImage('image'); + }; + + var snapshotChangeCallback = function() { + scope.disableFlavorsForImage('instance_snapshot'); }; $('#id_flavor').on('keyup change', eventCallback); $('#id_count').on('input', eventCallback); $('#id_image_id').on('change', imageChangeCallback); + $('#id_instance_snapshot_id').on('change', snapshotChangeCallback); } $(this.user_value_form_inputs).each(function(index, element) { diff --git a/openstack_dashboard/dashboards/project/instances/templates/instances/_flavors_and_quotas.html b/openstack_dashboard/dashboards/project/instances/templates/instances/_flavors_and_quotas.html index 53ecb6e3c..01ab0d18d 100644 --- a/openstack_dashboard/dashboards/project/instances/templates/instances/_flavors_and_quotas.html +++ b/openstack_dashboard/dashboards/project/instances/templates/instances/_flavors_and_quotas.html @@ -75,8 +75,8 @@ <script type="text/javascript" charset="utf-8"> - some_disabled_msg = '{{_("Some flavors not meeting minimum image requirements have been disabled.")|escapejs }}'; - all_disabled_msg = '{{_("No flavors meet minimum criteria for selected image.")|escapejs }}'; + some_disabled_msg = '{{_("Some flavors not meeting minimum boot source requirements have been disabled.")|escapejs }}'; + all_disabled_msg = '{{_("No flavors meet minimum criteria for selected boot source.")|escapejs }}'; if(typeof horizon.Quota !== 'undefined') { horizon.Quota.initWithFlavors({{ flavors|safe|default:"{}" }}); |