diff options
author | Omer Anson <omer.anson@toganetworks.com> | 2017-11-19 23:50:42 +0200 |
---|---|---|
committer | Ilya Shakhat <shakhat@gmail.com> | 2018-01-23 13:31:04 +0100 |
commit | 23ab27ad38b81a5e374ba7f7c8cadb83932701ab (patch) | |
tree | 74d23c885699f2012f560044e15346863aff0dff /osprofiler/cmd | |
parent | 0bb909c7a039f17b957d920c93d366d89e581280 (diff) | |
download | osprofiler-23ab27ad38b81a5e374ba7f7c8cadb83932701ab.tar.gz |
Add initial 'trace list' command
This is an initial trace list command, which acts both as a
starting-point, as well as an immediate solution for anyone
who needs the basic functionality of this feature.
Change-Id: I99ad62103914b047cfc3c33e50ae98b6a0d01d6d
Related-Bug: #1733232
Diffstat (limited to 'osprofiler/cmd')
-rw-r--r-- | osprofiler/cmd/commands.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/osprofiler/cmd/commands.py b/osprofiler/cmd/commands.py index 67aaa43..870b653 100644 --- a/osprofiler/cmd/commands.py +++ b/osprofiler/cmd/commands.py @@ -15,7 +15,10 @@ import json import os +import prettytable +import six +from oslo_utils import encodeutils from oslo_utils import uuidutils from osprofiler.cmd import cliutils @@ -150,3 +153,26 @@ class TraceCommands(BaseCommand): _create_sub_graph(trace) return dot + + @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") + def list(self, args): + try: + engine = base.get_driver(args.conn_str, **args.__dict__) + except Exception as e: + raise exc.CommandError(e.message) + + fields = ("base_id", "timestamp") + pretty_table = prettytable.PrettyTable(fields) + pretty_table.align = "l" + traces = engine.list_traces({}, fields) + for trace in traces: + row = [trace[field] for field in fields] + pretty_table.add_row(row) + if six.PY3: + print(encodeutils.safe_encode(pretty_table.get_string()).decode()) + else: + print(encodeutils.safe_encode(pretty_table.get_string())) |