Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions scripts/storage/qcow2/resizevolume.sh
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,22 @@ resizeqcow2() {
# if this is a shrink operation, fail if commands will shrink the volume and we haven't signed of on shrinking
failshrink

#move this back into cloudstack libvirt calls once the libvirt java bindings support block resize
#we try to inform hypervisor of new size, but don't fail if we can't
if `virsh help 2>/dev/null | grep -q blockresize`
then
if `virsh domstate $vmname >/dev/null 2>&1`
then
log "vm $vmname is running, use 'virsh blockresize' to resize the volume"
notifyqemu
if [ $? -eq 0 ]
then
log "performed successful resize - currentsize:$currentsize newsize:$newsize path:$path type:$ptype vmname:$vmname live:$liveresize shrink:$shrink"
exit 0
fi
fi
fi

output=`qemu-img resize $path $newsize 2>&1`
retval=$?

Expand All @@ -196,10 +212,6 @@ resizeqcow2() {
exit 1
fi

#move this back into cloudstack libvirt calls once the libvirt java bindings support block resize
#we try to inform hypervisor of new size, but don't fail if we can't
notifyqemu

log "performed successful resize - currentsize:$currentsize newsize:$newsize path:$path type:$ptype vmname:$vmname live:$liveresize shrink:$shrink"
}

Expand Down Expand Up @@ -244,7 +256,7 @@ then
resizelvm
elif [ "$ptype" == "QCOW2" ]
then
notifyqemu
resizeqcow2
elif [ "$ptype" == "NOTIFYONLY" ]
then
notifyqemu
Expand Down
3 changes: 3 additions & 0 deletions server/src/com/cloud/storage/VolumeApiServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -1158,6 +1158,9 @@ private VolumeVO orchestrateResizeVolume(long volumeId, long currentSize, long n
if (newDiskOfferingId != null) {
volume.setDiskOfferingId(newDiskOfferingId);
}
if (currentSize != newSize) {
volume.setSize(newSize);
}

_volsDao.update(volume.getId(), volume);

Expand Down
29 changes: 22 additions & 7 deletions ui/scripts/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -1536,14 +1536,27 @@
},
createForm: {
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: {
newdiskoffering: {
label: 'label.resize.new.offering.id',
select: function(args) {
if (args.context.volumes != null && args.context.volumes[0].type == 'ROOT') {
args.response.success({
data: []
});
return;
}

$.ajax({
url: createURL("listDiskOfferings"),
dataType: "json",
async: false,
success: function(json) {
diskofferingObjs = json.listdiskofferingsresponse.diskoffering;
var items = [];
Expand Down Expand Up @@ -1605,8 +1618,7 @@
validation: {
required: true,
number: true
},
isHidden: true
}
},
shrinkok: {
label: 'label.resize.shrink.ok',
Expand Down Expand Up @@ -1640,7 +1652,7 @@

var newDiskOffering = args.data.newdiskoffering;
var newSize;
if (selectedDiskOfferingObj.iscustomized == true) {
if (selectedDiskOfferingObj == null || selectedDiskOfferingObj.iscustomized == true) {
newSize = args.data.newsize;
}
if (newDiskOffering != null && newDiskOffering.length > 0) {
Expand All @@ -1651,9 +1663,9 @@
}

var minIops;
var maxIops
var maxIops;

if (selectedDiskOfferingObj.iscustomizediops == true) {
if (selectedDiskOfferingObj != null && selectedDiskOfferingObj.iscustomizediops == true) {
minIops = args.data.minIops;
maxIops = args.data.maxIops;
}
Expand Down Expand Up @@ -2338,11 +2350,14 @@
allowedActions.push("takeSnapshot");
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");
}
}

if (jsonObj.state != "Allocated") {
if ((jsonObj.vmstate == "Stopped" || jsonObj.virtualmachineid == null) && jsonObj.state == "Ready") {
allowedActions.push("downloadVolume");
Expand Down