Merge "Validate minimum RAM for snapshot source" into stable/mitaka

This commit is contained in:
Jenkins 2016-12-08 09:47:29 +00:00 committed by Gerrit Code Review
commit 9a460aad76
3 changed files with 26 additions and 19 deletions

View File

@ -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 () {

View File

@ -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) {

View File

@ -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:"{}" }});