properly validate hostname properly (hopefully for the last time)

This commit is contained in:
Jordan Rodgers 2018-03-21 22:20:41 -04:00
parent 7db17ab91d
commit e608c0dc10

View file

@ -1,3 +1,6 @@
import psycopg2
def get_next_ip(starrs, range_name):
c = starrs.cursor()
try:
@ -42,6 +45,10 @@ def renew_ip(starrs, addr):
def check_hostname(starrs, hostname):
c = starrs.cursor()
try:
c.execute("BEGIN")
c.callproc("api.initialize", ('root', ))
c.callproc("api.validate_name", (hostname, ))
c.execute("COMMIT")
c.execute("BEGIN")
c.callproc("api.initialize", ('root', ))
c.callproc("api.validate_domain", (hostname, 'csh.rit.edu'))