cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seb...@apache.org
Subject git commit: updated refs/heads/4.4-forward to fe84b67
Date Fri, 02 May 2014 20:36:52 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/4.4-forward f328f6157 -> fe84b674c


CLOUDSTACK-6472 listUsageRecords: Pull information from removed items as well, fixing NPEs/Null
UUIDs with usage API calls.


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

Branch: refs/heads/4.4-forward
Commit: fe84b674c14b6494770b489100e92a116b3b1f49
Parents: f328f61
Author: Sam Schmit <sam.schmit@appcore.com>
Authored: Fri May 2 13:07:34 2014 -0500
Committer: Sebastien Goasguen <runseb@gmail.com>
Committed: Fri May 2 16:36:37 2014 -0400

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


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/fe84b674/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 e8f275f..d8e26d8 100755
--- a/server/src/com/cloud/api/ApiResponseHelper.java
+++ b/server/src/com/cloud/api/ApiResponseHelper.java
@@ -3236,7 +3236,7 @@ public class ApiResponseHelper implements ResponseGenerator {
         usageRecResponse.setUsage(usageRecord.getUsageDisplay());
         usageRecResponse.setUsageType(usageRecord.getUsageType());
         if (usageRecord.getVmInstanceId() != null) {
-            VMInstanceVO vm = _entityMgr.findById(VMInstanceVO.class, usageRecord.getVmInstanceId());
+            VMInstanceVO vm = _entityMgr.findByIdIncludingRemoved(VMInstanceVO.class, usageRecord.getVmInstanceId());
             if (vm != null) {
                 usageRecResponse.setVirtualMachineId(vm.getUuid());
             }
@@ -3254,7 +3254,7 @@ public class ApiResponseHelper implements ResponseGenerator {
             //Service Offering Id
             usageRecResponse.setOfferingId(svcOffering.getUuid());
             //VM Instance ID
-            VMInstanceVO vm = _entityMgr.findById(VMInstanceVO.class, usageRecord.getUsageId().toString());
+            VMInstanceVO vm = _entityMgr.findByIdIncludingRemoved(VMInstanceVO.class, usageRecord.getUsageId().toString());
             if (vm != null) {
                 usageRecResponse.setUsageId(vm.getUuid());
             }
@@ -3267,7 +3267,7 @@ public class ApiResponseHelper implements ResponseGenerator {
             //isSystem
             usageRecResponse.setSystem((usageRecord.getSize() == 1) ? true : false);
             //IP Address ID
-            IPAddressVO ip = _entityMgr.findById(IPAddressVO.class, usageRecord.getUsageId().toString());
+            IPAddressVO ip = _entityMgr.findByIdIncludingRemoved(IPAddressVO.class, usageRecord.getUsageId().toString());
             if (ip != null) {
                 usageRecResponse.setUsageId(ip.getUuid());
             }
@@ -3277,19 +3277,19 @@ public class ApiResponseHelper implements ResponseGenerator {
             usageRecResponse.setType(usageRecord.getType());
             if (usageRecord.getType().equals("DomainRouter")) {
                 //Domain Router Id
-                VMInstanceVO vm = _entityMgr.findById(VMInstanceVO.class, usageRecord.getUsageId().toString());
+                VMInstanceVO vm = _entityMgr.findByIdIncludingRemoved(VMInstanceVO.class,
usageRecord.getUsageId().toString());
                 if (vm != null) {
                     usageRecResponse.setUsageId(vm.getUuid());
                 }
             } else {
                 //External Device Host Id
-                HostVO host = _entityMgr.findById(HostVO.class, usageRecord.getUsageId().toString());
+                HostVO host = _entityMgr.findByIdIncludingRemoved(HostVO.class, usageRecord.getUsageId().toString());
                 if (host != null) {
                     usageRecResponse.setUsageId(host.getUuid());
                 }
             }
             //Network ID
-            NetworkVO network = _entityMgr.findById(NetworkVO.class, usageRecord.getNetworkId().toString());
+            NetworkVO network = _entityMgr.findByIdIncludingRemoved(NetworkVO.class, usageRecord.getNetworkId().toString());
             if (network != null) {
                 usageRecResponse.setNetworkId(network.getUuid());
             }
@@ -3299,19 +3299,19 @@ public class ApiResponseHelper implements ResponseGenerator {
             //Device Type
             usageRecResponse.setType(usageRecord.getType());
             //VM Instance Id
-            VMInstanceVO vm = _entityMgr.findById(VMInstanceVO.class, usageRecord.getVmInstanceId().toString());
+            VMInstanceVO vm = _entityMgr.findByIdIncludingRemoved(VMInstanceVO.class, usageRecord.getVmInstanceId().toString());
             if (vm != null) {
                 usageRecResponse.setVirtualMachineId(vm.getUuid());
             }
             //Volume ID
-            VolumeVO volume = _entityMgr.findById(VolumeVO.class, usageRecord.getUsageId().toString());
+            VolumeVO volume = _entityMgr.findByIdIncludingRemoved(VolumeVO.class, usageRecord.getUsageId().toString());
             if (volume != null) {
                 usageRecResponse.setUsageId(volume.getUuid());
             }
 
         } else if (usageRecord.getUsageType() == UsageTypes.VOLUME) {
             //Volume ID
-            VolumeVO volume = _entityMgr.findById(VolumeVO.class, usageRecord.getUsageId().toString());
+            VolumeVO volume = _entityMgr.findByIdIncludingRemoved(VolumeVO.class, usageRecord.getUsageId().toString());
             if (volume != null) {
                 usageRecResponse.setUsageId(volume.getUuid());
             }
@@ -3319,13 +3319,13 @@ public class ApiResponseHelper implements ResponseGenerator {
             usageRecResponse.setSize(usageRecord.getSize());
             //Disk Offering Id
             if (usageRecord.getOfferingId() != null) {
-                DiskOfferingVO diskOff = _entityMgr.findById(DiskOfferingVO.class, usageRecord.getOfferingId().toString());
+                DiskOfferingVO diskOff = _entityMgr.findByIdIncludingRemoved(DiskOfferingVO.class,
usageRecord.getOfferingId().toString());
                 usageRecResponse.setOfferingId(diskOff.getUuid());
             }
 
         } else if (usageRecord.getUsageType() == UsageTypes.TEMPLATE || usageRecord.getUsageType()
== UsageTypes.ISO) {
             //Template/ISO ID
-            VMTemplateVO tmpl = _entityMgr.findById(VMTemplateVO.class, usageRecord.getUsageId().toString());
+            VMTemplateVO tmpl = _entityMgr.findByIdIncludingRemoved(VMTemplateVO.class, usageRecord.getUsageId().toString());
             usageRecResponse.setUsageId(tmpl.getUuid());
             if (tmpl != null) {
                 usageRecResponse.setUsageId(tmpl.getUuid());
@@ -3340,7 +3340,7 @@ public class ApiResponseHelper implements ResponseGenerator {
 
         } else if (usageRecord.getUsageType() == UsageTypes.SNAPSHOT) {
             //Snapshot ID
-            SnapshotVO snap = _entityMgr.findById(SnapshotVO.class, usageRecord.getUsageId().toString());
+            SnapshotVO snap = _entityMgr.findByIdIncludingRemoved(SnapshotVO.class, usageRecord.getUsageId().toString());
             if (snap != null) {
                 usageRecResponse.setUsageId(snap.getUuid());
             }
@@ -3349,39 +3349,39 @@ public class ApiResponseHelper implements ResponseGenerator {
 
         } else if (usageRecord.getUsageType() == UsageTypes.LOAD_BALANCER_POLICY) {
             //Load Balancer Policy ID
-            LoadBalancerVO lb = _entityMgr.findById(LoadBalancerVO.class, usageRecord.getUsageId().toString());
+            LoadBalancerVO lb = _entityMgr.findByIdIncludingRemoved(LoadBalancerVO.class,
usageRecord.getUsageId().toString());
             if (lb != null) {
                 usageRecResponse.setUsageId(lb.getUuid());
             }
         } else if (usageRecord.getUsageType() == UsageTypes.PORT_FORWARDING_RULE) {
             //Port Forwarding Rule ID
-            PortForwardingRuleVO pf = _entityMgr.findById(PortForwardingRuleVO.class, usageRecord.getUsageId().toString());
+            PortForwardingRuleVO pf = _entityMgr.findByIdIncludingRemoved(PortForwardingRuleVO.class,
usageRecord.getUsageId().toString());
             if (pf != null) {
                 usageRecResponse.setUsageId(pf.getUuid());
             }
 
         } else if (usageRecord.getUsageType() == UsageTypes.NETWORK_OFFERING) {
             //Network Offering Id
-            NetworkOfferingVO netOff = _entityMgr.findById(NetworkOfferingVO.class, usageRecord.getOfferingId().toString());
+            NetworkOfferingVO netOff = _entityMgr.findByIdIncludingRemoved(NetworkOfferingVO.class,
usageRecord.getOfferingId().toString());
             usageRecResponse.setOfferingId(netOff.getUuid());
             //is Default
             usageRecResponse.setDefault((usageRecord.getUsageId() == 1) ? true : false);
 
         } else if (usageRecord.getUsageType() == UsageTypes.VPN_USERS) {
             //VPN User ID
-            VpnUserVO vpnUser = _entityMgr.findById(VpnUserVO.class, usageRecord.getUsageId().toString());
+            VpnUserVO vpnUser = _entityMgr.findByIdIncludingRemoved(VpnUserVO.class, usageRecord.getUsageId().toString());
             if (vpnUser != null) {
                 usageRecResponse.setUsageId(vpnUser.getUuid());
             }
 
         } else if (usageRecord.getUsageType() == UsageTypes.SECURITY_GROUP) {
             //Security Group Id
-            SecurityGroupVO sg = _entityMgr.findById(SecurityGroupVO.class, usageRecord.getUsageId().toString());
+            SecurityGroupVO sg = _entityMgr.findByIdIncludingRemoved(SecurityGroupVO.class,
usageRecord.getUsageId().toString());
             if (sg != null) {
                 usageRecResponse.setUsageId(sg.getUuid());
             }
         } else if (usageRecord.getUsageType() == UsageTypes.VM_SNAPSHOT) {
-            VMInstanceVO vm = _entityMgr.findById(VMInstanceVO.class, usageRecord.getVmInstanceId().toString());
+            VMInstanceVO vm = _entityMgr.findByIdIncludingRemoved(VMInstanceVO.class, usageRecord.getVmInstanceId().toString());
             if (vm != null) {
                 usageRecResponse.setVmName(vm.getInstanceName());
                 usageRecResponse.setUsageId(vm.getUuid());


Mime
View raw message