Skip to content

Commit fb62b25

Browse files
CodeBleudhslove
authored andcommitted
ui: Allow edit source CIDR on load balancer rule (apache#11766)
1 parent a1bd0d4 commit fb62b25

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
@@ -452,6 +452,22 @@
452452
<a-select-option value="ssl" :label="$t('label.ssl')">{{ $t('label.ssl') }}</a-select-option>
453453
</a-select>
454454
</div>
455+
<div v-if="lbProvider !== 'Netris'" class="edit-rule__item">
456+
<p class="edit-rule__label">
457+
{{ $t('label.sourcecidrlist') }}
458+
<tooltip-label
459+
:title="''"
460+
bold
461+
:tooltip="createLoadBalancerRuleParams.cidrlist.description || 'Enter a comma-separated list of CIDR blocks.'"
462+
:tooltip-placement="'right'"
463+
style="display: inline; margin-left: 5px;"
464+
/>
465+
</p>
466+
<a-input
467+
v-model:value="editRuleDetails.cidrlist"
468+
:placeholder="$t('label.sourcecidrlist')"
469+
/>
470+
</div>
455471
<div :span="24" class="action-button">
456472
<a-button @click="() => editRuleModalVisible = false">{{ $t('label.cancel') }}</a-button>
457473
<a-button type="primary" @click="handleSubmitEditForm">{{ $t('label.ok') }}</a-button>
@@ -838,7 +854,8 @@ export default {
838854
editRuleDetails: {
839855
name: '',
840856
algorithm: '',
841-
protocol: ''
857+
protocol: '',
858+
cidrlist: ''
842859
},
843860
newRule: {
844861
algorithm: 'roundrobin',
@@ -1626,14 +1643,28 @@ export default {
16261643
this.editRuleDetails.name = this.selectedRule.name
16271644
this.editRuleDetails.algorithm = this.lbProvider !== 'Netris' ? this.selectedRule.algorithm : undefined
16281645
this.editRuleDetails.protocol = this.selectedRule.protocol
1646+
// Normalize cidrlist: replace spaces with commas and clean up
1647+
this.editRuleDetails.cidrlist = (this.selectedRule.cidrlist || '')
1648+
.split(/[\s,]+/) // Split on spaces or commas
1649+
.map(c => c.trim())
1650+
.filter(c => c)
1651+
.join(',') || ''
16291652
},
16301653
handleSubmitEditForm () {
16311654
if (this.editRuleModalLoading) return
16321655
this.loading = true
16331656
this.editRuleModalLoading = true
1657+
const payload = {
1658+
...this.editRuleDetails,
1659+
id: this.selectedRule.id,
1660+
...(this.editRuleDetails.cidrlist && {
1661+
cidrList: (this.editRuleDetails.cidrlist || '').split(',').map(c => c.trim()).filter(c => c)
1662+
})
1663+
}
16341664
postAPI('updateLoadBalancerRule', {
16351665
...this.editRuleDetails,
1636-
id: this.selectedRule.id
1666+
id: this.selectedRule.id,
1667+
...payload
16371668
}).then(response => {
16381669
this.$pollJob({
16391670
jobId: response.updateloadbalancerruleresponse.jobid,

0 commit comments

Comments
 (0)