From ddaf9aa379c34159763dbb0b5e9949c0f71c4297 Mon Sep 17 00:00:00 2001 From: Will Nilges Date: Wed, 13 Jul 2022 22:58:00 -0400 Subject: [PATCH] Fix Joe's complaints --- HACKING/README.md | 72 +++++++++++++++++++++++++++++++---------------- README.md | 15 +--------- proxstar/vnc.py | 4 +-- 3 files changed, 51 insertions(+), 40 deletions(-) diff --git a/HACKING/README.md b/HACKING/README.md index 4e234e6..04df1c5 100644 --- a/HACKING/README.md +++ b/HACKING/README.md @@ -1,31 +1,24 @@ -## Setting up a full dev environment +# Contributing +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`) -If you want to work on Proxstar using a 1:1 development setup, there are a couple things you're going to need +2. Follow the _Podman Environment Instructions_ to set up a Podman dev environment. If you'd like to run Proxstar entirely on your own hardware, check out _Setting up a full dev environment_ -- A machine you can - - SSH into - - With portforwarding (see `man ssh` for info on the `-L` option) - - and run - - Flask - - Redis - - Docker -- At least one (1) Proxmox host running Proxmox >6.3 -- A CSH account -- An RTP (to tell you secrets) - -1. Configure your Proxmox node (Not required if you're using the CSH cluster) - -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. - -When you log into your Proxstar instance, it should auto-create the pool. If for some reason it doesn't, you can set up a pool on your Proxmox node with your CSH username. To do this, go into `Datacenter > Permissions > Pools > Create`. - -2. Set up your environment - -If you're trying to run this all on a VM without a graphical web browser, you can forward traffic to your computer using SSH. +3. Create a Virtualenv to do your linting in ``` -ssh example@dev-server.csh.rit.edu -L 8000:localhost:8000 +mkdir venv +python3.8 -m venv venv +source venv/bin/activate ``` -# New Deployment Instructions + +4. Make your changes locally, commit, and push to your fork + - If you want to test locally, you should copy `HACKING/.env.sample` to `HACKING/.env`, 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. + +5. Create a [Pull Request](https://help.github.com/en/articles/about-pull-requests) on this repo for our Webmasters to review + +### Podman Environment Instructions 1. Build your containers. The `proxstar` container serves as proxstar, rq, rq-scheduler, and VNC. The `proxstar-postgres` container sets up the database schema. @@ -44,3 +37,34 @@ ssh example@dev-server.csh.rit.edu -L 8000:localhost:8000 4. To stop all containers, use the provided script `./HACKING/stop_env.sh` + +## Setting up a full dev environment + +If you want to work on Proxstar using a 1:1 development setup, there are a couple things you're going to need + +- A machine you can + - SSH into + - With portforwarding (see `man ssh` for info on the `-L` option) + - and run + - Podman + - Flask + - Redis + - Postgres + - RQ +- At least one (1) Proxmox host running Proxmox >6.3 +- A CSH account +- An RTP (to tell you secrets) + +1. Configure your Proxmox node (Not required if you're using the CSH cluster) + +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. + +When you log into your Proxstar instance, it should auto-create the pool. If for some reason it doesn't, you can set up a pool on your Proxmox node with your CSH username. To do this, go into `Datacenter > Permissions > Pools > Create`. + +2. Set up your environment + +If you're trying to run this all on a VM without a graphical web browser, you can forward traffic to your computer using SSH. +``` +ssh example@dev-server.csh.rit.edu -L 8000:localhost:8000 +``` + diff --git a/README.md b/README.md index d3aa792..44bc855 100644 --- a/README.md +++ b/README.md @@ -15,20 +15,7 @@ It is available to house members at [proxstar.csh.rit.edu](https://proxstar.csh. ## Contributing -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`) -2. Create a Virtualenv to do your work in. -``` -mkdir venv -python3.8 -m venv venv -source venv/bin/activate -``` - -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. - - 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 +Check out `HACKING/` for more info. ## Questions/Concerns diff --git a/proxstar/vnc.py b/proxstar/vnc.py index 8d9180e..7a14fb4 100644 --- a/proxstar/vnc.py +++ b/proxstar/vnc.py @@ -81,7 +81,7 @@ def open_vnc_session(vmid, node, proxmox_user, proxmox_pass): # TODO (willnilges): Report errors data = {'username': proxmox_user, 'password': proxmox_pass} response_data = requests.post( - f'https://{node}.csh.rit.edu:8006/' + 'api2/json/access/ticket', + f'https://{node}.csh.rit.edu:8006/api2/json/access/ticket', verify=False, data=data, ).json()['data'] @@ -103,7 +103,7 @@ def open_vnc_session(vmid, node, proxmox_user, proxmox_pass): return urllib.parse.quote_plus(vncproxy_response_data['ticket']), vncproxy_response_data['port'] - +@deprecated('No longer in use') def start_ssh_tunnel(node, port): """Forwards a port on a node to the proxstar container