コード例 #1
0
def main():
    """The main program sets up the commands then delegates to one of them."""
    all_command_handlers = []
    parser = argparse.ArgumentParser(
        description='Helper tool to interact with Spinnaker deployment metrics.'
    )
    add_global_args(parser)

    spectator_client.CONFIG_DIR = os.path.join(CONFIG_DIR)

    subparsers = parser.add_subparsers(title='commands', dest='command')
    spectator_handlers.add_handlers(all_command_handlers, subparsers)
    datadog_handlers.add_handlers(all_command_handlers, subparsers)
    stackdriver_handlers.add_handlers(all_command_handlers, subparsers)
    server_handlers.MonitorCommandHandler.register_metric_service_factory(
        prometheus_service.PrometheusServiceFactory())
    server_handlers.MonitorCommandHandler.register_metric_service_factory(
        datadog_service.DatadogServiceFactory())
    server_handlers.MonitorCommandHandler.register_metric_service_factory(
        stackdriver_service.StackdriverServiceFactory())
    server_handlers.add_handlers(all_command_handlers, subparsers)

    opts = parser.parse_args()
    options = vars(opts)
    init_logging(options)
    options = util.merge_options_and_yaml_from_path(
        options, os.path.join(opts.config_dir, 'spinnaker-monitoring.conf'))

    command_processor.process_command(options['command'], options,
                                      all_command_handlers)
コード例 #2
0
def prepare_commands():
    """Returns a list of commands and command-line parser for options."""
    all_command_handlers = []
    parser = argparse.ArgumentParser(
        description='Helper tool to interact with Spinnaker deployment metrics.'
    )
    add_global_args(parser)

    subparsers = parser.add_subparsers(title='commands', dest='command')
    spectator_handlers.add_handlers(all_command_handlers, subparsers)
    datadog_handlers.add_handlers(all_command_handlers, subparsers)
    stackdriver_handlers.add_handlers(all_command_handlers, subparsers)
    server_handlers.MonitorCommandHandler.register_metric_service_factory(
        prometheus_service.PrometheusServiceFactory())
    server_handlers.MonitorCommandHandler.register_metric_service_factory(
        datadog_service.DatadogServiceFactory())
    server_handlers.MonitorCommandHandler.register_metric_service_factory(
        stackdriver_service.StackdriverServiceFactory())
    server_handlers.add_handlers(all_command_handlers, subparsers)

    return all_command_handlers, parser