cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From santhosheduku...@apache.org
Subject git commit: updated refs/heads/master to 19ffc93
Date Thu, 21 Aug 2014 11:40:45 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/master 6c0a4f766 -> 19ffc93e2


Fixed few coverity reported issues:Aug22 2014


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

Branch: refs/heads/master
Commit: 19ffc93e2e376a5f076eb2d4f7d7493cf4d6e4e5
Parents: 6c0a4f7
Author: Santhosh Edukulla <santhosh.edukulla@gmail.com>
Authored: Thu Aug 21 17:09:09 2014 +0530
Committer: Santhosh Edukulla <santhosh.edukulla@gmail.com>
Committed: Thu Aug 21 17:09:27 2014 +0530

----------------------------------------------------------------------
 .../cloud/agent/api/to/VirtualMachineTO.java    |  1 -
 .../ConfigureVirtualRouterElementCmd.java       |  6 +++--
 .../router/CreateVirtualRouterElementCmd.java   |  6 +++--
 .../admin/usage/ListTrafficTypesCmd.java        | 13 +++++-----
 .../api/command/admin/user/RegisterCmd.java     |  6 +++--
 .../admin/vlan/CreateVlanIpRangeCmd.java        |  2 +-
 .../user/address/AssociateIPAddrCmd.java        |  4 ---
 .../command/user/address/UpdateIPAddrCmd.java   |  8 +++---
 .../orchestration/NetworkOrchestrator.java      | 13 +++++-----
 .../network/resource/NetscalerResource.java     |  4 ++-
 .../cloud/api/dispatch/ParamProcessWorker.java  | 11 ++++++---
 .../lb/LoadBalancingRulesManagerImpl.java       |  4 ++-
 .../com/cloud/storage/VolumeApiServiceImpl.java | 13 +++++-----
 .../storage/download/DownloadMonitorImpl.java   | 26 +++++++++++---------
 14 files changed, 66 insertions(+), 51 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/19ffc93e/api/src/com/cloud/agent/api/to/VirtualMachineTO.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/agent/api/to/VirtualMachineTO.java b/api/src/com/cloud/agent/api/to/VirtualMachineTO.java
index a1d9452..4b36df5 100644
--- a/api/src/com/cloud/agent/api/to/VirtualMachineTO.java
+++ b/api/src/com/cloud/agent/api/to/VirtualMachineTO.java
@@ -50,7 +50,6 @@ public class VirtualMachineTO {
     String platformEmulator;
     String bootArgs;
     String[] bootupScripts;
-    boolean rebootOnCrash;
     boolean enableHA;
     boolean limitCpuUse;
     boolean enableDynamicallyScaleVm;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/19ffc93e/api/src/org/apache/cloudstack/api/command/admin/router/ConfigureVirtualRouterElementCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/router/ConfigureVirtualRouterElementCmd.java
b/api/src/org/apache/cloudstack/api/command/admin/router/ConfigureVirtualRouterElementCmd.java
index b8fafb6..6dd05a4 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/router/ConfigureVirtualRouterElementCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/router/ConfigureVirtualRouterElementCmd.java
@@ -127,8 +127,10 @@ public class ConfigureVirtualRouterElementCmd extends BaseAsyncCmd {
         VirtualRouterProvider result = _service.get(0).configure(this);
         if (result != null) {
             VirtualRouterProviderResponse routerResponse = _responseGenerator.createVirtualRouterProviderResponse(result);
-            routerResponse.setResponseName(getCommandName());
-            this.setResponseObject(routerResponse);
+            if(routerResponse != null) {
+                routerResponse.setResponseName(getCommandName());
+                this.setResponseObject(routerResponse);
+            }
         } else {
             throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to configure
the virtual router provider");
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/19ffc93e/api/src/org/apache/cloudstack/api/command/admin/router/CreateVirtualRouterElementCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/router/CreateVirtualRouterElementCmd.java
b/api/src/org/apache/cloudstack/api/command/admin/router/CreateVirtualRouterElementCmd.java
index f43b143..10cf00f 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/router/CreateVirtualRouterElementCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/router/CreateVirtualRouterElementCmd.java
@@ -110,8 +110,10 @@ public class CreateVirtualRouterElementCmd extends BaseAsyncCreateCmd
{
         VirtualRouterProvider result = _service.get(0).getCreatedElement(getEntityId());
         if (result != null) {
             VirtualRouterProviderResponse response = _responseGenerator.createVirtualRouterProviderResponse(result);
-            response.setResponseName(getCommandName());
-            this.setResponseObject(response);
+            if(response != null) {
+                response.setResponseName(getCommandName());
+                this.setResponseObject(response);
+            }
         } else {
             throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add Virtual
Router entity to physical network");
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/19ffc93e/api/src/org/apache/cloudstack/api/command/admin/usage/ListTrafficTypesCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/usage/ListTrafficTypesCmd.java
b/api/src/org/apache/cloudstack/api/command/admin/usage/ListTrafficTypesCmd.java
index fd06359..a5a5a5d 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/usage/ListTrafficTypesCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/usage/ListTrafficTypesCmd.java
@@ -80,13 +80,14 @@ public class ListTrafficTypesCmd extends BaseListCmd {
         Pair<List<? extends PhysicalNetworkTrafficType>, Integer> trafficTypes
= _networkService.listTrafficTypes(getPhysicalNetworkId());
         ListResponse<TrafficTypeResponse> response = new ListResponse<TrafficTypeResponse>();
         List<TrafficTypeResponse> trafficTypesResponses = new ArrayList<TrafficTypeResponse>();
-        for (PhysicalNetworkTrafficType trafficType : trafficTypes.first()) {
-            TrafficTypeResponse trafficTypeResponse = _responseGenerator.createTrafficTypeResponse(trafficType);
-            trafficTypesResponses.add(trafficTypeResponse);
+        if(trafficTypes != null) {
+            for (PhysicalNetworkTrafficType trafficType : trafficTypes.first()) {
+                TrafficTypeResponse trafficTypeResponse = _responseGenerator.createTrafficTypeResponse(trafficType);
+                trafficTypesResponses.add(trafficTypeResponse);
+            }
+            response.setResponses(trafficTypesResponses, trafficTypes.second());
+            response.setResponseName(getCommandName());
         }
-
-        response.setResponses(trafficTypesResponses, trafficTypes.second());
-        response.setResponseName(getCommandName());
         this.setResponseObject(response);
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/19ffc93e/api/src/org/apache/cloudstack/api/command/admin/user/RegisterCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/user/RegisterCmd.java b/api/src/org/apache/cloudstack/api/command/admin/user/RegisterCmd.java
index 2090d21..bb80999 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/user/RegisterCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/user/RegisterCmd.java
@@ -75,8 +75,10 @@ public class RegisterCmd extends BaseCmd {
     public void execute() {
         String[] keys = _accountService.createApiKeyAndSecretKey(this);
         RegisterResponse response = new RegisterResponse();
-        response.setApiKey(keys[0]);
-        response.setSecretKey(keys[1]);
+        if (keys != null) {
+            response.setApiKey(keys[0]);
+            response.setSecretKey(keys[1]);
+        }
         response.setObjectName("userkeys");
         response.setResponseName(getCommandName());
         this.setResponseObject(response);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/19ffc93e/api/src/org/apache/cloudstack/api/command/admin/vlan/CreateVlanIpRangeCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/vlan/CreateVlanIpRangeCmd.java
b/api/src/org/apache/cloudstack/api/command/admin/vlan/CreateVlanIpRangeCmd.java
index 6032625..a2da7db 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/vlan/CreateVlanIpRangeCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/vlan/CreateVlanIpRangeCmd.java
@@ -129,7 +129,7 @@ public class CreateVlanIpRangeCmd extends BaseCmd {
     }
 
     public Boolean isForVirtualNetwork() {
-        return forVirtualNetwork == null ? true : forVirtualNetwork;
+        return forVirtualNetwork == null ? Boolean.TRUE : forVirtualNetwork;
     }
 
     public String getGateway() {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/19ffc93e/api/src/org/apache/cloudstack/api/command/user/address/AssociateIPAddrCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/address/AssociateIPAddrCmd.java
b/api/src/org/apache/cloudstack/api/command/user/address/AssociateIPAddrCmd.java
index ae13717..63939dc 100644
--- a/api/src/org/apache/cloudstack/api/command/user/address/AssociateIPAddrCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/address/AssociateIPAddrCmd.java
@@ -172,10 +172,6 @@ public class AssociateIPAddrCmd extends BaseAsyncCreateCmd {
         }
         Long zoneId = getZoneId();
 
-        if (zoneId == null) {
-            return null;
-        }
-
         DataCenter zone = _entityMgr.findById(DataCenter.class, zoneId);
         if (zone.getNetworkType() == NetworkType.Advanced) {
             List<? extends Network> networks = _networkService.getIsolatedNetworksOwnedByAccountInZone(getZoneId(),
_accountService.getAccount(getEntityOwnerId()));

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/19ffc93e/api/src/org/apache/cloudstack/api/command/user/address/UpdateIPAddrCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/address/UpdateIPAddrCmd.java b/api/src/org/apache/cloudstack/api/command/user/address/UpdateIPAddrCmd.java
index c64b641..f0ea667 100644
--- a/api/src/org/apache/cloudstack/api/command/user/address/UpdateIPAddrCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/address/UpdateIPAddrCmd.java
@@ -127,8 +127,10 @@ public class UpdateIPAddrCmd extends BaseAsyncCustomIdCmd {
             NetworkRuleConflictException {
 
         IpAddress result = _networkService.updateIP(getId(), getCustomId(), getDisplayIp());
-        IPAddressResponse ipResponse = _responseGenerator.createIPAddressResponse(ResponseView.Restricted,
result);
-        ipResponse.setResponseName(getCommandName());
-        setResponseObject(ipResponse);
+        if(result != null) {
+            IPAddressResponse ipResponse = _responseGenerator.createIPAddressResponse(ResponseView.Restricted,
result);
+            ipResponse.setResponseName(getCommandName());
+            setResponseObject(ipResponse);
+        }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/19ffc93e/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java
b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java
index ca0b86d..9bb23a9 100755
--- a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java
+++ b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java
@@ -749,14 +749,15 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
                         }
 
                         Pair<NicProfile, Integer> vmNicPair = allocateNic(requested,
config, isDefaultNic, deviceId, vm);
-
-                        NicProfile vmNic = vmNicPair.first();
-                        if (vmNic == null) {
-                            continue;
+                        NicProfile vmNic = null;
+                        if(vmNicPair != null) {
+                            vmNic = vmNicPair.first();
+                            if (vmNic == null) {
+                                continue;
+                            }
+                            deviceId = vmNicPair.second();
                         }
 
-                        deviceId = vmNicPair.second();
-
                         int devId = vmNic.getDeviceId();
                         if (devId > deviceIds.length) {
                             throw new IllegalArgumentException("Device id for nic is too
large: " + vmNic);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/19ffc93e/plugins/network-elements/netscaler/src/com/cloud/network/resource/NetscalerResource.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/netscaler/src/com/cloud/network/resource/NetscalerResource.java
b/plugins/network-elements/netscaler/src/com/cloud/network/resource/NetscalerResource.java
index d556362..485da8d 100644
--- a/plugins/network-elements/netscaler/src/com/cloud/network/resource/NetscalerResource.java
+++ b/plugins/network-elements/netscaler/src/com/cloud/network/resource/NetscalerResource.java
@@ -3174,7 +3174,9 @@ public class NetscalerResource implements ServerResource {
                 scaleUpAction.set_vserver(nsVirtualServerName); // Actions Vserver, the one
that is autoscaled, with CS
                 // now both are same. Not exposed in API.
                 scaleUpAction.set_profilename(profileName);
-                scaleUpAction.set_quiettime(scaleUpQuietTime);
+                if(scaleUpQuietTime != null) {
+                    scaleUpAction.set_quiettime(scaleUpQuietTime);
+                }
                 String scaleUpParameters =
                         "command=deployVirtualMachine" + "&" + ApiConstants.ZONE_ID +
"=" + profileTO.getZoneId() + "&" + ApiConstants.SERVICE_OFFERING_ID + "=" +
                                 profileTO.getServiceOfferingId() + "&" + ApiConstants.TEMPLATE_ID
+ "=" + profileTO.getTemplateId() + "&" + ApiConstants.DISPLAY_NAME + "=" +

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/19ffc93e/server/src/com/cloud/api/dispatch/ParamProcessWorker.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/dispatch/ParamProcessWorker.java b/server/src/com/cloud/api/dispatch/ParamProcessWorker.java
index ad90812..9a98f33 100644
--- a/server/src/com/cloud/api/dispatch/ParamProcessWorker.java
+++ b/server/src/com/cloud/api/dispatch/ParamProcessWorker.java
@@ -341,11 +341,14 @@ public class ParamProcessWorker implements DispatchWorker {
                     field.set(cmdObj, Short.valueOf(paramObj.toString()));
                     break;
                 case STRING:
-                    if ((paramObj != null) && paramObj.toString().length() > annotation.length())
{
-                        s_logger.error("Value greater than max allowed length " + annotation.length()
+ " for param: " + field.getName());
-                        throw new InvalidParameterValueException("Value greater than max
allowed length " + annotation.length() + " for param: " + field.getName());
+                    if ((paramObj != null)) {
+                        if (paramObj.toString().length() > annotation.length()) {
+                            s_logger.error("Value greater than max allowed length " + annotation.length()
+ " for param: " + field.getName());
+                            throw new InvalidParameterValueException("Value greater than
max allowed length " + annotation.length() + " for param: " + field.getName());
+                        } else {
+                            field.set(cmdObj, paramObj.toString());
+                        }
                     }
-                    field.set(cmdObj, paramObj.toString());
                     break;
                 case TZDATE:
                     field.set(cmdObj, DateUtil.parseTZDateString(paramObj.toString()));

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/19ffc93e/server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java b/server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java
index 427e3ec..52233de 100755
--- a/server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java
+++ b/server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java
@@ -1600,7 +1600,9 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase
implements
             NetworkOffering off = _entityMgr.findById(NetworkOffering.class, network.getNetworkOfferingId());
             if (off.getElasticLb() && ipVO == null && network.getVpcId()
== null) {
                 systemIp = _ipAddrMgr.assignSystemIp(networkId, lbOwner, true, false);
-                ipVO = _ipAddressDao.findById(systemIp.getId());
+                if (systemIp != null) {
+                    ipVO = _ipAddressDao.findById(systemIp.getId());
+                }
             }
 
             // Validate ip address

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/19ffc93e/server/src/com/cloud/storage/VolumeApiServiceImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/VolumeApiServiceImpl.java b/server/src/com/cloud/storage/VolumeApiServiceImpl.java
index fa104ed..0734385 100644
--- a/server/src/com/cloud/storage/VolumeApiServiceImpl.java
+++ b/server/src/com/cloud/storage/VolumeApiServiceImpl.java
@@ -2141,7 +2141,7 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
         }
 
         if (sendCommand) {
-            if (host.getHypervisorType() == HypervisorType.KVM &&
+            if (host != null && host.getHypervisorType() == HypervisorType.KVM &&
                     volumeToAttachStoragePool.isManaged() &&
                     volumeToAttach.getPath() == null) {
                 volumeToAttach.setPath(volumeToAttach.get_iScsiName());
@@ -2178,8 +2178,9 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
             try {
                 answer = (AttachAnswer)_agentMgr.send(hostId, cmd);
             } catch (Exception e) {
-                volService.disconnectVolumeFromHost(volFactory.getVolume(volumeToAttach.getId()),
host, dataStore);
-
+                if(host!=null) {
+                    volService.disconnectVolumeFromHost(volFactory.getVolume(volumeToAttach.getId()),
host, dataStore);
+                }
                 throw new CloudRuntimeException(errorMsg + " due to: " + e.getMessage());
             }
         }
@@ -2216,9 +2217,9 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
                     errorMsg += "; " + details;
                 }
             }
-
-            volService.disconnectVolumeFromHost(volFactory.getVolume(volumeToAttach.getId()),
host, dataStore);
-
+            if(host!= null) {
+                volService.disconnectVolumeFromHost(volFactory.getVolume(volumeToAttach.getId()),
host, dataStore);
+            }
             throw new CloudRuntimeException(errorMsg);
         }
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/19ffc93e/server/src/com/cloud/storage/download/DownloadMonitorImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/download/DownloadMonitorImpl.java b/server/src/com/cloud/storage/download/DownloadMonitorImpl.java
index 1b44a12..eed1581 100755
--- a/server/src/com/cloud/storage/download/DownloadMonitorImpl.java
+++ b/server/src/com/cloud/storage/download/DownloadMonitorImpl.java
@@ -182,21 +182,23 @@ public class DownloadMonitorImpl extends ManagerBase implements DownloadMonitor
 
     @Override
     public void downloadTemplateToStorage(DataObject template, AsyncCompletionCallback<DownloadAnswer>
callback) {
-        long templateId = template.getId();
-        DataStore store = template.getDataStore();
-        if (isTemplateUpdateable(templateId, store.getId())) {
-            if (template != null && template.getUri() != null) {
-                initiateTemplateDownload(template, callback);
+        if(template != null) {
+            long templateId = template.getId();
+            DataStore store = template.getDataStore();
+            if (isTemplateUpdateable(templateId, store.getId())) {
+                if (template.getUri() != null) {
+                    initiateTemplateDownload(template, callback);
+                } else {
+                    s_logger.info("Template url is null, cannot download");
+                    DownloadAnswer ans = new DownloadAnswer("Template url is null", Status.UNKNOWN);
+                    callback.complete(ans);
+                }
             } else {
-                s_logger.info("Template url is null, cannot download");
-                DownloadAnswer ans = new DownloadAnswer("Template url is null", Status.UNKNOWN);
+                s_logger.info("Template download is already in progress or already downloaded");
+                DownloadAnswer ans =
+                        new DownloadAnswer("Template download is already in progress or already
downloaded", Status.UNKNOWN);
                 callback.complete(ans);
             }
-        } else {
-            s_logger.info("Template download is already in progress or already downloaded");
-            DownloadAnswer ans =
-                new DownloadAnswer("Template download is already in progress or already downloaded",
Status.UNKNOWN);
-            callback.complete(ans);
         }
     }
 


Mime
View raw message