I am new to Meraki and Python APIs. I am trying to write a script to find the details of a client in my organization when I search with IP address. Below is my code: from meraki import meraki import login
(API_KEY, ORG_ID) = (login.api_key, login.org_id)
def find_client(client_ip, status):
for device in status:
serialnum = device['serial']
clientList = meraki.getclients(API_KEY,serialnum)
for client in clientList:
if client['ip'] == client_ip:
network = find_network(device)
return client, network
def find_network(device) :
for network in networks:
if device['networkId'] == network['id']:
return network
status = meraki.get_device_statuses(API_KEY, ORG_ID)
networks = meraki.getnetworklist(API_KEY, ORG_ID)
client_ip = input('Enter client IP: ')
client, network = find_client(client_ip, status) I have a couple of questions 1) Is there any efficient way to do this because my current code takes so long to find the client as it checks clients in each network of my organization. (Note: In my organization, each device (Switch/Firewall/AP) is in separate network) 2) Furthermore, after each iteration it prints "Device Clients Operation Successful - See returned data for results" on the console/prompt. Is there a way to avoid printing this ?
... View more