lxd-api-gateway
RESTful API for LXD with USER access limitations
Use it with Dashboard
For installation actual version of lxdmanager-api-gateway you can use install.sh script.
# Download the script
curl https://raw.githubusercontent.com/Miso-K/lxd-api-gateway/master/install.sh > install.sh
# Set execution permissions
chmod +x install.sh
# Run script to install program
./install.sh
git clone --recursive https://github.com/Miso-K/lxd-api-gateway
# Installation require Redis DB for storing jwt tokens
apt install redis-server
# install python dependencies
apt update
apt install python3-pip python3-dev build-essential libssl-dev libffi-dev python3-setuptools
apt install python3-venv
cd lxd-api-gateway
# create virtual env
python3 -m venv lgw-env
# activate env
source lgw-env/bin/activate
pip install -r requirements.txt
nano config/default.py
nano lxdconfig.conf
python3 install/setup.py
Change "example.com" to your domain. * would make it accessible from everywhere.
sudo lxc config set core.https_address [::]:8443
sudo lxc config set core.https_allowed_origin "*.example.com"
sudo lxc config set core.https_allowed_methods "GET, POST, PUT, DELETE, OPTIONS"
sudo lxc config set core.https_allowed_headers "Content-Type"
sudo service lxd restart # sometimes is required
openssl genrsa -out lxd.key 4096 # Generate a private key.
openssl req -new -key lxd.key -out lxd.csr # Create a certificate request.
openssl x509 -req -days 3650 -in lxd.csr -signkey lxd.key -out lxd.crt # Generate an auto signed certificate.
lxc config trust add lxd.crt # Tells LXC to use this certificate for auth.
Copy lxd.crt and lxd.key to installation folder and edit lxdconfig.conf settings.
python3 run.py
gunicorn --bind :5000 app:app
uwsgi --socket :5000 --protocol=http --wsgi app:app
Set headers :
key | value |
---|---|
Content-Type |
application/json |
Authorization |
Bearer <token> |
- From your browser, get the swagger doc at http://localhost:5000/doc/
You can store instance configuration in instance/config.py
or
Set your own env var :
export LWP_CONFIG_FILE='/path/to/config/production.py'