renew starrs during renewal, add ability to change vm cores

This commit is contained in:
Jordan Rodgers 2017-12-10 23:32:38 -05:00
parent f3d69381c1
commit 9fa6bf051d
5 changed files with 133 additions and 15 deletions

View file

@ -15,7 +15,7 @@ def get_next_ip(starrs, range_name):
c = starrs.cursor()
try:
c.execute("BEGIN")
c.callproc("api.initialize", ('root', ))
c.callproc("api.initialize", ('root',))
c.callproc("api.get_address_from_range", (range_name, ))
results = c.fetchall()
c.execute("COMMIT")
@ -28,8 +28,21 @@ def get_ip_for_mac(starrs, mac):
c = starrs.cursor()
try:
c.execute("BEGIN")
c.callproc("api.initialize", ('root', ))
c.callproc("api.get_system_interface_addresses", (mac.lower(), ))
c.callproc("api.initialize", ('root',))
c.callproc("api.get_system_interface_addresses", (mac.lower(),))
results = c.fetchall()
c.execute("COMMIT")
finally:
c.close()
return results[0][3]
def renew_ip(starrs, addr):
c = starrs.cursor()
try:
c.execute("BEGIN")
c.callproc("api.initialize", ('root',))
c.callproc("api.renew_interface_address", (addr,))
results = c.fetchall()
c.execute("COMMIT")
finally:
@ -41,14 +54,14 @@ def check_hostname(starrs, hostname):
c = starrs.cursor()
try:
c.execute("BEGIN")
c.callproc("api.initialize", ('root', ))
c.callproc("api.initialize", ('root',))
c.callproc("api.validate_name", (hostname,))
valid = False
if hostname == c.fetchall()[0][0]:
valid = True
c.execute("COMMIT")
c.execute("BEGIN")
c.callproc("api.initialize", ('root', ))
c.callproc("api.initialize", ('root',))
c.callproc("api.check_dns_hostname", (hostname, 'csh.rit.edu'))
available = False
if not c.fetchall()[0][0]:
@ -66,7 +79,7 @@ def register_starrs(starrs, name, owner, mac, addr):
c = starrs.cursor()
try:
c.execute("BEGIN")
c.callproc("api.initialize", ('root', ))
c.callproc("api.initialize", ('root',))
c.callproc(
"api.create_system_quick",
(name, owner, 'members', mac, addr, 'csh.rit.edu', 'dhcp', True))
@ -81,7 +94,7 @@ def delete_starrs(starrs, name):
c = starrs.cursor()
try:
c.execute("BEGIN")
c.callproc("api.initialize", ('root', ))
c.callproc("api.initialize", ('root',))
c.callproc("api.remove_system", (name, ))
results = c.fetchall()
c.execute("COMMIT")