summaryrefslogtreecommitdiff
path: root/http
diff options
context:
space:
mode:
authorRoberto Berto <463349+robertoberto@users.noreply.github.com>2024-05-23 17:49:52 +0000
committerRoberto Berto <463349+robertoberto@users.noreply.github.com>2024-05-23 17:49:52 +0000
commitb2c4d5920e8e34b286d035bf1a0b2070fca75f38 (patch)
tree481d197cce56dc721d4cb1fa7a369a37db1c5dcb /http
parent634fa2ba708173da81c7d709063e9fd94b43e94f (diff)
downloadpacker-vyos-b2c4d5920e8e34b286d035bf1a0b2070fca75f38.tar.gz
packer-vyos-b2c4d5920e8e34b286d035bf1a0b2070fca75f38.zip
improved vyos configure cleanup and cloud-init
Diffstat (limited to 'http')
-rw-r--r--http/cleanup-vyos-configure.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/http/cleanup-vyos-configure.py b/http/cleanup-vyos-configure.py
new file mode 100644
index 0000000..b58b03b
--- /dev/null
+++ b/http/cleanup-vyos-configure.py
@@ -0,0 +1,25 @@
+import json
+from vyos.configtree import ConfigTree
+
+config_path = '/config/config.boot'
+
+with open(config_path, 'r') as file:
+ config_string = file.read()
+
+config = ConfigTree(config_string=config_string)
+
+interfaces = config.list_nodes(['interfaces', 'ethernet'])
+
+# remove all hw-id from interfaces ethernet since it cause issue on interface order
+# for interface in interfaces:
+# hw_id_path = ['interfaces', 'ethernet', interface, 'hw-id']
+# if config.exists(hw_id_path):
+# config.delete(hw_id_path)
+
+# remove all interfaces ethernet
+for interface in interfaces:
+ hw_id_path = ['interfaces', 'ethernet', interface]
+ config.delete(hw_id_path)
+
+with open(config_path, 'w') as config_file:
+ config_file.write(config.to_string())