@@ -3236,7 +3236,7 @@ public UsageRecordResponse createUsageResponse(Usage usageRecord) {
32363236 usageRecResponse .setUsage (usageRecord .getUsageDisplay ());
32373237 usageRecResponse .setUsageType (usageRecord .getUsageType ());
32383238 if (usageRecord .getVmInstanceId () != null ) {
3239- VMInstanceVO vm = _entityMgr .findById (VMInstanceVO .class , usageRecord .getVmInstanceId ());
3239+ VMInstanceVO vm = _entityMgr .findByIdIncludingRemoved (VMInstanceVO .class , usageRecord .getVmInstanceId ());
32403240 if (vm != null ) {
32413241 usageRecResponse .setVirtualMachineId (vm .getUuid ());
32423242 }
@@ -3254,7 +3254,7 @@ public UsageRecordResponse createUsageResponse(Usage usageRecord) {
32543254 //Service Offering Id
32553255 usageRecResponse .setOfferingId (svcOffering .getUuid ());
32563256 //VM Instance ID
3257- VMInstanceVO vm = _entityMgr .findById (VMInstanceVO .class , usageRecord .getUsageId ().toString ());
3257+ VMInstanceVO vm = _entityMgr .findByIdIncludingRemoved (VMInstanceVO .class , usageRecord .getUsageId ().toString ());
32583258 if (vm != null ) {
32593259 usageRecResponse .setUsageId (vm .getUuid ());
32603260 }
@@ -3267,7 +3267,7 @@ public UsageRecordResponse createUsageResponse(Usage usageRecord) {
32673267 //isSystem
32683268 usageRecResponse .setSystem ((usageRecord .getSize () == 1 ) ? true : false );
32693269 //IP Address ID
3270- IPAddressVO ip = _entityMgr .findById (IPAddressVO .class , usageRecord .getUsageId ().toString ());
3270+ IPAddressVO ip = _entityMgr .findByIdIncludingRemoved (IPAddressVO .class , usageRecord .getUsageId ().toString ());
32713271 if (ip != null ) {
32723272 usageRecResponse .setUsageId (ip .getUuid ());
32733273 }
@@ -3277,19 +3277,19 @@ public UsageRecordResponse createUsageResponse(Usage usageRecord) {
32773277 usageRecResponse .setType (usageRecord .getType ());
32783278 if (usageRecord .getType ().equals ("DomainRouter" )) {
32793279 //Domain Router Id
3280- VMInstanceVO vm = _entityMgr .findById (VMInstanceVO .class , usageRecord .getUsageId ().toString ());
3280+ VMInstanceVO vm = _entityMgr .findByIdIncludingRemoved (VMInstanceVO .class , usageRecord .getUsageId ().toString ());
32813281 if (vm != null ) {
32823282 usageRecResponse .setUsageId (vm .getUuid ());
32833283 }
32843284 } else {
32853285 //External Device Host Id
3286- HostVO host = _entityMgr .findById (HostVO .class , usageRecord .getUsageId ().toString ());
3286+ HostVO host = _entityMgr .findByIdIncludingRemoved (HostVO .class , usageRecord .getUsageId ().toString ());
32873287 if (host != null ) {
32883288 usageRecResponse .setUsageId (host .getUuid ());
32893289 }
32903290 }
32913291 //Network ID
3292- NetworkVO network = _entityMgr .findById (NetworkVO .class , usageRecord .getNetworkId ().toString ());
3292+ NetworkVO network = _entityMgr .findByIdIncludingRemoved (NetworkVO .class , usageRecord .getNetworkId ().toString ());
32933293 if (network != null ) {
32943294 usageRecResponse .setNetworkId (network .getUuid ());
32953295 }
@@ -3299,33 +3299,33 @@ public UsageRecordResponse createUsageResponse(Usage usageRecord) {
32993299 //Device Type
33003300 usageRecResponse .setType (usageRecord .getType ());
33013301 //VM Instance Id
3302- VMInstanceVO vm = _entityMgr .findById (VMInstanceVO .class , usageRecord .getVmInstanceId ().toString ());
3302+ VMInstanceVO vm = _entityMgr .findByIdIncludingRemoved (VMInstanceVO .class , usageRecord .getVmInstanceId ().toString ());
33033303 if (vm != null ) {
33043304 usageRecResponse .setVirtualMachineId (vm .getUuid ());
33053305 }
33063306 //Volume ID
3307- VolumeVO volume = _entityMgr .findById (VolumeVO .class , usageRecord .getUsageId ().toString ());
3307+ VolumeVO volume = _entityMgr .findByIdIncludingRemoved (VolumeVO .class , usageRecord .getUsageId ().toString ());
33083308 if (volume != null ) {
33093309 usageRecResponse .setUsageId (volume .getUuid ());
33103310 }
33113311
33123312 } else if (usageRecord .getUsageType () == UsageTypes .VOLUME ) {
33133313 //Volume ID
3314- VolumeVO volume = _entityMgr .findById (VolumeVO .class , usageRecord .getUsageId ().toString ());
3314+ VolumeVO volume = _entityMgr .findByIdIncludingRemoved (VolumeVO .class , usageRecord .getUsageId ().toString ());
33153315 if (volume != null ) {
33163316 usageRecResponse .setUsageId (volume .getUuid ());
33173317 }
33183318 //Volume Size
33193319 usageRecResponse .setSize (usageRecord .getSize ());
33203320 //Disk Offering Id
33213321 if (usageRecord .getOfferingId () != null ) {
3322- DiskOfferingVO diskOff = _entityMgr .findById (DiskOfferingVO .class , usageRecord .getOfferingId ().toString ());
3322+ DiskOfferingVO diskOff = _entityMgr .findByIdIncludingRemoved (DiskOfferingVO .class , usageRecord .getOfferingId ().toString ());
33233323 usageRecResponse .setOfferingId (diskOff .getUuid ());
33243324 }
33253325
33263326 } else if (usageRecord .getUsageType () == UsageTypes .TEMPLATE || usageRecord .getUsageType () == UsageTypes .ISO ) {
33273327 //Template/ISO ID
3328- VMTemplateVO tmpl = _entityMgr .findById (VMTemplateVO .class , usageRecord .getUsageId ().toString ());
3328+ VMTemplateVO tmpl = _entityMgr .findByIdIncludingRemoved (VMTemplateVO .class , usageRecord .getUsageId ().toString ());
33293329 usageRecResponse .setUsageId (tmpl .getUuid ());
33303330 if (tmpl != null ) {
33313331 usageRecResponse .setUsageId (tmpl .getUuid ());
@@ -3340,7 +3340,7 @@ public UsageRecordResponse createUsageResponse(Usage usageRecord) {
33403340
33413341 } else if (usageRecord .getUsageType () == UsageTypes .SNAPSHOT ) {
33423342 //Snapshot ID
3343- SnapshotVO snap = _entityMgr .findById (SnapshotVO .class , usageRecord .getUsageId ().toString ());
3343+ SnapshotVO snap = _entityMgr .findByIdIncludingRemoved (SnapshotVO .class , usageRecord .getUsageId ().toString ());
33443344 if (snap != null ) {
33453345 usageRecResponse .setUsageId (snap .getUuid ());
33463346 }
@@ -3349,39 +3349,39 @@ public UsageRecordResponse createUsageResponse(Usage usageRecord) {
33493349
33503350 } else if (usageRecord .getUsageType () == UsageTypes .LOAD_BALANCER_POLICY ) {
33513351 //Load Balancer Policy ID
3352- LoadBalancerVO lb = _entityMgr .findById (LoadBalancerVO .class , usageRecord .getUsageId ().toString ());
3352+ LoadBalancerVO lb = _entityMgr .findByIdIncludingRemoved (LoadBalancerVO .class , usageRecord .getUsageId ().toString ());
33533353 if (lb != null ) {
33543354 usageRecResponse .setUsageId (lb .getUuid ());
33553355 }
33563356 } else if (usageRecord .getUsageType () == UsageTypes .PORT_FORWARDING_RULE ) {
33573357 //Port Forwarding Rule ID
3358- PortForwardingRuleVO pf = _entityMgr .findById (PortForwardingRuleVO .class , usageRecord .getUsageId ().toString ());
3358+ PortForwardingRuleVO pf = _entityMgr .findByIdIncludingRemoved (PortForwardingRuleVO .class , usageRecord .getUsageId ().toString ());
33593359 if (pf != null ) {
33603360 usageRecResponse .setUsageId (pf .getUuid ());
33613361 }
33623362
33633363 } else if (usageRecord .getUsageType () == UsageTypes .NETWORK_OFFERING ) {
33643364 //Network Offering Id
3365- NetworkOfferingVO netOff = _entityMgr .findById (NetworkOfferingVO .class , usageRecord .getOfferingId ().toString ());
3365+ NetworkOfferingVO netOff = _entityMgr .findByIdIncludingRemoved (NetworkOfferingVO .class , usageRecord .getOfferingId ().toString ());
33663366 usageRecResponse .setOfferingId (netOff .getUuid ());
33673367 //is Default
33683368 usageRecResponse .setDefault ((usageRecord .getUsageId () == 1 ) ? true : false );
33693369
33703370 } else if (usageRecord .getUsageType () == UsageTypes .VPN_USERS ) {
33713371 //VPN User ID
3372- VpnUserVO vpnUser = _entityMgr .findById (VpnUserVO .class , usageRecord .getUsageId ().toString ());
3372+ VpnUserVO vpnUser = _entityMgr .findByIdIncludingRemoved (VpnUserVO .class , usageRecord .getUsageId ().toString ());
33733373 if (vpnUser != null ) {
33743374 usageRecResponse .setUsageId (vpnUser .getUuid ());
33753375 }
33763376
33773377 } else if (usageRecord .getUsageType () == UsageTypes .SECURITY_GROUP ) {
33783378 //Security Group Id
3379- SecurityGroupVO sg = _entityMgr .findById (SecurityGroupVO .class , usageRecord .getUsageId ().toString ());
3379+ SecurityGroupVO sg = _entityMgr .findByIdIncludingRemoved (SecurityGroupVO .class , usageRecord .getUsageId ().toString ());
33803380 if (sg != null ) {
33813381 usageRecResponse .setUsageId (sg .getUuid ());
33823382 }
33833383 } else if (usageRecord .getUsageType () == UsageTypes .VM_SNAPSHOT ) {
3384- VMInstanceVO vm = _entityMgr .findById (VMInstanceVO .class , usageRecord .getVmInstanceId ().toString ());
3384+ VMInstanceVO vm = _entityMgr .findByIdIncludingRemoved (VMInstanceVO .class , usageRecord .getVmInstanceId ().toString ());
33853385 if (vm != null ) {
33863386 usageRecResponse .setVmName (vm .getInstanceName ());
33873387 usageRecResponse .setUsageId (vm .getUuid ());
0 commit comments