allow cluster ops flag added

This commit is contained in:
Sergey Lukjanov
2013-02-26 15:18:58 +04:00
parent 4dbd12582e
commit 22a101f286
4 changed files with 23 additions and 1 deletions

View File

@@ -30,13 +30,21 @@ def main():
'--stub-data, --stub_data', action='store_true', dest='stub_data',
help='put stub templates and clusters into db'
)
parser.add_argument(
'--allow-cluster-ops, --allow_cluster_ops', action='store_true',
dest='allow_cluster_ops', help='allow cluster ops (default: False)'
)
args = parser.parse_args()
opts = dict()
opts['DEBUG'] = args.dev
opts['LOG_LEVEL'] = args.log_level
opts['RESET_DB'] = args.reset_db
opts['STUB_DATA'] = args.stub_data
opts['ALLOW_CLUSTER_OPS'] = args.allow_cluster_ops
app = server.make_app(**opts)
wsgi.server(eventlet.listen((args.host, args.port), backlog=500), app,
debug=args.dev)

View File

@@ -1,5 +1,6 @@
import logging
from eho.server.scheduler import setup_scheduler
from eho.server.service.api import setup_api
from eho.server.storage.defaults import setup_defaults
from eho.server.utils.api import render
from eventlet import monkey_patch
@@ -39,6 +40,7 @@ def make_app(**local_conf):
setup_storage(app)
setup_defaults(app)
setup_scheduler(app)
setup_api(app)
def make_json_error(ex):
status_code = (ex.code

View File

@@ -7,6 +7,14 @@ from eho.server.service import cluster_ops
import eventlet
ALLOW_CLUSTER_OPS = False
def setup_api(app):
global ALLOW_CLUSTER_OPS
ALLOW_CLUSTER_OPS = app.config['ALLOW_CLUSTER_OPS']
def _clean_nones(obj):
d_type = type(obj)
if d_type is not dict or d_type is not list:
@@ -183,7 +191,10 @@ def cluster_creation_job(cluster_id):
logging.debug("Starting cluster '%s' creation: %s", cluster_id,
_cluster(cluster).dict)
cluster_ops.launch_cluster(cluster)
if ALLOW_CLUSTER_OPS:
cluster_ops.launch_cluster(cluster)
else:
logging.info("Cluster ops are disabled, use --allow-cluster-ops flag")
# update cluster status
cluster = Cluster.query.filter_by(id=cluster.id).first()

View File

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