04-19-2020 09:09 AM
Hi,
In devnet sandbox meraki lab i am trying to update my switch bridge priority in my network on which i have admin rights.I able to do this from dashboard but not able to update it from meraki sdk python script.
Below is the script and result.
Please help.
script:
04-19-2020 12:31 PM - edited 04-19-2020 12:41 PM
Hi
if you print - network_devices - line 25
the list is empty so no device info is being sent
replace network["id"] with network_id on line 24 and 28
the serial of the switch in your network is different - its showing Q2GW-2CA5-RW6A
this works for me -
from meraki_sdk.meraki_sdk_client import MerakiSdkClient
import json
from pprint import pprint
x_cisco_meraki_api_key = 'e2e6ef21b94daf2fe4363510d40bb7cb80dae67c' # Demo DevNet Sandbox
meraki = MerakiSdkClient(x_cisco_meraki_api_key)
orgs = meraki.organizations.get_organizations()
for org in orgs:
print(org["name"])
if org["name"] == "DevNet Sandbox":
organization_id = org["id"]
# print(organization_id)
collect = {}
collect['organization_id'] = organization_id
networks = meraki.networks.get_organization_networks(collect)
for network in networks:
if network["name"] == "DNENT3-jxxx9gmail.com":
network_id = network["id"]
print(network["id"])
collect['network_id'] = network_id
network_devices = meraki.devices.get_network_devices(network_id)
# pprint(network_devices)
serial = "Q2GW-2CA5-RW6A"
switch_stp = meraki.switch_settings.get_network_switch_settings_stp(network_id)
#pprint(switch_stp)
print("....................................................................................")
template = switch_stp
template["stpBridgePriority"][0]['stpPriority'] = 4096
#pprint(template)
update_network_switch_settings_stp = template
collect1 = {}
collect1['network_id'] = network_id
collect1['update_network_switch_settings_stp'] = update_network_switch_settings_stp
result = meraki.switch_settings.update_network_switch_settings_stp(collect1)
04-19-2020 01:46 PM - edited 04-19-2020 01:47 PM
Hi,
Thank you it worked with your suggested changes.
But i wanted to know that if i don't change network["id"] with network_id i get list of devices which is not in my network, list is not empty and network["id"] holds same value as network_id so how this change completely changed the outcome in line 24 and 28.
WITH YOUR CHANGES
DevNet Sandbox
L_646829496481105035
[{u'address': u'',
u'firmware': u'switch-11-31',
u'floorPlanId': None,
u'lanIp': None,
u'lat': 37.4180951010362,
u'lng': -122.098531723022,
u'mac': u'34:56:fe:a5:6c:20',
u'model': u'MS225-24P',
u'networkId': u'L_646829496481105033',
u'serial': u'Q2GW-2CA5-RW6A',
u'switchProfileId': None,
u'url': u'https://n149.meraki.com/DNENT3-jxxx9gmai/n/k4sbcdvc/manage/nodes/new_list/57548244085792'},
{u'address': u'',
u'firmware': u'wired-14-40',
u'floorPlanId': None,
u'lanIp': None,
u'lat': 37.4180951010362,
u'lng': -122.098531723022,
u'mac': u'e0:55:3d:11:c1:d0',
u'model': u'MX84',
u'networkId': u'L_646829496481105033',
u'serial': u'Q2PN-PSMX-KDDC',
u'url': u'https://n149.meraki.com/DNENT3-jxxx9gmai/n/TFcqSbvc/manage/nodes/new_list/246656701415888',
u'wan1Ip': None,
u'wan2Ip': None},
{u'address': u'',
u'firmware': u'wireless-26-6-1',
u'floorPlanId': None,
u'lanIp': None,
u'lat': 37.4180951010362,
u'lng': -122.098531723022,
u'mac': u'e0:cb:bc:51:45:80',
u'model': u'MR53',
u'networkId': u'L_646829496481105033',
u'serial': u'Q2MD-MFNY-6L6H',
u'url': u'https://n149.meraki.com/DNENT3-jxxx9gmai/n/0NtyUavc/manage/nodes/new_list/247165642425728'},
{u'address': u'',
u'firmware': u'camera-4-0',
u'floorPlanId': None,
u'lanIp': None,
u'lat': 37.4180951010362,
u'lng': -122.098531723022,
u'mac': u'34:56:fe:a2:58:86',
u'model': u'MV12WE',
u'networkId': u'L_646829496481105033',
u'serial': u'Q2FV-W72R-U7WX',
u'url': u'https://n149.meraki.com/DNENT3-jxxx9gmai/n/SE797cvc/manage/nodes/new_list/57548243884166',
u'wirelessMac': u'34:56:fe:a2:58:87'}]
WITHOUT YOUR CHANGES
DevNet Sandbox
L_646829496481105035
[{u'address': u'',
u'firmware': u'Not running configured version',
u'floorPlanId': None,
u'lanIp': None,
u'lat': 37.4180951010362,
u'lng': -122.098531723022,
u'mac': u'34:56:fe:a2:58:89',
u'model': u'MV12WE',
u'networkId': u'L_646829496481105035',
u'serial': u'Q2FV-4QSY-KBF6',
u'url': u'https://n149.meraki.com/DNENT1-camera/n/vBfLIbvc/manage/nodes/new_list/57548243884169',
u'wirelessMac': u'34:56:fe:a2:58:8a'},
{u'address': u'',
u'firmware': u'wireless-26-6-1',
u'floorPlanId': None,
u'lanIp': u'192.168.128.3',
u'lat': 37.4180951010362,
u'lng': -122.098531723022,
u'mac': u'e0:cb:bc:51:23:be',
u'model': u'MR53',
u'networkId': u'L_646829496481105035',
u'serial': u'Q2MD-C3CG-4DBC',
u'url': u'https://n149.meraki.com/DNENT1-wireless/n/8UYmOdvc/manage/nodes/new_list/247165642417086'},
{u'address': u'',
u'firmware': u'switch-11-31',
u'floorPlanId': None,
u'lanIp': u'192.168.128.4',
u'lat': 37.4180951010362,
u'lng': -122.098531723022,
u'mac': u'34:56:fe:a5:6d:20',
u'model': u'MS225-24P',
u'networkId': u'L_646829496481105035',
u'serial': u'Q2GW-2CPC-JCYZ',
u'switchProfileId': None,
u'url': u'https://n149.meraki.com/DNENT1-switch/n/wV4s4dvc/manage/nodes/new_list/57548244086048'},
{u'address': u'',
u'firmware': u'wired-14-40',
u'floorPlanId': None,
u'lanIp': u'10.10.10.116',
u'lat': 37.4180951010362,
u'lng': -122.098531723022,
u'mac': u'88:15:44:9e:8e:10',
u'model': u'MX84',
u'networkId': u'L_646829496481105035',
u'serial': u'Q2PN-JRAG-STZY',
u'url': u'https://n149.meraki.com/DNENT1-appliance/n/lr_8Qavc/manage/nodes/new_list/149624926932496',
u'wan1Ip': u'10.10.10.116',
u'wan2Ip': None}]
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide