fix: Support multi add networks/routers to neutron agent

1. Support multi add networks to DHCP agent
2. Support multi add routers to L3 agent

Change-Id: I375e3c0f39da8be2b3839cd5c057b5b6005be2f0
This commit is contained in:
zhangjingwei 2021-08-09 09:01:32 +08:00 committed by Jingwei.Zhang
parent 3ba3223cf9
commit 2912303311
3 changed files with 25 additions and 19 deletions

View File

@ -280,13 +280,15 @@ export default class BaseForm extends React.Component {
callback(true, false);
}
if (response instanceof Array) {
const instanceNameArr = this.instanceName.split(', ');
const instanceNameArr = this.instanceName
? this.instanceName.split(', ')
: null;
const failedNames = response
.map((it, idx) => {
if (it.status === 'rejected') {
return {
reason: it.reason,
name: instanceNameArr[idx],
name: instanceNameArr ? instanceNameArr[idx] : '',
};
}
return null;

View File

@ -45,8 +45,9 @@ export default class AddNetwork extends ModalAction {
return t('add network');
}
get messageHasItemName() {
return false;
get instanceName() {
const { network: { selectedRows = [] } = {} } = this.values;
return selectedRows.map((it) => it.name).join(', ');
}
get detail() {
@ -63,7 +64,7 @@ export default class AddNetwork extends ModalAction {
if (!agentId) {
return;
}
await this.store.fetchList({ agentId });
await this.store.fetchList({ agentId, all_projects: true });
this.updateDefaultValue();
}
@ -77,7 +78,7 @@ export default class AddNetwork extends ModalAction {
disabledFunc = (record) => {
const { id } = record;
return this.dhcpNetworks.indexOf(id) >= 0;
return this.dhcpNetworks.includes(id);
};
get defaultValue() {
@ -137,6 +138,7 @@ export default class AddNetwork extends ModalAction {
disabledFunc: this.disabledFunc,
extraParams: { all_projects: true },
required: true,
isMulti: true,
filterParams: this.getSearchFilters(),
columns: this.getColumns(),
...networkSortProps,
@ -145,11 +147,11 @@ export default class AddNetwork extends ModalAction {
}
onSubmit = (values) => {
const { network } = values;
const body = {
network_id: network.selectedRowKeys[0],
};
const { network: { selectedRowKeys = [] } = {} } = values;
const data = selectedRowKeys.map((it) => ({
network_id: it,
}));
const { agentId } = this;
return this.store.add({ agentId }, body);
return this.store.add({ agentId }, data);
};
}

View File

@ -48,8 +48,9 @@ export default class AddRouter extends ModalAction {
return t('add router');
}
get messageHasItemName() {
return false;
get instanceName() {
const { router: { selectedRows = [] } = {} } = this.values;
return selectedRows.map((it) => it.name).join(', ');
}
get detail() {
@ -66,7 +67,7 @@ export default class AddRouter extends ModalAction {
if (!agentId) {
return;
}
await this.store.fetchList({ agentId });
await this.store.fetchList({ agentId, all_projects: true });
this.updateDefaultValue();
}
@ -123,6 +124,7 @@ export default class AddRouter extends ModalAction {
disabledFunc: this.disabledFunc,
extraParams: { all_projects: true },
required: true,
isMulti: true,
filterParams: this.getFilters(),
columns: this.getColumns(),
...routerSortProps,
@ -131,11 +133,11 @@ export default class AddRouter extends ModalAction {
}
onSubmit = (values) => {
const { router } = values;
const body = {
router_id: router.selectedRowKeys[0],
};
const { router: { selectedRowKeys = [] } = {} } = values;
const data = selectedRowKeys.map((it) => ({
router_id: it,
}));
const { agentId } = this;
return this.store.add({ agentId }, body);
return this.store.add({ agentId }, data);
};
}