Fix edit member of lb listener

It is forbidden to have the same ip and port when editing a member

Closes-Bug: #1991356
Change-Id: I6e867a9ae70a678574914b639fd5db6d9b32a82b
This commit is contained in:
xusongfu 2022-09-30 14:11:38 +08:00
parent c160574dce
commit f9cc92a032

View File

@ -43,6 +43,20 @@ export class Edit extends ModalAction {
static policy = 'os_load-balancer_api:member:put';
protocolValidator = (rule, value) => {
const { address, protocol_port } = this.item;
const repeatPort = (globalPoolMemberStore.list.data || []).find(
(member) =>
member.address === address &&
value === member.protocol_port &&
value !== protocol_port
);
if (repeatPort) {
return Promise.reject(new Error(t('Invalid IP Address and Port')));
}
return Promise.resolve();
};
get formItems() {
return [
{
@ -56,6 +70,7 @@ export class Edit extends ModalAction {
label: t('Port'),
type: 'input-number',
required: true,
validator: this.protocolValidator,
},
];
}