API’s and Python are fun. Since I started learning Python and working with Juniper/Mist API’s I am absolutely addicted. There are so many people I am thankful to, who have helped me every time I was stuck and they still do.
Recently I dove a little bit into Ruckus APIs. Initially, I almost gave up, they were very frustrating to work with as compared to Juniper/Mist APIs. Login process is not fun. Then, I ran into Ruckus vSZ API Client by Victor Santiago. Using the Ruckus vSZ API Client, life is a bit easier when interacting with the Ruckus Virtual Smart Zone. There are really good instructions on how to install.
Possibilities are endless but with my limited Python knowledge I was able to come up with some useful scripts.
List all the Domain:
import RuckusVirtualSmartZoneAPIClient
client = RuckusVirtualSmartZoneAPIClient.Client(api_version='v9_1')
client.connect(url='https://vsz-url.com', username='artofrf', password='P@ssword1234')
response = client.get(method='/domains')
results = (json.dumps(response.json(), indent=4))
print(results)
client.disconnect()
List all the Zones:
import RuckusVirtualSmartZoneAPIClient
client = RuckusVirtualSmartZoneAPIClient.Client(api_version='v9_1')
client.connect(url='https://vsz-url.com', username='artofrf', password='P@ssword1234')
response = client.get(method='/rkszones')
results = (json.dumps(response.json(), indent=4))
print(results)
client.disconnect()
List Zones with AP Firmware:
import RuckusVirtualSmartZoneAPIClient
client = RuckusVirtualSmartZoneAPIClient.Client(api_version='v9_1')
client.connect(url='https://vsz-url.com', username='artofrf', password='P@ssword1234')
#response = client.get(method='/rkszones/{zone-id}/apFirmware')
#results = (json.dumps(response.json(), indent=4))
#print(results)
client.disconnect()
Push/Change Zone/AP Firmware:
import RuckusVirtualSmartZoneAPIClient
client = RuckusVirtualSmartZoneAPIClient.Client(api_version='v9_1')
client.connect(url='https://vsz-url.com', username='artofrf', password='P@ssword1234')
response = client.put(method=f'/rkszones/{zone-id}/apFirmware', data={"firmwareVersion": "3.6.2.0.765"})
#204 = Success code
print(response.status_code) # --> 204
client.disconnect()
When changing Zone/AP Firmware it is important that you have the desired firmware present, other wise the process will fail. This does cause a downtime so I like to do it after hours for obvious reasons. Data can be further manipulated with multiple zones using a csv file or by simply taking the output and inserting it into a loop so that the script can iterate through all the zones and push the firmware. Doing it one zone at a time takes a long time and if you are an MSP and/or managing multiple Domains/Zones upgrading Zone/AP firmware one zone at a time will not be fun. It is always a good idea to test every script out in the lab before using it in the production. One of my old bosses used to say, “Never do something that you can not undo”.
Always happy to hear comments and feedback to improve myself and what I write. Thank you for reading.
