Do not override user-defined Device Size
This change introduces a flag which identifies whether or not the user has manually set the Device Size field when launching an instance with a new volume. If the user has made a change then the value will not be overridden by the logic that sets the Device Size based on the selected image/flavor unless the user-defined value is too small. Change-Id: I1f02fd386a9b6836fb95433d9cb819af4f267d6c Closes-bug: 1370080
This commit is contained in:
parent
9a5bb3e070
commit
59af5f5c5a
|
@ -1,5 +1,6 @@
|
|||
horizon.instances = {
|
||||
user_decided_length: false,
|
||||
user_volume_size: false,
|
||||
networks_selected: [],
|
||||
networks_available: [],
|
||||
|
||||
|
@ -207,19 +208,27 @@ horizon.addInitFunction(function () {
|
|||
function update_device_size() {
|
||||
var volume_size = horizon.Quota.getSelectedFlavor().disk;
|
||||
var image = horizon.Quota.getSelectedImage();
|
||||
var size_field = $("#id_volume_size");
|
||||
|
||||
if(image !== undefined) {
|
||||
if(image.min_disk > volume_size) {
|
||||
volume_size = image.min_disk;
|
||||
if (image !== undefined && image.min_disk > volume_size) {
|
||||
volume_size = image.min_disk;
|
||||
}
|
||||
|
||||
// If the user has manually changed the volume size, do not override
|
||||
// unless user-defined value is too small.
|
||||
if (horizon.instances.user_volume_size) {
|
||||
var user_value = size_field.val();
|
||||
if (user_value > volume_size) {
|
||||
volume_size = user_value;
|
||||
}
|
||||
}
|
||||
|
||||
// Make sure the new value is >= the minimum allowed (1GB)
|
||||
if(volume_size < 1) {
|
||||
if (volume_size < 1) {
|
||||
volume_size = 1;
|
||||
}
|
||||
|
||||
$("#id_volume_size").val(volume_size);
|
||||
size_field.val(volume_size);
|
||||
}
|
||||
|
||||
$(document).on('change', '.workflow #id_flavor', function (evt) {
|
||||
|
@ -230,6 +239,13 @@ horizon.addInitFunction(function () {
|
|||
update_device_size();
|
||||
});
|
||||
|
||||
$(document).on('input', '.workflow #id_volume_size', function (evt) {
|
||||
horizon.instances.user_volume_size = true;
|
||||
// We only need to listen for the first user input to this field,
|
||||
// so remove the listener after the first time it gets called.
|
||||
$(document).off('input', '.workflow #id_volume_size');
|
||||
});
|
||||
|
||||
horizon.instances.decrypt_password = function(encrypted_password, private_key) {
|
||||
var crypt = new JSEncrypt();
|
||||
crypt.setKey(private_key);
|
||||
|
|
Loading…
Reference in New Issue