Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions HACKING/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
volume/
volume/*
.env.local
.env
.env.ignore
ssh_key
8 changes: 5 additions & 3 deletions HACKING/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ services:
context: ./proxstar-postgres
environment:
POSTGRES_PASSWORD: changeme
ports:
- "5432:5432"
volumes:
- ./proxstar-postgres/volume:/var/lib/postgresql/data:Z
networks:
Expand All @@ -19,7 +21,7 @@ services:
proxstar-rq-scheduler:
build:
context: ..
env_file: .env
env_file: .env.local
entrypoint: ./start_scheduler.sh
networks:
- proxstar
Expand All @@ -28,7 +30,7 @@ services:
proxstar-rq:
build:
context: ..
env_file: .env
env_file: .env.local
entrypoint: ./start_worker.sh
networks:
- proxstar
Expand All @@ -40,7 +42,7 @@ services:
ports:
- "8000:8000"
- "8001:8001"
env_file: .env
env_file: .env.local
entrypoint: ["gunicorn", "proxstar:app", "--bind=0.0.0.0:8000"]
networks:
- proxstar
Expand Down
19 changes: 18 additions & 1 deletion proxstar/starrs.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ def get_next_ip(starrs, range_name):
c.callproc('api.get_address_from_range', (range_name,))
results = c.fetchall()
c.execute('COMMIT')
except Exception as e:
print(e)
starrs.rollback()
finally:
c.close()
return results[0][0]
Expand All @@ -22,6 +25,9 @@ def get_ip_for_mac(starrs, mac):
c.callproc('api.get_system_interface_addresses', (mac.lower(),))
results = c.fetchall()
c.execute('COMMIT')
except Exception as e:
print(e)
starrs.rollback()
finally:
c.close()
if not results:
Expand All @@ -37,6 +43,9 @@ def renew_ip(starrs, addr):
c.callproc('api.renew_interface_address', (addr,))
results = c.fetchall()
c.execute('COMMIT')
except Exception as e:
print(e)
starrs.rollback()
finally:
c.close()
return results
Expand Down Expand Up @@ -72,9 +81,11 @@ def check_hostname(starrs, hostname):
if c.fetchall():
available = False
c.execute('COMMIT')
except psycopg2.InternalError:
except Exception as e:
print(e)
valid = False
available = False
starrs.rollback()
finally:
c.close()
return valid, available
Expand All @@ -95,6 +106,9 @@ def register_starrs(starrs, name, owner, mac, addr):
c.callproc('api.initialize', ('root',))
c.callproc('api.modify_system', (name, 'comment', f'Owned by {owner}'))
c.execute('COMMIT')
except Exception as e:
print(e)
starrs.rollback()
finally:
c.close()
return results
Expand All @@ -108,6 +122,9 @@ def delete_starrs(starrs, name):
c.callproc('api.remove_system', (name,))
results = c.fetchall()
c.execute('COMMIT')
except Exception as e:
print(e)
starrs.rollback()
finally:
c.close()
return results
Loading