def do_metric_available_list(cc, args): data = cc.metrics.list_available_metrics( gnocchi_metric=args.gnocchi_metric, refresh=args.refresh) fields = [ 'metric', 'gnocchi_unit', 'unit', 'has_cost', 'function', 'granularities', 'timespans', 'filters' ] fields_labels = [ 'Metric', 'Gnocchi Unit', 'Unit', 'Has Cost', 'Function', 'Granularities', 'Timespans', 'Filters' ] utils.print_list(data["metrics"], fields, fields_labels, formatters={ "metric": utils.dict_formatter("metric"), "gnocchi_unit": utils.dict_formatter("gnocchi_unit"), "unit": utils.dict_formatter("unit"), "has_cost": utils.dict_formatter("has_cost"), "function": utils.dict_formatter("function"), "granularities": utils.granularity_formatter("granularities"), "timespans": utils.granularity_formatter("timespans"), "filters": utils.filters_formatter("filters") }, sortby=None)
def do_report_definition_list(cc, args): data = cc.metrics.reports.list() fields = ['id', 'name', 'description', 'metrics', 'granularities', 'time_range_start', 'time_range_end', 'group_by', 'status', 'billing_user', 'updated_at', 'hidden', 'items_per_page'] fields_labels = ['Id', 'Name', 'Description', 'Metrics', 'Granularities', 'Time Range Start', 'Time Range End', 'Group By', 'Status', 'Billing User', 'Updated at', 'Hidden', 'Items per Page'] utils.print_list(data, fields, fields_labels, sortby=0)
def do_metric_definition_list(cc, args): data = cc.metrics.mappings.list() fields = [ 'id', 'gnocchi_metric', 'name', 'description', 'show_measures', 'show_cost', 'function', 'reaggregation' ] fields_labels = [ 'Id', 'Metric', 'Name', 'Description', 'Show Measures', 'Show Cost', 'Function', 'Reaggregation' ] utils.print_list(data, fields, fields_labels, sortby=0)
def do_rating_metadata_rule_set_list(cc, args={}): """List metadata rule sets.""" try: created_metadata_rule_set = cc.gnocchi.metadata_rule_sets.list( metric_rule_set_id=args.metric_rule_set_id) except exc.HTTPNotFound: raise exc.CommandError('Metadata rule sets not found: %s' % args.counter_name) else: field_labels = ['Id', 'Name', 'Metadata rule set id'] fields = ['id', 'name', 'metric_rule_set_id'] utils.print_list(created_metadata_rule_set, fields, field_labels, sortby=0)
def do_dashboard_definition_list(cc, args): data = cc.charts.dashboards.list() fields = [ 'id', 'name', 'description', 'charts', 'charts_width', 'charts_height', 'charts_x', 'charts_y', 'status', 'billing_user', 'is_default', 'updated_at', 'hidden' ] fields_labels = [ 'Id', 'Name', 'Description', 'Charts', 'Charts Widths', 'Charts Heights', 'Charts X', 'Charts Y', 'Status', 'Billing User', 'Is Default', 'Updated at', 'Hidden' ] utils.print_list(data, fields, fields_labels, sortby=0)
def do_rating_metric_rule_set_list(cc, args={}): """List metric rule sets.""" try: metric_rule_sets = cc.gnocchi.metric_rule_sets.list() except exc.HTTPNotFound: raise exc.CommandError('Metric rule sets not found: %s' % args.counter_name) else: field_labels = ['Gnocchi Metric', 'Aggregation Function', 'Gnocchi Unit', 'Billing Unit', 'Id'] fields = ['gnocchi_metric', 'aggregation_function', 'gnocchi_unit', 'billing_unit', 'id'] utils.print_list(metric_rule_sets, fields, field_labels, sortby=0)
def do_rating_metric_rule_list(cc, args={}): """List metric rules.""" if args.metric_rule_set_id is None: raise exc.CommandError("Provide metric-rule-set-id") try: metric_rules = cc.gnocchi.metric_rules.list( metric_rule_set_id=args.metric_rule_set_id) except exc.HTTPNotFound: raise exc.CommandError('Metric rule not found: %s' % args.counter_name) else: field_labels = ['Id', 'Cost', 'Type', 'Metric rule set id', 'Valid Since', 'Valid Until', 'Providers'] fields = ['id', 'cost', 'type', 'metric_rule_set_id', 'valid_since', 'valid_until', 'providers'] utils.print_list(metric_rules, fields, field_labels, sortby=0)
def do_chart_definition_list(cc, args): data = cc.charts.mappings.list() fields = [ 'id', 'gnocchi_metric', 'name', 'description', 'granularities', 'time_range_start', 'time_range_end', 'group_by', 'show_measures', 'show_cost', 'billing_user', 'function', 'reaggregation', 'chart_type', 'chart_width', 'chart_height', 'chart_x', 'chart_y', 'is_in_use', 'hidden' ] fields_labels = [ 'Id', 'Metric', 'Name', 'Description', 'Granularities', 'Time Range Start', 'Time Range End', 'Group By', 'Show Measures', 'Show Cost', 'Billing User', 'Function', 'Reaggregation', 'Chart Type', 'Chart Width', 'Chart Heigth', 'Chart posX', 'Chart posY', 'Is in Use', 'Hidden' ] utils.print_list(data, fields, fields_labels, sortby=0)
def _print_chart_definition_measures(data): if isinstance(data, dict): data_dict = data else: data_dict = data.to_dict() print("Chart name: " + unicode(data_dict["name"])) print("Chart description: " + unicode(data_dict["description"])) print("Chart unit: " + unicode(data_dict["unit"])) print("Chart has measures: " + unicode(data_dict["has_measures"])) print("Chart has cost: " + unicode(data_dict["has_cost"])) for group in data_dict["definition_measures"]: for key, val in group.iteritems(): if key != 'measures': print(key + ": " + unicode(val["display_name"])) if (len(group["measures"]) > 0 and "value" in group["measures"][0] and "cost" in group["measures"][0]): fields = ['timestamp', 'value', 'cost', 'granularity'] fields_labels = ['Timestamp', 'Value', 'Cost', 'Granularity'] utils.print_list(group["measures"], fields, fields_labels, formatters={ "timestamp": _dict_formatter("timestamp"), "value": _dict_formatter("value"), "cost": _dict_formatter("cost"), "granularity": _dict_formatter("granularity") }, sortby=0) elif len(group["measures"]) > 0 and "value" in group["measures"][0]: fields = ['timestamp', 'value', 'granularity'] fields_labels = ['Timestamp', 'Value', 'Granularity'] utils.print_list(group["measures"], fields, fields_labels, formatters={ "timestamp": _dict_formatter("timestamp"), "value": _dict_formatter("value"), "granularity": _dict_formatter("granularity") }, sortby=0) else: fields = ['timestamp', 'cost', 'granularity'] fields_labels = ['Timestamp', 'Cost', 'Granularity'] utils.print_list(group["measures"], fields, fields_labels, formatters={ "timestamp": _dict_formatter("timestamp"), "cost": _dict_formatter("cost"), "granularity": _dict_formatter("granularity") }, sortby=0)