@utils.arg('<STR_LIT:name>', metavar='<STR_LIT>',<EOL>help='<STR_LIT>')<EOL>@utils.arg('<STR_LIT>', metavar='<STR_LIT>',<EOL>help='<STR_LIT>'<EOL>'<STR_LIT>')<EOL>@utils.arg('<STR_LIT>', metavar='<STR_LIT>',<EOL>help='<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>',<EOL>action='<STR_LIT>')<EOL>@utils.arg('<STR_LIT>', metavar='<STR_LIT>',<EOL>help='<STR_LIT>'<EOL>'<STR_LIT>')<EOL>@utils.arg('<STR_LIT>', metavar='<STR_LIT>',<EOL>help='<STR_LIT>')<EOL>@utils.arg('<STR_LIT>', metavar='<STR_LIT>',<EOL>help='<STR_LIT>')<EOL>@utils.arg('<STR_LIT>', metavar='<STR_LIT>',<EOL>help='<STR_LIT>')<EOL>@utils.arg('<STR_LIT>', metavar='<STR_LIT>',<EOL>help='<STR_LIT>')<EOL>@utils.arg('<STR_LIT>', action='<STR_LIT>',<EOL>const=True,<EOL>help='<STR_LIT>')<EOL>@utils.arg('<STR_LIT>', metavar='<STR_LIT>',<EOL>help='<STR_LIT>')<EOL>@utils.arg('<STR_LIT>', metavar='<STR_LIT>',<EOL>help="<STR_LIT>"<EOL>"<STR_LIT>")<EOL>def do_metric_statistics(mc, args):
statistic_types = ['<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>']<EOL>statlist = args.statistics.split('<STR_LIT:U+002C>')<EOL>for stat in statlist:<EOL><INDENT>if stat.upper() not in statistic_types:<EOL><INDENT>errmsg = ('<STR_LIT>' +<EOL>'<STR_LIT:U+002CU+0020>'.join(statistic_types) + '<STR_LIT:]>')<EOL>raise osc_exc.CommandError(errmsg)<EOL><DEDENT><DEDENT>fields = {}<EOL>fields['<STR_LIT:name>'] = args.name<EOL>if args.dimensions:<EOL><INDENT>fields['<STR_LIT>'] = utils.format_dimensions_query(args.dimensions)<EOL><DEDENT>_translate_starttime(args)<EOL>fields['<STR_LIT>'] = args.starttime<EOL>if args.endtime:<EOL><INDENT>fields['<STR_LIT>'] = args.endtime<EOL><DEDENT>if args.period:<EOL><INDENT>fields['<STR_LIT>'] = args.period<EOL><DEDENT>fields['<STR_LIT>'] = args.statistics<EOL>if args.limit:<EOL><INDENT>fields['<STR_LIT>'] = args.limit<EOL><DEDENT>if args.offset:<EOL><INDENT>fields['<STR_LIT>'] = args.offset<EOL><DEDENT>if args.merge_metrics:<EOL><INDENT>fields['<STR_LIT>'] = args.merge_metrics<EOL><DEDENT>if args.group_by:<EOL><INDENT>fields['<STR_LIT>'] = args.group_by<EOL><DEDENT>if args.tenant_id:<EOL><INDENT>fields['<STR_LIT>'] = args.tenant_id<EOL><DEDENT>try:<EOL><INDENT>metric = mc.metrics.list_statistics(**fields)<EOL><DEDENT>except (osc_exc.ClientException, k_exc.HttpError) as he:<EOL><INDENT>raise osc_exc.CommandError('<STR_LIT>' % (he.message, he.details))<EOL><DEDENT>else:<EOL><INDENT>if args.json:<EOL><INDENT>print(utils.json_formatter(metric))<EOL>return<EOL><DEDENT>cols = ['<STR_LIT:name>', '<STR_LIT>']<EOL>if metric:<EOL><INDENT>column_names = metric[<NUM_LIT:0>]['<STR_LIT>']<EOL>for name in column_names:<EOL><INDENT>cols.append(name)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>cols.append('<STR_LIT>')<EOL><DEDENT>formatters = {<EOL>'<STR_LIT:name>': lambda x: x['<STR_LIT:name>'],<EOL>'<STR_LIT>': lambda x: utils.format_dict(x['<STR_LIT>']),<EOL>'<STR_LIT>': lambda x:<EOL>format_statistic_timestamp(x['<STR_LIT>'], x['<STR_LIT>'],<EOL>'<STR_LIT>'),<EOL>'<STR_LIT>': lambda x:<EOL>format_statistic_value(x['<STR_LIT>'], x['<STR_LIT>'], '<STR_LIT>'),<EOL>'<STR_LIT>': lambda x:<EOL>format_statistic_value(x['<STR_LIT>'], x['<STR_LIT>'], '<STR_LIT>'),<EOL>'<STR_LIT>': lambda x:<EOL>format_statistic_value(x['<STR_LIT>'], x['<STR_LIT>'], '<STR_LIT>'),<EOL>'<STR_LIT:count>': lambda x:<EOL>format_statistic_value(x['<STR_LIT>'], x['<STR_LIT>'], '<STR_LIT:count>'),<EOL>'<STR_LIT>': lambda x:<EOL>format_statistic_value(x['<STR_LIT>'], x['<STR_LIT>'], '<STR_LIT>'),<EOL>}<EOL>if isinstance(metric, list):<EOL><INDENT>utils.print_list(metric, cols, formatters=formatters)<EOL><DEDENT>else:<EOL><INDENT>metric_list = list()<EOL>metric_list.append(metric)<EOL>utils.print_list(<EOL>metric_list,<EOL>cols,<EOL>formatters=formatters)<EOL><DEDENT><DEDENT>
List measurement statistics for the specified metric.