diff --git a/streamparse/cli/common.py b/streamparse/cli/common.py index 54d0907a..6846f975 100644 --- a/streamparse/cli/common.py +++ b/streamparse/cli/common.py @@ -177,6 +177,13 @@ def add_timeout(parser): '(default: %(default)s)') +def add_user(parser): + """ Add --user option to parser """ + parser.add_argument('--user', + help='User argument to sudo when deleting files.', + default='root') + + def add_wait(parser): """ Add --wait option to parser """ parser.add_argument('--wait', diff --git a/streamparse/cli/remove_logs.py b/streamparse/cli/remove_logs.py index c3e9aa8d..2791d549 100644 --- a/streamparse/cli/remove_logs.py +++ b/streamparse/cli/remove_logs.py @@ -64,6 +64,7 @@ def subparser_hook(subparsers): add_override_name(subparser) add_pattern(subparser) add_pool_size(subparser) + # Not using add_user because we need -u for backward compatibility subparser.add_argument('-u', '--user', help="User argument to sudo when deleting logs.", default='root') diff --git a/streamparse/cli/submit.py b/streamparse/cli/submit.py index 370c63ec..7379e2fe 100644 --- a/streamparse/cli/submit.py +++ b/streamparse/cli/submit.py @@ -25,7 +25,8 @@ from .common import (add_ackers, add_config, add_debug, add_environment, add_name, add_options, add_override_name, add_overwrite_virtualenv, add_pool_size, add_requirements, - add_timeout, add_wait, add_workers, resolve_options) + add_timeout, add_user, add_wait, add_workers, + resolve_options) from .jar import jar_for_deploy from .kill import _kill_topology from .list import _list_topologies @@ -144,7 +145,7 @@ def submit_topology(name=None, env_name=None, options=None, force=False, wait=None, simple_jar=True, override_name=None, requirements_paths=None, local_jar_path=None, remote_jar_path=None, timeout=None, config_file=None, - overwrite_virtualenv=False): + overwrite_virtualenv=False, user='root'): """Submit a topology to a remote Storm cluster.""" config = get_config() name, topology_file = get_topology_definition(name, config_file=config_file) @@ -180,7 +181,8 @@ def submit_topology(name=None, env_name=None, options=None, force=False, virtualenv_name=virtualenv_name, requirements_paths=requirements_paths, config_file=config_file, - overwrite_virtualenv=overwrite_virtualenv) + overwrite_virtualenv=overwrite_virtualenv, + user=user) streamparse_run_path = '/'.join([env.virtualenv_root, virtualenv_name, 'bin', 'streamparse_run']) # Update python paths in bolts @@ -276,6 +278,7 @@ def subparser_hook(subparsers): 'components in your topology. Useful if you ' 'are providing your own seriailzer class.', dest='simple_jar', action='store_false') + add_user(subparser) add_wait(subparser) add_workers(subparser) @@ -292,4 +295,5 @@ def main(args): remote_jar_path=args.remote_jar_path, timeout=args.timeout, config_file=args.config, - overwrite_virtualenv=args.overwrite_virtualenv) + overwrite_virtualenv=args.overwrite_virtualenv, + user=args.user) diff --git a/streamparse/cli/update_virtualenv.py b/streamparse/cli/update_virtualenv.py index 82836c75..e01ede23 100644 --- a/streamparse/cli/update_virtualenv.py +++ b/streamparse/cli/update_virtualenv.py @@ -16,7 +16,8 @@ from .common import (add_config, add_environment, add_name, add_options, add_override_name, add_overwrite_virtualenv, - add_pool_size, add_requirements, resolve_options) + add_pool_size, add_requirements, add_user, + resolve_options) from ..util import (activate_env, die, get_config, get_env_config, get_topology_definition, get_topology_from_file) @@ -134,10 +135,7 @@ def subparser_hook(subparsers): add_override_name(subparser) add_pool_size(subparser) add_requirements(subparser) - subparser.add_argument('-u', '--user', - help="User argument to sudo when deleting " - "virtualenv for --overwrite_virtualenv.", - default='root') + add_user(subparser) def main(args):