mirror of
https://github.com/ComputerScienceHouse/proxstar.git
synced 2025-02-12 13:01:51 +00:00
Fix hardcoded variables, tweak schema/dockerfile
Change config.local.py to config_local.py Fix 2AM Willard Moments™ Made a few errors last night that should be corrected.
This commit is contained in:
parent
262b5b10eb
commit
74a0990997
18 changed files with 38 additions and 18814 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,4 +1,6 @@
|
|||
config_local.py
|
||||
config.local.py
|
||||
.env
|
||||
__pycache__/*
|
||||
*/__pycache__/*
|
||||
rrd/*
|
||||
|
|
|
@ -18,7 +18,7 @@ It is available to house members at [proxstar.csh.rit.edu](https://proxstar.csh.
|
|||
1. [Fork](https://help.github.com/en/articles/fork-a-repo) this repository
|
||||
- Optionally create a new [git branch](https://git-scm.com/book/en/v2/Git-Branching-Branches-in-a-Nutshell) if your change is more than a small tweak (`git checkout -b BRANCH-NAME-HERE`)
|
||||
3. Make your changes locally, commit, and push to your fork
|
||||
- If you want to test locally, you should copy `config.py` to `config.local.py`, and talk to an RTP about filling in secrets.
|
||||
- If you want to test locally, you should copy `config.py` to `config_local.py`, and talk to an RTP about filling in secrets.
|
||||
- Lint and format your local changes with `pylint proxstar` and `black proxstar`
|
||||
- You'll need dependencies installed locally to do this. You should do that in a [venv](https://packaging.python.org/tutorials/installing-packages/#creating-virtual-environments) of some sort to keep your system clean. All the dependencies are listed in [requirements.txt](./requirements.txt), so you can install everything with `pip install -r requirements.txt`. You'll need python 3.6 at minimum, though things should work up to python 3.8.
|
||||
4. Create a [Pull Request](https://help.github.com/en/articles/about-pull-requests) on this repo for our Webmasters to review
|
||||
|
|
|
@ -4,6 +4,10 @@ from os import environ
|
|||
VM_EXPIRE_MONTHS = int(environ.get('PROXSTAR_VM_EXPIRE_MONTHS', '3'))
|
||||
VNC_CLEANUP_TOKEN = environ.get('PROXSTAR_VNC_CLEANUP_TOKEN', '')
|
||||
|
||||
# Development options
|
||||
USE_STARRS = environ.get('PROXSTAR_USE_STARRS', 'True')
|
||||
FORCE_STANDARD_USER = environ.get('PROXSTAR_FORCE_STANDARD_USER', 'False')
|
||||
|
||||
# Flask
|
||||
IP = environ.get('PROXSTAR_IP', '0.0.0.0')
|
||||
PORT = environ.get('PROXSTAR_PORT', '5000')
|
||||
|
@ -25,6 +29,7 @@ PROXMOX_HOSTS = [host.strip() for host in environ.get('PROXSTAR_PROXMOX_HOSTS',
|
|||
PROXMOX_USER = environ.get('PROXSTAR_PROXMOX_USER', '')
|
||||
PROXMOX_PASS = environ.get('PROXSTAR_PROXMOX_PASS', '')
|
||||
PROXMOX_ISO_STORAGE = environ.get('PROXSTAR_PROXMOX_ISO_STORAGE', 'nfs-iso')
|
||||
PROXMOX_VM_STORAGE = environ.get('PROXSTAR_PROXMOX_VM_STORAGE', 'ceph')
|
||||
PROXMOX_SSH_USER = environ.get('PROXSTAR_PROXMOX_SSH_USER', '')
|
||||
PROXMOX_SSH_KEY = environ.get('PROXSTAR_PROXMOX_SSH_KEY', '')
|
||||
PROXMOX_SSH_KEY_PASS = environ.get('PROXSTAR_PROXMOX_SSH_KEY_PASS', '')
|
||||
|
|
|
@ -11,7 +11,7 @@ If you want to work on Proxstar using a 1:1 development setup, there are a coupl
|
|||
|
||||
1. Configure your Proxmox node
|
||||
|
||||
I would recommend setting up a development account on your Proxmox node. Name it anything. (Maybe `proxstartest`?). This is necessary to grab authentication tokens and the like. It should have the same permissions as `root@pam`. If you do this, then it's easy to enable/disable it for development. You should also generate an SSH key for the user.
|
||||
I would recommend setting up a development account on your Proxmox node. Name it anything. (Maybe `proxstartest`?). This is necessary to grab authentication tokens and the like. It should have the same permissions as `root@pam`. You can accomplish this by creating a group in `Datacenter > Permissions > Groups` and adding `Administrator` permissions to the group, then adding your user to the group. If you do this, then it's easy to enable/disable it for development. You should also generate an SSH key for the user.
|
||||
|
||||
You will also have to set up a pool on your Proxmox node with your csh username. To do this, go into `Datacenter > Permissions > Pools > Create`.
|
||||
|
||||
|
@ -30,10 +30,10 @@ pip install -r requirements.txt
|
|||
pip install click==7.1.2
|
||||
pip install python-dotenv
|
||||
```
|
||||
Fill out the required fields in your config.local.py file. Some of this you might have to come back to after you run the docker compose.
|
||||
Fill out the required fields in your config_local.py file. Some of this you might have to come back to after you run the docker compose.
|
||||
```
|
||||
cp config.py config.local.py
|
||||
vim config.local.py
|
||||
cp config.py config_local.py
|
||||
vim config_local.py
|
||||
```
|
||||
|
||||
(Here's some advice on how to fill out your config file.)
|
||||
|
@ -178,14 +178,18 @@ docker-compose up -d
|
|||
|
||||
Restore the databse in your new podman container. This might throw a TON of errors, but don't worry about it.
|
||||
```
|
||||
psql postgresql://postgres:********@10.69.69.69
|
||||
CREATE DATABASE proxstar;
|
||||
CREATE DATABASE starrs;
|
||||
quit;
|
||||
echo 'CREATE DATABASE proxstar; CREATE DATABASE starrs; CREATE ROLE proxstar; CREATE ROLE starrs;' | psql postgresql://postgres:********@10.69.69.69
|
||||
|
||||
pg_restore -U postgres -d proxstar -1 proxstar_schema_willard -h localhost
|
||||
psql postgresql://postgres:tits12348@10.10.51.185/starrs < harmon_starrs.db
|
||||
# psql postgresql://postgres:tits12348@10.10.51.185/proxstar < restore_proxstar.sql # Probably unnecessary
|
||||
cat developing/schema/starrs/restore.sql | psql postgresql://postgres:********@10.69.69.69
|
||||
cat developing/schema/proxstar/restore.sql | psql postgresql://postgres:********@10.69.69.69
|
||||
```
|
||||
|
||||
Get a shell in your postgres real quick and install a perl thing.
|
||||
|
||||
```
|
||||
docker exec -it developing_proxstar-postgres_1 bash
|
||||
cpan
|
||||
install Data::Validate::Domain
|
||||
```
|
||||
|
||||
Now, you should be ready to run your dev instance. I like to use `tmux` for this to run proxstar and the `rq worker` in separate panes.
|
||||
|
|
|
@ -3,4 +3,6 @@ FROM postgres:12
|
|||
RUN apt-get update \
|
||||
&& apt-get install -y postgresql-plperl-12 \
|
||||
&& apt-get install -y postgresql-plpython3-12 \
|
||||
&& apt-get install -y libnet-ip-perl perl-net libnet-ldap-perl libnet-dns-perl libnet-snmp-perl libnet-server-mail-perl libcrypt-des-perl \
|
||||
&& apt-get install -y libperl-dev build-essential \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
|
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -4,8 +4,8 @@ import subprocess
|
|||
from flask import Flask
|
||||
|
||||
app = Flask(__name__)
|
||||
if os.path.exists(os.path.join(app.config.get('ROOT_DIR', os.getcwd()), "config.local.py")):
|
||||
config = os.path.join(app.config.get('ROOT_DIR', os.getcwd()), "config.local.py")
|
||||
if os.path.exists(os.path.join(app.config.get('ROOT_DIR', os.getcwd()), "config_local.py")):
|
||||
config = os.path.join(app.config.get('ROOT_DIR', os.getcwd()), "config_local.py")
|
||||
else:
|
||||
config = os.path.join(app.config.get('ROOT_DIR', os.getcwd()), "config.py")
|
||||
app.config.from_pyfile(config)
|
||||
|
|
|
@ -158,6 +158,8 @@ def list_vms(user_view=None):
|
|||
user = User(session['userinfo']['preferred_username'])
|
||||
rtp_view = False
|
||||
connect_proxmox()
|
||||
if eval(app.config['FORCE_STANDARD_USER']):
|
||||
user.rtp = False
|
||||
if user_view and not user.rtp:
|
||||
abort(403)
|
||||
elif user_view and user.rtp:
|
||||
|
|
|
@ -60,7 +60,8 @@ def get_vm_node(proxmox, vmid):
|
|||
|
||||
def get_isos(proxmox, storage):
|
||||
isos = []
|
||||
for iso in proxmox.nodes('proxmox01').storage(storage).content.get():
|
||||
first_node = app.config['PROXMOX_HOSTS'][0].split('.')[0] # Get the name of the first node.
|
||||
for iso in proxmox.nodes(first_node).storage(storage).content.get():
|
||||
isos.append(iso['volid'].split('/')[1])
|
||||
return isos
|
||||
|
||||
|
|
|
@ -83,11 +83,12 @@ def create_vm_task(user, name, cores, memory, disk, iso):
|
|||
set_job_status(job, 'failed to provision')
|
||||
delete_vm_task(vmid)
|
||||
return
|
||||
logging.info('[{}] Registering in STARRS.'.format(name))
|
||||
set_job_status(job, 'registering in STARRS')
|
||||
vm = VM(vmid)
|
||||
ip = get_next_ip(starrs, app.config['STARRS_IP_RANGE'])
|
||||
register_starrs(starrs, name, app.config['STARRS_USER'], vm.get_mac(), ip)
|
||||
if (eval(app.config['USE_STARRS'])):
|
||||
logging.info('[{}] Registering in STARRS.'.format(name))
|
||||
set_job_status(job, 'registering in STARRS')
|
||||
ip = get_next_ip(starrs, app.config['STARRS_IP_RANGE'])
|
||||
register_starrs(starrs, name, app.config['STARRS_USER'], vm.get_mac(), ip)
|
||||
set_job_status(job, 'setting VM expiration')
|
||||
get_vm_expire(db, vmid, app.config['VM_EXPIRE_MONTHS'])
|
||||
vm.set_boot_order(['Hard Disk', 'CD-ROM', 'Network'])
|
||||
|
|
|
@ -250,8 +250,8 @@ def create_vm(proxmox, user, name, cores, memory, disk, iso):
|
|||
name=name,
|
||||
cores=cores,
|
||||
memory=memory,
|
||||
storage='ceph',
|
||||
virtio0='ceph:{}'.format(disk),
|
||||
storage=app.config['PROXMOX_VM_STORAGE'],
|
||||
virtio0='{}:{}'.format(app.config['PROXMOX_VM_STORAGE'], disk),
|
||||
ide2='{},media=cdrom'.format(iso),
|
||||
net0='virtio,bridge=vmbr0',
|
||||
pool=user,
|
||||
|
|
Loading…
Reference in a new issue