Skip to content

Commit 12b0f37

Browse files
committed
fix system name, improve config/info, require auth to load
1 parent e7731bc commit 12b0f37

File tree

4 files changed

+24
-12
lines changed

4 files changed

+24
-12
lines changed

proxstar/__init__.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,10 @@
3838

3939
ssh_tunnels = []
4040

41-
retry = 0
42-
while retry < 5:
43-
try:
44-
auth = OIDCAuthentication(
45-
app,
46-
issuer=app.config['OIDC_ISSUER'],
47-
client_registration_info=app.config['OIDC_CLIENT_CONFIG'])
48-
break
49-
except:
50-
retry += 1
51-
time.sleep(2)
41+
auth = OIDCAuthentication(
42+
app,
43+
issuer=app.config['OIDC_ISSUER'],
44+
client_registration_info=app.config['OIDC_CLIENT_CONFIG'])
5245

5346
redis_conn = Redis(app.config['REDIS_HOST'], app.config['REDIS_PORT'])
5447
q = Queue(connection=redis_conn)

proxstar/starrs.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,25 +42,36 @@ def renew_ip(starrs, addr):
4242
return results
4343

4444

45+
# Use various STARRS stored procedures to make sure the hostname is valid/available
4546
def check_hostname(starrs, hostname):
4647
c = starrs.cursor()
4748
try:
49+
# Check for invalid characters in hostname
4850
c.execute("BEGIN")
4951
c.callproc("api.initialize", ('root', ))
5052
c.callproc("api.validate_name", (hostname, ))
5153
c.execute("COMMIT")
54+
# Validate the entire domain name using Data::Validate::Domain
5255
c.execute("BEGIN")
5356
c.callproc("api.initialize", ('root', ))
5457
c.callproc("api.validate_domain", (hostname, 'csh.rit.edu'))
5558
valid = c.fetchall()[0][0]
5659
c.execute("COMMIT")
60+
# Check if the hostname is available (checks A/SRV/CNAME records)
5761
c.execute("BEGIN")
5862
c.callproc("api.initialize", ('root', ))
5963
c.callproc("api.check_dns_hostname", (hostname, 'csh.rit.edu'))
6064
available = False
6165
if not c.fetchall()[0][0]:
6266
available = True
6367
c.execute("COMMIT")
68+
# Check if the system name is taken
69+
c.execute("BEGIN")
70+
c.callproc("api.initialize", ('root', ))
71+
c.callproc("api.get_system", (hostname, ))
72+
if c.fetchall():
73+
available = False
74+
c.execute("COMMIT")
6475
except (psycopg2.InternalError):
6576
valid = False
6677
available = False

proxstar/user.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def usage(self):
7474
if 'status' in vm:
7575
vm = VM(vm['vmid'])
7676
if vm.status == 'running' or vm.status == 'paused':
77-
usage['cpu'] += int(vm.cpu * vm.config.get('sockets', 1))
77+
usage['cpu'] += int(vm.cpu)
7878
usage['mem'] += (int(vm.mem) / 1024)
7979
for disk in vm.disks:
8080
usage['disk'] += int(disk[1])

proxstar/vm.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,19 @@ def resume(self):
9999

100100
@lazy_property
101101
def info(self):
102+
return self.get_info()
103+
104+
@retry(wait=wait_fixed(2), stop=stop_after_attempt(5))
105+
def get_info(self):
102106
proxmox = connect_proxmox()
103107
return proxmox.nodes(self.node).qemu(self.id).status.current.get()
104108

105109
@lazy_property
106110
def config(self):
111+
return self.get_config()
112+
113+
@retry(wait=wait_fixed(2), stop=stop_after_attempt(5))
114+
def get_config(self):
107115
proxmox = connect_proxmox()
108116
return proxmox.nodes(self.node).qemu(self.id).config.get()
109117

0 commit comments

Comments
 (0)