Skip to content

Commit 8dce4a4

Browse files
sureshanapartiLocharla, Sandeep
authored andcommitted
UI: Option to choose the isolation method when creating the public IP range (apache#12000)
1 parent e51cebe commit 8dce4a4

File tree

4 files changed

+28
-3
lines changed

4 files changed

+28
-3
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import com.cloud.exception.ResourceAllocationException;
3535
import com.cloud.exception.ResourceUnavailableException;
3636
import com.cloud.user.Account;
37+
import com.cloud.utils.StringUtils;
3738

3839
@APICommand(name = "createManagementNetworkIpRange",
3940
description = "Creates a Management network IP range.",
@@ -118,7 +119,7 @@ public Boolean isForSystemVms() {
118119
}
119120

120121
public String getVlan() {
121-
if (vlan == null || vlan.isEmpty()) {
122+
if (StringUtils.isBlank(vlan)) {
122123
vlan = "untagged";
123124
}
124125
return vlan;

server/src/main/java/com/cloud/server/ManagementServerImpl.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4133,7 +4133,6 @@ public List<Class<?>> getCommands() {
41334133
cmdList.add(StartInternalLBVMCmd.class);
41344134
cmdList.add(ListInternalLBVMsCmd.class);
41354135
cmdList.add(ListNetworkIsolationMethodsCmd.class);
4136-
cmdList.add(ListNetworkIsolationMethodsCmd.class);
41374136
cmdList.add(CreateNetworkACLListCmd.class);
41384137
cmdList.add(DeleteNetworkACLListCmd.class);
41394138
cmdList.add(ListNetworkACLListsCmd.class);

ui/public/locales/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,7 @@
532532
"label.checksum": "Checksum",
533533
"label.choose.resource.icon": "Choose icon",
534534
"label.choose.saml.identity": "Choose SAML identity provider",
535+
"label.choose.isolation.method.public.ip.range": "Choose the proper isolation method for the public IP range in accordance with the zone. Valid options currently 'vlan' or 'vxlan', defaults to 'vlan'.",
535536
"label.cidr": "CIDR",
536537
"label.cidrsize": "CIDR size",
537538
"label.cidr.destination.network": "Destination Network CIDR",

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

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,20 @@
220220
<a-select-option v-for="pod in pods" :key="pod.id" :value="pod.id" :label="pod.name">{{ pod.name }}</a-select-option>
221221
</a-select>
222222
</a-form-item>
223+
<a-form-item name="isolationmethod" ref="isolationmethod" class="form__item" v-if="!basicGuestNetwork">
224+
<tooltip-label :title="$t('label.isolation.method')" :tooltip="$t('label.choose.isolation.method.public.ip.range')" class="tooltip-label-wrapper"/>
225+
<a-select
226+
v-model:value="form.isolationmethod"
227+
showSearch
228+
optionFilterProp="label"
229+
:filterOption="(input, option) => {
230+
return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0
231+
}" >
232+
<a-select-option value="">{{ }}</a-select-option>
233+
<a-select-option value="vlan"> VLAN </a-select-option>
234+
<a-select-option value="vxlan"> VXLAN </a-select-option>
235+
</a-select>
236+
</a-form-item>
223237
<a-form-item name="vlan" ref="vlan" :label="$t('label.vlan')" class="form__item" v-if="!basicGuestNetwork">
224238
<a-input v-model:value="form.vlan" />
225239
</a-form-item>
@@ -472,7 +486,8 @@ export default {
472486
initAddIpRangeForm () {
473487
this.formRef = ref()
474488
this.form = reactive({
475-
iptype: ''
489+
iptype: '',
490+
isolationmethod: ''
476491
})
477492
this.rules = reactive({
478493
podid: [{ required: true, message: this.$t('label.required') }],
@@ -644,6 +659,15 @@ export default {
644659
if (!this.basicGuestNetwork) {
645660
params.zoneId = this.resource.zoneid
646661
params.vlan = values.vlan
662+
const vlanInput = (values.vlan || '').toString().trim()
663+
if (vlanInput) {
664+
const vlanInputLower = vlanInput.toLowerCase()
665+
const startsWithPrefix = vlanInputLower.startsWith('vlan') || vlanInputLower.startsWith('vxlan')
666+
const isNumeric = /^[0-9]+$/.test(vlanInput)
667+
if (!startsWithPrefix && isNumeric && values.isolationmethod) {
668+
params.vlan = `${values.isolationmethod}://${vlanInput}`
669+
}
670+
}
647671
params.forsystemvms = values.forsystemvms
648672
params.account = values.forsystemvms ? null : values.account
649673
params.domainid = values.forsystemvms ? null : values.domain

0 commit comments

Comments
 (0)