feat: support disable/enable snat

1. support disable snat when the router's enable_snat is true
2. support enable snat when the router's enable_snat is false

Change-Id: I15a0eee4760100d923bc9a7d3619f5caf35cbe27
This commit is contained in:
zhangjingwei 2024-03-21 16:22:14 +08:00
parent e1a9d17f4c
commit d02497a15d
9 changed files with 138 additions and 0 deletions

View File

@ -0,0 +1,8 @@
---
features:
- |
Support disable/enable SNAT for router:
* Support disable SNAT when the router's `enable_snat` is `true`.
* Support enable SNAT when the router's `enable_snat` is `false`.

View File

@ -788,6 +788,7 @@
"Disable Compute Service": "Disable Compute Service",
"Disable Gateway": "Disable Gateway",
"Disable Neutron Agent": "Disable Neutron Agent",
"Disable SNAT": "Disable SNAT",
"Disable TLS": "Disable TLS",
"Disable compute host": "Disable compute host",
"Disabled": "Disabled",
@ -914,6 +915,7 @@
"Enable Project": "Enable Project",
"Enable QoS Policy": "Enable QoS Policy",
"Enable Registry": "Enable Registry",
"Enable SNAT": "Enable SNAT",
"Enable Service": "Enable Service",
"Enable User": "Enable User",
"Enable auto heal": "Enable auto heal",

View File

@ -788,6 +788,7 @@
"Disable Compute Service": "Compute Service 비활성화",
"Disable Gateway": "Gateway 비활성화",
"Disable Neutron Agent": "Neutron Agent 비활성화",
"Disable SNAT": "SNAT 비활성화",
"Disable TLS": "TLS 비활성화",
"Disable compute host": "Compute Host 비활성화",
"Disabled": "비활성화됨",
@ -914,6 +915,7 @@
"Enable Project": "Project 활성화",
"Enable QoS Policy": "QoS Policy 활성화",
"Enable Registry": "Registr 활성화",
"Enable SNAT": "SNAT 활성화",
"Enable Service": "Service 활성화",
"Enable User": "User 활성화",
"Enable auto heal": "Auto Heal 활성화",

View File

@ -788,6 +788,7 @@
"Disable Compute Service": "Отключить службу вычислений",
"Disable Gateway": "Отключить шлюз",
"Disable Neutron Agent": "Отключить агента Neutron",
"Disable SNAT": "Отключить SNAT",
"Disable TLS": "Отключить TLS",
"Disable compute host": "Отключить узел вычислений",
"Disabled": "Отключено",
@ -914,6 +915,7 @@
"Enable Project": "Включить проект",
"Enable QoS Policy": "Включить политику QoS",
"Enable Registry": "Включить реестр",
"Enable SNAT": "Включить SNAT",
"Enable Service": "Включить сервис",
"Enable User": "Включить пользователя",
"Enable auto heal": "Включить автоматическое восстановление",

View File

@ -788,6 +788,7 @@
"Disable Compute Service": "Hesaplama Servisini Devre Dışı Bırak",
"Disable Gateway": "Ağ Geçidini Devre Dışı Bırak",
"Disable Neutron Agent": "Neutron Ajanını Devre Dışı Bırak",
"Disable SNAT": "SNAT Devre Dışı Bırak",
"Disable TLS": "TLS'yi Devre Dışı Bırak",
"Disable compute host": "Hesaplama ana bilgisayarını devre dışı bırak",
"Disabled": "Devre Dışı",
@ -914,6 +915,7 @@
"Enable Project": "Projeyi Etkinleştir",
"Enable QoS Policy": "QoS İlkesini Etkinleştir",
"Enable Registry": "Kayıt Defterini Etkinleştir",
"Enable SNAT": "SNAT Etkinleştir",
"Enable Service": "Hizmeti Etkinleştir",
"Enable User": "Kullanıcıyı Etkinleştir",
"Enable auto heal": "Otomatik Onarımı Etkinleştir",

View File

@ -788,6 +788,7 @@
"Disable Compute Service": "禁用计算服务",
"Disable Gateway": "禁用网关",
"Disable Neutron Agent": "禁用网络服务",
"Disable SNAT": "禁用 SNAT",
"Disable TLS": "禁用TLS",
"Disable compute host": "禁用计算节点",
"Disabled": "已关闭",
@ -914,6 +915,7 @@
"Enable Project": "启用项目",
"Enable QoS Policy": "启用QoS策略",
"Enable Registry": "启用注册表",
"Enable SNAT": "启用 SNAT",
"Enable Service": "启用服务",
"Enable User": "启用用户",
"Enable auto heal": "启用自动修复",

View File

@ -0,0 +1,55 @@
// Copyright 2021 99cloud
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import { ConfirmAction } from 'containers/Action';
import globalRouterStore from 'stores/neutron/router';
export default class DisableSnat extends ConfirmAction {
get id() {
return 'disable-snat';
}
get title() {
return t('Disable SNAT');
}
get actionName() {
return t('Disable SNAT');
}
policy = [
'update_router',
'update_router:external_gateway_info',
'update_router:external_gateway_info:network_id',
'update_router:external_gateway_info:enable_snat',
];
allowedCheckFunc = (item) => {
return item?.external_gateway_info?.enable_snat;
};
onSubmit = (item) => {
const {
id,
external_gateway_info: { network_id },
} = item;
const body = {
external_gateway_info: {
network_id,
enable_snat: false,
},
};
return globalRouterStore.edit({ id }, body);
};
}

View File

@ -0,0 +1,57 @@
// Copyright 2021 99cloud
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import { ConfirmAction } from 'containers/Action';
import globalRouterStore from 'stores/neutron/router';
export default class EnableSnat extends ConfirmAction {
get id() {
return 'enable-snat';
}
get title() {
return t('Enable SNAT');
}
get actionName() {
return t('Enable SNAT');
}
policy = [
'update_router',
'update_router:external_gateway_info',
'update_router:external_gateway_info:network_id',
'update_router:external_gateway_info:enable_snat',
];
allowedCheckFunc = (item) => {
return (
item?.external_gateway_info && !item.external_gateway_info.enable_snat
);
};
onSubmit = (item) => {
const {
id,
external_gateway_info: { network_id },
} = item;
const body = {
external_gateway_info: {
network_id,
enable_snat: true,
},
};
return globalRouterStore.edit({ id }, body);
};
}

View File

@ -20,6 +20,8 @@ import SetGateway from './SetGateway';
// import AssociateFip from './AssociateFip';
import ConnectSubnet from './ConnectSubnet';
import DisconnectSubnet from './DisconnectSubnet';
import EnableSnat from './EnableSnat';
import DisableSnat from './DisableSnat';
// import DisassociateFip from './DisassociateFip';
const actionConfigs = {
@ -41,6 +43,12 @@ const actionConfigs = {
{
action: SetGateway,
},
{
action: EnableSnat,
},
{
action: DisableSnat,
},
// {
// action: AssociateFip,
// },