UI: Option to choose the isolation method when creating the public IP range (#12000)

This commit is contained in:
Suresh Kumar Anaparti 2025-12-15 14:07:18 +05:30 committed by GitHub
parent 494c56a499
commit 67217d4d2e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 30 additions and 4 deletions

View File

@ -34,6 +34,7 @@ import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.user.Account;
import com.cloud.utils.StringUtils;
@APICommand(name = "createManagementNetworkIpRange",
description = "Creates a Management network IP range.",
@ -118,7 +119,7 @@ public class CreateManagementNetworkIpRangeCmd extends BaseAsyncCmd {
}
public String getVlan() {
if (vlan == null || vlan.isEmpty()) {
if (StringUtils.isBlank(vlan)) {
vlan = "untagged";
}
return vlan;

View File

@ -17,6 +17,7 @@
package org.apache.cloudstack.api.command.admin.vlan;
import com.cloud.utils.net.NetUtils;
import com.cloud.utils.StringUtils;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
@ -162,7 +163,7 @@ public class CreateVlanIpRangeCmd extends BaseCmd {
}
public String getVlan() {
if ((vlan == null || vlan.isEmpty()) && !isForNsx()) {
if (StringUtils.isBlank(vlan) && !isForNsx()) {
vlan = "untagged";
}
return vlan;

View File

@ -4005,7 +4005,6 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
cmdList.add(StartInternalLBVMCmd.class);
cmdList.add(ListInternalLBVMsCmd.class);
cmdList.add(ListNetworkIsolationMethodsCmd.class);
cmdList.add(ListNetworkIsolationMethodsCmd.class);
cmdList.add(CreateNetworkACLListCmd.class);
cmdList.add(DeleteNetworkACLListCmd.class);
cmdList.add(ListNetworkACLListsCmd.class);

View File

@ -497,6 +497,7 @@
"label.checksum": "Checksum",
"label.choose.resource.icon": "Choose icon",
"label.choose.saml.identity": "Choose SAML identity provider",
"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'.",
"label.cidr": "CIDR",
"label.cidrsize": "CIDR size",
"label.cidr.destination.network": "Destination Network CIDR",

View File

@ -220,6 +220,20 @@
<a-select-option v-for="pod in pods" :key="pod.id" :value="pod.id" :label="pod.name">{{ pod.name }}</a-select-option>
</a-select>
</a-form-item>
<a-form-item name="isolationmethod" ref="isolationmethod" class="form__item" v-if="!basicGuestNetwork">
<tooltip-label :title="$t('label.isolation.method')" :tooltip="$t('label.choose.isolation.method.public.ip.range')" class="tooltip-label-wrapper"/>
<a-select
v-model:value="form.isolationmethod"
showSearch
optionFilterProp="label"
:filterOption="(input, option) => {
return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0
}" >
<a-select-option value="">{{ }}</a-select-option>
<a-select-option value="vlan"> VLAN </a-select-option>
<a-select-option value="vxlan"> VXLAN </a-select-option>
</a-select>
</a-form-item>
<a-form-item name="vlan" ref="vlan" :label="$t('label.vlan')" class="form__item" v-if="!basicGuestNetwork">
<a-input v-model:value="form.vlan" />
</a-form-item>
@ -452,7 +466,8 @@ export default {
initAddIpRangeForm () {
this.formRef = ref()
this.form = reactive({
iptype: ''
iptype: '',
isolationmethod: ''
})
this.rules = reactive({
podid: [{ required: true, message: this.$t('label.required') }],
@ -624,6 +639,15 @@ export default {
if (!this.basicGuestNetwork) {
params.zoneId = this.resource.zoneid
params.vlan = values.vlan
const vlanInput = (values.vlan || '').toString().trim()
if (vlanInput) {
const vlanInputLower = vlanInput.toLowerCase()
const startsWithPrefix = vlanInputLower.startsWith('vlan') || vlanInputLower.startsWith('vxlan')
const isNumeric = /^[0-9]+$/.test(vlanInput)
if (!startsWithPrefix && isNumeric && values.isolationmethod) {
params.vlan = `${values.isolationmethod}://${vlanInput}`
}
}
params.forsystemvms = values.forsystemvms
params.account = values.forsystemvms ? null : values.account
params.domainid = values.forsystemvms ? null : values.domain