diff --git a/releasenotes/notes/Support-Disable-Enable-Router-SNAT-1f09d5e8aa1a07bb.yaml b/releasenotes/notes/Support-Disable-Enable-Router-SNAT-1f09d5e8aa1a07bb.yaml new file mode 100644 index 00000000..b040a5e4 --- /dev/null +++ b/releasenotes/notes/Support-Disable-Enable-Router-SNAT-1f09d5e8aa1a07bb.yaml @@ -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`. diff --git a/src/locales/en.json b/src/locales/en.json index ab67d524..e77bcb09 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -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", diff --git a/src/locales/ko-kr.json b/src/locales/ko-kr.json index 3b11a80e..2d68578f 100644 --- a/src/locales/ko-kr.json +++ b/src/locales/ko-kr.json @@ -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 활성화", diff --git a/src/locales/ru.json b/src/locales/ru.json index d2f37092..4999d4c6 100644 --- a/src/locales/ru.json +++ b/src/locales/ru.json @@ -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": "Включить автоматическое восстановление", diff --git a/src/locales/tr-tr.json b/src/locales/tr-tr.json index 75b4ff10..f96ae6c8 100644 --- a/src/locales/tr-tr.json +++ b/src/locales/tr-tr.json @@ -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", diff --git a/src/locales/zh-hans.json b/src/locales/zh-hans.json index 2c830acc..72f65cb7 100644 --- a/src/locales/zh-hans.json +++ b/src/locales/zh-hans.json @@ -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": "启用自动修复", diff --git a/src/pages/network/containers/Router/actions/DisableSnat.jsx b/src/pages/network/containers/Router/actions/DisableSnat.jsx new file mode 100644 index 00000000..60a3c3ee --- /dev/null +++ b/src/pages/network/containers/Router/actions/DisableSnat.jsx @@ -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); + }; +} diff --git a/src/pages/network/containers/Router/actions/EnableSnat.jsx b/src/pages/network/containers/Router/actions/EnableSnat.jsx new file mode 100644 index 00000000..6556b6a2 --- /dev/null +++ b/src/pages/network/containers/Router/actions/EnableSnat.jsx @@ -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); + }; +} diff --git a/src/pages/network/containers/Router/actions/index.jsx b/src/pages/network/containers/Router/actions/index.jsx index c3917616..436e8261 100644 --- a/src/pages/network/containers/Router/actions/index.jsx +++ b/src/pages/network/containers/Router/actions/index.jsx @@ -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, // },