Skip to content

Commit 1f3f02b

Browse files
api: Updated pod response, moved the parameters: startip, endip, vlanid, forsystemvms to ipranges (new parameter to hold the list of IP range details). (#5424)
This PR updates the pod response, grouped the parameters: startip, endip, vlanid, forsystemvms as ip range response and added to ipranges parameter (a new parameter to hold the list of IP range details).
1 parent 4b1fc19 commit 1f3f02b

File tree

5 files changed

+143
-36
lines changed

5 files changed

+143
-36
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,7 @@ public class ApiConstants {
567567
public static final String TRAFFIC_TYPE_IMPLEMENTOR = "traffictypeimplementor";
568568
public static final String KEYWORD = "keyword";
569569
public static final String LIST_ALL = "listall";
570+
public static final String IP_RANGES = "ipranges";
570571
public static final String SPECIFY_IP_RANGES = "specifyipranges";
571572
public static final String IS_SOURCE_NAT = "issourcenat";
572573
public static final String IS_STATIC_NAT = "isstaticnat";
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
package org.apache.cloudstack.api.response;
18+
19+
import com.google.gson.annotations.SerializedName;
20+
21+
import org.apache.cloudstack.api.ApiConstants;
22+
import org.apache.cloudstack.api.BaseResponse;
23+
24+
import com.cloud.serializer.Param;
25+
26+
@SuppressWarnings("unused")
27+
public class IpRangeResponse extends BaseResponse {
28+
29+
@SerializedName(ApiConstants.START_IP)
30+
@Param(description = "the starting IP for the range")
31+
private String startIp;
32+
33+
@SerializedName(ApiConstants.END_IP)
34+
@Param(description = "the ending IP for the range")
35+
private String endIp;
36+
37+
@SerializedName(ApiConstants.FOR_SYSTEM_VMS)
38+
@Param(description = "indicates if range is dedicated for CPVM and SSVM")
39+
private String forSystemVms;
40+
41+
@SerializedName(ApiConstants.VLAN_ID)
42+
@Param(description = "indicates Vlan ID for the range")
43+
private String vlanId;
44+
45+
public String getStartIp() {
46+
return startIp;
47+
}
48+
49+
public void setStartIp(String startIp) {
50+
this.startIp = startIp;
51+
}
52+
53+
public String getEndIp() {
54+
return endIp;
55+
}
56+
57+
public void setEndIp(String endIp) {
58+
this.endIp = endIp;
59+
}
60+
61+
public void setForSystemVms(String forSystemVms) {
62+
this.forSystemVms = forSystemVms;
63+
}
64+
65+
public String getForSystemVms() {
66+
return forSystemVms;
67+
}
68+
69+
public String getVlanId() {
70+
return vlanId;
71+
}
72+
73+
public void setVlanId(String vlanId) {
74+
this.vlanId = vlanId;
75+
}
76+
}

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

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,53 +29,61 @@
2929

3030
@EntityReference(value = Pod.class)
3131
public class PodResponse extends BaseResponseWithAnnotations {
32-
@SerializedName("id")
32+
@SerializedName(ApiConstants.ID)
3333
@Param(description = "the ID of the Pod")
3434
private String id;
3535

36-
@SerializedName("name")
36+
@SerializedName(ApiConstants.NAME)
3737
@Param(description = "the name of the Pod")
3838
private String name;
3939

40-
@SerializedName("zoneid")
40+
@SerializedName(ApiConstants.ZONE_ID)
4141
@Param(description = "the Zone ID of the Pod")
4242
private String zoneId;
4343

4444
@SerializedName(ApiConstants.ZONE_NAME)
4545
@Param(description = "the Zone name of the Pod")
4646
private String zoneName;
4747

48-
@SerializedName("gateway")
48+
@SerializedName(ApiConstants.GATEWAY)
4949
@Param(description = "the gateway of the Pod")
5050
private String gateway;
5151

52-
@SerializedName("netmask")
52+
@SerializedName(ApiConstants.NETMASK)
5353
@Param(description = "the netmask of the Pod")
5454
private String netmask;
5555

56-
@SerializedName("startip")
57-
@Param(description = "the starting IP for the Pod")
56+
@SerializedName(ApiConstants.IP_RANGES)
57+
@Param(description = "the IP ranges for the Pod", responseObject = IpRangeResponse.class, since = "4.16.0")
58+
private List<IpRangeResponse> ipRanges;
59+
60+
@Deprecated(since = "4.16")
61+
@SerializedName(ApiConstants.START_IP)
62+
@Param(description = "the starting IP for the Pod. This parameter is deprecated, please use 'startip' from ipranges parameter.")
5863
private List<String> startIp;
5964

60-
@SerializedName("endip")
61-
@Param(description = "the ending IP for the Pod")
65+
@Deprecated(since = "4.16")
66+
@SerializedName(ApiConstants.END_IP)
67+
@Param(description = "the ending IP for the Pod. This parameter is deprecated, please use 'endip' from ipranges parameter.")
6268
private List<String> endIp;
6369

64-
@SerializedName("forsystemvms")
65-
@Param(description = "indicates if range is dedicated for CPVM and SSVM")
70+
@Deprecated(since = "4.16")
71+
@SerializedName(ApiConstants.FOR_SYSTEM_VMS)
72+
@Param(description = "indicates if range is dedicated for CPVM and SSVM. This parameter is deprecated, please use 'forsystemvms' from ipranges parameter.")
6673
private List<String> forSystemVms;
6774

68-
@SerializedName("vlanid")
69-
@Param(description = "indicates Vlan ID for the range")
75+
@Deprecated(since = "4.16")
76+
@SerializedName(ApiConstants.VLAN_ID)
77+
@Param(description = "indicates Vlan ID for the range. This parameter is deprecated, please use 'vlanid' from ipranges parameter.")
7078
private List<String> vlanId;
7179

72-
@SerializedName("allocationstate")
80+
@SerializedName(ApiConstants.ALLOCATION_STATE)
7381
@Param(description = "the allocation state of the Pod")
7482
private String allocationState;
7583

76-
@SerializedName("capacity")
84+
@SerializedName(ApiConstants.CAPACITY)
7785
@Param(description = "the capacity of the Pod", responseObject = CapacityResponse.class)
78-
private List<CapacityResponse> capacitites;
86+
private List<CapacityResponse> capacities;
7987

8088
public String getId() {
8189
return id;
@@ -125,6 +133,10 @@ public void setNetmask(String netmask) {
125133
this.netmask = netmask;
126134
}
127135

136+
public void setIpRanges(List<IpRangeResponse> ipRanges) {
137+
this.ipRanges = ipRanges;
138+
}
139+
128140
public List<String> getStartIp() {
129141
return startIp;
130142
}
@@ -165,11 +177,11 @@ public void setAllocationState(String allocationState) {
165177
this.allocationState = allocationState;
166178
}
167179

168-
public List<CapacityResponse> getCapacitites() {
169-
return capacitites;
180+
public List<CapacityResponse> getCapacities() {
181+
return capacities;
170182
}
171183

172-
public void setCapacitites(List<CapacityResponse> capacitites) {
173-
this.capacitites = capacitites;
184+
public void setCapacities(List<CapacityResponse> capacities) {
185+
this.capacities = capacities;
174186
}
175187
}

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

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
import org.apache.cloudstack.api.response.InstanceGroupResponse;
8787
import org.apache.cloudstack.api.response.InternalLoadBalancerElementResponse;
8888
import org.apache.cloudstack.api.response.IpForwardingRuleResponse;
89+
import org.apache.cloudstack.api.response.IpRangeResponse;
8990
import org.apache.cloudstack.api.response.IsolationMethodResponse;
9091
import org.apache.cloudstack.api.response.LBHealthCheckPolicyResponse;
9192
import org.apache.cloudstack.api.response.LBHealthCheckResponse;
@@ -1084,24 +1085,40 @@ public GlobalLoadBalancerResponse createGlobalLoadBalancerResponse(GlobalLoadBal
10841085
@Override
10851086
public PodResponse createPodResponse(Pod pod, Boolean showCapacities) {
10861087
String[] ipRange = new String[2];
1087-
List<String> startIp = new ArrayList<String>();
1088-
List<String> endIp = new ArrayList<String>();
1088+
List<String> startIps = new ArrayList<String>();
1089+
List<String> endIps = new ArrayList<String>();
10891090
List<String> forSystemVms = new ArrayList<String>();
10901091
List<String> vlanIds = new ArrayList<String>();
10911092

1093+
List<IpRangeResponse> ipRanges = new ArrayList<>();
1094+
10921095
if (pod.getDescription() != null && pod.getDescription().length() > 0) {
10931096
final String[] existingPodIpRanges = pod.getDescription().split(",");
10941097

10951098
for(String podIpRange: existingPodIpRanges) {
1099+
IpRangeResponse ipRangeResponse = new IpRangeResponse();
10961100
final String[] existingPodIpRange = podIpRange.split("-");
10971101

1098-
startIp.add(((existingPodIpRange.length > 0) && (existingPodIpRange[0] != null)) ? existingPodIpRange[0] : "");
1099-
endIp.add(((existingPodIpRange.length > 1) && (existingPodIpRange[1] != null)) ? existingPodIpRange[1] : "");
1100-
forSystemVms.add((existingPodIpRange.length > 2) && (existingPodIpRange[2] != null) ? existingPodIpRange[2] : "0");
1101-
vlanIds.add((existingPodIpRange.length > 3) &&
1102+
String startIp = ((existingPodIpRange.length > 0) && (existingPodIpRange[0] != null)) ? existingPodIpRange[0] : "";
1103+
ipRangeResponse.setStartIp(startIp);
1104+
startIps.add(startIp);
1105+
1106+
String endIp = ((existingPodIpRange.length > 1) && (existingPodIpRange[1] != null)) ? existingPodIpRange[1] : "";
1107+
ipRangeResponse.setEndIp(endIp);
1108+
endIps.add(endIp);
1109+
1110+
String forSystemVm = (existingPodIpRange.length > 2) && (existingPodIpRange[2] != null) ? existingPodIpRange[2] : "0";
1111+
ipRangeResponse.setForSystemVms(forSystemVm);
1112+
forSystemVms.add(forSystemVm);
1113+
1114+
String vlanId = (existingPodIpRange.length > 3) &&
11021115
(existingPodIpRange[3] != null && !existingPodIpRange[3].equals("untagged")) ?
11031116
BroadcastDomainType.Vlan.toUri(existingPodIpRange[3]).toString() :
1104-
BroadcastDomainType.Vlan.toUri(Vlan.UNTAGGED).toString());
1117+
BroadcastDomainType.Vlan.toUri(Vlan.UNTAGGED).toString();
1118+
ipRangeResponse.setVlanId(vlanId);
1119+
vlanIds.add(vlanId);
1120+
1121+
ipRanges.add(ipRangeResponse);
11051122
}
11061123
}
11071124

@@ -1114,8 +1131,9 @@ public PodResponse createPodResponse(Pod pod, Boolean showCapacities) {
11141131
podResponse.setZoneName(zone.getName());
11151132
}
11161133
podResponse.setNetmask(NetUtils.getCidrNetmask(pod.getCidrSize()));
1117-
podResponse.setStartIp(startIp);
1118-
podResponse.setEndIp(endIp);
1134+
podResponse.setIpRanges(ipRanges);
1135+
podResponse.setStartIp(startIps);
1136+
podResponse.setEndIp(endIps);
11191137
podResponse.setForSystemVms(forSystemVms);
11201138
podResponse.setVlanId(vlanIds);
11211139
podResponse.setGateway(pod.getGateway());
@@ -1144,7 +1162,7 @@ public PodResponse createPodResponse(Pod pod, Boolean showCapacities) {
11441162
}
11451163
// Do it for stats as well.
11461164
capacityResponses.addAll(getStatsCapacityresponse(null, null, pod.getId(), pod.getDataCenterId()));
1147-
podResponse.setCapacitites(new ArrayList<CapacityResponse>(capacityResponses));
1165+
podResponse.setCapacities(new ArrayList<CapacityResponse>(capacityResponses));
11481166
}
11491167
podResponse.setHasAnnotation(annotationDao.hasAnnotations(pod.getUuid(), AnnotationService.EntityType.POD.name(),
11501168
_accountMgr.isRootAdmin(CallContext.current().getCallingAccount().getId())));

ui/src/views/infra/network/IpRangesTabManagement.vue

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -229,17 +229,17 @@ export default {
229229
this.total = response.listpodsresponse.count || 0
230230
this.pods = response.listpodsresponse.pod ? response.listpodsresponse.pod : []
231231
for (const pod of this.pods) {
232-
if (pod && pod.startip && pod.startip.length > 0) {
233-
for (var idx = 0; idx < pod.startip.length; idx++) {
232+
if (pod && pod.ipranges && pod.ipranges.length > 0) {
233+
for (var idx = 0; idx < pod.ipranges.length; idx++) {
234234
this.items.push({
235235
id: pod.id,
236236
name: pod.name,
237237
gateway: pod.gateway,
238238
netmask: pod.netmask,
239-
vlanid: pod.vlanid[idx],
240-
startip: pod.startip[idx],
241-
endip: pod.endip[idx],
242-
forsystemvms: pod.forsystemvms[idx] === '1'
239+
vlanid: pod.ipranges[idx].vlanid,
240+
startip: pod.ipranges[idx].startip,
241+
endip: pod.ipranges[idx].endip,
242+
forsystemvms: pod.ipranges[idx].forsystemvms === '1'
243243
})
244244
}
245245
}

0 commit comments

Comments
 (0)