diff --git a/core/src/com/cloud/network/resource/TrafficSentinelResource.java b/core/src/com/cloud/network/resource/TrafficSentinelResource.java index cac3ae3f06a..610190ae7cc 100644 --- a/core/src/com/cloud/network/resource/TrafficSentinelResource.java +++ b/core/src/com/cloud/network/resource/TrafficSentinelResource.java @@ -222,9 +222,6 @@ public class TrafficSentinelResource implements ServerResource { String publicIp = st.nextToken(); Long bytesSent = new Long(st.nextToken()); Long bytesRcvd = new Long(st.nextToken()); - if (bytesSent == null || bytesRcvd == null) { - s_logger.debug("Incorrect bytes for IP: " + publicIp); - } long[] bytesSentAndReceived = new long[2]; bytesSentAndReceived[0] = bytesSent; bytesSentAndReceived[1] = bytesRcvd; diff --git a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java index ebb030e5233..32bf54c9de0 100755 --- a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java +++ b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java @@ -2675,12 +2675,6 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac s_logger.debug("Not processing listener " + this + " as connect happens on rebalance process"); return; } - - if (forRebalance) { - s_logger.debug("Not processing listener " + this + " as connect happens on rebalance process"); - return; - } - Long clusterId = agent.getClusterId(); long agentId = agent.getId(); 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 41019fbc0b6..7427f37c4cb 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 @@ -404,14 +404,14 @@ public class StorageSystemSnapshotStrategy extends SnapshotStrategyBase { DataStore dataStore = _dataStoreMgr.getDataStore(storagePoolId, DataStoreRole.Primary); Map mapCapabilities = dataStore.getDriver().getCapabilities(); + if(mapCapabilities != null) { + String value = mapCapabilities.get(DataStoreCapabilities.STORAGE_SYSTEM_SNAPSHOT.toString()); + Boolean supportsStorageSystemSnapshots = new Boolean(value); - String value = mapCapabilities.get(DataStoreCapabilities.STORAGE_SYSTEM_SNAPSHOT.toString()); - Boolean supportsStorageSystemSnapshots = new Boolean(value); - - if (supportsStorageSystemSnapshots) { - return StrategyPriority.HIGHEST; + if (supportsStorageSystemSnapshots) { + return StrategyPriority.HIGHEST; + } } - return StrategyPriority.CANT_HANDLE; } } diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java index 21f59195b1f..562cf5f50ad 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java @@ -1082,7 +1082,9 @@ public class KVMStorageProcessor implements StorageProcessor { volume.getProvisioningType(), disksize); VolumeObjectTO newVol = new VolumeObjectTO(); - newVol.setPath(vol.getName()); + if(vol != null) { + newVol.setPath(vol.getName()); + } newVol.setSize(volume.getSize()); newVol.setFormat(ImageFormat.valueOf(format.toString().toUpperCase())); diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java index c882a787482..8c9ea6926f5 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java @@ -915,6 +915,9 @@ public class LibvirtStorageAdaptor implements StorageAdaptor { try { String newUuid = name; disk = destPool.createPhysicalDisk(newUuid, format, provisioningType, template.getVirtualSize()); + if (disk == null) { + throw new CloudRuntimeException("Failed to create disk from template " + template.getName()); + } if (template.getFormat() == PhysicalDiskFormat.TAR) { Script.runSimpleBashScript("tar -x -f " + template.getPath() + " -C " + disk.getPath(), timeout); // TO BE FIXED to aware provisioningType } else if (template.getFormat() == PhysicalDiskFormat.DIR) { @@ -960,9 +963,6 @@ public class LibvirtStorageAdaptor implements StorageAdaptor { } } - if (disk == null) { - throw new CloudRuntimeException("Failed to create disk from template " + template.getName()); - } return disk; } diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/ManagedNfsStorageAdaptor.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/ManagedNfsStorageAdaptor.java index af2e6f6e125..c00e8cb9581 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/ManagedNfsStorageAdaptor.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/ManagedNfsStorageAdaptor.java @@ -100,6 +100,9 @@ public class ManagedNfsStorageAdaptor implements StorageAdaptor { LibvirtStoragePoolDef spd = null; try { conn = LibvirtConnection.getConnection(); + if (conn == null) { + throw new CloudRuntimeException("Failed to create Libvrt Connection"); + } targetPath = "/mnt" + volumeUuid; spd = new LibvirtStoragePoolDef(poolType.NETFS, volumeUuid, details.get(DiskTO.UUID), pool.getSourceHost(), details.get(DiskTO.MOUNT_POINT), targetPath); @@ -140,7 +143,7 @@ public class ManagedNfsStorageAdaptor implements StorageAdaptor { if (result == null) { s_logger.error("Succeeded in unmounting " + targetPath); try { - sp = conn.storagePoolCreateXML(spd.toString(), 0); + conn.storagePoolCreateXML(spd.toString(), 0); s_logger.error("Succeeded in redefining storage"); return true; } catch (LibvirtException l) { @@ -176,9 +179,6 @@ public class ManagedNfsStorageAdaptor implements StorageAdaptor { } LibvirtStorageVolumeDef.volFormat libvirtformat = null; - String volPath = null; - String volName = null; - long volAllocation = 0; long volCapacity = 0; // check whether the volume is present on the given pool StorageVol vol = getVolume(virtPool, volumeUuid); @@ -194,13 +194,8 @@ public class ManagedNfsStorageAdaptor implements StorageAdaptor { s_logger.debug(volDef.toString()); vol = virtPool.storageVolCreateXML(volDef.toString(), 0); - volPath = vol.getPath(); - volName = vol.getName(); - volAllocation = vol.getInfo().allocation; - volCapacity = vol.getInfo().capacity; } - KVMPhysicalDisk disk = new KVMPhysicalDisk(vol.getPath(), volumeUuid, pool); disk.setFormat(PhysicalDiskFormat.QCOW2); disk.setSize(vol.getInfo().allocation); diff --git a/plugins/hypervisors/vmware/src/com/cloud/network/element/CiscoNexusVSMElement.java b/plugins/hypervisors/vmware/src/com/cloud/network/element/CiscoNexusVSMElement.java index 0e2a9117f10..81e4f8637ed 100644 --- a/plugins/hypervisors/vmware/src/com/cloud/network/element/CiscoNexusVSMElement.java +++ b/plugins/hypervisors/vmware/src/com/cloud/network/element/CiscoNexusVSMElement.java @@ -294,7 +294,7 @@ public class CiscoNexusVSMElement extends CiscoNexusVSMDeviceManagerImpl impleme CiscoNexusVSMDeviceVO vsm = null; if (_vsmDao.getVSMbyIpaddress(vsmIp) == null) { vsm = new CiscoNexusVSMDeviceVO(vsmIp, vsmUser, vsmPassword); - vsm = _vsmDao.persist(vsm); + _vsmDao.persist(vsm); } // Create a mapping between the cluster and the vsm. vsm = _vsmDao.getVSMbyIpaddress(vsmIp); diff --git a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java index ac013c40842..16258898014 100755 --- a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java +++ b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java @@ -309,17 +309,21 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager, throw new InvalidParameterValueException("Volume is not in ready state"); } - boolean backedUp = false; + // does the caller have the authority to act on this volume _accountMgr.checkAccess(CallContext.current().getCallingAccount(), null, true, volume); SnapshotInfo snapshot = snapshotFactory.getSnapshot(snapshotId, DataStoreRole.Primary); - + if(snapshot != null) + { + s_logger.debug("Failed to create snapshot"); + throw new CloudRuntimeException("Failed to create snapshot"); + } try { postCreateSnapshot(volumeId, snapshot.getId(), policyId); //Check if the snapshot was removed while backingUp. If yes, do not log snapshot create usage event SnapshotVO freshSnapshot = _snapshotDao.findById(snapshot.getId()); - if ((freshSnapshot != null) && backedUp) { + if (freshSnapshot != null) { UsageEventUtils.publishUsageEvent(EventTypes.EVENT_SNAPSHOT_CREATE, snapshot.getAccountId(), snapshot.getDataCenterId(), snapshotId, snapshot.getName(), null, null, volume.getSize(), snapshot.getClass().getName(), snapshot.getUuid()); } diff --git a/server/src/com/cloud/template/TemplateManagerImpl.java b/server/src/com/cloud/template/TemplateManagerImpl.java index d3ad2db376d..d854579b902 100755 --- a/server/src/com/cloud/template/TemplateManagerImpl.java +++ b/server/src/com/cloud/template/TemplateManagerImpl.java @@ -156,7 +156,6 @@ import com.cloud.user.AccountManager; import com.cloud.user.AccountService; import com.cloud.user.AccountVO; import com.cloud.user.ResourceLimitService; -import com.cloud.user.User; import com.cloud.user.dao.AccountDao; import com.cloud.uservm.UserVm; import com.cloud.utils.DateUtil; @@ -1350,10 +1349,6 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager, @DB @ActionEvent(eventType = EventTypes.EVENT_TEMPLATE_CREATE, eventDescription = "creating template", async = true) public VirtualMachineTemplate createPrivateTemplate(CreateTemplateCmd command) throws CloudRuntimeException { - Long userId = CallContext.current().getCallingUserId(); - if (userId == null) { - userId = User.UID_SYSTEM; - } final long templateId = command.getEntityId(); Long volumeId = command.getVolumeId(); Long snapshotId = command.getSnapshotId(); diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java index 609f781131b..abb5b7bb190 100755 --- a/server/src/com/cloud/vm/UserVmManagerImpl.java +++ b/server/src/com/cloud/vm/UserVmManagerImpl.java @@ -748,12 +748,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir } catch (CloudException e) { throw new CloudRuntimeException("Unable to contact the agent to stop the virtual machine " + vm, e); } - - if (status) { - return status; - } else { - return status; - } + return status; } private UserVm rebootVirtualMachine(long userId, long vmId) throws InsufficientCapacityException, ResourceUnavailableException { @@ -1328,16 +1323,15 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir if (vmSnapshots.size() > 0) { throw new InvalidParameterValueException("Unable to scale VM, please remove VM snapshots before scaling VM"); } + if (vmInstance.getState().equals(State.Stopped)) { + upgradeStoppedVirtualMachine(vmId, newServiceOfferingId, customParameters); + return true; + } + if (vmInstance.getState().equals(State.Running)) { + return upgradeRunningVirtualMachine(vmId, newServiceOfferingId, customParameters); + } } - - if (vmInstance.getState().equals(State.Stopped)) { - upgradeStoppedVirtualMachine(vmId, newServiceOfferingId, customParameters); - return true; - } - if (vmInstance.getState().equals(State.Running)) { - return upgradeRunningVirtualMachine(vmId, newServiceOfferingId, customParameters); - } - return false; + return false; } private boolean upgradeRunningVirtualMachine(Long vmId, Long newServiceOfferingId, Map customParameters) throws ResourceUnavailableException, diff --git a/server/src/org/apache/cloudstack/region/RegionsApiUtil.java b/server/src/org/apache/cloudstack/region/RegionsApiUtil.java index 7894e3797da..92c5ed4e17e 100644 --- a/server/src/org/apache/cloudstack/region/RegionsApiUtil.java +++ b/server/src/org/apache/cloudstack/region/RegionsApiUtil.java @@ -237,11 +237,6 @@ public class RegionsApiUtil { String apiKey = ""; String secretKey = ""; - - if (apiKey == null || secretKey == null) { - return region.getEndPoint() + "?" + apiParams; - } - String encodedApiKey; try { encodedApiKey = URLEncoder.encode(apiKey, "UTF-8"); diff --git a/services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java b/services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java index 86d94df9e8a..806905054a3 100755 --- a/services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java +++ b/services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java @@ -988,11 +988,12 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar if (host != null) { s_logger.debug("Removing host entry for ssvm id=" + vmId); _hostDao.remove(host.getId()); + //Expire the download urls in the entire zone for templates and volumes. + _tmplStoreDao.expireDnldUrlsForZone(host.getDataCenterId()); + _volumeStoreDao.expireDnldUrlsForZone(host.getDataCenterId()); + return true; } - //Expire the download urls in the entire zone for templates and volumes. - _tmplStoreDao.expireDnldUrlsForZone(host.getDataCenterId()); - _volumeStoreDao.expireDnldUrlsForZone(host.getDataCenterId()); - return true; + return false; } catch (ResourceUnavailableException e) { s_logger.warn("Unable to expunge " + ssvm, e); return false;