diff --git a/HACKING/.gitignore b/HACKING/.gitignore index d7a062b..cd3bed0 100644 --- a/HACKING/.gitignore +++ b/HACKING/.gitignore @@ -1,4 +1,6 @@ volume/ volume/* +.env.local .env +.env.ignore ssh_key \ No newline at end of file diff --git a/HACKING/docker-compose.yml b/HACKING/docker-compose.yml index 0ae4855..331e0ee 100644 --- a/HACKING/docker-compose.yml +++ b/HACKING/docker-compose.yml @@ -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: @@ -19,7 +21,7 @@ services: proxstar-rq-scheduler: build: context: .. - env_file: .env + env_file: .env.local entrypoint: ./start_scheduler.sh networks: - proxstar @@ -28,7 +30,7 @@ services: proxstar-rq: build: context: .. - env_file: .env + env_file: .env.local entrypoint: ./start_worker.sh networks: - proxstar @@ -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 diff --git a/proxstar/starrs.py b/proxstar/starrs.py index 14f4dec..5d1e663 100644 --- a/proxstar/starrs.py +++ b/proxstar/starrs.py @@ -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] @@ -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: @@ -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 @@ -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 @@ -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 @@ -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