Skip to content

Commit

Permalink
CLI: Add param to display perfdata column
Browse files Browse the repository at this point in the history
  • Loading branch information
AymericDu committed Jun 24, 2021
1 parent 8eea507 commit 9fcb4bc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
4 changes: 2 additions & 2 deletions oio/cli/common/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ def run(self, argv):
res = super(OpenIOShell, self).run(argv)
perfdata = self.client_manager.cli_conf().get('perfdata')
if perfdata:
LOG.debug("Performance data: x %s",
json.dumps(perfdata, sort_keys=True, indent=4))
LOG.warning("Performance data: %s",
json.dumps(perfdata, sort_keys=True, indent=4))
return res
except Exception as e:
LOG.error('Exception raised: %s', e)
Expand Down
14 changes: 11 additions & 3 deletions oio/cli/object/object.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import os
from logging import getLogger

from oio.common.json import json
from oio.cli import Command, Lister, ShowOne
from oio.common.http_urllib3 import get_pool_manager
from oio.common.utils import depaginate
Expand Down Expand Up @@ -155,6 +156,12 @@ def get_parser(self, prog_name):
help='Upgrade RAWX connection to TLS',
default=False
)
parser.add_argument(
'--perfdata-column',
action="store_true",
help='Add a column to display performance data',
default=False
)
return parser

def take_action(self, parsed_args):
Expand Down Expand Up @@ -200,8 +207,9 @@ def take_action(self, parsed_args):
tls=parsed_args.tls)

res = (name, data[1], data[2].upper(), 'Ok')
if perfdata:
res += (perfdata,)
if parsed_args.perfdata_column:
res += (json.dumps(perfdata, sort_keys=True,
indent=4),)

results.append(res)
except KeyboardInterrupt:
Expand All @@ -216,7 +224,7 @@ def take_action(self, parsed_args):

listing = (obj for obj in results)
columns = ('Name', 'Size', 'Hash', 'Status')
if perfdata:
if parsed_args.perfdata_column:
columns += ('Perfdata',)
if any_error:
self.produce_output(parsed_args, columns, listing)
Expand Down

0 comments on commit 9fcb4bc

Please sign in to comment.