cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bhais...@apache.org
Subject [12/22] git commit: updated refs/heads/4.5 to 78b9be0
Date Thu, 05 Feb 2015 11:51:48 GMT
Fixed Coverity Issues


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/c25263ba
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/c25263ba
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/c25263ba

Branch: refs/heads/4.5
Commit: c25263ba81b709ffab54085c5f09878d4dd3e0fd
Parents: b442d77
Author: Santhosh Edukulla <santhosh.edukulla@gmail.com>
Authored: Mon Nov 3 16:34:26 2014 +0530
Committer: Rohit Yadav <rohit.yadav@shapeblue.com>
Committed: Thu Feb 5 15:59:29 2015 +0530

----------------------------------------------------------------------
 .../resource/TrafficSentinelResource.java       |  3 ---
 .../com/cloud/vm/VirtualMachineManagerImpl.java |  6 -----
 .../kvm/storage/KVMStorageProcessor.java        |  4 +++-
 .../kvm/storage/LibvirtStorageAdaptor.java      |  6 ++---
 .../network/element/CiscoNexusVSMElement.java   |  2 +-
 .../storage/snapshot/SnapshotManagerImpl.java   | 10 +++++---
 .../com/cloud/template/TemplateManagerImpl.java |  5 ----
 server/src/com/cloud/vm/UserVmManagerImpl.java  | 24 ++++++++------------
 .../cloudstack/region/RegionsApiUtil.java       |  5 ----
 .../SecondaryStorageManagerImpl.java            |  9 ++++----
 10 files changed, 28 insertions(+), 46 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c25263ba/core/src/com/cloud/network/resource/TrafficSentinelResource.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/network/resource/TrafficSentinelResource.java b/core/src/com/cloud/network/resource/TrafficSentinelResource.java
index cac3ae3..610190a 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;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c25263ba/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
index 4c90dbe..609aa5b 100755
--- a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
+++ b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
@@ -2708,12 +2708,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();
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c25263ba/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java
----------------------------------------------------------------------
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 e7ed264..5752d57 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
@@ -1073,7 +1073,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()));
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c25263ba/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java
----------------------------------------------------------------------
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 86176d2..767c462 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
@@ -912,6 +912,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) {
@@ -957,9 +960,6 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
             }
         }
 
-        if (disk == null) {
-            throw new CloudRuntimeException("Failed to create disk from template " + template.getName());
-        }
 
         return disk;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c25263ba/plugins/hypervisors/vmware/src/com/cloud/network/element/CiscoNexusVSMElement.java
----------------------------------------------------------------------
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 0e2a911..81e4f86 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);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c25263ba/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
index a3eb7b0..214c6fc 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());
             }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c25263ba/server/src/com/cloud/template/TemplateManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/template/TemplateManagerImpl.java b/server/src/com/cloud/template/TemplateManagerImpl.java
index a498dc7..67fdc7c 100755
--- a/server/src/com/cloud/template/TemplateManagerImpl.java
+++ b/server/src/com/cloud/template/TemplateManagerImpl.java
@@ -155,7 +155,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;
@@ -1352,10 +1351,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();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c25263ba/server/src/com/cloud/vm/UserVmManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java
index c74c74e..466d0ea 100755
--- a/server/src/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/com/cloud/vm/UserVmManagerImpl.java
@@ -746,12 +746,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 {
@@ -1335,16 +1330,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<String,
String> customParameters) throws ResourceUnavailableException,

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c25263ba/server/src/org/apache/cloudstack/region/RegionsApiUtil.java
----------------------------------------------------------------------
diff --git a/server/src/org/apache/cloudstack/region/RegionsApiUtil.java b/server/src/org/apache/cloudstack/region/RegionsApiUtil.java
index 7894e37..92c5ed4 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");

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c25263ba/services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java
----------------------------------------------------------------------
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 8212a41..f9a343a 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
@@ -1007,11 +1007,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;


Mime
View raw message