Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Miso-K/lxd-api-gateway
LXD API gateway that adds user management options and provide API backend for lxdmanager
https://github.com/Miso-K/lxd-api-gateway
Last synced: 4 months ago
JSON representation
LXD API gateway that adds user management options and provide API backend for lxdmanager
- Host: GitHub
- URL: https://github.com/Miso-K/lxd-api-gateway
- Owner: Miso-K
- License: mit
- Created: 2019-07-11T09:27:41.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-05-01T20:15:53.000Z (almost 2 years ago)
- Last Synced: 2024-07-31T19:29:15.009Z (6 months ago)
- Language: Python
- Homepage:
- Size: 130 KB
- Stars: 16
- Watchers: 4
- Forks: 4
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
lxd-api-gateway
RESTful API for LXD with USER access limitations
Use it with [Dashboard](https://github.com/Miso-K/lxdmanager-vue-dashboard)
[![Python version](https://img.shields.io/badge/Python-3.7-blue.svg)](https://www.python.org/downloads/release/python-350/)
---
## Installation
For installation actual version of *lxdmanager-api-gateway* you can use *install.sh* script.
``` bash
# 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
```### Manual installation
```shell
git clone --recursive https://github.com/Miso-K/lxd-api-gateway
```### Install requirements
```shell
# 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-venvcd lxd-api-gateway
# create virtual env
python3 -m venv lgw-env# activate env
source lgw-env/bin/activatepip install -r requirements.txt
```### Change secret key to unique
``` shell
nano config/default.py
```### Update lxdconfig.conf
```
nano lxdconfig.conf
```### Create database
```shell
python3 install/setup.py
```---
### LXD host settings
Change "example.com" to your domain. * would make it accessible from everywhere.
```shell
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
```#### Generate authentication certificates (Self Signed)
```
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.
---
### Run the server
#### Werkzeug *(dev only)*
```shell
python3 run.py
```#### Gunicorn
```shell
gunicorn --bind :5000 app:app
```#### uWSGI
```shell
uwsgi --socket :5000 --protocol=http --wsgi app:app
```---
## Usage
### RequestsSet headers :
| key | value |
| :-------------- | :----------------- |
| `Content-Type` | `application/json` |
| `Authorization` | `Bearer ` |---
## Documentation
* From your browser, get the swagger doc at [http://localhost:5000/doc/](http://localhost:5000/doc/)
## Configuration
You can store instance configuration in `instance/config.py`or
Set your own env var :
`export LWP_CONFIG_FILE='/path/to/config/production.py'`