# 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.4.2.3: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() # Open the CSV file to write with open('ap_info.txt', mode = 'w') as csv_file: filewriter = csv.writer(csv_file, delimiter = ',') # Get a list of APs aps = session.get(main_api + 'aps').json() for each in aps['list']: filewriter.writerow([each['mac'], each['name']]) print('Wrote AP MAC: ' + each['mac'] + ' to the file.') # End Session session.close()