mirror of
https://git.isptech.ru/ISPsystem/isp-maintenance.git
synced 2025-09-13 14:43:08 +02:00
Update: dockerize app, rename pkg to mgrctl, fix imports
This commit is contained in:
15
mgrctl/settings/__init__.py
Normal file
15
mgrctl/settings/__init__.py
Normal file
@@ -0,0 +1,15 @@
|
||||
from mgrctl.settings.general import BASE_DIR
|
||||
|
||||
from mgrctl.settings.platform import (
|
||||
PLATFORM_TYPE,
|
||||
PLATFORM_URL,
|
||||
PLATFORM_CONFIG
|
||||
)
|
||||
|
||||
from mgrctl.settings.db import(
|
||||
DB_ENGINE,
|
||||
DB_HOST,
|
||||
DB_PORT,
|
||||
DB_USER,
|
||||
DB_PASSWORD
|
||||
)
|
10
mgrctl/settings/api.py
Normal file
10
mgrctl/settings/api.py
Normal file
@@ -0,0 +1,10 @@
|
||||
from mgrctl.settings.platform import PLATFORM_TYPE
|
||||
|
||||
# Name of nginx container:
|
||||
INPUT_HOSTNAME = 'input' if PLATFORM_TYPE == 'vm' else 'dci_input_1'
|
||||
|
||||
# Port that nginx container is listening:
|
||||
INPUT_PORT = '1500'
|
||||
|
||||
# Headers for internal auth:
|
||||
HEADERS = {"Internal-Auth": "on", "Accept": "application/json"}
|
23
mgrctl/settings/db.py
Normal file
23
mgrctl/settings/db.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from mgrctl.settings.environment import env
|
||||
from mgrctl.settings.platform import PLATFORM_CONFIG
|
||||
|
||||
|
||||
# ! Required because some instance use psql db:
|
||||
DB_ENGINE = env.str(
|
||||
'DB_ENGINE',
|
||||
PLATFORM_CONFIG.get('DatabaseType', 'mysql')
|
||||
)
|
||||
|
||||
# Connection parameters:
|
||||
DB_HOST = env.str(
|
||||
'DB_HOST',
|
||||
PLATFORM_CONFIG.get('DatabaseType', 'mysql')
|
||||
)
|
||||
DB_PORT = env.int('DB_PORT', 3306)
|
||||
DB_USER = env.str('DB_USER', 'root')
|
||||
|
||||
# ! Do not pass password on production. Use value from config.json
|
||||
DB_PASSWORD = env.str(
|
||||
'DB_PASSWORD',
|
||||
PLATFORM_CONFIG.get('MysqlRootPassword', '')
|
||||
)
|
9
mgrctl/settings/environment.py
Normal file
9
mgrctl/settings/environment.py
Normal file
@@ -0,0 +1,9 @@
|
||||
from environs import Env
|
||||
|
||||
|
||||
# Init environment:
|
||||
env = Env()
|
||||
|
||||
# read .env file, if it exists
|
||||
# reed more about .env file here: https://github.com/sloria/environs
|
||||
env.read_env()
|
14
mgrctl/settings/general.py
Normal file
14
mgrctl/settings/general.py
Normal file
@@ -0,0 +1,14 @@
|
||||
import pathlib
|
||||
|
||||
|
||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||
BASE_DIR = pathlib.Path(__file__).resolve().parent.parent
|
||||
|
||||
INSTALLED_APPS = {
|
||||
'vm6': {
|
||||
'auth': 'mgrctl.apps.vm6.auth.commands.cli',
|
||||
},
|
||||
'dci6': {
|
||||
'auth': 'mgrctl.apps.dci6.auth.commands.cli',
|
||||
},
|
||||
}
|
17
mgrctl/settings/platform.py
Normal file
17
mgrctl/settings/platform.py
Normal file
@@ -0,0 +1,17 @@
|
||||
from mgrctl.settings.environment import env
|
||||
from mgrctl.utils.helpers import parse_json_file
|
||||
|
||||
|
||||
PLATFORM_TYPE = env.str('PLATFORM_TYPE', 'vm')
|
||||
|
||||
PLATFORM_CONFIG = env.str(
|
||||
'PLATFORM_CONFIG',
|
||||
f'/opt/ispsystem/{PLATFORM_TYPE}/config.json'
|
||||
)
|
||||
|
||||
PLATFORM_CONFIG = parse_json_file(PLATFORM_CONFIG)
|
||||
|
||||
PLATFORM_URL = env.url(
|
||||
'PLATFORM_URL',
|
||||
f"https://{PLATFORM_CONFIG.get('DomainName' ,'replace.me')}"
|
||||
)
|
Reference in New Issue
Block a user