TODO merge with devicehub | devicehub adapted to trustchain oc1 orchestral (dpp branch)
This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
Go to file
Cayo Puigdefabregas cf5150b7c9 fix lots 2023-03-10 21:15:00 +01:00
.github Run selenium only on reviews 2022-09-29 12:11:10 +02:00
docs clean 2022-11-24 12:21:42 +01:00
ereuse_devicehub fix lots 2023-03-10 21:15:00 +01:00
examples add token to user registration and admin email 2022-10-19 18:55:34 +02:00
scripts remove script 2022-12-20 13:37:17 +01:00
tests fix test render 2023-02-28 17:25:42 +01:00
.babelrc.json use babel to support old browsers 2022-05-09 11:07:57 +02:00
.eslintignore ESLint ignore builded JS files 2022-05-11 19:07:52 +02:00
.eslintrc.json eslint avoid class limit 2022-05-13 21:29:29 +02:00
.gitignore add ignore files 2022-11-02 09:57:50 +01:00
.pre-commit-config.yaml Add pip-compile pre-commit hook 2022-09-29 12:22:22 +02:00
.prettierrc.json add prettier rule 2022-04-20 11:55:15 +02:00
CHANGELOG.md add settings version to snapshots model 2022-11-30 16:25:11 +01:00
CONTRIBUTING.md Manage dependencies using pip-tools 2022-09-29 12:11:10 +02:00
LICENSE.txt Add GPLV3 License 2019-06-09 08:48:09 +02:00
MANIFEST.in Better installation; add example_app 2018-07-07 18:51:15 +02:00
README.md Fix typo. 2022-06-07 11:16:20 +02:00
alembic.ini Update README 2020-05-15 20:14:00 +02:00
development-setup.md Remove duplicated setup steps 2022-04-12 12:32:20 +02:00
licences.txt fixing bug of 2 users with the same device and launch one live 2021-01-08 10:46:34 +01:00
package.json Fix build-js pre-commit hook 2022-09-29 12:04:05 +02:00
pyproject.toml Fix black & isort compatibility config on pre-commit 2022-03-08 10:04:59 +01:00
requirements-dev.txt Move selenium to requirements-dev.txt 2022-07-15 12:03:06 +02:00
requirements-prod.txt Move sentry & blinker to requirements-prod.txt 2022-07-15 11:59:06 +02:00
requirements.in fix requirements 2022-10-20 17:41:06 +02:00
requirements.txt fix requirements 2022-10-20 17:41:06 +02:00
setup.cfg Enhance testing config 2018-09-16 15:56:20 +02:00
setup.py change config to set readme.md instead of rst 2022-04-04 17:23:25 +02:00
tox.ini Add pre-commit hook to run black, flake8 & isort 2022-02-10 14:05:26 +01:00

README.md

Devicehub

Devicehub is a distributed IT Asset Management System focused in reusing devices, created under the project eReuse.org

This README explains how to install and use Devicehub. The documentation explains the concepts and the API.

Devicehub is built with Teal and Flask.

Installing

The requirements are:

Install Devicehub with pip: pip3 install -U -r requirements.txt -e .

Running

Create a PostgreSQL database called devicehub by running create-db:

  • In Linux, execute the following two commands (adapt them to your distro):

    1. sudo su - postgres.
    2. bash examples/create-db.sh devicehub dhub, and password ereuse.
  • In MacOS: bash examples/create-db.sh devicehub dhub, and password ereuse.

Configure project using environment file (you can use provided example as quickstart):

$ cp examples/env.example .env

Using the dh tool for set up with one or multiple inventories. Create the tables in the database by executing:

$  export dhi=dbtest;  dh inv add --common --name dbtest

Finally, run the app:

$ export dhi=dbtest;dh run --debugger

The error bdist_wheel can happen when you work with a virtual environment. To fix it, install in the virtual environment wheel package. pip3 install wheel

Multiple instances

Devicehub can run as a single inventory or with multiple inventories, each inventory being an instance of the devicehub. To add a new inventory execute:

$ export dhi=dbtest;  dh inv add --name dbtest

Note: The dh command is like flask, but it allows you to create and delete instances, and interface to them directly.

Testing

  1. git clone this project.
  2. Create a database for testing executing create-db.sh like the normal installation but changing the first parameter from devicehub to dh_test: create-db.sh dh_test dhub and password ereuse.
  3. Execute at the root folder of the project python3 setup.py test.

Migrations

At this stage, migration files are created manually. Set up the database:

$ sudo su - postgres
$ bash $PATH_TO_DEVIHUBTEAL/examples/create-db.sh devicehub dhub

Initialize the database:

$ export dhi=dbtest; dh inv add --common --name dbtest

This command will create the schemas, tables in the specified database. Then we need to stamp the initial migration.

$ alembic stamp head

This command will set the revision fbb7e2a0cde0_initial as our initial migration. For more info in migration stamping please see https://alembic.sqlalchemy.org/en/latest/cookbook.html

Whenever a change needed eg to create a new schema, alter an existing table, column or perform any operation on tables, create a new revision file:

$ alembic revision -m "A table change"

This command will create a new revision file with name <revision_id>_a_table_change. Edit the generated file with the necessary operations to perform the migration:

$ alembic edit <revision_id>

Apply migrations using:

$ alembic -x inventory=dbtest upgrade head

Then to go back to previous db version:

$ alembic -x inventory=dbtest downgrade <revision_id>

To see a full list of migrations use

$ alembic history

Upgrade a deployment

For upgrade an instance of devicehub you need to do:

$ cd $PATH_TO_DEVIHUBTEAL
$ source venv/bin/activate
$ git pull
$ alembic -x inventory=dbtest upgrade head

If all migrations pass successfully, then it is necessary restart the devicehub. Normaly you can use a little script for restart.

# sh gunicorn_api.sh

Generating the docs

  1. git clone this project.
  2. Install plantuml. In Debian 9 is # apt install plantuml.
  3. Execute pip3 install -e .[docs] in the project root folder.
  4. Go to <project root folder>/docs and execute make html. Repeat this step to generate new docs.

To auto-generate the docs do pip3 install -e .[docs-auto], then execute, in the root folder of the project sphinx-autobuild docs docs/_build/html.