CLOUDSTACK-9101: add UI support for root volume resize

This commit is contained in:
Wei Zhou 2015-12-03 11:53:42 +01:00
parent 119b27b2c6
commit d6e21f7416

View File

@ -1536,14 +1536,27 @@
}, },
createForm: { createForm: {
title: 'label.action.resize.volume', title: 'label.action.resize.volume',
preFilter: function(args) {
if (args.context.volumes != null && args.context.volumes[0].type == 'ROOT') {
args.$form.find('.form-item[rel=newdiskoffering]').hide();
} else {
args.$form.find('.form-item[rel=newsize]').hide();
}
},
fields: { fields: {
newdiskoffering: { newdiskoffering: {
label: 'label.resize.new.offering.id', label: 'label.resize.new.offering.id',
select: function(args) { select: function(args) {
if (args.context.volumes != null && args.context.volumes[0].type == 'ROOT') {
args.response.success({
data: []
});
return;
}
$.ajax({ $.ajax({
url: createURL("listDiskOfferings"), url: createURL("listDiskOfferings"),
dataType: "json", dataType: "json",
async: false,
success: function(json) { success: function(json) {
diskofferingObjs = json.listdiskofferingsresponse.diskoffering; diskofferingObjs = json.listdiskofferingsresponse.diskoffering;
var items = []; var items = [];
@ -1605,8 +1618,7 @@
validation: { validation: {
required: true, required: true,
number: true number: true
}, }
isHidden: true
}, },
shrinkok: { shrinkok: {
label: 'label.resize.shrink.ok', label: 'label.resize.shrink.ok',
@ -1640,7 +1652,7 @@
var newDiskOffering = args.data.newdiskoffering; var newDiskOffering = args.data.newdiskoffering;
var newSize; var newSize;
if (selectedDiskOfferingObj.iscustomized == true) { if (selectedDiskOfferingObj == null || selectedDiskOfferingObj.iscustomized == true) {
newSize = args.data.newsize; newSize = args.data.newsize;
} }
if (newDiskOffering != null && newDiskOffering.length > 0) { if (newDiskOffering != null && newDiskOffering.length > 0) {
@ -1651,9 +1663,9 @@
} }
var minIops; var minIops;
var maxIops var maxIops;
if (selectedDiskOfferingObj.iscustomizediops == true) { if (selectedDiskOfferingObj != null && selectedDiskOfferingObj.iscustomizediops == true) {
minIops = args.data.minIops; minIops = args.data.minIops;
maxIops = args.data.maxIops; maxIops = args.data.maxIops;
} }
@ -2338,11 +2350,14 @@
allowedActions.push("takeSnapshot"); allowedActions.push("takeSnapshot");
allowedActions.push("recurringSnapshot"); allowedActions.push("recurringSnapshot");
} }
}
if (jsonObj.type == "DATADISK") { if (jsonObj.hypervisor == "KVM" || jsonObj.hypervisor == "XenServer" || jsonObj.hypervisor == "VMware") {
if (jsonObj.state == "Ready" || jsonObj.state == "Allocated") {
allowedActions.push("resize"); allowedActions.push("resize");
} }
} }
if (jsonObj.state != "Allocated") { if (jsonObj.state != "Allocated") {
if ((jsonObj.vmstate == "Stopped" || jsonObj.virtualmachineid == null) && jsonObj.state == "Ready") { if ((jsonObj.vmstate == "Stopped" || jsonObj.virtualmachineid == null) && jsonObj.state == "Ready") {
allowedActions.push("downloadVolume"); allowedActions.push("downloadVolume");