So I am fairly confident I narrowed down the issue. It would seem that if I install any of the other meraki modules it will cause errors. For example, if I start a project and only install meraki, it will work. However, if I also install merakiapi, it will error out. Maybe there is a confliction. Now that I have a better understanding of the API, I can rephrase what I am looking for. 1) I want a list of all the VLANs currently in use on the network. 2) I want a list of all hosts and their mac/ips that are getting an ip from the dhcp server that is running on our meraki ms425. The end goal here is to migrate off of meraki dhcp and onto windows server dhcp. However, in order to do that we would need a csv of { hostname, mac, ip ( and any other information meraki could provide if possible ( ie dns, gateway, etc) }. Powershell can take care of the rest. Here is the updated script for anyone that would like it import meraki as mer from pprint import pprint as pp import csv ''' Utility functions to be made as we go ''' # This will get us all of our network ids def getNetworkIDS(inventory): network_ids = set() # a set keeps unique values for device in inventory: network_id = device["networkId"] if network_id is not None: network_ids.add(network_id) return network_ids # This will output our inventory as a csv file for further reading def dictToCSV(inventory): keys = inventory[0].keys() with open('inventory.csv', 'w', encoding='utf8', newline='') as output_file: dict_writer = csv.DictWriter(output_file, fieldnames=inventory[0].keys()) dict_writer.writeheader() dict_writer.writerows(inventory) # Start our API calls by creating a dashboard instance dashboard = mer.DashboardAPI(api_key = "fdgssgdffgdsfdghshgsfd", print_console=False) # Next we get our organization information organizations = dashboard.organizations.getOrganizations() # Next we will get an inventory of our devices inventory = dashboard.organizations.getOrganizationInventory(organizations[0]['id']) # Since our inventory consists of APs we will need to filter those out network_ids = set() for item in inventory: if not item['model'] == 'MR42' and item["networkId"]: network_ids.add(item["networkId"]) vlan_csv = 'Network ID, VLAN ID,VLAN Name,Gateway,CIDR,DNS Servers\n' for network_id in network_ids: ''' This does not print out anything useful but it was an attempt {'defaultPolicy': 'allow', 'blockedServers': []} ''' try: print(dashboard.switch_settings.getNetworkSwitchSettingsDhcpServerPolicy(network_id)) except mer.exceptions.APIError as err: # Error handling is hard so I make it easy by doing something terrible print("There was an error trying to get the DHCP information from %s \n %s" % (network_id, err)) ''' The goal here is to go into each switch, and see what vlans each port is advertising. I want to get a list of all VLANs currently in the network ''' try: for vlan in dashboard.vlans.getNetworkVlans(network_id): print("\nWorking with Network ID : %s\n" % network_id) vlan_id = str(vlan['id']) name = str(vlan['name']) gateway = str(vlan['applianceIp']) cidr = str(vlan['subnet']) dns = str(str(vlan['dnsNameservers']).replace("\n", ":")) dhcpHandling = str(vlan['dhcpHandling']) #dhcpBootOptionsEnabled = vlan['dhcpBootOptionsEnabled'] row = str(','.join([network_id, vlan_id, name, gateway, cidr, dns, dhcpHandling])) + "\n" vlan_csv += row except mer.exceptions.APIError as err: # Error handling is hard so I make it easy by doing something terrible print("There was an error trying to get the VLANS from %s \n %s" % (network_id, err)) print("\n RESULTS \n") print(vlan_csv)
... View more