Skip to content

Commit b79407c

Browse files
authored
api: Adding missing fields to API responses (#4167)
Adding missing fields in the following APIs osdisplayname in listVirtualMachines vpcofferingname in listVpcs vpcname in listPublicIpAddresses vpcname in listPrivateGateways vpcname in listVpnGateways templatename, podname in listRouters templatename, podname in listSystemVms Fixes: #4161
1 parent c03f8a1 commit b79407c

11 files changed

Lines changed: 114 additions & 4 deletions

File tree

api/src/main/java/org/apache/cloudstack/api/ApiConstants.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ public class ApiConstants {
326326
public static final String TARGET_IQN = "targetiqn";
327327
public static final String TEMPLATE_FILTER = "templatefilter";
328328
public static final String TEMPLATE_ID = "templateid";
329+
public static final String TEMPLATE_NAME = "templatename";
329330
public static final String ISO_ID = "isoid";
330331
public static final String TIMEOUT = "timeout";
331332
public static final String TIMEZONE = "timezone";
@@ -566,8 +567,10 @@ public class ApiConstants {
566567
public static final String END_POINT = "endpoint";
567568
public static final String REGION_ID = "regionid";
568569
public static final String VPC_OFF_ID = "vpcofferingid";
570+
public static final String VPC_OFF_NAME = "vpcofferingname";
569571
public static final String NETWORK = "network";
570572
public static final String VPC_ID = "vpcid";
573+
public static final String VPC_NAME = "vpcname";
571574
public static final String GATEWAY_ID = "gatewayid";
572575
public static final String CAN_USE_FOR_DEPLOY = "canusefordeploy";
573576
public static final String RESOURCE_IDS = "resourceids";

api/src/main/java/org/apache/cloudstack/api/response/DomainRouterResponse.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ public class DomainRouterResponse extends BaseResponse implements ControlledView
7777
@Param(description = "the Pod ID for the router")
7878
private String podId;
7979

80+
@SerializedName(ApiConstants.POD_NAME)
81+
@Param(description = "the Pod name for the router", since = "4.13.2")
82+
private String podName;
83+
8084
@SerializedName(ApiConstants.HOST_ID)
8185
@Param(description = "the host ID for the router")
8286
private String hostId;
@@ -145,6 +149,10 @@ public class DomainRouterResponse extends BaseResponse implements ControlledView
145149
@Param(description = "the template ID for the router")
146150
private String templateId;
147151

152+
@SerializedName(ApiConstants.TEMPLATE_NAME)
153+
@Param(description = "the template name for the router", since = "4.13.2")
154+
private String templateName;
155+
148156
@SerializedName(ApiConstants.CREATED)
149157
@Param(description = "the date and time the router was created")
150158
private Date created;
@@ -266,6 +274,10 @@ public void setPodId(String podId) {
266274
this.podId = podId;
267275
}
268276

277+
public void setPodName(String podName) {
278+
this.podName = podName;
279+
}
280+
269281
public void setHostId(String hostId) {
270282
this.hostId = hostId;
271283
}
@@ -310,6 +322,10 @@ public void setTemplateId(String templateId) {
310322
this.templateId = templateId;
311323
}
312324

325+
public void setTemplateName(String templateName) {
326+
this.templateName = templateName;
327+
}
328+
313329
public void setCreated(Date created) {
314330
this.created = created;
315331
}

api/src/main/java/org/apache/cloudstack/api/response/IPAddressResponse.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,13 @@ public class IPAddressResponse extends BaseResponse implements ControlledEntityR
136136
private String purpose;
137137

138138
@SerializedName(ApiConstants.VPC_ID)
139-
@Param(description = "VPC the ip belongs to")
139+
@Param(description = "VPC id the ip belongs to")
140140
private String vpcId;
141+
142+
@SerializedName(ApiConstants.VPC_NAME)
143+
@Param(description = "VPC name the ip belongs to", since = "4.13.2")
144+
private String vpcName;
145+
141146
@SerializedName(ApiConstants.TAGS)
142147
@Param(description = "the list of resource tags associated with ip address", responseObject = ResourceTagResponse.class)
143148
private List<ResourceTagResponse> tags;
@@ -273,6 +278,10 @@ public void setVpcId(String vpcId) {
273278
this.vpcId = vpcId;
274279
}
275280

281+
public void setVpcName(String vpcName) {
282+
this.vpcName = vpcName;
283+
}
284+
276285
public void setTags(List<ResourceTagResponse> tags) {
277286
this.tags = tags;
278287
}

api/src/main/java/org/apache/cloudstack/api/response/PrivateGatewayResponse.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,13 @@ public class PrivateGatewayResponse extends BaseResponse implements ControlledEn
5858
private String broadcastUri;
5959

6060
@SerializedName(ApiConstants.VPC_ID)
61-
@Param(description = "VPC the private gateaway belongs to")
61+
@Param(description = "VPC id the private gateway belongs to")
6262
private String vpcId;
6363

64+
@SerializedName(ApiConstants.VPC_NAME)
65+
@Param(description = "VPC name the private gateway belongs to", since = "4.13.2")
66+
private String vpcName;
67+
6468
@SerializedName(ApiConstants.PHYSICAL_NETWORK_ID)
6569
@Param(description = "the physical network id")
6670
private String physicalNetworkId;
@@ -130,6 +134,10 @@ public void setVpcId(String vpcId) {
130134
this.vpcId = vpcId;
131135
}
132136

137+
public void setVpcName(String vpcName) {
138+
this.vpcName = vpcName;
139+
}
140+
133141
public void setAddress(String address) {
134142
this.address = address;
135143
}

api/src/main/java/org/apache/cloudstack/api/response/Site2SiteVpnGatewayResponse.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ public class Site2SiteVpnGatewayResponse extends BaseResponse implements Control
4242
@Param(description = "the vpc id of this gateway")
4343
private String vpcId;
4444

45+
@SerializedName(ApiConstants.VPC_NAME)
46+
@Param(description = "the vpc name of this gateway", since = "4.13.2")
47+
private String vpcName;
48+
4549
@SerializedName(ApiConstants.ACCOUNT)
4650
@Param(description = "the owner")
4751
private String accountName;
@@ -82,6 +86,10 @@ public void setVpcId(String vpcId) {
8286
this.vpcId = vpcId;
8387
}
8488

89+
public void setVpcName(String vpcName) {
90+
this.vpcName = vpcName;
91+
}
92+
8593
public void setRemoved(Date removed) {
8694
this.removed = removed;
8795
}

api/src/main/java/org/apache/cloudstack/api/response/SystemVmResponse.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ public class SystemVmResponse extends BaseResponse {
7878
@Param(description = "the Pod ID for the system VM")
7979
private String podId;
8080

81+
@SerializedName("podname")
82+
@Param(description = "the Pod name for the system VM", since = "4.13.2")
83+
private String podName;
84+
8185
@SerializedName("hostid")
8286
@Param(description = "the host ID for the system VM")
8387
private String hostId;
@@ -130,6 +134,10 @@ public class SystemVmResponse extends BaseResponse {
130134
@Param(description = "the template ID for the system VM")
131135
private String templateId;
132136

137+
@SerializedName("templatename")
138+
@Param(description = "the template name for the system VM", since = "4.13.2")
139+
private String templateName;
140+
133141
@SerializedName("created")
134142
@Param(description = "the date and time the system VM was created")
135143
private Date created;
@@ -243,10 +251,18 @@ public String getPodId() {
243251
return podId;
244252
}
245253

254+
public String getPodName() {
255+
return podName;
256+
}
257+
246258
public void setPodId(String podId) {
247259
this.podId = podId;
248260
}
249261

262+
public void setPodName(String podName) {
263+
this.podName = podName;
264+
}
265+
250266
public String getHostId() {
251267
return hostId;
252268
}
@@ -323,10 +339,18 @@ public String getTemplateId() {
323339
return templateId;
324340
}
325341

342+
public String getTemplateName() {
343+
return templateName;
344+
}
345+
326346
public void setTemplateId(String templateId) {
327347
this.templateId = templateId;
328348
}
329349

350+
public void setTemplateName(String templateName) {
351+
this.templateName = templateName;
352+
}
353+
330354
public Date getCreated() {
331355
return created;
332356
}

api/src/main/java/org/apache/cloudstack/api/response/UserVmResponse.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,10 @@ public class UserVmResponse extends BaseResponseWithTagInformation implements Co
290290
@Param(description = "OS type id of the vm", since = "4.4")
291291
private String osTypeId;
292292

293+
@SerializedName(ApiConstants.OS_DISPLAY_NAME)
294+
@Param(description = "OS name of the vm", since = "4.13.2")
295+
private String osDisplayName;
296+
293297
public UserVmResponse() {
294298
securityGroupList = new LinkedHashSet<SecurityGroupResponse>();
295299
nics = new LinkedHashSet<NicResponse>();
@@ -822,6 +826,10 @@ public void setOsTypeId(String osTypeId) {
822826
this.osTypeId = osTypeId;
823827
}
824828

829+
public void setOsDisplayName(String osDisplayName) {
830+
this.osDisplayName = osDisplayName;
831+
}
832+
825833
public Set<Long> getTagIds() {
826834
return tagIds;
827835
}
@@ -849,4 +857,8 @@ public void setDynamicallyScalable(Boolean dynamicallyScalable) {
849857
public String getOsTypeId() {
850858
return osTypeId;
851859
}
860+
861+
public String getOsDisplayName() {
862+
return osDisplayName;
863+
}
852864
}

api/src/main/java/org/apache/cloudstack/api/response/VpcResponse.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ public class VpcResponse extends BaseResponse implements ControlledEntityRespons
6767
@Param(description = "vpc offering id the VPC is created from")
6868
private String vpcOfferingId;
6969

70+
@SerializedName(ApiConstants.VPC_OFF_NAME)
71+
@Param(description = "vpc offering name the VPC is created from", since = "4.13.2")
72+
private String vpcOfferingName;
73+
7074
@SerializedName(ApiConstants.CREATED)
7175
@Param(description = "the date this VPC was created")
7276
private Date created;
@@ -184,6 +188,10 @@ public void setVpcOfferingId(final String vpcOfferingId) {
184188
this.vpcOfferingId = vpcOfferingId;
185189
}
186190

191+
public void setVpcOfferingName(final String vpcOfferingName) {
192+
this.vpcOfferingName = vpcOfferingName;
193+
}
194+
187195
public List<NetworkResponse> getNetworks() {
188196
return networks;
189197
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -860,6 +860,7 @@ public IPAddressResponse createIPAddressResponse(ResponseView view, IpAddress ip
860860
Vpc vpc = ApiDBUtils.findVpcById(ipAddr.getVpcId());
861861
if (vpc != null) {
862862
ipResponse.setVpcId(vpc.getUuid());
863+
ipResponse.setVpcName(vpc.getName());
863864
}
864865
}
865866

@@ -1361,11 +1362,13 @@ public SystemVmResponse createSystemVmResponse(VirtualMachine vm) {
13611362
HostPodVO pod = ApiDBUtils.findPodById(vm.getPodIdToDeployIn());
13621363
if (pod != null) {
13631364
vmResponse.setPodId(pod.getUuid());
1365+
vmResponse.setPodName(pod.getName());
13641366
}
13651367
}
13661368
VMTemplateVO template = ApiDBUtils.findTemplateById(vm.getTemplateId());
13671369
if (template != null) {
13681370
vmResponse.setTemplateId(template.getUuid());
1371+
vmResponse.setTemplateName(template.getName());
13691372
}
13701373
vmResponse.setCreated(vm.getCreated());
13711374

@@ -2884,6 +2887,7 @@ public VpcResponse createVpcResponse(ResponseView view, Vpc vpc) {
28842887
VpcOffering voff = ApiDBUtils.findVpcOfferingById(vpc.getVpcOfferingId());
28852888
if (voff != null) {
28862889
response.setVpcOfferingId(voff.getUuid());
2890+
response.setVpcOfferingName(voff.getName());
28872891
}
28882892
response.setCidr(vpc.getCidr());
28892893
response.setRestartRequired(vpc.isRestartRequired());
@@ -2956,6 +2960,7 @@ public PrivateGatewayResponse createPrivateGatewayResponse(PrivateGateway result
29562960
if (result.getVpcId() != null) {
29572961
Vpc vpc = ApiDBUtils.findVpcById(result.getVpcId());
29582962
response.setVpcId(vpc.getUuid());
2963+
response.setVpcName(vpc.getName());
29592964
}
29602965

29612966
DataCenter zone = ApiDBUtils.findZoneById(result.getZoneId());
@@ -3146,6 +3151,7 @@ public Site2SiteVpnGatewayResponse createSite2SiteVpnGatewayResponse(Site2SiteVp
31463151
Vpc vpc = ApiDBUtils.findVpcById(result.getVpcId());
31473152
if (vpc != null) {
31483153
response.setVpcId(vpc.getUuid());
3154+
response.setVpcName(vpc.getName());
31493155
}
31503156
response.setRemoved(result.getRemoved());
31513157
response.setForDisplay(result.isDisplay());

server/src/main/java/com/cloud/api/query/dao/DomainRouterJoinDaoImpl.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,14 @@
3030
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
3131
import org.apache.cloudstack.utils.CloudStackVersion;
3232

33+
import com.cloud.api.ApiDBUtils;
3334
import com.cloud.api.ApiResponseHelper;
3435
import com.cloud.api.query.vo.DomainRouterJoinVO;
36+
import com.cloud.dc.HostPodVO;
3537
import com.cloud.network.Networks.TrafficType;
3638
import com.cloud.network.router.VirtualRouter;
3739
import com.cloud.network.router.VirtualRouter.Role;
40+
import com.cloud.storage.VMTemplateVO;
3841
import com.cloud.user.Account;
3942
import com.cloud.user.AccountManager;
4043
import com.cloud.utils.db.GenericDaoBase;
@@ -46,7 +49,7 @@ public class DomainRouterJoinDaoImpl extends GenericDaoBase<DomainRouterJoinVO,
4649
public static final Logger s_logger = Logger.getLogger(DomainRouterJoinDaoImpl.class);
4750

4851
@Inject
49-
private ConfigurationDao _configDao;
52+
private ConfigurationDao _configDao;
5053
@Inject
5154
public AccountManager _accountMgr;
5255

@@ -74,6 +77,10 @@ public DomainRouterResponse newDomainRouterResponse(DomainRouterJoinVO router, A
7477
routerResponse.setZoneId(router.getDataCenterUuid());
7578
routerResponse.setName(router.getName());
7679
routerResponse.setTemplateId(router.getTemplateUuid());
80+
VMTemplateVO template = ApiDBUtils.findTemplateById(router.getTemplateId());
81+
if (template != null) {
82+
routerResponse.setTemplateName(template.getName());
83+
}
7784
routerResponse.setCreated(router.getCreated());
7885
routerResponse.setState(router.getState());
7986
routerResponse.setIsRedundantRouter(router.isRedundantRouter());
@@ -98,6 +105,10 @@ public DomainRouterResponse newDomainRouterResponse(DomainRouterJoinVO router, A
98105
routerResponse.setHypervisor(router.getHypervisorType().toString());
99106
}
100107
routerResponse.setPodId(router.getPodUuid());
108+
HostPodVO pod = ApiDBUtils.findPodById(router.getPodId());
109+
if (pod != null) {
110+
routerResponse.setPodName(pod.getName());
111+
}
101112
long nic_id = router.getNicId();
102113
if (nic_id > 0) {
103114
TrafficType ty = router.getTrafficType();

0 commit comments

Comments
 (0)