Skip to content

Commit a6d6468

Browse files
author
Kishan Kavala
committed
CLOUDSTACK-4289, CLOUDSTACK-4290, CLOUDSTACK-4291 : Check for null when populated UUID while listing usage records.
Filed CLOUDSTACK-4299 to make these entities always available.
1 parent 836c4c4 commit a6d6468

1 file changed

Lines changed: 14 additions & 11 deletions

File tree

‎server/src/com/cloud/api/ApiResponseHelper.java‎

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3349,27 +3349,30 @@ public UsageRecordResponse createUsageResponse(Usage usageRecord) {
33493349
//Snapshot Size
33503350
usageRecResponse.setSize(usageRecord.getSize());
33513351

3352-
} else if(usageRecord.getUsageType() == UsageTypes.LOAD_BALANCER_POLICY){
3353-
//Load Balancer Policy ID
3352+
} else if(usageRecord.getUsageType() == UsageTypes.LOAD_BALANCER_POLICY){
3353+
//Load Balancer Policy ID
33543354
LoadBalancerVO lb = _entityMgr.findByIdIncludingRemoved(LoadBalancerVO.class, usageRecord.getUsageId().toString());
3355-
usageRecResponse.setUsageId(lb.getUuid());
3356-
} else if(usageRecord.getUsageType() == UsageTypes.PORT_FORWARDING_RULE){
3357-
//Port Forwarding Rule ID
3355+
if(lb != null){
3356+
usageRecResponse.setUsageId(lb.getUuid());
3357+
}
3358+
} else if(usageRecord.getUsageType() == UsageTypes.PORT_FORWARDING_RULE){
3359+
//Port Forwarding Rule ID
33583360
PortForwardingRuleVO pf = _entityMgr.findByIdIncludingRemoved(PortForwardingRuleVO.class, usageRecord.getUsageId().toString());
3359-
usageRecResponse.setUsageId(pf.getUuid());
3360-
3361+
if(pf != null){
3362+
usageRecResponse.setUsageId(pf.getUuid());
3363+
}
33613364
} else if(usageRecord.getUsageType() == UsageTypes.NETWORK_OFFERING){
33623365
//Network Offering Id
33633366
NetworkOfferingVO netOff = _entityMgr.findByIdIncludingRemoved(NetworkOfferingVO.class, usageRecord.getOfferingId().toString());
33643367
usageRecResponse.setOfferingId(netOff.getUuid());
33653368
//is Default
33663369
usageRecResponse.setDefault((usageRecord.getUsageId() == 1)? true:false);
3367-
3368-
} else if(usageRecord.getUsageType() == UsageTypes.VPN_USERS){
3369-
//VPN User ID
3370+
} else if(usageRecord.getUsageType() == UsageTypes.VPN_USERS){
3371+
//VPN User ID
33703372
VpnUserVO vpnUser = _entityMgr.findByIdIncludingRemoved(VpnUserVO.class, usageRecord.getUsageId().toString());
3373+
if(vpnUser != null){
33713374
usageRecResponse.setUsageId(vpnUser.getUuid());
3372-
3375+
}
33733376
} else if(usageRecord.getUsageType() == UsageTypes.SECURITY_GROUP){
33743377
//Security Group Id
33753378
SecurityGroupVO sg = _entityMgr.findByIdIncludingRemoved(SecurityGroupVO.class, usageRecord.getUsageId().toString());

0 commit comments

Comments
 (0)