Browse Source

Add support for allowing local LAN access.

Joe Clarke 2 years ago
parent
commit
f0b1e97d50
2 changed files with 36 additions and 1 deletions
  1. 26 0
      meraki_api/meraki_api.py
  2. 10 1
      setup-meraki-nets.py

+ 26 - 0
meraki_api/meraki_api.py

@@ -453,6 +453,32 @@ class SSID(Meraki):
 
         return True
 
+    def allow_local_lan(self):
+        if not self._check_obj():
+            return False
+
+        payload = {
+            "comment": "Wireless clients accessing LAN",
+            "policy": "allow",
+            "protocol": "Any",
+            "destPort": "Any",
+            "destCidr": "Local LAN",
+        }
+        url = self.SSID_API + self._id + "/firewall/l3FirewallRules"
+        try:
+            response = requests.request("PUT", url, json=payload, headers=self._headers)
+            response.raise_for_status()
+        except Exception as e:
+            msg = "Error updating SSID firewall for {}: {} ({})".format(self._id, e, Meraki._get_json_errors(response))
+            if self._logit:
+                logging.error(msg)
+            else:
+                print(msg)
+
+                return False
+
+        return True
+
 
 class Vlan(Meraki):
     def __init__(self, **kwargs):

+ 10 - 1
setup-meraki-nets.py

@@ -258,7 +258,7 @@ def main():
                     print("{}update: Update VLAN {} ({}){}".format(Fore.YELLOW, vname, vargs_str, Style.RESET_ALL))
 
         if "ssids" in network:
-            if len(network["ssids"]) > 15:
+            if len(network["ssids"].keys()) > 15:
                 print("{}Only fifteen SSIDs are allowed per network!{}".format(Fore.RED, Style.RESET_ALL))
                 nerrors += 1
             else:
@@ -276,6 +276,15 @@ def main():
                         nerrors += 1
                     else:
                         print("{}update: Update SSID {} ({}){}".format(Fore.YELLOW, sname, sargs_str, Style.RESET_ALL))
+
+                    if "allow_lan_access" in ssid and ssid["allow_lan_access"]:
+                        sres = ssid_obj.allow_local_lan()
+                        if not sres:
+                            print("{}Error allowing local LAN access for SSID {}!{}".format(Fore.RED, sname, Style.RESET_ALL))
+                            nerrors += 1
+                        else:
+                            print("{}update: Allowing local LAN access for SSID {}{}".format(Fore.YELLOW, sname, Style.RESET_ALL))
+
                     si += 1
 
         if "switches" in network: