# This Python script logs into a Ruckus Smartzone Controller and performs API calls # to read AP MAC Addresses and Names from a file, then use that informations to rename APs. # Note: This program assumes you are only using the Default Zone. # import modules import getpass import requests import json import csv # disable SSL certificate warnings requests.packages.urllib3.disable_warnings() # Ask for the username and password. print('Please Enter your username and Password: ') uname = input('Username: ') pword = getpass.getpass(prompt = 'Password: ') # Main API URL to Smartzone 3.6 and login credentials main_api = "https://10.8.6.32:8443/wsg/api/public/v6_0/" body = {'username': uname, 'password': pword} # Create session to retain cookie information # all commands must be in the session to retain the token with requests.session() as session: r = session.post(main_api + 'session', data = json.dumps(body), verify = False).json() # Print the Controller Version number and captions version = r['controllerVersion'] print() print('Controller Version: ' + version) print('**************************************') print() # Read information from a CSV file with open('RuckusAPList.csv') as csv_file: filereader = csv.reader(csv_file, delimiter = ',') next(filereader) for row in filereader: apMac = row[0] apName = row[1] info = {'name': apName} session.patch(main_api + 'aps/' + apMac, json = (info)) # Get a list of APs aps = session.get(main_api + 'aps').json() for each in aps['list']: print('AP Name: ' + each['name']) print('AP MAC Address: ' + each['mac']) print() # End Session session.close()