Skip to content

Commit c9ce6e3

Browse files
authored
ui: Allow edit source CIDR on load balancer rule (#11766)
1 parent 5e7ae22 commit c9ce6e3

File tree

2 files changed

+37
-3
lines changed

2 files changed

+37
-3
lines changed

server/src/main/java/com/cloud/network/router/CommandSetupHelper.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,10 @@ public void createApplyLoadBalancingRulesCommands(final List<LoadBalancingRule>
365365
final List<LbDestination> destinations = rule.getDestinations();
366366
final List<LbStickinessPolicy> stickinessPolicies = rule.getStickinessPolicies();
367367
final LoadBalancerTO lb = new LoadBalancerTO(uuid, srcIp, srcPort, protocol, algorithm, revoked, false, inline, destinations, stickinessPolicies);
368-
lb.setCidrList(rule.getCidrList());
368+
String cidrList = rule.getCidrList();
369+
if (cidrList != null && !cidrList.isEmpty()) {
370+
lb.setCidrList(String.join(" ", cidrList.split(",")));
371+
}
369372
lb.setLbProtocol(lb_protocol);
370373
lb.setLbSslCert(rule.getLbSslCert());
371374
lbs[i++] = lb;

ui/src/views/network/LoadBalancing.vue

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,22 @@
451451
<a-select-option value="ssl" :label="$t('label.ssl')">{{ $t('label.ssl') }}</a-select-option>
452452
</a-select>
453453
</div>
454+
<div v-if="lbProvider !== 'Netris'" class="edit-rule__item">
455+
<p class="edit-rule__label">
456+
{{ $t('label.sourcecidrlist') }}
457+
<tooltip-label
458+
:title="''"
459+
bold
460+
:tooltip="createLoadBalancerRuleParams.cidrlist.description || 'Enter a comma-separated list of CIDR blocks.'"
461+
:tooltip-placement="'right'"
462+
style="display: inline; margin-left: 5px;"
463+
/>
464+
</p>
465+
<a-input
466+
v-model:value="editRuleDetails.cidrlist"
467+
:placeholder="$t('label.sourcecidrlist')"
468+
/>
469+
</div>
454470
<div :span="24" class="action-button">
455471
<a-button @click="() => editRuleModalVisible = false">{{ $t('label.cancel') }}</a-button>
456472
<a-button type="primary" @click="handleSubmitEditForm">{{ $t('label.ok') }}</a-button>
@@ -837,7 +853,8 @@ export default {
837853
editRuleDetails: {
838854
name: '',
839855
algorithm: '',
840-
protocol: ''
856+
protocol: '',
857+
cidrlist: ''
841858
},
842859
newRule: {
843860
algorithm: 'roundrobin',
@@ -1625,14 +1642,28 @@ export default {
16251642
this.editRuleDetails.name = this.selectedRule.name
16261643
this.editRuleDetails.algorithm = this.lbProvider !== 'Netris' ? this.selectedRule.algorithm : undefined
16271644
this.editRuleDetails.protocol = this.selectedRule.protocol
1645+
// Normalize cidrlist: replace spaces with commas and clean up
1646+
this.editRuleDetails.cidrlist = (this.selectedRule.cidrlist || '')
1647+
.split(/[\s,]+/) // Split on spaces or commas
1648+
.map(c => c.trim())
1649+
.filter(c => c)
1650+
.join(',') || ''
16281651
},
16291652
handleSubmitEditForm () {
16301653
if (this.editRuleModalLoading) return
16311654
this.loading = true
16321655
this.editRuleModalLoading = true
1656+
const payload = {
1657+
...this.editRuleDetails,
1658+
id: this.selectedRule.id,
1659+
...(this.editRuleDetails.cidrlist && {
1660+
cidrList: (this.editRuleDetails.cidrlist || '').split(',').map(c => c.trim()).filter(c => c)
1661+
})
1662+
}
16331663
postAPI('updateLoadBalancerRule', {
16341664
...this.editRuleDetails,
1635-
id: this.selectedRule.id
1665+
id: this.selectedRule.id,
1666+
...payload
16361667
}).then(response => {
16371668
this.$pollJob({
16381669
jobId: response.updateloadbalancerruleresponse.jobid,

0 commit comments

Comments
 (0)