Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: rogergithub3/admin
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: tesla-project/admin
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Able to merge. These branches can be automatically merged.
  • 2 commits
  • 1,410 files changed
  • 2 contributors

Commits on Aug 1, 2019

  1. Code release

    xbaro committed Aug 1, 2019
    Copy the full SHA
    24e12f8 View commit details

Commits on Sep 19, 2019

  1. update readme.md

    rogergithub3 authored Sep 19, 2019
    Copy the full SHA
    5679926 View commit details
Showing 1,410 changed files with 412,752 additions and 2 deletions.
20 changes: 20 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
DB_HOST=database
DB_PASSWORD=test
DB_USER=tesla
DB_NAME=admin
DB_PORT=5432

INSTRUMENT_PORT=443
TEP_URL=https://tep.tesla.xbaro.eu
TEP_PORT=443
USE_STDOUT=1
LOGS_FOLDER=/var/logs/
SECRET_PREFIX=ADMIN

INSTITUTION=UOC
COUNTRY=ES
DOMAIN=tesla.xbaro.eu

BROKER_URL=http://localhost
BROKER_PORT=443
BROKER_API_BASE=/api/v1/
5 changes: 5 additions & 0 deletions .env_console
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PYTHONUNBUFFERED=1
FLASK_APP=manage.py
DB_NAME=admin
DB_USER=tesla
DB_PASSWORD=test
115 changes: 115 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
# Created by .ignore support plugin (hsz.mobi)
### Python template
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/

# Translations
*.mo
*.pot

# Django stuff:
*.log
.static_storage/
.media/
local_settings.py

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
#.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.idea/
!/tesla_admin/messages.pot
!/tesla_admin/static/vendor/messenger-hubspot/build/
!/tesla_admin/static/vendor/messenger-hubspot/lib/
/data/
certs/
/data_admin/conf_repo/

venv3/
17 changes: 17 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
before_script:
- python -V
- docker info
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
- git submodule init tesla_models
- git submodule update tesla_models
- cd tesla_models
- git pull origin master
- cd ..

build-images:
stage: build
script:
- docker build --pull --no-cache -t "$CI_REGISTRY_IMAGE" -f docker/Dockerfile .
- docker push "$CI_REGISTRY_IMAGE"
only:
- master
104 changes: 102 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,102 @@
# admin
TeSLA Administration
# TeSLA Administration (ADMIN)

---

## Synopsis
The TeSLA Administration is a module that manage the institution part of TeSLA.

---

## Configuration

The environment variables used by ADMIN are:

### General Admin configuration
* SECRET_KEY=secret_key
* DEBUG=False
* CONFIG=production
* SECRET_PREFIX=secret_prefix
* TMP_PATH=/tmp
* CERT_PATH=/run/secrets/
* USE_REDIS=0
* COUNTRY=ES
* MODULE_NAME=ADMIN
* DOMAIN=domain.tesla-project.eu
* INSTITUTION=institution acronym

### Enable or disable the use of local JS and CSS
* USE_LOCAL_LIBS=0

### Logging options
* LOG_LEVEL=INFO
* USE_FILE_ROTATING_LOG=1
* LOGS_FOLDER=/logs
* LOG_ROTATE_MAX_BYTES=20971520
* LOG_ROTATE_BACKUP_COUNT=5
* LOG_FILE=tesla_admin.log
* USE_ES_LOGS=0
* USE_STDOUT=1

### Celery properties
* USE_CELERY=1
* CELERY_TIMEZONE = 'Europe/Berlin'

### Initial administration account
* ADMIN_MAIL = 'xbaro@uoc.edu'
* ADMIN_PASSWORD = 'admin'

### Database
* DB_PORT=5432
* DB_USER=db_user
* DB_NAME=db_name
* DB_PASSWORD=db_password
* DB_HOST=db_host
* DB_SCHEMA=db_schema

### TEP Database
* TEP_DB_NAME=tep_db_name
* TEP_DB_HOST=tep_db_host
* TEP_DB_PASSWORD=tep_db_password
* TEP_DB_USER=tep_db_user
* TEP_DB_PORT=tep_db_port
* TEP_DB_ENGINE=tep_db_engine

### Git repository configuration
* USE_GIT_CONFIG=0
* GIT_WORKING_PATH=./data_admin/conf_repo/
* GIT_USER=git_user
* GIT_PASSWORD=git_password
* GIT_REPOSITORY=git_repository

### Rabbit MQ configuration
* RABBITMQ_PASSWORD=RABBIT_PASSWORD
* RABBITMQ_MANAGER_PORT=15672
* RABBITMQ_PORT=5672
* RABBITMQ_USER=RABBIT_USER
* RABBITMQ_VHOST=/
* RABBITMQ_HOST=rabbit

### TIP configuration
* TIP_URL=https://tipurl.eu

---


## Installation

.env file has all the environment variables used by the ADMIN, and docker-compose configuration file shows how to setup an instance of the ADMIN and required database.

Docker compose assigns the .env variables to different containers.



---

## Contributors
- Xavier Baró <xbaro@uoc.edu>
- Roger Muñoz <rmunozber@uoc.edu>
- David Gañan <dganan@uoc.edu>

---
## License
This software is released under AGPL-3.0 license
25 changes: 25 additions & 0 deletions bin/run_service.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env python

# TeSLA Admin
# Copyright (C) 2019 Universitat Oberta de Catalunya
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

from tesla_admin import app, logger

instrument_port = app.config['INSTRUMENT_PORT']

if __name__ == '__main__':
logger.info("SERVICE STARTED")
app.run(host='0.0.0.0', port=instrument_port, debug=True, use_reloader=False)
25 changes: 25 additions & 0 deletions bin/start_service.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash

if [ "$USE_GIT_CONFIG" -eq 0 ]; then
echo "Waiting for database connection..."
until nc -z -v -w30 $DB_HOST $DB_PORT
do
sleep 1
done
else
cp /app/data/certs/modules/admin.${DOMAIN}/cert.pem /run/secrets/${SECRET_PREFIX}SERVER_CERT
cp /app/data/certs/modules/admin.${DOMAIN}/key.pem /run/secrets/${SECRET_PREFIX}SERVER_KEY
cp /app/data/certs/deploy-manager/ca.pem /run/secrets/${SECRET_PREFIX}SERVER_CA
fi

# Perform migrations
flask db upgrade

# Start uwsgi
uwsgi --emperor /etc/uwsgi/emperor.ini &

# Initialize Nginx configuration
envsubst '${INSTRUMENT_PORT}:${SECRET_PREFIX}' < /app/nginx.vh.default.conf > /etc/nginx/conf.d/default.conf

# Start Nginx
nginx
Loading