Ver código fonte

Bring env OSPROFILER_CONNECTION_STRING into effect

The --connection-string is marked required, and parse_args()
assumes the flag invalid if it's not supplied as command line
argument, even if env OSPROFILER_CONNECTION_STRING is setted.

We should not rely on the required=True of argparse module,
but check the required args on our own to take env arguments
into consideration.

Change-Id: I50f5f369ec41ddc82f9b66f5910b7805940fb387
(cherry picked from commit ede0ec402e)
tags/2.3.1^0
francotseng 11 meses atrás
pai
commit
6c035399ad
1 arquivos alterados com 11 adições e 2 exclusões
  1. +11
    -2
      osprofiler/cmd/commands.py

+ 11
- 2
osprofiler/cmd/commands.py Ver arquivo

@@ -36,7 +36,6 @@ class TraceCommands(BaseCommand):
@cliutils.arg("trace", help="File with trace or trace id")
@cliutils.arg("--connection-string", dest="conn_str",
default=(cliutils.env("OSPROFILER_CONNECTION_STRING")),
required=True,
help="Storage driver's connection string. Defaults to "
"env[OSPROFILER_CONNECTION_STRING] if set")
@cliutils.arg("--transport-url", dest="transport_url",
@@ -59,6 +58,12 @@ class TraceCommands(BaseCommand):
def show(self, args):
"""Display trace results in HTML, JSON or DOT format."""

if not args.conn_str:
raise exc.CommandError(
"You must provide connection string via"
" either --connection-string or "
"via env[OSPROFILER_CONNECTION_STRING]")

trace = None

if not uuidutils.is_uuid_like(args.trace):
@@ -156,7 +161,6 @@ class TraceCommands(BaseCommand):

@cliutils.arg("--connection-string", dest="conn_str",
default=cliutils.env("OSPROFILER_CONNECTION_STRING"),
required=True,
help="Storage driver's connection string. Defaults to "
"env[OSPROFILER_CONNECTION_STRING] if set")
@cliutils.arg("--error-trace", dest="error_trace",
@@ -164,6 +168,11 @@ class TraceCommands(BaseCommand):
help="List all traces that contain error.")
def list(self, args):
"""List all traces"""
if not args.conn_str:
raise exc.CommandError(
"You must provide connection string via"
" either --connection-string or "
"via env[OSPROFILER_CONNECTION_STRING]")
try:
engine = base.get_driver(args.conn_str, **args.__dict__)
except Exception as e:


Carregando…
Cancelar
Salvar