using conf files instead of hardcoded values

This commit is contained in:
Sergey Lukjanov 2013-03-01 16:34:45 +04:00
parent 4347e186d0
commit b5cbe1eaeb
5 changed files with 31 additions and 13 deletions

1
.gitignore vendored
View File

@ -29,3 +29,4 @@ doc/source/apidoc
.coverage
nosetests.xml
pylint-report.txt
etc/local.cfg

View File

@ -22,9 +22,15 @@ def make_app(**local_conf):
Entry point for Elastic Hadoop on OpenStack REST API server
"""
app = Flask('eho.api')
# todo(slukjanov): is it needed?
app.config.from_pyfile('etc/eho-api.cfg', silent=True)
app.config.from_pyfile('../etc/eho-api.cfg', silent=True)
# reading defaults
app.config.from_pyfile('etc/default.cfg', silent=True)
app.config.from_pyfile('../etc/default.cfg', silent=True)
# read local conf
app.config.from_pyfile('etc/local.cfg', silent=True)
app.config.from_pyfile('../etc/local.cfg', silent=True)
app.config.from_envvar('EHO_API_CFG', silent=True)
app.config.update(**local_conf)
@ -43,7 +49,7 @@ def make_app(**local_conf):
setup_storage(app)
setup_defaults(app)
setup_scheduler(app)
setup_ops()
setup_ops(app)
setup_api(app)
def make_json_error(ex):

View File

@ -16,15 +16,16 @@ OPENSTACK_CONF = {}
OPENSTACK_NODE_CONF = {}
def setup_ops():
OPENSTACK_CONF['user'] = 'admin'
OPENSTACK_CONF['password'] = 'nova'
OPENSTACK_CONF['tenant'] = 'admin'
OPENSTACK_CONF['auth_url'] = 'http://172.18.79.139:5000/v2.0/'
OPENSTACK_CONF['vm_internal_net'] = "novanetwork"
def setup_ops(app):
OPENSTACK_CONF['user'] = app.config.get('OPENSTACK_USER')
OPENSTACK_CONF['password'] = app.config.get('OPENSTACK_PASSWORD')
OPENSTACK_CONF['tenant'] = app.config.get('OPENSTACK_TENANT')
OPENSTACK_CONF['auth_url'] = app.config.get('OPENSTACK_AUTH_URL')
OPENSTACK_CONF['vm_internal_net'] = \
app.config.get('OPENSTACK_VM_INTERNAL_NET')
OPENSTACK_NODE_CONF['user'] = 'root'
OPENSTACK_NODE_CONF['password'] = 'swordfish'
OPENSTACK_NODE_CONF['user'] = app.config.get('NODE_USER')
OPENSTACK_NODE_CONF['password'] = app.config.get('NODE_PASSWORD')
def _create_nova_client():

View File

@ -1,3 +1,3 @@
SQLALCHEMY_DATABASE_URI = 'sqlite:////tmp/eho-server.db'
SQLALCHEMY_ECHO = False
SQLALCHEMY_ECHO=False
ALLOW_CLUSTER_OPS=False

10
etc/local.cfg-sample Normal file
View File

@ -0,0 +1,10 @@
# OPENSTACK CONF
OPENSTACK_USER=admin
OPENSTACK_PASSWORD=nova
OPENSTACK_TENANT=admin
OPENSTACK_AUTH_URL=http://172.18.79.139:5000/v2.0/
OPENSTACK_VM_INTERNAL_NET=novanetwork
# NODE CONF
NODE_USER=root
NODE_PASSWORD=swordfish