- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Updating MX Ports using Python API
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.
- Labels:
-
Code Sample
-
Dashboard API
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Like this:
params = {
"vlan":400,
"accessPolicy":"open",
"enabled" : True,
"type":"access",
"dropUntaggedTraffic":False
}
dashboard.mx_vlan_ports.updateNetworkAppliancePort(def_network, 3, **params)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Just to be sure. MX is bind to templated network or not ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
No,
The MX will be installed not using a template. I want to script a new and fresh installation
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dashboard is the session ID
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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"'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Like this:
params = {
"vlan":400,
"accessPolicy":"open",
"enabled" : True,
"type":"access",
"dropUntaggedTraffic":False
}
dashboard.mx_vlan_ports.updateNetworkAppliancePort(def_network, 3, **params)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yup kind of. In python terms it's called unpacking. If you want more information about it have a look here:
