Skip to content

Instantly share code, notes, and snippets.

@yujiterada
Created February 7, 2024 13:12
Show Gist options
  • Save yujiterada/c59f8c4007c8a541c56ce20b7c6606fc to your computer and use it in GitHub Desktop.
Save yujiterada/c59f8c4007c8a541c56ce20b7c6606fc to your computer and use it in GitHub Desktop.
Sample script to output MX L3 ACL to CSV
import os
# run "pip3 install meraki"
import meraki
import json
MERAKI_API_KEY = os.environ.get("MERAKI_API_KEY")
ORG_ID = "734417"
dashboard = meraki.DashboardAPI(
api_key=MERAKI_API_KEY,
suppress_logging=True,
output_log=False)
organizations = dashboard.organizations.getOrganizations()
#print(json.dumps(organizations, indent=4))
networks = dashboard.organizations.getOrganizationNetworks(organizationId=ORG_ID)
with open('sample.csv', 'w') as file:
file.write("network_name, network_id, comment, policy, protocol, srcPort, srcCidr, destPort, destCidr, syslogEnabled\n")
for network in networks:
if 'appliance' in network['productTypes']:
rules = dashboard.appliance.getNetworkApplianceFirewallL3FirewallRules(networkId=network['id'])['rules']
for rule in rules:
line = "{}, {}, {}, {}, {}, {}, {}, {}, {}, {}\n".format(
network['name'],
network['id'],
rule["comment"],
rule["policy"],
rule["protocol"],
rule["srcPort"],
rule["srcCidr"],
rule["destPort"],
rule["destCidr"],
rule["syslogEnabled"]
)
file.write(line)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment