mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-03 04:12:31 +01:00
api: Add vpcid in usage network response (#4361)
* Add vpcid in usage network response Currently vpcid is displayed in listUsageNetworks response. Add the vpcid so that we can see to which vpc, the network belongs * use new function to get removed
This commit is contained in:
parent
aa67f9c6e2
commit
beb1edcdbc
@ -144,6 +144,10 @@ public class UsageRecordResponse extends BaseResponseWithTagInformation implemen
|
||||
@Param(description = "True if the resource is default")
|
||||
private Boolean isDefault;
|
||||
|
||||
@SerializedName("vpcid")
|
||||
@Param(description = "id of the vpc")
|
||||
private String vpcId;
|
||||
|
||||
public UsageRecordResponse() {
|
||||
tags = new LinkedHashSet<ResourceTagResponse>();
|
||||
}
|
||||
@ -276,4 +280,8 @@ public class UsageRecordResponse extends BaseResponseWithTagInformation implemen
|
||||
public String getDomainName(){
|
||||
return domainName;
|
||||
}
|
||||
|
||||
public void setVpcId(String vpcId) {
|
||||
this.vpcId = vpcId;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1571,6 +1571,10 @@ public class ApiDBUtils {
|
||||
return s_vpcDao.findById(vpcId);
|
||||
}
|
||||
|
||||
public static VpcVO findVpcByIdIncludingRemoved(long vpcId) {
|
||||
return s_vpcDao.findByIdIncludingRemoved(vpcId);
|
||||
}
|
||||
|
||||
public static SnapshotPolicy findSnapshotPolicyById(long policyId) {
|
||||
return s_snapshotPolicyDao.findById(policyId);
|
||||
}
|
||||
|
||||
@ -3471,8 +3471,15 @@ public class ApiResponseHelper implements ResponseGenerator {
|
||||
network = _entityMgr.findByIdIncludingRemoved(NetworkVO.class, usageRecord.getNetworkId().toString());
|
||||
if (network != null) {
|
||||
resourceType = ResourceObjectType.Network;
|
||||
resourceId = network.getId();
|
||||
usageRecResponse.setNetworkId(network.getUuid());
|
||||
if (network.getTrafficType() == TrafficType.Public) {
|
||||
VirtualRouter router = ApiDBUtils.findDomainRouterById(usageRecord.getUsageId());
|
||||
Vpc vpc = ApiDBUtils.findVpcByIdIncludingRemoved(router.getVpcId());
|
||||
usageRecResponse.setVpcId(vpc.getUuid());
|
||||
resourceId = vpc.getId();
|
||||
} else {
|
||||
usageRecResponse.setNetworkId(network.getUuid());
|
||||
resourceId = network.getId();
|
||||
}
|
||||
usageRecResponse.setResourceName(network.getName());
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user