@@ -3318,11 +3318,11 @@ public UsageRecordResponse createUsageResponse(Usage usageRecord) {
33183318 }
33193319
33203320 if (usageRecord .getUsageType () == UsageTypes .RUNNING_VM || usageRecord .getUsageType () == UsageTypes .ALLOCATED_VM ){
3321- ServiceOfferingVO svcOffering = _entityMgr .findById (ServiceOfferingVO .class , usageRecord .getOfferingId ().toString ());
3321+ ServiceOfferingVO svcOffering = _entityMgr .findByIdIncludingRemoved (ServiceOfferingVO .class , usageRecord .getOfferingId ().toString ());
33223322 //Service Offering Id
33233323 usageRecResponse .setOfferingId (svcOffering .getUuid ());
33243324 //VM Instance ID
3325- VMInstanceVO vm = _entityMgr .findById (VMInstanceVO .class , usageRecord .getUsageId ().toString ());
3325+ VMInstanceVO vm = _entityMgr .findByIdIncludingRemoved (VMInstanceVO .class , usageRecord .getUsageId ().toString ());
33263326 if (vm != null ) {
33273327 usageRecResponse .setUsageId (vm .getUuid ());
33283328 }
@@ -3335,7 +3335,7 @@ public UsageRecordResponse createUsageResponse(Usage usageRecord) {
33353335 //isSystem
33363336 usageRecResponse .setSystem ((usageRecord .getSize () == 1 )?true :false );
33373337 //IP Address ID
3338- IPAddressVO ip = _entityMgr .findById (IPAddressVO .class , usageRecord .getUsageId ().toString ());
3338+ IPAddressVO ip = _entityMgr .findByIdIncludingRemoved (IPAddressVO .class , usageRecord .getUsageId ().toString ());
33393339 if (ip != null ) {
33403340 usageRecResponse .setUsageId (ip .getUuid ());
33413341 }
@@ -3345,19 +3345,19 @@ public UsageRecordResponse createUsageResponse(Usage usageRecord) {
33453345 usageRecResponse .setType (usageRecord .getType ());
33463346 if (usageRecord .getType ().equals ("DomainRouter" )){
33473347 //Domain Router Id
3348- VMInstanceVO vm = _entityMgr .findById (VMInstanceVO .class , usageRecord .getUsageId ().toString ());
3348+ VMInstanceVO vm = _entityMgr .findByIdIncludingRemoved (VMInstanceVO .class , usageRecord .getUsageId ().toString ());
33493349 if (vm != null ) {
33503350 usageRecResponse .setUsageId (vm .getUuid ());
33513351 }
33523352 } else {
33533353 //External Device Host Id
3354- HostVO host = _entityMgr .findById (HostVO .class , usageRecord .getUsageId ().toString ());
3354+ HostVO host = _entityMgr .findByIdIncludingRemoved (HostVO .class , usageRecord .getUsageId ().toString ());
33553355 if (host != null ) {
33563356 usageRecResponse .setUsageId (host .getUuid ());
33573357 }
33583358 }
33593359 //Network ID
3360- NetworkVO network = _entityMgr .findById (NetworkVO .class , usageRecord .getNetworkId ().toString ());
3360+ NetworkVO network = _entityMgr .findByIdIncludingRemoved (NetworkVO .class , usageRecord .getNetworkId ().toString ());
33613361 if (network != null ) {
33623362 usageRecResponse .setNetworkId (network .getUuid ());
33633363 }
@@ -3367,33 +3367,33 @@ public UsageRecordResponse createUsageResponse(Usage usageRecord) {
33673367 //Device Type
33683368 usageRecResponse .setType (usageRecord .getType ());
33693369 //VM Instance Id
3370- VMInstanceVO vm = _entityMgr .findById (VMInstanceVO .class , usageRecord .getVmInstanceId ().toString ());
3370+ VMInstanceVO vm = _entityMgr .findByIdIncludingRemoved (VMInstanceVO .class , usageRecord .getVmInstanceId ().toString ());
33713371 if (vm != null ) {
33723372 usageRecResponse .setVirtualMachineId (vm .getUuid ());
33733373 }
33743374 //Volume ID
3375- VolumeVO volume = _entityMgr .findById (VolumeVO .class , usageRecord .getUsageId ().toString ());
3375+ VolumeVO volume = _entityMgr .findByIdIncludingRemoved (VolumeVO .class , usageRecord .getUsageId ().toString ());
33763376 if (volume != null ) {
33773377 usageRecResponse .setUsageId (volume .getUuid ());
33783378 }
33793379
33803380 } else if (usageRecord .getUsageType () == UsageTypes .VOLUME ){
33813381 //Volume ID
3382- VolumeVO volume = _entityMgr .findById (VolumeVO .class , usageRecord .getUsageId ().toString ());
3382+ VolumeVO volume = _entityMgr .findByIdIncludingRemoved (VolumeVO .class , usageRecord .getUsageId ().toString ());
33833383 if (volume != null ) {
33843384 usageRecResponse .setUsageId (volume .getUuid ());
33853385 }
33863386 //Volume Size
33873387 usageRecResponse .setSize (usageRecord .getSize ());
33883388 //Disk Offering Id
33893389 if (usageRecord .getOfferingId () != null ){
3390- DiskOfferingVO diskOff = _entityMgr .findById (DiskOfferingVO .class , usageRecord .getOfferingId ().toString ());
3390+ DiskOfferingVO diskOff = _entityMgr .findByIdIncludingRemoved (DiskOfferingVO .class , usageRecord .getOfferingId ().toString ());
33913391 usageRecResponse .setOfferingId (diskOff .getUuid ());
33923392 }
33933393
33943394 } else if (usageRecord .getUsageType () == UsageTypes .TEMPLATE || usageRecord .getUsageType () == UsageTypes .ISO ){
33953395 //Template/ISO ID
3396- VMTemplateVO tmpl = _entityMgr .findById (VMTemplateVO .class , usageRecord .getUsageId ().toString ());
3396+ VMTemplateVO tmpl = _entityMgr .findByIdIncludingRemoved (VMTemplateVO .class , usageRecord .getUsageId ().toString ());
33973397 if (tmpl != null ) {
33983398 usageRecResponse .setUsageId (tmpl .getUuid ());
33993399 }
@@ -3407,7 +3407,7 @@ public UsageRecordResponse createUsageResponse(Usage usageRecord) {
34073407
34083408 } else if (usageRecord .getUsageType () == UsageTypes .SNAPSHOT ){
34093409 //Snapshot ID
3410- SnapshotVO snap = _entityMgr .findById (SnapshotVO .class , usageRecord .getUsageId ().toString ());
3410+ SnapshotVO snap = _entityMgr .findByIdIncludingRemoved (SnapshotVO .class , usageRecord .getUsageId ().toString ());
34113411 if (snap != null ) {
34123412 usageRecResponse .setUsageId (snap .getUuid ());
34133413 }
@@ -3416,39 +3416,39 @@ public UsageRecordResponse createUsageResponse(Usage usageRecord) {
34163416
34173417 } else if (usageRecord .getUsageType () == UsageTypes .LOAD_BALANCER_POLICY ){
34183418 //Load Balancer Policy ID
3419- LoadBalancerVO lb = _entityMgr .findById (LoadBalancerVO .class , usageRecord .getUsageId ().toString ());
3419+ LoadBalancerVO lb = _entityMgr .findByIdIncludingRemoved (LoadBalancerVO .class , usageRecord .getUsageId ().toString ());
34203420 if (lb != null ){
34213421 usageRecResponse .setUsageId (lb .getUuid ());
34223422 }
34233423 } else if (usageRecord .getUsageType () == UsageTypes .PORT_FORWARDING_RULE ){
34243424 //Port Forwarding Rule ID
3425- PortForwardingRuleVO pf = _entityMgr .findById (PortForwardingRuleVO .class , usageRecord .getUsageId ().toString ());
3425+ PortForwardingRuleVO pf = _entityMgr .findByIdIncludingRemoved (PortForwardingRuleVO .class , usageRecord .getUsageId ().toString ());
34263426 if (pf != null ){
34273427 usageRecResponse .setUsageId (pf .getUuid ());
34283428 }
34293429
34303430 } else if (usageRecord .getUsageType () == UsageTypes .NETWORK_OFFERING ){
34313431 //Network Offering Id
3432- NetworkOfferingVO netOff = _entityMgr .findById (NetworkOfferingVO .class , usageRecord .getOfferingId ().toString ());
3432+ NetworkOfferingVO netOff = _entityMgr .findByIdIncludingRemoved (NetworkOfferingVO .class , usageRecord .getOfferingId ().toString ());
34333433 usageRecResponse .setOfferingId (netOff .getUuid ());
34343434 //is Default
34353435 usageRecResponse .setDefault ((usageRecord .getUsageId () == 1 )? true :false );
34363436
34373437 } else if (usageRecord .getUsageType () == UsageTypes .VPN_USERS ){
34383438 //VPN User ID
3439- VpnUserVO vpnUser = _entityMgr .findById (VpnUserVO .class , usageRecord .getUsageId ().toString ());
3439+ VpnUserVO vpnUser = _entityMgr .findByIdIncludingRemoved (VpnUserVO .class , usageRecord .getUsageId ().toString ());
34403440 if (vpnUser != null ){
34413441 usageRecResponse .setUsageId (vpnUser .getUuid ());
34423442 }
34433443
34443444 } else if (usageRecord .getUsageType () == UsageTypes .SECURITY_GROUP ){
34453445 //Security Group Id
3446- SecurityGroupVO sg = _entityMgr .findById (SecurityGroupVO .class , usageRecord .getUsageId ().toString ());
3446+ SecurityGroupVO sg = _entityMgr .findByIdIncludingRemoved (SecurityGroupVO .class , usageRecord .getUsageId ().toString ());
34473447 if (sg != null ) {
34483448 usageRecResponse .setUsageId (sg .getUuid ());
34493449 }
34503450 } else if (usageRecord .getUsageType () == UsageTypes .VM_SNAPSHOT ){
3451- VMInstanceVO vm = _entityMgr .findById (VMInstanceVO .class , usageRecord .getVmInstanceId ().toString ());
3451+ VMInstanceVO vm = _entityMgr .findByIdIncludingRemoved (VMInstanceVO .class , usageRecord .getVmInstanceId ().toString ());
34523452 if (vm != null ) {
34533453 usageRecResponse .setVmName (vm .getInstanceName ());
34543454 usageRecResponse .setUsageId (vm .getUuid ());
0 commit comments