cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From santhosheduku...@apache.org
Subject [1/2] git commit: updated refs/heads/master to 7bbe7fc
Date Fri, 25 Jul 2014 11:11:42 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/master 2018d7d97 -> 7bbe7fc69


Fixed Coverity Issues Reported


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

Branch: refs/heads/master
Commit: 16b1746111bdb09c26ece1adea74ac60a7f64d19
Parents: 2018d7d
Author: Santhosh Edukulla <santhosh.edukulla@gmail.com>
Authored: Fri Jul 25 16:40:43 2014 +0530
Committer: Santhosh Edukulla <santhosh.edukulla@gmail.com>
Committed: Fri Jul 25 16:40:43 2014 +0530

----------------------------------------------------------------------
 server/src/com/cloud/api/ApiResponseHelper.java | 76 +++++++++++---------
 1 file changed, 44 insertions(+), 32 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/16b17461/server/src/com/cloud/api/ApiResponseHelper.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiResponseHelper.java b/server/src/com/cloud/api/ApiResponseHelper.java
index 013da0b..70ed47d 100755
--- a/server/src/com/cloud/api/ApiResponseHelper.java
+++ b/server/src/com/cloud/api/ApiResponseHelper.java
@@ -1026,20 +1026,24 @@ public class ApiResponseHelper implements ResponseGenerator {
 
 
         IpAddress ip = ApiDBUtils.findIpAddressById(fwRule.getSourceIpAddressId());
-        response.setPublicIpAddressId(ip.getUuid());
-        response.setPublicIpAddress(ip.getAddress().addr());
 
-        if (ip != null && fwRule.getDestinationIpAddress() != null) {
-            response.setDestNatVmIp(fwRule.getDestinationIpAddress().toString());
-            UserVm vm = ApiDBUtils.findUserVmById(fwRule.getVirtualMachineId());
-            if (vm != null) {
-                response.setVirtualMachineId(vm.getUuid());
-                response.setVirtualMachineName(vm.getHostName());
+        if (ip != null)
+        {
+            response.setPublicIpAddressId(ip.getUuid());
+            response.setPublicIpAddress(ip.getAddress().addr());
+            if (fwRule.getDestinationIpAddress() != null)
+            {
+                response.setDestNatVmIp(fwRule.getDestinationIpAddress().toString());
+                UserVm vm = ApiDBUtils.findUserVmById(fwRule.getVirtualMachineId());
+                if (vm != null) {
+                    response.setVirtualMachineId(vm.getUuid());
+                    response.setVirtualMachineName(vm.getHostName());
 
-                if (vm.getDisplayName() != null) {
-                    response.setVirtualMachineDisplayName(vm.getDisplayName());
-                } else {
-                    response.setVirtualMachineDisplayName(vm.getHostName());
+                    if (vm.getDisplayName() != null) {
+                        response.setVirtualMachineDisplayName(vm.getDisplayName());
+                    } else {
+                        response.setVirtualMachineDisplayName(vm.getHostName());
+                    }
                 }
             }
         }
@@ -1071,18 +1075,20 @@ public class ApiResponseHelper implements ResponseGenerator {
         response.setProtocol(fwRule.getProtocol());
 
         IpAddress ip = ApiDBUtils.findIpAddressById(fwRule.getSourceIpAddressId());
-        response.setPublicIpAddressId(ip.getId());
-        response.setPublicIpAddress(ip.getAddress().addr());
-
-        if (ip != null && fwRule.getDestIpAddress() != null) {
-            UserVm vm = ApiDBUtils.findUserVmById(ip.getAssociatedWithVmId());
-            if (vm != null) {// vm might be destroyed
-                response.setVirtualMachineId(vm.getUuid());
-                response.setVirtualMachineName(vm.getHostName());
-                if (vm.getDisplayName() != null) {
-                    response.setVirtualMachineDisplayName(vm.getDisplayName());
-                } else {
-                    response.setVirtualMachineDisplayName(vm.getHostName());
+
+        if (ip != null) {
+            response.setPublicIpAddressId(ip.getId());
+            response.setPublicIpAddress(ip.getAddress().addr());
+            if (fwRule.getDestIpAddress() != null) {
+                UserVm vm = ApiDBUtils.findUserVmById(ip.getAssociatedWithVmId());
+                if (vm != null) {// vm might be destroyed
+                    response.setVirtualMachineId(vm.getUuid());
+                    response.setVirtualMachineName(vm.getHostName());
+                    if (vm.getDisplayName() != null) {
+                        response.setVirtualMachineDisplayName(vm.getDisplayName());
+                    } else {
+                        response.setVirtualMachineDisplayName(vm.getHostName());
+                    }
                 }
             }
         }
@@ -1701,7 +1707,9 @@ public class ApiResponseHelper implements ResponseGenerator {
 
         Map<Service, Set<Provider>> serviceProviderMap = ApiDBUtils.listNetworkOfferingServices(offering.getId());
         List<ServiceResponse> serviceResponses = new ArrayList<ServiceResponse>();
-        for (Service service : serviceProviderMap.keySet()) {
+        for (Map.Entry<Service,Set<Provider>> entry : serviceProviderMap.entrySet())
{
+            Service service = entry.getKey();
+            Set<Provider> srvc_providers = entry.getValue();
             ServiceResponse svcRsp = new ServiceResponse();
             // skip gateway service
             if (service == Service.Gateway) {
@@ -1709,7 +1717,7 @@ public class ApiResponseHelper implements ResponseGenerator {
             }
             svcRsp.setName(service.getName());
             List<ProviderResponse> providers = new ArrayList<ProviderResponse>();
-            for (Provider provider : serviceProviderMap.get(service)) {
+            for (Provider provider : srvc_providers) {
                 if (provider != null) {
                     ProviderResponse providerRsp = new ProviderResponse();
                     providerRsp.setName(provider.getName());
@@ -1956,8 +1964,9 @@ public class ApiResponseHelper implements ResponseGenerator {
             Domain domain = ApiDBUtils.findDomainById(dedicatedDomainId);
             if (domain != null) {
                 response.setDomainId(domain.getUuid());
+                response.setDomainName(domain.getName());
             }
-            response.setDomainName(domain.getName());
+
         }
 
         response.setSpecifyIpRanges(network.getSpecifyIpRanges());
@@ -2563,7 +2572,10 @@ public class ApiResponseHelper implements ResponseGenerator {
 
         Map<Service, Set<Provider>> serviceProviderMap = ApiDBUtils.listVpcOffServices(offering.getId());
         List<ServiceResponse> serviceResponses = new ArrayList<ServiceResponse>();
-        for (Service service : serviceProviderMap.keySet()) {
+        for (Map.Entry<Service, Set<Provider>> entry : serviceProviderMap.entrySet())
{
+            Service service = entry.getKey();
+            Set<Provider> srvc_providers = entry.getValue();
+
             ServiceResponse svcRsp = new ServiceResponse();
             // skip gateway service
             if (service == Service.Gateway) {
@@ -2571,7 +2583,7 @@ public class ApiResponseHelper implements ResponseGenerator {
             }
             svcRsp.setName(service.getName());
             List<ProviderResponse> providers = new ArrayList<ProviderResponse>();
-            for (Provider provider : serviceProviderMap.get(service)) {
+            for (Provider provider : srvc_providers) {
                 if (provider != null) {
                     ProviderResponse providerRsp = new ProviderResponse();
                     providerRsp.setName(provider.getName());
@@ -3114,7 +3126,6 @@ public class ApiResponseHelper implements ResponseGenerator {
         } else if (usageRecord.getUsageType() == UsageTypes.TEMPLATE || usageRecord.getUsageType()
== UsageTypes.ISO) {
             //Template/ISO ID
             VMTemplateVO tmpl = _entityMgr.findByIdIncludingRemoved(VMTemplateVO.class, usageRecord.getUsageId().toString());
-            usageRecResponse.setUsageId(tmpl.getUuid());
             if (tmpl != null) {
                 usageRecResponse.setUsageId(tmpl.getUuid());
             }
@@ -3389,10 +3400,11 @@ public class ApiResponseHelper implements ResponseGenerator {
 
         //set Lb instances information
         List<ApplicationLoadBalancerInstanceResponse> instanceResponses = new ArrayList<ApplicationLoadBalancerInstanceResponse>();
-        for (Ip ip : lbInstances.keySet()) {
+        for (Map.Entry<Ip,UserVm> entry : lbInstances.entrySet()) {
+            Ip ip = entry.getKey();
+            UserVm vm = entry.getValue();
             ApplicationLoadBalancerInstanceResponse instanceResponse = new ApplicationLoadBalancerInstanceResponse();
             instanceResponse.setIpAddress(ip.addr());
-            UserVm vm = lbInstances.get(ip);
             instanceResponse.setId(vm.getUuid());
             instanceResponse.setName(vm.getInstanceName());
             instanceResponse.setObjectName("loadbalancerinstance");


Mime
View raw message