-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.py
114 lines (102 loc) · 3.2 KB
/
config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# -*- coding:utf-8 -*-
# !/usr/bin/env python
#
# Author: Shawn.T, Leann Mak
# Email: [email protected], [email protected]
# This is the config file of global package of promise.
import os
basedir = os.path.abspath(os.path.dirname('..'))
"""
database configuration
"""
# database access string setting, by default we use mysql
# for common using
SQLALCHEMY_DATABASE_URI = 'mysql://[email protected]:3306/common'
# SQLALCHEMY_POOL_RECYCLE = 3600
# for eater:
SQLALCHEMY_BINDS = {
'eater': 'mysql://[email protected]:3306/common'
}
# when testing, put your instance setting in instance/config.py to cover it
# SQLALCHEMY_DATABASE_URI = 'mysql://root:[email protected]:3306/dev4test'
# ADVISE:create instance/config.py, your sqlite setting might like this:
# get some folders and dirs:
# import os
basedir = os.path.abspath(os.path.dirname('..'))
DB_FOLDER = os.path.join(basedir, '.data')
DB_FILE = 'app.db'
DB_SOURCEFILE = 'data.sql'
DB_FILEPATH = os.path.join(DB_FOLDER, DB_FILE)
DB_SOURCEFILEPATH = os.path.join(DB_FOLDER, DB_SOURCEFILE)
# config the sqlite acces URI:
# SQLALCHEMY_DATABASE_URI = 'sqlite:///' + os.path.join(DB_FOLDER, DB_FILE)
SQLALCHEMY_POOL_RECYCLE = 5
"""
log file configuration
"""
LOGGER_FOLDER = os.path.join(basedir, '.log')
LOGGER_FILE = os.path.join(LOGGER_FOLDER, 'debug.log')
"""
encryption & auth configuration
"""
# encryption keys
SECRET_KEY = 'your SECRET_KEY'
# salt used by token generation
AUTH_SALT = 'your AUTH SALT'
# salt used by password md5 hash
PSW_SALT = 'your PSW SALT'
# token duration (in seconds), 2hours by default
TOKEN_DURATION = 7200 # in second
ACCESS_TOKEN_EXPIRATION = 3600 # in second
REFRESH_TOKEN_EXPIRATION = 86400 # in second
# root user default setting
DEFAULT_ROOT_USERNAME = 'admin'
DEFAULT_ROOT_PASSWORD = 'admin'
"""
walker configuration
"""
WALKER_MISSION_TIMEOUT = 180 # in second
ROOT_SSH_KEY_FILE = os.path.join(basedir, '.ssh_key/root_id_rsa')
ADMIN_SSH_KEY_FILE = os.path.join(basedir, '.ssh_key/admin_id_rsa')
"""
forward configuration
"""
FORWARD_LOGLEVEL = 'info'
FORWARD_LOGGER_FILE = os.path.join(LOGGER_FOLDER, 'forward.log')
FORWARD_TIMEOUT = 2
FORWARD_USERNAME = 'python_script'
FORWARD_USER_PRIVATE_KEY = os.path.join(
basedir, '.ssh_key/forward_private_rsa')
FORWARD_USER_PUBLIC_KEY = os.path.join(basedir, '.ssh_key/forward_public_rsa')
"""
zabbix access configuration
"""
# zabbix url
DEFAULT_ZABBIX_URL = 'http://192.168.182.150/zabbix'
# zabbix user info
DEFAULT_ZABBIX_USER_NAME = 'cloudlab'
DEFAULT_ZABBIX_PASSWORD = 'cloudlab'
"""
celery configuration
"""
# use sqlalchemy as broker and resultset
SQLA = os.path.join(DB_FOLDER, 'celerydb.sqlite')
CELERY_BROKER_URL = 'sqla+sqlite:///%s' % SQLA
CELERY_RESULT_BACKEND = 'db+sqlite:///%s' % SQLA
CELERY_TIMEZONE = 'Asia/Shanghai'
CELERY_ENABLE_UTC = True
CELERYBEAT_SCHEDULE_FILENAME = os.path.join(DB_FOLDER, 'celerybeat-schedule')
# CELERY_IGNORE_RESULT = True
# CELERY_TRACK_STARTED = True
# CELERY_REDIRECT_STDOUTS_LEVEL = 'DEBUG'
from celery import platforms
platforms.C_FORCE_ROOT = True
"""
forward database configuration
"""
FORWARD_DB_USER = 'root'
FORWARD_DB_PASS = ''
FORWARD_DB_HOST = '127.0.0.1'
FORWARD_DB_PORT = 3306
FORWARD_DB_NAME = 'forward'
FORWARD_DB_TIMEOUT = 2