Skip to content

Commit a4f6305

Browse files
authored
NSX: Make LB service selectable in network offering (#8512)
* NSX: Make LB service selectable in network offering * fix label * address comments * address comments
1 parent 19bbec4 commit a4f6305

File tree

6 files changed

+93
-8
lines changed

6 files changed

+93
-8
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
@@ -824,6 +824,7 @@ public class ApiConstants {
824824
public static final String SPLIT_CONNECTIONS = "splitconnections";
825825
public static final String FOR_VPC = "forvpc";
826826
public static final String FOR_NSX = "fornsx";
827+
public static final String NSX_SUPPORT_LB = "nsxsupportlb";
827828
public static final String FOR_TUNGSTEN = "fortungsten";
828829
public static final String SHRINK_OK = "shrinkok";
829830
public static final String NICIRA_NVP_DEVICE_ID = "nvpdeviceid";

api/src/main/java/org/apache/cloudstack/api/command/admin/network/CreateNetworkOfferingCmd.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,12 @@ public class CreateNetworkOfferingCmd extends BaseCmd {
154154
since = "4.20.0")
155155
private String nsxMode;
156156

157+
@Parameter(name = ApiConstants.NSX_SUPPORT_LB,
158+
type = CommandType.BOOLEAN,
159+
description = "true if network offering for NSX network offering supports Load balancer service.",
160+
since = "4.20.0")
161+
private Boolean nsxSupportsLbService;
162+
157163
@Parameter(name = ApiConstants.FOR_TUNGSTEN,
158164
type = CommandType.BOOLEAN,
159165
description = "true if network offering is meant to be used for Tungsten-Fabric, false otherwise.")
@@ -247,9 +253,11 @@ public List<String> getSupportedServices() {
247253
StaticNat.getName(),
248254
SourceNat.getName(),
249255
PortForwarding.getName(),
250-
UserData.getName(),
251-
Lb.getName()
256+
UserData.getName()
252257
));
258+
if (getNsxSupportsLbService()) {
259+
services.add(Lb.getName());
260+
}
253261
if (Boolean.TRUE.equals(forVpc)) {
254262
services.add(NetworkACL.getName());
255263
} else {
@@ -294,6 +302,10 @@ public String getNsxMode() {
294302
return nsxMode;
295303
}
296304

305+
public boolean getNsxSupportsLbService() {
306+
return BooleanUtils.isTrue(nsxSupportsLbService);
307+
}
308+
297309
public Boolean getForTungsten() {
298310
return forTungsten;
299311
}
@@ -356,6 +368,9 @@ private void getServiceProviderMapForNsx(Map<String, List<String>> serviceProvid
356368
serviceProviderMap.put(service, List.of(routerProvider));
357369
else
358370
serviceProviderMap.put(service, List.of(Network.Provider.Nsx.getName()));
371+
if (!getNsxSupportsLbService()) {
372+
serviceProviderMap.remove(Lb.getName());
373+
}
359374
}
360375
}
361376

api/src/main/java/org/apache/cloudstack/api/command/admin/vpc/CreateVPCOfferingCmd.java

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,12 @@ public class CreateVPCOfferingCmd extends BaseAsyncCreateCmd {
126126
since = "4.20.0")
127127
private String nsxMode;
128128

129+
@Parameter(name = ApiConstants.NSX_SUPPORT_LB,
130+
type = CommandType.BOOLEAN,
131+
description = "true if network offering for NSX VPC offering supports Load balancer service.",
132+
since = "4.20.0")
133+
private Boolean nsxSupportsLbService;
134+
129135
@Parameter(name = ApiConstants.ENABLE,
130136
type = CommandType.BOOLEAN,
131137
description = "set to true if the offering is to be enabled during creation. Default is false",
@@ -149,16 +155,18 @@ public List<String> getSupportedServices() {
149155
throw new InvalidParameterValueException("Supported services needs to be provided");
150156
}
151157
if (isForNsx()) {
152-
return List.of(
158+
supportedServices = new ArrayList<>(List.of(
153159
Dhcp.getName(),
154160
Dns.getName(),
155-
Lb.getName(),
156161
StaticNat.getName(),
157162
SourceNat.getName(),
158163
NetworkACL.getName(),
159164
PortForwarding.getName(),
160165
UserData.getName()
161-
);
166+
));
167+
if (getNsxSupportsLbService()) {
168+
supportedServices.add(Lb.getName());
169+
}
162170
}
163171
return supportedServices;
164172
}
@@ -171,6 +179,10 @@ public String getNsxMode() {
171179
return nsxMode;
172180
}
173181

182+
public boolean getNsxSupportsLbService() {
183+
return org.apache.commons.lang3.BooleanUtils.isTrue(nsxSupportsLbService);
184+
}
185+
174186
public Map<String, List<String>> getServiceProviders() {
175187
Map<String, List<String>> serviceProviderMap = new HashMap<>();
176188
if (serviceProviderList != null && !serviceProviderList.isEmpty() && !isForNsx()) {
@@ -213,6 +225,9 @@ private void getServiceProviderMapForNsx(Map<String, List<String>> serviceProvid
213225
else
214226
serviceProviderMap.put(service, List.of(Network.Provider.Nsx.getName()));
215227
}
228+
if (!getNsxSupportsLbService()) {
229+
serviceProviderMap.remove(Lb.getName());
230+
}
216231
}
217232

218233
public Map<String, List<String>> getServiceCapabilityList() {

ui/public/locales/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1444,6 +1444,7 @@
14441444
"label.nsx.provider.edgecluster": "NSX provider edge cluster",
14451445
"label.nsx.provider.tier0gateway": "NSX provider tier-0 gateway",
14461446
"label.nsx.provider.transportzone": "NSX provider transport zone",
1447+
"label.nsx.supports.lb": "Enable NSX LB service",
14471448
"label.num.cpu.cores": "# of CPU cores",
14481449
"label.number": "#Rule",
14491450
"label.numretries": "Number of retries",

ui/src/views/offering/AddNetworkOffering.vue

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,16 @@
129129
</a-form-item>
130130
</a-col>
131131
</a-row>
132+
<a-row :gutter="12" v-if="forNsx">
133+
<a-col :md="12" :lg="12">
134+
<a-form-item name="nsxsupportlb" ref="nsxsupportlb" v-if="guestType === 'isolated'">
135+
<template #label>
136+
<tooltip-label :title="$t('label.nsx.supports.lb')" :tooltip="apiParams.nsxsupportlb.description"/>
137+
</template>
138+
<a-switch v-model:checked="form.nsxsupportlb" @change="val => { handleNsxLbService(val) }" />
139+
</a-form-item>
140+
</a-col>
141+
</a-row>
132142
<a-form-item name="nsxmode" ref="nsxmode" v-if="forNsx">
133143
<template #label>
134144
<tooltip-label :title="$t('label.nsxmode')" :tooltip="apiParams.nsxmode.description"/>
@@ -633,7 +643,8 @@ export default {
633643
conservemode: true,
634644
availability: 'optional',
635645
egressdefaultpolicy: 'deny',
636-
ispublic: this.isPublic
646+
ispublic: this.isPublic,
647+
nsxsupportlb: true
637648
})
638649
this.rules = reactive({
639650
name: [{ required: true, message: this.$t('message.error.name') }],
@@ -851,6 +862,12 @@ export default {
851862
supportedServices = supportedServices.filter(svc => {
852863
return Object.keys(this.nsxSupportedServicesMap).includes(svc.name)
853864
})
865+
supportedServices = supportedServices.map(svc => {
866+
if (!['Dhcp', 'Dns', 'UserData'].includes(svc.name)) {
867+
svc.provider = [this.NSX]
868+
}
869+
return svc
870+
})
854871
self.supportedSvcs = self.supportedServices
855872
self.supportedServices = supportedServices
856873
self.supportedServiceLoading = false
@@ -889,6 +906,15 @@ export default {
889906
}
890907
this.fetchSupportedServiceData()
891908
},
909+
handleNsxLbService (supportLb) {
910+
if (!supportLb && 'Lb' in this.nsxSupportedServicesMap) {
911+
delete this.nsxSupportedServicesMap.Lb
912+
}
913+
if (supportLb && !('Lb' in this.nsxSupportedServicesMap)) {
914+
this.nsxSupportedServicesMap.Lb = this.NSX
915+
}
916+
this.fetchSupportedServiceData()
917+
},
892918
handleLbTypeChange (lbType) {
893919
this.lbType = lbType
894920
this.updateSupportedServices()
@@ -998,6 +1024,7 @@ export default {
9981024
if (values.fornsx === true) {
9991025
params.fornsx = true
10001026
params.nsxmode = values.nsxmode
1027+
params.nsxsupportlb = values.nsxsupportlb
10011028
}
10021029
if (values.guestiptype === 'shared' || values.guestiptype === 'isolated') {
10031030
if (values.conservemode !== true) {

ui/src/views/offering/AddVpcOffering.vue

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,18 @@
7676
<a-switch v-model:checked="form.fornsx" @change="val => { handleForNsxChange(val) }" />
7777
</a-form-item>
7878
</a-col>
79+
<a-col :md="12" :lg="12" v-if="forNsx">
80+
<a-form-item name="nsxsupportlb" ref="nsxsupportlb">
81+
<template #label>
82+
<tooltip-label :title="$t('label.nsx.supports.lb')" :tooltip="apiParams.nsxsupportlb.description"/>
83+
</template>
84+
<a-switch v-model:checked="form.nsxsupportlb" @change="val => { handleNsxLbService(val) }" />
85+
</a-form-item>
86+
</a-col>
7987
</a-row>
8088
<a-form-item name="nsxmode" ref="nsxmode" v-if="forNsx">
8189
<template #label>
82-
<tooltip-label :title="$t('label.nsx.mode')" :tooltip="apiParams.nsxmode.description"/>
90+
<tooltip-label :title="$t('label.nsxmode')" :tooltip="apiParams.nsxmode.description"/>
8391
</template>
8492
<a-select
8593
v-if="showMode"
@@ -293,7 +301,8 @@ export default {
293301
regionlevelvpc: true,
294302
distributedrouter: true,
295303
ispublic: true,
296-
internetprotocol: this.internetProtocolValue
304+
internetprotocol: this.internetProtocolValue,
305+
nsxsupportlb: true
297306
})
298307
this.rules = reactive({
299308
name: [{ required: true, message: this.$t('message.error.name') }],
@@ -482,8 +491,24 @@ export default {
482491
async handleForNsxChange (forNsx) {
483492
this.forNsx = forNsx
484493
this.showMode = forNsx
494+
if (forNsx) {
495+
this.form.nsxsupportlb = true
496+
this.handleNsxLbService(true)
497+
}
485498
this.fetchSupportedServiceData()
486499
},
500+
handleNsxLbService (supportLb) {
501+
if (!supportLb) {
502+
this.supportedServices = this.supportedServices.filter(svc => svc.name !== 'Lb')
503+
}
504+
if (supportLb) {
505+
this.supportedServices.push({
506+
name: 'Lb',
507+
enabled: true,
508+
provider: [{ name: 'Nsx' }]
509+
})
510+
}
511+
},
487512
handleSupportedServiceChange (service, checked, provider) {
488513
if (service === 'Connectivity') {
489514
this.connectivityServiceChecked = checked
@@ -561,6 +586,7 @@ export default {
561586
if (values.fornsx === true) {
562587
params.fornsx = true
563588
params.nsxmode = values.nsxmode
589+
params.nsxsupportlb = values.nsxsupportlb
564590
}
565591
if (this.selectedServiceProviderMap != null) {
566592
var supportedServices = Object.keys(this.selectedServiceProviderMap)

0 commit comments

Comments
 (0)