diff options
author | Christian Poessinger <christian@poessinger.com> | 2020-05-01 16:46:06 +0200 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2020-05-16 15:30:26 +0200 |
commit | a5650abb6d575de2f696a934d52468992ac9f1e9 (patch) | |
tree | dbff8b9439983072f8e16dd506d99fcae8a046fa /src/conf_mode | |
parent | 7caf1568bbb6be59e5f13693c31f23ade9349daa (diff) | |
download | vyos-1x-a5650abb6d575de2f696a934d52468992ac9f1e9.tar.gz vyos-1x-a5650abb6d575de2f696a934d52468992ac9f1e9.zip |
nat: T2198: migrate to common template for source/destination NAT
Diffstat (limited to 'src/conf_mode')
-rwxr-xr-x | src/conf_mode/nat.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/conf_mode/nat.py b/src/conf_mode/nat.py index 538999f9a..b4e8c2053 100755 --- a/src/conf_mode/nat.py +++ b/src/conf_mode/nat.py @@ -19,6 +19,7 @@ from sys import exit from netifaces import interfaces from vyos.config import Config +from vyos.util import call from vyos.template import render from vyos import ConfigError @@ -27,8 +28,7 @@ default_config_data = { 'destination': [] } -nat_source_config = '/tmp/nat_source' -nat_destination_config = '/tmp/nat_destination' +iptables_nat_config = '/tmp/iptables_nat_config' def parse_source_destination(conf, source_dest): """ Common wrapper to read in both NAT source and destination CLI """ @@ -128,12 +128,14 @@ def generate(nat): if not nat: return None - render(nat_source_config, 'nat/nat-source.tmpl', nat, trim_blocks=True) - render(nat_destination_config, 'nat/nat-destination.tmpl', nat, trim_blocks=True) - + render(iptables_nat_config, 'nat/iptables-restore.tmpl', nat, trim_blocks=True) return None def apply(nat): + if not nat: + return None + + call(f'iptables-restore --test < {iptables_nat_config}') return None |