Created
November 30, 2013 01:12
-
-
Save jeid64/7714120 to your computer and use it in GitHub Desktop.
STARRS + DRUGS Creates a system using quick create. Totes not supported officially. Also, doesn't work for non-rtp's right now due to an extra form being put in for RTP's.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import mechanize | |
import urllib | |
import argparse | |
def login(br, username, password): | |
url = "http://starrs.csh.rit.edu" | |
br.open(url) | |
br.select_form(nr = 0) | |
br.form['username'] = username | |
br.form['password'] = password | |
br.submit() | |
def getip (br): | |
values = {"range": "Servers NAT"} | |
urlRange = "https://starrs.csh.rit.edu/address/getfromrange" | |
data = urllib.urlencode(values) | |
br.open(urlRange, data) | |
return br.response().read() | |
#Doesn't work with non rtp's due to extra form. Fix soon. | |
def create(br, system_name, mac): | |
address = getip(br) | |
br.open("https://starrs.csh.rit.edu/system/quickcreate/") | |
# on non rtp's this is 0. | |
br.select_form(nr = 1) | |
system_name = system_name | |
range_ip = ["Servers NAT"] | |
br.form['system_name'] = system_name | |
br.form['mac'] = mac | |
br.form['range'] = range_ip | |
br.form['address'] = address | |
br.submit() | |
if __name__ == "__main__": | |
parser = argparse.ArgumentParser(description='Quick create a system on STARRS in the Servers NAT range.') | |
parser.add_argument("username", help="Your CSH username") | |
parser.add_argument("password", help="Your CSH password") | |
parser.add_argument("system_name", help="System name that you want. Will also create DNS entry.") | |
parser.add_argument("mac", help="Your MAC address to register the interface with.") | |
parser = parser.parse_args() | |
br = mechanize.Browser() | |
login(br, parser.username, parser.password) | |
create(br, parser.system_name, parser.mac) | |
print ("Success.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment