You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aurora.apache.org by wf...@apache.org on 2014/12/08 18:56:23 UTC
incubator-aurora git commit: Don't fall back to old command syntax in
the new client.
Repository: incubator-aurora
Updated Branches:
refs/heads/master fda926193 -> f30c50937
Don't fall back to old command syntax in the new client.
Bugs closed: AURORA-782
Reviewed at https://reviews.apache.org/r/28771/
Project: http://git-wip-us.apache.org/repos/asf/incubator-aurora/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-aurora/commit/f30c5093
Tree: http://git-wip-us.apache.org/repos/asf/incubator-aurora/tree/f30c5093
Diff: http://git-wip-us.apache.org/repos/asf/incubator-aurora/diff/f30c5093
Branch: refs/heads/master
Commit: f30c509372a711cdb27f41c1fc4dc6fa42be0ffa
Parents: fda9261
Author: Bill Farner <wf...@apache.org>
Authored: Mon Dec 8 09:56:32 2014 -0800
Committer: Bill Farner <wf...@apache.org>
Committed: Mon Dec 8 09:56:32 2014 -0800
----------------------------------------------------------------------
src/main/python/apache/aurora/client/cli/BUILD | 10 +-
.../python/apache/aurora/client/cli/client.py | 123 +++++++++++++------
.../aurora/client/cli/standalone_client.py | 112 -----------------
3 files changed, 86 insertions(+), 159 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/f30c5093/src/main/python/apache/aurora/client/cli/BUILD
----------------------------------------------------------------------
diff --git a/src/main/python/apache/aurora/client/cli/BUILD b/src/main/python/apache/aurora/client/cli/BUILD
index 8d34bf7..2167c71 100644
--- a/src/main/python/apache/aurora/client/cli/BUILD
+++ b/src/main/python/apache/aurora/client/cli/BUILD
@@ -20,14 +20,8 @@ python_binary(
],
)
-python_binary(
- name='aurora2_so',
- entry_point = 'apache.aurora.client.cli.standalone_client:proxy_main',
- dependencies = [
- ':client_lib'
- ]
-)
+# TODO(wfarner): Remove this along with the rest of the v1 client code.
python_library(
name = 'bridge',
sources = ['bridge.py']
@@ -49,6 +43,7 @@ python_library(
name='cli',
sources = [
'__init__.py',
+ 'client.py',
'config.py',
'context.py',
'command_hooks.py',
@@ -57,7 +52,6 @@ python_library(
'logsetup.py',
'options.py',
'quota.py',
- 'standalone_client.py',
'sla.py',
'task.py',
'update.py',
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/f30c5093/src/main/python/apache/aurora/client/cli/client.py
----------------------------------------------------------------------
diff --git a/src/main/python/apache/aurora/client/cli/client.py b/src/main/python/apache/aurora/client/cli/client.py
index a1df788..93120a1 100644
--- a/src/main/python/apache/aurora/client/cli/client.py
+++ b/src/main/python/apache/aurora/client/cli/client.py
@@ -11,57 +11,102 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-import sys
-
-from apache.aurora.client.cli.bridge import Bridge, CommandProcessor
-from apache.aurora.client.cli.standalone_client import AuroraCommandLine
+from __future__ import print_function
+import logging
+import sys
-# TODO(mchucarroll): the entire bridged executable mechanism here is
-# intended to be deprecated once clientv2 has proven to be stable
-# and adopted by most users. Once we reach that point, this should
-# be replaced by the standalone executable defined in standalone_client.py.
-class AuroraClientV2CommandProcessor(CommandProcessor):
- def __init__(self):
- self.commandline = AuroraCommandLine()
-
- @property
- def name(self):
- return "Aurora Client v2"
+from apache.aurora.client.cli import CommandLine, ConfigurationPlugin
+from apache.aurora.client.cli.logsetup import setup_default_log_handlers
+from apache.aurora.client.cli.options import CommandOption
- def get_commands(self):
- return self.commandline.registered_nouns
- def execute(self, args):
- return self.commandline.execute(args[1:])
+class AuroraLogConfigurationPlugin(ConfigurationPlugin):
+ """Plugin for configuring log level settings for the aurora client."""
+ def __init__(self):
+ super(AuroraLogConfigurationPlugin, self).__init__()
+ self.logging_level = None
+
+ def get_options(self):
+ return [
+ CommandOption("--verbose-logging", "-v", default=False, action="store_true",
+ help=("Show verbose logging, including all logs up to level INFO (equivalent to "
+ "--logging-level=20)")),
+ CommandOption("--logging-level", default=None, type=int, metavar="numeric_level",
+ help="Set logging to a specific numeric level, using the standard python log-levels.")
+ ]
+
+ def before_dispatch(self, raw_args):
+ # We need to process the loglevel arguments before dispatch, so that we can
+ # do logging during dispatch. That means that we need to cheat, and manually
+ # check for the logging arguments. (We still register them in get_options,
+ # so that they'll show up in the help message.)
+ loglevel = logging.WARN
+ for arg in raw_args:
+ if arg == "--verbose-logging" or arg == "-v":
+ if loglevel > logging.INFO:
+ loglevel = logging.INFO
+ if arg.startswith("--logging-level="):
+ arg_bits = arg.split("=")
+ # If the format here is wrong, argparse will generate error, so we just skip
+ # it if it's incorrect.
+ if len(arg_bits) == 2:
+ try:
+ loglevel = int(arg_bits[1])
+ except ValueError:
+ print("Invalid value for log level; must be an integer, but got %s" % arg_bits[1],
+ file=sys.stderr)
+ raise
+ setup_default_log_handlers(loglevel)
+ self.logging_level = loglevel
+ return raw_args
+
+ def before_execution(self, context):
+ context.logging_level = self.logging_level
+
+ def after_execution(self, context, result_code):
+ pass
+
+
+class AuroraCommandLine(CommandLine):
+ """The CommandLine implementation for the Aurora client v2 command line."""
-class AuroraClientV1CommandProcessor(CommandProcessor):
- # TODO(mchucarroll): deprecate client v1. (AURORA-131)
+ def __init__(self):
+ super(AuroraCommandLine, self).__init__()
+ self.register_plugin(AuroraLogConfigurationPlugin())
@property
def name(self):
- return "Aurora Client v1"
-
- def show_help(self):
- print("Supported commands are: %s" % ", ".join(self.get_commands()))
- print("\nRun '%s help _command_' for help on a specific command" % sys.argv[0])
-
- def get_commands(self):
- return ["cancel_update", "create", "diff", "get_quota", "inspect", "kill", "list_jobs",
- "open", "restart", "run", "ssh", "start_cron", "status", "update", "version"]
-
- def execute(self, args):
- from apache.aurora.client.bin.aurora_client import proxy_main as clientone_proxy_main
- return clientone_proxy_main()
+ return 'aurora'
+
+ @classmethod
+ def get_description(cls):
+ return 'Aurora client command line'
+
+ def register_nouns(self):
+ super(AuroraCommandLine, self).register_nouns()
+ from apache.aurora.client.cli.cron import CronNoun
+ self.register_noun(CronNoun())
+ from apache.aurora.client.cli.jobs import Job
+ self.register_noun(Job())
+ from apache.aurora.client.cli.config import ConfigNoun
+ self.register_noun(ConfigNoun())
+ from apache.aurora.client.cli.quota import Quota
+ self.register_noun(Quota())
+ from apache.aurora.client.cli.sla import Sla
+ self.register_noun(Sla())
+ from apache.aurora.client.cli.task import Task
+ self.register_noun(Task())
+ from apache.aurora.client.cli.update import Update
+ self.register_noun(Update())
def proxy_main():
- v2 = AuroraClientV2CommandProcessor()
- v1 = AuroraClientV1CommandProcessor()
- bridge = Bridge([v2, v1], default=v1)
- sys.exit(bridge.execute(sys.argv))
-
+ client = AuroraCommandLine()
+ if len(sys.argv) == 1:
+ sys.argv.append("help")
+ sys.exit(client.execute(sys.argv[1:]))
if __name__ == '__main__':
proxy_main()
http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/f30c5093/src/main/python/apache/aurora/client/cli/standalone_client.py
----------------------------------------------------------------------
diff --git a/src/main/python/apache/aurora/client/cli/standalone_client.py b/src/main/python/apache/aurora/client/cli/standalone_client.py
deleted file mode 100644
index 93120a1..0000000
--- a/src/main/python/apache/aurora/client/cli/standalone_client.py
+++ /dev/null
@@ -1,112 +0,0 @@
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-from __future__ import print_function
-
-import logging
-import sys
-
-from apache.aurora.client.cli import CommandLine, ConfigurationPlugin
-from apache.aurora.client.cli.logsetup import setup_default_log_handlers
-from apache.aurora.client.cli.options import CommandOption
-
-
-class AuroraLogConfigurationPlugin(ConfigurationPlugin):
- """Plugin for configuring log level settings for the aurora client."""
-
- def __init__(self):
- super(AuroraLogConfigurationPlugin, self).__init__()
- self.logging_level = None
-
- def get_options(self):
- return [
- CommandOption("--verbose-logging", "-v", default=False, action="store_true",
- help=("Show verbose logging, including all logs up to level INFO (equivalent to "
- "--logging-level=20)")),
- CommandOption("--logging-level", default=None, type=int, metavar="numeric_level",
- help="Set logging to a specific numeric level, using the standard python log-levels.")
- ]
-
- def before_dispatch(self, raw_args):
- # We need to process the loglevel arguments before dispatch, so that we can
- # do logging during dispatch. That means that we need to cheat, and manually
- # check for the logging arguments. (We still register them in get_options,
- # so that they'll show up in the help message.)
- loglevel = logging.WARN
- for arg in raw_args:
- if arg == "--verbose-logging" or arg == "-v":
- if loglevel > logging.INFO:
- loglevel = logging.INFO
- if arg.startswith("--logging-level="):
- arg_bits = arg.split("=")
- # If the format here is wrong, argparse will generate error, so we just skip
- # it if it's incorrect.
- if len(arg_bits) == 2:
- try:
- loglevel = int(arg_bits[1])
- except ValueError:
- print("Invalid value for log level; must be an integer, but got %s" % arg_bits[1],
- file=sys.stderr)
- raise
- setup_default_log_handlers(loglevel)
- self.logging_level = loglevel
- return raw_args
-
- def before_execution(self, context):
- context.logging_level = self.logging_level
-
- def after_execution(self, context, result_code):
- pass
-
-
-class AuroraCommandLine(CommandLine):
- """The CommandLine implementation for the Aurora client v2 command line."""
-
- def __init__(self):
- super(AuroraCommandLine, self).__init__()
- self.register_plugin(AuroraLogConfigurationPlugin())
-
- @property
- def name(self):
- return 'aurora'
-
- @classmethod
- def get_description(cls):
- return 'Aurora client command line'
-
- def register_nouns(self):
- super(AuroraCommandLine, self).register_nouns()
- from apache.aurora.client.cli.cron import CronNoun
- self.register_noun(CronNoun())
- from apache.aurora.client.cli.jobs import Job
- self.register_noun(Job())
- from apache.aurora.client.cli.config import ConfigNoun
- self.register_noun(ConfigNoun())
- from apache.aurora.client.cli.quota import Quota
- self.register_noun(Quota())
- from apache.aurora.client.cli.sla import Sla
- self.register_noun(Sla())
- from apache.aurora.client.cli.task import Task
- self.register_noun(Task())
- from apache.aurora.client.cli.update import Update
- self.register_noun(Update())
-
-
-def proxy_main():
- client = AuroraCommandLine()
- if len(sys.argv) == 1:
- sys.argv.append("help")
- sys.exit(client.execute(sys.argv[1:]))
-
-if __name__ == '__main__':
- proxy_main()