Add database management with SQLAlchemy

Add management of the pvcprov database with SQLAlchemy, to allow
seamless management of the database. Add automatic tasks to the postinst
of the API to execute these migrations.
This commit is contained in:
2020-02-15 22:10:34 -05:00
parent 670596ed8e
commit 560cb609ba
9 changed files with 274 additions and 13 deletions

17
api-daemon/pvc-api-db-init Executable file
View File

@ -0,0 +1,17 @@
#!/bin/bash
# Initialize the PVC database and migrations for future upgrades
# Part of the Parallel Virtual Cluster (PVC) system
export PVC_CONFIG_FILE="/etc/pvc/pvcapid.yaml"
if [[ ! -f ${PVC_CONFIG_FILE} ]]; then
echo "Create a configuration file at ${PVC_CONFIG_FILE} before initializing the database."
exit 1
fi
pushd /usr/share/pvc
./pvcapid-manage.py db init
./pvcapid-manage.py db migrate
./pvcapid-manage.py db upgrade
popd