Created
September 23, 2014 02:50
-
-
Save rossdylan/e589d608abbb9261d056 to your computer and use it in GitHub Desktop.
starrs
This file contains hidden or 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 psycopg2 | |
import getpass | |
class STARRS(object): | |
def __init__(self, dbname, user, host, password): | |
self.conn = psycopg2.connect("dbname={0} user={1} host={2} password={3}".format(dbname, user, host, password)) | |
self.cursor = self.conn.cursor() | |
self.cursor.execute("select * from api.initialize('root')") | |
def get_free_addr(self, _range): | |
""" | |
Ranges of note: | |
'50net User Machines' | |
'Server Room' | |
""" | |
sql = "select api.get_address_from_range(%s)" | |
self.cursor.execute(sql, (_range,)) | |
addr = self.cursor.fetchone() | |
return addr | |
def quick(self, name, owner, group, mac, addr, zone, config, dns): | |
sql = "select * from api.create_system_quick(%s,%s,%s,%s,%s,%s,%s,%s)" | |
self.cursor.execute(sql, (name, owner, group, mac, addr, zone, config, dns)) | |
self.conn.commit() | |
def stupid(): | |
starrs = STARRS("impulse", "impulse_admin", "postgres.csh.rit.edu", getpass.getpass("Enter impulse_admin pass: ")) | |
starrs.quick("FUCKSHITSTACK", "rossdylan", "RTP", '02:15:e0:ec:01:00', starrs.get_free_addr("50net User Machines")[0], "csh.rit.edu", "dhcp", True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment