From 8a47d63edec61a856421873d9e89c30508eed56a Mon Sep 17 00:00:00 2001
From: Andrew Keuhs <andrew@andrewk.net>
Date: Sat, 17 Feb 2024 00:34:06 +0000
Subject: [PATCH] added main loop stuff

---
 arista-vlan-sync.py | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/arista-vlan-sync.py b/arista-vlan-sync.py
index 3f7f88d..128caf1 100644
--- a/arista-vlan-sync.py
+++ b/arista-vlan-sync.py
@@ -15,6 +15,8 @@ from pathlib import Path  # python3 only
 env_path = Path('.') / '.env'
 load_dotenv(dotenv_path=env_path)
 
+version = "1.00" # set a version to the program
+
 # Define master switch details
 MASTER_SWITCH = {
     "ip": "23.169.120.2",
@@ -40,6 +42,7 @@ SWITCHES = [
 # Saved as tuple as these should only be read and not altered
 PROTECTED_VLANS = ("1")
 
+# sync vlan function
 def sync_vlans(master_switch, switch):
 
     # Establish SSH connection to master switch
@@ -121,6 +124,9 @@ def sync_vlans(master_switch, switch):
         master_client.close()
         switch_client.close()
 
-# Loop through each switch and sync VLANs
-for switch in SWITCHES:
-    sync_vlans(MASTER_SWITCH, switch)
+# Main loop
+if __name__ == "__main__":
+
+    # Loop through switches and run sync
+    for switch in SWITCHES:
+        sync_vlans(MASTER_SWITCH, switch)
\ No newline at end of file