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 f328f61
Date Fri, 02 May 2014 20:36:03 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/4.4-forward c7c10f522 -> f328f6157


Review from pyr https://reviews.apache.org/r/20557/


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

Branch: refs/heads/4.4-forward
Commit: f328f6157b682abc5bce007400f1cdf476097745
Parents: c7c10f5
Author: Sebastien Goasguen <runseb@gmail.com>
Authored: Fri Apr 25 16:59:47 2014 -0400
Committer: Sebastien Goasguen <runseb@gmail.com>
Committed: Fri May 2 16:35:46 2014 -0400

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


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f328f615/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 1155d1f..e8f275f 100755
--- a/server/src/com/cloud/api/ApiResponseHelper.java
+++ b/server/src/com/cloud/api/ApiResponseHelper.java
@@ -3237,7 +3237,9 @@ public class ApiResponseHelper implements ResponseGenerator {
         usageRecResponse.setUsageType(usageRecord.getUsageType());
         if (usageRecord.getVmInstanceId() != null) {
             VMInstanceVO vm = _entityMgr.findById(VMInstanceVO.class, usageRecord.getVmInstanceId());
-            usageRecResponse.setVirtualMachineId(vm.getUuid());
+            if (vm != null) {
+                usageRecResponse.setVirtualMachineId(vm.getUuid());
+            }
         }
         usageRecResponse.setVmName(usageRecord.getVmName());
         if (usageRecord.getTemplateId() != null) {
@@ -3253,7 +3255,9 @@ public class ApiResponseHelper implements ResponseGenerator {
             usageRecResponse.setOfferingId(svcOffering.getUuid());
             //VM Instance ID
             VMInstanceVO vm = _entityMgr.findById(VMInstanceVO.class, usageRecord.getUsageId().toString());
-            usageRecResponse.setUsageId(vm.getUuid());
+            if (vm != null) {
+                usageRecResponse.setUsageId(vm.getUuid());
+            }
             //Hypervisor Type
             usageRecResponse.setType(usageRecord.getType());
 
@@ -3264,7 +3268,9 @@ public class ApiResponseHelper implements ResponseGenerator {
             usageRecResponse.setSystem((usageRecord.getSize() == 1) ? true : false);
             //IP Address ID
             IPAddressVO ip = _entityMgr.findById(IPAddressVO.class, usageRecord.getUsageId().toString());
-            usageRecResponse.setUsageId(ip.getUuid());
+            if (ip != null) {
+                usageRecResponse.setUsageId(ip.getUuid());
+            }
 
         } else if (usageRecord.getUsageType() == UsageTypes.NETWORK_BYTES_SENT || usageRecord.getUsageType()
== UsageTypes.NETWORK_BYTES_RECEIVED) {
             //Device Type
@@ -3272,15 +3278,21 @@ public class ApiResponseHelper implements ResponseGenerator {
             if (usageRecord.getType().equals("DomainRouter")) {
                 //Domain Router Id
                 VMInstanceVO vm = _entityMgr.findById(VMInstanceVO.class, usageRecord.getUsageId().toString());
-                usageRecResponse.setUsageId(vm.getUuid());
+                if (vm != null) {
+                    usageRecResponse.setUsageId(vm.getUuid());
+                }
             } else {
                 //External Device Host Id
                 HostVO host = _entityMgr.findById(HostVO.class, usageRecord.getUsageId().toString());
-                usageRecResponse.setUsageId(host.getUuid());
+                if (host != null) {
+                    usageRecResponse.setUsageId(host.getUuid());
+                }
             }
             //Network ID
             NetworkVO network = _entityMgr.findById(NetworkVO.class, usageRecord.getNetworkId().toString());
-            usageRecResponse.setNetworkId(network.getUuid());
+            if (network != null) {
+                usageRecResponse.setNetworkId(network.getUuid());
+            }
 
         } else if (usageRecord.getUsageType() == UsageTypes.VM_DISK_IO_READ || usageRecord.getUsageType()
== UsageTypes.VM_DISK_IO_WRITE
                 || usageRecord.getUsageType() == UsageTypes.VM_DISK_BYTES_READ || usageRecord.getUsageType()
== UsageTypes.VM_DISK_BYTES_WRITE) {
@@ -3288,15 +3300,21 @@ public class ApiResponseHelper implements ResponseGenerator {
             usageRecResponse.setType(usageRecord.getType());
             //VM Instance Id
             VMInstanceVO vm = _entityMgr.findById(VMInstanceVO.class, usageRecord.getVmInstanceId().toString());
-            usageRecResponse.setVirtualMachineId(vm.getUuid());
+            if (vm != null) {
+                usageRecResponse.setVirtualMachineId(vm.getUuid());
+            }
             //Volume ID
             VolumeVO volume = _entityMgr.findById(VolumeVO.class, usageRecord.getUsageId().toString());
-            usageRecResponse.setUsageId(volume.getUuid());
+            if (volume != null) {
+                usageRecResponse.setUsageId(volume.getUuid());
+            }
 
         } else if (usageRecord.getUsageType() == UsageTypes.VOLUME) {
             //Volume ID
             VolumeVO volume = _entityMgr.findById(VolumeVO.class, usageRecord.getUsageId().toString());
-            usageRecResponse.setUsageId(volume.getUuid());
+            if (volume != null) {
+                usageRecResponse.setUsageId(volume.getUuid());
+            }
             //Volume Size
             usageRecResponse.setSize(usageRecord.getSize());
             //Disk Offering Id
@@ -3309,6 +3327,9 @@ public class ApiResponseHelper implements ResponseGenerator {
             //Template/ISO ID
             VMTemplateVO tmpl = _entityMgr.findById(VMTemplateVO.class, usageRecord.getUsageId().toString());
             usageRecResponse.setUsageId(tmpl.getUuid());
+            if (tmpl != null) {
+                usageRecResponse.setUsageId(tmpl.getUuid());
+            }
             //Template/ISO Size
             usageRecResponse.setSize(usageRecord.getSize());
             if (usageRecord.getUsageType() == UsageTypes.ISO) {
@@ -3320,7 +3341,9 @@ public class ApiResponseHelper implements ResponseGenerator {
         } else if (usageRecord.getUsageType() == UsageTypes.SNAPSHOT) {
             //Snapshot ID
             SnapshotVO snap = _entityMgr.findById(SnapshotVO.class, usageRecord.getUsageId().toString());
-            usageRecResponse.setUsageId(snap.getUuid());
+            if (snap != null) {
+                usageRecResponse.setUsageId(snap.getUuid());
+            }
             //Snapshot Size
             usageRecResponse.setSize(usageRecord.getSize());
 
@@ -3354,11 +3377,15 @@ public class ApiResponseHelper implements ResponseGenerator {
         } else if (usageRecord.getUsageType() == UsageTypes.SECURITY_GROUP) {
             //Security Group Id
             SecurityGroupVO sg = _entityMgr.findById(SecurityGroupVO.class, usageRecord.getUsageId().toString());
-            usageRecResponse.setUsageId(sg.getUuid());
+            if (sg != null) {
+                usageRecResponse.setUsageId(sg.getUuid());
+            }
         } else if (usageRecord.getUsageType() == UsageTypes.VM_SNAPSHOT) {
             VMInstanceVO vm = _entityMgr.findById(VMInstanceVO.class, usageRecord.getVmInstanceId().toString());
-            usageRecResponse.setVmName(vm.getInstanceName());
-            usageRecResponse.setUsageId(vm.getUuid());
+            if (vm != null) {
+                usageRecResponse.setVmName(vm.getInstanceName());
+                usageRecResponse.setUsageId(vm.getUuid());
+            }
             usageRecResponse.setSize(usageRecord.getSize());
             if (usageRecord.getOfferingId() != null) {
                 usageRecResponse.setOfferingId(usageRecord.getOfferingId().toString());


Mime
View raw message