Hello,
I'm getting my feet wet on new Meraki SDK. I'm having trouble understanding how to call different functions from this link.
What is the logic for e.g. function getNetworkDeviceManagementInterfaceSettings()?
import meraki
api_key = '<api_key>'
m = meraki.DashboardAPI(api_key)
orgs = m.organizations.getOrganizations()
org_id = orgs[0]['id']
#get Networks
nets = m.networks.getOrganizationNetworks
#how to call getNetworkDeviceManagementInterfaceSettings()?
m.networks.getOrganizationNetworks('<network_id>').getNetworkDeviceManagementInterfaceSettings()#?
Regards
Solved! Go to solution.
It's a little bit tricky.
you need to know the network and the serial of each device in the network
import meraki
api_key = "<api_key>"
m = meraki.DashboardAPI(api_key)
orgs = m.organizations.getOrganizations()
org_id = orgs[0]["id"]
#get Networks
networks = m.networks.getOrganizationNetworks(org_id)
#iterate through all the networks in the organization
for net in networks:
devices = m.devices.getNetworkDevices(net["id"])
#iterate through all the devices in the network
for d in devices:
#extract the management interface setting for each device
settings = m.management_interface_settings.getNetworkDeviceManagementInterfaceSettings(net["id"],d["serial"])
print(settings)
It's a little bit tricky.
you need to know the network and the serial of each device in the network
import meraki
api_key = "<api_key>"
m = meraki.DashboardAPI(api_key)
orgs = m.organizations.getOrganizations()
org_id = orgs[0]["id"]
#get Networks
networks = m.networks.getOrganizationNetworks(org_id)
#iterate through all the networks in the organization
for net in networks:
devices = m.devices.getNetworkDevices(net["id"])
#iterate through all the devices in the network
for d in devices:
#extract the management interface setting for each device
settings = m.management_interface_settings.getNetworkDeviceManagementInterfaceSettings(net["id"],d["serial"])
print(settings)
I tried to use different function from that class to update mgmt interface, but It doesn't work for me. What am I doing wrong? How can I update interface WAN2?
below is just a portion of code.
data = {'wan1': {'wanEnabled': 'not configured', 'usingStaticIp': False, 'vlan': None}, 'wan2': {'wanEnabled': 'not configured','usingStaticIp': True,'staticIp': '1.1.1.1','staticSubnetMask': '255.255.255.252','staticGatewayIp': '1.1.1.2.','staticDns': [ '8.8.8.8', '8.8.8.8.']} 'vlan': None}}
settings = m.management_interface_settings.getNetworkDeviceManagementInterfaceSettings(networkID,mx_serial_number, data)
every method which starts with "get" will read the data from the dashboard. You won't be able to update the settings with this.
In your case you will need updateNetworkDeviceManagementInterfaceSettings
def updateNetworkDeviceManagementInterfaceSettings(self, networkId: str, serial: str, **kwargs):
"""
**Update the management interface settings for a device**
https://api.meraki.com/api_docs#update-the-management-interface-settings-for-a-device
- networkId (string)
- serial (string)
- wan1 (object): WAN 1 settings
- wan2 (object): WAN 2 settings (only for MX devices)
"""
sry it was a typo, I meant updateNetworkDeviceManagementInterfaceSettings() but how to passe arguments for wan2 link?
I haven't tried it, but from the docs it should work like that:
data_wan1 = {'wanEnabled': 'not configured', 'usingStaticIp': False, 'vlan': None}
data_wan2 = {'wanEnabled': 'not configured','usingStaticIp': True,'staticIp': '1.1.1.1','staticSubnetMask': '255.255.255.252','staticGatewayIp': '1.1.1.2.','staticDns': [ '8.8.8.8', '8.8.8.8.']} 'vlan': None}
m.management_interface_settings.updateNetworkDeviceManagementInterfaceSettings(networkID,mx_serial_number, wan1=data_wan1, wan2=data_wan2)
Thank you!