diff --git a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/StorageSystemSnapshotStrategy.java b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/StorageSystemSnapshotStrategy.java index 2c71525aad5..d1470e43596 100644 --- a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/StorageSystemSnapshotStrategy.java +++ b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/StorageSystemSnapshotStrategy.java @@ -442,6 +442,12 @@ public class StorageSystemSnapshotStrategy extends SnapshotStrategyBase { public StrategyPriority canHandle(Snapshot snapshot, SnapshotOperation op) { long volumeId = snapshot.getVolumeId(); VolumeVO volumeVO = _volumeDao.findById(volumeId); + if (SnapshotOperation.REVERT.equals(op)) { + if (volumeVO != null && ImageFormat.QCOW2.equals(volumeVO.getFormat())) + return StrategyPriority.DEFAULT; + else + return StrategyPriority.CANT_HANDLE; + } long storagePoolId; @@ -459,13 +465,6 @@ public class StorageSystemSnapshotStrategy extends SnapshotStrategyBase { storagePoolId = volumeVO.getPoolId(); } - if (SnapshotOperation.REVERT.equals(op)) { - if (volumeVO != null && ImageFormat.QCOW2.equals(volumeVO.getFormat())) - return StrategyPriority.DEFAULT; - else - return StrategyPriority.CANT_HANDLE; - } - DataStore dataStore = _dataStoreMgr.getDataStore(storagePoolId, DataStoreRole.Primary); Map mapCapabilities = dataStore.getDriver().getCapabilities(); diff --git a/plugins/api/rate-limit/pom.xml b/plugins/api/rate-limit/pom.xml index 81f266d4ce9..b501aa92d16 100644 --- a/plugins/api/rate-limit/pom.xml +++ b/plugins/api/rate-limit/pom.xml @@ -32,7 +32,8 @@ org.apache.maven.plugins maven-surefire-plugin - -Xmx1024m + always + -Xmx2048m -XX:MaxPermSize=1024m org/apache/cloudstack/ratelimit/integration/* diff --git a/plugins/hypervisors/ovm3/src/main/java/com/cloud/hypervisor/ovm3/resources/Ovm3HypervisorGuru.java b/plugins/hypervisors/ovm3/src/main/java/com/cloud/hypervisor/ovm3/resources/Ovm3HypervisorGuru.java index 5f21c7de034..0d60a2d39bf 100755 --- a/plugins/hypervisors/ovm3/src/main/java/com/cloud/hypervisor/ovm3/resources/Ovm3HypervisorGuru.java +++ b/plugins/hypervisors/ovm3/src/main/java/com/cloud/hypervisor/ovm3/resources/Ovm3HypervisorGuru.java @@ -85,15 +85,6 @@ public class Ovm3HypervisorGuru extends HypervisorGuruBase implements Hypervisor */ public Pair getCommandHostDelegation(long hostId, Command cmd) { LOGGER.debug("getCommandHostDelegation: " + cmd.getClass()); - performSideEffectsForDelegationOnCommand(hostId, cmd); - return new Pair(Boolean.FALSE, Long.valueOf(hostId)); - } - - /** - * @param hostId - * @param cmd - */ - void performSideEffectsForDelegationOnCommand(long hostId, Command cmd) { if (cmd instanceof StorageSubSystemCommand) { StorageSubSystemCommand c = (StorageSubSystemCommand)cmd; c.setExecuteInSequence(true); @@ -103,17 +94,19 @@ public class Ovm3HypervisorGuru extends HypervisorGuruBase implements Hypervisor DataTO srcData = cpyCommand.getSrcTO(); DataTO destData = cpyCommand.getDestTO(); - if (srcData.getObjectType() == DataObjectType.SNAPSHOT && destData.getObjectType() == DataObjectType.TEMPLATE) { + if (HypervisorType.Ovm3.equals(srcData.getHypervisorType()) && srcData.getObjectType() == DataObjectType.SNAPSHOT && destData.getObjectType() == DataObjectType.TEMPLATE) { LOGGER.debug("Snapshot to Template: " + cmd); DataStoreTO srcStore = srcData.getDataStore(); DataStoreTO destStore = destData.getDataStore(); if (srcStore instanceof NfsTO && destStore instanceof NfsTO) { HostVO host = hostDao.findById(hostId); EndPoint ep = endPointSelector.selectHypervisorHost(new ZoneScope(host.getDataCenterId())); - host = hostDao.findById(ep.getId()); - hostDao.loadDetails(host); + if (ep != null) { + return new Pair(Boolean.TRUE, Long.valueOf(ep.getId())); + } } } } + return new Pair(Boolean.FALSE, Long.valueOf(hostId)); } } diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/XenServerGuru.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/XenServerGuru.java index 7153c5749fd..e6ebe555da6 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/XenServerGuru.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/XenServerGuru.java @@ -183,7 +183,8 @@ public class XenServerGuru extends HypervisorGuruBase implements HypervisorGuru, DataTO srcData = cpyCommand.getSrcTO(); DataTO destData = cpyCommand.getDestTO(); - if (srcData.getObjectType() == DataObjectType.SNAPSHOT && destData.getObjectType() == DataObjectType.TEMPLATE) { + if (srcData.getHypervisorType() == HypervisorType.XenServer && srcData.getObjectType() == DataObjectType.SNAPSHOT && + destData.getObjectType() == DataObjectType.TEMPLATE) { DataStoreTO srcStore = srcData.getDataStore(); DataStoreTO destStore = destData.getDataStore(); if (srcStore instanceof NfsTO && destStore instanceof NfsTO) { @@ -191,9 +192,13 @@ public class XenServerGuru extends HypervisorGuruBase implements HypervisorGuru, EndPoint ep = endPointSelector.selectHypervisorHost(new ZoneScope(host.getDataCenterId())); host = hostDao.findById(ep.getId()); hostDao.loadDetails(host); + String hypervisorVersion = host.getHypervisorVersion(); String snapshotHotFixVersion = host.getDetail(XenserverConfigs.XS620HotFix); - if (snapshotHotFixVersion != null && snapshotHotFixVersion.equalsIgnoreCase(XenserverConfigs.XSHotFix62ESP1004)) { - return new Pair(Boolean.TRUE, new Long(ep.getId())); + if (hypervisorVersion != null && !hypervisorVersion.equalsIgnoreCase("6.1.0")) { + if (!(hypervisorVersion.equalsIgnoreCase("6.2.0") && + !(snapshotHotFixVersion != null && snapshotHotFixVersion.equalsIgnoreCase(XenserverConfigs.XSHotFix62ESP1004)))) { + return new Pair(Boolean.TRUE, new Long(ep.getId())); + } } } } diff --git a/scripts/storage/qcow2/resizevolume.sh b/scripts/storage/qcow2/resizevolume.sh index 1e6ffd648f5..da77cb1adca 100755 --- a/scripts/storage/qcow2/resizevolume.sh +++ b/scripts/storage/qcow2/resizevolume.sh @@ -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=$? @@ -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" } @@ -244,7 +256,7 @@ then resizelvm elif [ "$ptype" == "QCOW2" ] then - notifyqemu + resizeqcow2 elif [ "$ptype" == "NOTIFYONLY" ] then notifyqemu diff --git a/server/src/com/cloud/hypervisor/HypervisorGuruManagerImpl.java b/server/src/com/cloud/hypervisor/HypervisorGuruManagerImpl.java index 243bbe43191..02778cbed4e 100644 --- a/server/src/com/cloud/hypervisor/HypervisorGuruManagerImpl.java +++ b/server/src/com/cloud/hypervisor/HypervisorGuruManagerImpl.java @@ -27,7 +27,6 @@ import org.apache.log4j.Logger; import org.springframework.stereotype.Component; import com.cloud.agent.api.Command; -import com.cloud.host.HostVO; import com.cloud.host.dao.HostDao; import com.cloud.hypervisor.Hypervisor.HypervisorType; import com.cloud.utils.Pair; @@ -73,9 +72,7 @@ public class HypervisorGuruManagerImpl extends ManagerBase implements Hypervisor @Override public long getGuruProcessedCommandTargetHost(long hostId, Command cmd) { - HostVO host = _hostDao.findById(hostId); - HypervisorGuru guru = getGuru(host.getHypervisorType()); - if (guru != null) { + for (HypervisorGuru guru : _hvGuruList) { Pair result = guru.getCommandHostDelegation(hostId, cmd); if (result.first()) { return result.second(); diff --git a/server/src/com/cloud/storage/VolumeApiServiceImpl.java b/server/src/com/cloud/storage/VolumeApiServiceImpl.java index 8a776291b6e..ba2b7bc1052 100644 --- a/server/src/com/cloud/storage/VolumeApiServiceImpl.java +++ b/server/src/com/cloud/storage/VolumeApiServiceImpl.java @@ -1158,6 +1158,9 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic if (newDiskOfferingId != null) { volume.setDiskOfferingId(newDiskOfferingId); } + if (currentSize != newSize) { + volume.setSize(newSize); + } _volsDao.update(volume.getId(), volume); diff --git a/ui/scripts/accounts.js b/ui/scripts/accounts.js index 376ef125d54..db0ab3fc34d 100644 --- a/ui/scripts/accounts.js +++ b/ui/scripts/accounts.js @@ -1876,10 +1876,14 @@ }, action: function(args) { var data = { - domainid: args.context.sshkeypairs[0].domainid, - account: args.context.sshkeypairs[0].account, name: args.context.sshkeypairs[0].name }; + if (!args.context.projects) { + $.extend(data, { + domainid: args.context.sshkeypairs[0].domainid, + account: args.context.sshkeypairs[0].account, + }); + } $.ajax({ url: createURL('deleteSSHKeyPair'), data: data, diff --git a/ui/scripts/storage.js b/ui/scripts/storage.js index 09d0052629a..2f93917319c 100644 --- a/ui/scripts/storage.js +++ b/ui/scripts/storage.js @@ -1550,14 +1550,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 = []; @@ -1619,8 +1632,7 @@ validation: { required: true, number: true - }, - isHidden: true + } }, shrinkok: { label: 'label.resize.shrink.ok', @@ -1654,7 +1666,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) { @@ -1665,9 +1677,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; } @@ -2352,11 +2364,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");