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/master to 744e2a5
Date Fri, 25 Apr 2014 21:00:01 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/master 78c683f56 -> 744e2a54e


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/744e2a54
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/744e2a54
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/744e2a54

Branch: refs/heads/master
Commit: 744e2a54e8b05d8136382664d8e5b9e3649fe88e
Parents: 78c683f
Author: Sebastien Goasguen <runseb@gmail.com>
Authored: Fri Apr 25 16:59:47 2014 -0400
Committer: Sebastien Goasguen <runseb@gmail.com>
Committed: Fri Apr 25 16:59:47 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/744e2a54/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 ba1e91f..250f5a9 100755
--- a/server/src/com/cloud/api/ApiResponseHelper.java
+++ b/server/src/com/cloud/api/ApiResponseHelper.java
@@ -2969,7 +2969,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) {
@@ -2985,7 +2987,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());
 
@@ -2996,7 +3000,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
@@ -3004,15 +3010,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) {
@@ -3020,15 +3032,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
@@ -3041,6 +3059,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) {
@@ -3052,7 +3073,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());
 
@@ -3086,11 +3109,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