summaryrefslogtreecommitdiff
path: root/src/migration-scripts
diff options
context:
space:
mode:
authorerkin <e.altunbas@vyos.io>2021-09-10 21:14:46 +0300
committererkin <e.altunbas@vyos.io>2021-09-10 21:14:46 +0300
commitd73c862e24a8e5eaf4ff3058836f6fae50653f6e (patch)
tree8b595aa486e7c89fbf63e9bb76a14fb7d6bb8422 /src/migration-scripts
parent69ec102365ee60a476ba750b7ca7d4c26e2e72fa (diff)
downloadvyos-1x-d73c862e24a8e5eaf4ff3058836f6fae50653f6e.tar.gz
vyos-1x-d73c862e24a8e5eaf4ff3058836f6fae50653f6e.zip
T3275: conntrack: Backport XML/Python implementation of conntrack CLI
Diffstat (limited to 'src/migration-scripts')
-rwxr-xr-xsrc/migration-scripts/conntrack/2-to-337
1 files changed, 37 insertions, 0 deletions
diff --git a/src/migration-scripts/conntrack/2-to-3 b/src/migration-scripts/conntrack/2-to-3
new file mode 100755
index 000000000..8a8b43279
--- /dev/null
+++ b/src/migration-scripts/conntrack/2-to-3
@@ -0,0 +1,37 @@
+#!/usr/bin/env python3
+
+# Conntrack syntax version 3
+# Enables all conntrack modules (previous default behaviour) and omits manually disabled modules.
+
+import sys
+
+from vyos.configtree import ConfigTree
+from vyos.version import get_version
+
+if len(sys.argv) < 1:
+ print('Must specify file name!')
+ sys.exit(1)
+
+filename = sys.argv[1]
+
+with open(filename, 'r') as f:
+ config = ConfigTree(f.read())
+
+module_path = ['system', 'conntrack', 'modules']
+
+# Go over all conntrack modules available as of v1.3.0.
+for module in ['ftp', 'h323', 'nfs', 'pptp', 'sip', 'sqlnet', 'tftp']:
+ # 'disable' is being phased out.
+ if config.exists(module_path + [module, 'disable']):
+ config.delete(module_path + [module])
+ # If it wasn't manually 'disable'd, it was enabled by default.
+ else:
+ config.set(module_path + [module])
+
+try:
+ if config.exists(module_path):
+ with open(filename, 'w') as f:
+ f.write(config.to_string())
+except OSError as e:
+ print(f'Failed to save the modified config: {e}')
+ sys.exit(1)