Skip to content

Commit 36adc90

Browse files
author
Renat Idrisov
committed
Disable server functions outside full source version
1 parent 30157a2 commit 36adc90

File tree

2 files changed

+28
-15
lines changed

2 files changed

+28
-15
lines changed

bin/mzbench

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
#!/usr/bin/env python
2-
"""mzbench CLI interface
2+
from __future__ import print_function
3+
try:
4+
import mzbench_server_marker
5+
assert(mzbench_server_marker)
6+
server_functions = True
7+
except ImportError:
8+
server_functions = False
9+
10+
# Client-only functions
11+
doc_acc = """mzbench CLI interface
312
413
Usage:
5-
mzbench clean
6-
mzbench start_server [--config=<config>]
7-
mzbench stop_server
8-
mzbench restart_server [--config=<config>]
914
mzbench [--host=<host>] (start|run)
1015
[--nodes=<nodes>|--workers_per_node=<workers_per_node>]
1116
[--nodes_file=<filename>]
@@ -22,18 +27,25 @@ Usage:
2227
mzbench [--host=<host>] status [--wait] <bench_id>
2328
mzbench [--host=<host>] stop <bench_id>
2429
mzbench [--host=<host>] log <bench_id>
25-
mzbench [--host=<host>] data [(--target=<name>...)] [--format=(csv|json)] <bench_id>
30+
mzbench [--host=<host>] data [(--target=<name>...)] [--format=(csv|json)] <bench_id>"""
31+
32+
if server_functions:
33+
doc_acc += """
34+
mzbench clean
35+
mzbench start_server [--config=<config>]
36+
mzbench stop_server
37+
mzbench restart_server [--config=<config>]
2638
mzbench run_local <script> [--env=<name=value>...]
2739
mzbench validate <script> [--env=<name=value>...]
2840
mzbench list_templates
2941
mzbench new_worker [--template=<template>] <name>
30-
mzbench selfcheck
42+
mzbench selfcheck"""
43+
44+
doc_acc += """
3145
mzbench -h | --help
3246
3347
Options:
3448
-h, --help Show this help
35-
--skip_install Skip stage with building and deploying RPMs
36-
--tests <tests> Execute only the specified tests
3749
--host <host> Specify host providing mzbench api. Alternatively,
3850
you can set environment variable MZBENCH_API_HOST.
3951
--nodes <nodes> Specify either an amount of nodes to be allocated or a
@@ -77,14 +89,14 @@ Options:
7789
Specify cloud provider to use. If not set server will use
7890
first available provider.
7991
--env <name=value>
80-
Pass a variable to script
92+
Pass a variable to script"""
93+
94+
if server_functions:
95+
doc_acc += """
8196
--template <template>
8297
Choose a template for new worker, default is 'empty'
8398
--config <config>
84-
Configuation file to use
85-
"""
86-
87-
from __future__ import print_function
99+
Configuation file to use"""
88100

89101
from shutil import copytree
90102
import csv
@@ -504,7 +516,7 @@ def apply_args(fun, kwargs):
504516
return fun(**dict((k, get_arg(k, kwargs)) for k in argnames))
505517

506518
def main():
507-
args = docopt.docopt(__doc__, version='0.1.0')
519+
args = docopt.docopt(doc_acc, version='0.1.0')
508520
augment_args(args)
509521

510522
known_commands = [k for k in args

bin/mzbench_server_marker.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Fake module just to make sure that CLI is started from a complete environment

0 commit comments

Comments
 (0)