03-03-2020 04:59 AM
Hi there,
I have been browsing through the forum and saw one thread for this item, but not using the same code examples. i would like to change the MX VLAN ports using the Python meraki API. This is different than the solution posted here where they use the request/REST function and not the api. I get a 200 Ok but the changing have not been done. I am a bit clueless now how to parse all this..
I want to update port 3 with a VLAN setting
A piece of code :
Solved! Go to Solution.
03-03-2020 06:18 AM
Like this:
params = {
"vlan":400,
"accessPolicy":"open",
"enabled" : True,
"type":"access",
"dropUntaggedTraffic":False
}
dashboard.mx_vlan_ports.updateNetworkAppliancePort(def_network, 3, **params)
03-03-2020 05:00 AM
Hi,
Just to be sure. MX is bind to templated network or not ?
03-03-2020 05:04 AM
No,
The MX will be installed not using a template. I want to script a new and fresh installation
03-03-2020 05:12 AM
I'm not sure if is the problem but in the Documentation there is some underscore in the put request :
mx_vlan_ports_controller.update_network_appliance_port(collect)
Your one is :
dashboard.mx_vlan_ports.updateNetworkAppliancePort
03-03-2020 05:41 AM
Dashboard is the session ID
03-03-2020 05:52 AM
The function is actually expecting the parameters in a different way.
Try changing it to:
result = dashboard.mx_vlan_ports.updateNetworkAppliancePort(def_network,"3",vlan=400, accessPolicy="open", enabled = True, type="access",dropUntaggedTraffic=False)
03-03-2020 06:09 AM
Okay,
We are almost there 😉 that part works, however i want to have that part in a variable which i can easily manipulate
vlan=400, accessPolicy="open", enabled = True, type="access",dropUntaggedTraffic=False
cause this does not work
pay_load = 'enabled = True, type = "access", dropUntaggedTraffic = False, vlan = 400, accessPolicy = "open"'
03-03-2020 06:18 AM
Like this:
params = {
"vlan":400,
"accessPolicy":"open",
"enabled" : True,
"type":"access",
"dropUntaggedTraffic":False
}
dashboard.mx_vlan_ports.updateNetworkAppliancePort(def_network, 3, **params)
03-03-2020 06:32 AM
That works, thanks... been looking for that some time (but were afraid to ask 😉 )
basically using a dict variable and add/change values to it... Then the **params is setting a pointer to params values
Thnx for the help....
03-03-2020 06:51 AM
Yup kind of. In python terms it's called unpacking. If you want more information about it have a look here:
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