def do_storage_dataframe_list(cc, args):
    data = cc.storage.dataframes.list(begin=args.begin, end=args.end,
                                      tenant_id=args.tenant,
                                      resource_type=args.resource_type)
    fields = ['begin', 'end', 'tenant_id', 'resources']
    fields_labels = ['Begin', 'End', 'Tenant ID', 'Resources']
    utils.print_list(data, fields, fields_labels, sortby=0)
Exemplo n.º 2
0
def do_storage_dataframe_list(cc, args):
    """List dataframes."""
    data = cc.storage.dataframes.list(begin=args.begin, end=args.end,
                                      tenant_id=args.tenant,
                                      resource_type=args.resource_type)
    fields = ['begin', 'end', 'tenant_id', 'resources']
    fields_labels = ['Begin', 'End', 'Tenant ID', 'Resources']
    utils.print_list(data, fields, fields_labels, sortby=0)
Exemplo n.º 3
0
def do_pyscripts_script_list(cc, args={}):
    """List scripts."""
    request_args = {}
    if not args.show_data:
        request_args['no_data'] = True
    scripts = cc.pyscripts.scripts.list(**request_args)
    field_labels = ['Name', 'Script id', 'Data', 'Checksum']
    fields = ['name', 'script_id', 'data', 'checksum']
    utils.print_list(scripts, fields, field_labels, sortby=0)
def do_total_get(cc, args):
    try:
        total = cc.reports.get_total(args.billing_month, args.total_tenant_id)
    except exc.HTTPNotFound:
        raise exc.CommandError('Total cost not found: %s' % args.counter_name)
    else:
        field_labels = ['Tenant ID', 'Tenant Name', 'Organization Name', 'Cost']
        fields = ['tenant_id', 'tenant_name', 'org_name', 'total']
        utils.print_list(total, fields, field_labels, sortby=0)
Exemplo n.º 5
0
def do_hashmap_field_list(cc, args={}):
    """List fields."""
    try:
        created_field = cc.hashmap.fields.list(service_id=args.service_id)
    except exc.HTTPNotFound:
        raise exc.CommandError('Fields not found: %s' % args.counter_name)
    else:
        field_labels = ['Name', 'Field id']
        fields = ['name', 'field_id']
        utils.print_list(created_field, fields, field_labels, sortby=0)
Exemplo n.º 6
0
def do_hashmap_service_list(cc, args={}):
    """List services."""
    try:
        services = cc.hashmap.services.list()
    except exc.HTTPNotFound:
        raise exc.CommandError('Services not found: %s' % args.counter_name)
    else:
        field_labels = ['Name', 'Service id']
        fields = ['name', 'service_id']
        utils.print_list(services, fields, field_labels, sortby=0)
def do_services_cost_list(cc, args):
    total_by_service = cc.billings.list_services_cost(args.billing_month,
                                 args.total_tenant_id)
    field_labels = ['Service', 'qty', 'unit', 'rate']
    fields = ['service_id', 'qty', 'unit', 'rate']
    servicesRate = []
    for serviceRate in total_by_service['servicesRate']:
        servicesRate.append(utils.Dict2Obj(serviceRate))
    
    utils.print_list(servicesRate, fields, field_labels, sortby=0)
Exemplo n.º 8
0
def do_hashmap_group_list(cc, args={}):
    """List groups."""
    try:
        groups = cc.hashmap.groups.list()
    except exc.HTTPNotFound:
        raise exc.CommandError('Mapping not found: %s' % args.counter_name)
    else:
        field_labels = ['Name', 'Group id']
        fields = ['name', 'group_id']
        utils.print_list(groups, fields, field_labels, sortby=0)
Exemplo n.º 9
0
def do_hashmap_service_list(cc, args={}):
    """List services."""
    try:
        services = cc.hashmap.services.list()
    except exc.HTTPNotFound:
        raise exc.CommandError('Services not found: %s' % args.counter_name)
    else:
        field_labels = ['Name', 'Service id']
        fields = ['name', 'service_id']
        utils.print_list(services, fields, field_labels,
                         sortby=0)
Exemplo n.º 10
0
def do_pricing_list(cc, args={}):
    """List pricing informations."""
    try:
        pricing_infos = cc.common.pricing_infos.list(charging_key_id=args.charging_key_id, pricing_version=args.pricing_version)
    except exc.HTTPNotFound:
        raise exc.CommandError('Pricing informations not found: %s' % args.counter_name)
    else:
        field_labels = ['UUID', 'Charging Key', 'Resource Type', 'Unit Price', 'Time Based', 'Pricing Version']
        fields = ['pricing_info_id', 'charging_key', 'res_type', 'unit_price', 'time_based', 'version']
        utils.print_list(pricing_infos, fields, field_labels,
                         sortby=5)
Exemplo n.º 11
0
def do_pricing_version_list(cc, args={}):
    """List pricing versions."""
    try:
        pricing_vers = cc.common.pricing_vers.list(version=args.pricing_version)
    except exc.HTTPNotFound:
        raise exc.CommandError('Pricing version not found: %s' % args.counter_name)
    else:
        field_labels = ['Pricing Version', 'Effective Billing Month', 'Effective Time']
        fields = ['version', 'effective_billing_month', 'effective_time']
        utils.print_list(pricing_vers, fields, field_labels,
                         sortby=0)
Exemplo n.º 12
0
def do_module_list(cc, args):
    '''List the samples for this meters.'''
    try:
        modules = cc.modules.list()
    except exc.HTTPNotFound:
        raise exc.CommandError('Modules not found: %s' % args.counter_name)
    else:
        field_labels = ['Module', 'Enabled']
        fields = ['module_id', 'enabled']
        utils.print_list(modules, fields, field_labels,
                         sortby=0)
Exemplo n.º 13
0
def do_module_list(cc, args):
    '''List the samples for this meters.'''
    try:
        modules = cc.modules.list()
    except exceptions.NotFound:
        raise exc.CommandError('Modules not found')
    else:
        field_labels = ['Module', 'Enabled', 'Priority']
        fields = ['module_id', 'enabled', 'priority']
        utils.print_list(modules, fields, field_labels,
                         sortby=0)
Exemplo n.º 14
0
def do_hashmap_field_list(cc, args={}):
    """Create a field."""
    try:
        created_field = cc.hashmap.fields.list(service_id=args.service_id)
    except exc.HTTPNotFound:
        raise exc.CommandError('Fields not found: %s' % args.counter_name)
    else:
        field_labels = ['Name', 'Field id']
        fields = ['name', 'field_id']
        utils.print_list(created_field, fields, field_labels,
                         sortby=0)
Exemplo n.º 15
0
def do_consumer_trends_get(cc, args):
    consumer_trends = \
        cc.billings.get_consumer_trends(args.counter_type,
                                        args.back,
                                        args.tenant)
    field_labels = ['Time', 'Cost']
    fields = ['time', 'cost']
    consumer_trends_obj = []
    for consumer_trend in consumer_trends['consumerTrends']:
        consumer_trends_obj.append(utils.Dict2Obj(consumer_trend))

    utils.print_list(consumer_trends_obj, fields, field_labels, sortby=0)
Exemplo n.º 16
0
def do_hashmap_group_list(cc, args={}):
    """List groups."""
    try:
        groups = cc.hashmap.groups.list()
    except exc.HTTPNotFound:
        raise exc.CommandError('Mapping not found: %s' % args.counter_name)
    else:
        field_labels = ['Name',
                        'Group id']
        fields = ['name', 'group_id']
        utils.print_list(groups, fields, field_labels,
                         sortby=0)
Exemplo n.º 17
0
def do_pyscripts_script_list(cc, args={}):
    """List scripts."""
    request_args = {}
    if not args.show_data:
        request_args['no_data'] = True
    scripts = cc.pyscripts.scripts.list(**request_args)
    field_labels = ['Name', 'Script id', 'Data', 'Checksum']
    fields = ['name', 'script_id', 'data', 'checksum']
    utils.print_list(scripts,
                     fields,
                     field_labels,
                     sortby=0)
Exemplo n.º 18
0
def do_service_rate_list(cc, args):
    total_by_service = cc.rate_services.list_service_rate(args.total_tenant_id,
                                 args.begin,
                                 args.end)
    field_labels = ['Service', 'qty', 'unit', 'rate']
    fields = ['service_id', 'qty', 'unit', 'rate']
    servicesRate = []
    for serviceRate in total_by_service['servicesRate']:
        servicesRate.append(utils.Dict2Obj(serviceRate))
    
    print total_by_service
    utils.print_list(servicesRate, fields, field_labels, sortby=0)    
Exemplo n.º 19
0
def do_hashmap_group_list(cc, args={}):
    """List groups."""
    try:
        groups = cc.hashmap.groups.list()
    except exceptions.NotFound:
        raise exc.CommandError('Groups not found.')
    else:
        field_labels = ['Name',
                        'Group id']
        fields = ['name', 'group_id']
        utils.print_list(groups, fields, field_labels,
                         sortby=0)
Exemplo n.º 20
0
def do_total_cost_get(cc, args):
    try:
        totals = cc.billings.get_total_cost(args.billing_month, args.total_tenant_id)
    except exc.HTTPNotFound:
        raise exc.CommandError('Total cost not found: %s' % args.counter_name)
    else:
        field_labels = ['Tenant ID', 'Tenant Name', 'Organization Name', 'Cost']
        fields = ['tenant_id', 'tenant_name', 'org_name', 'cost']
        total_cost = []
        for total in totals['totals']:
            total_cost.append(utils.Dict2Obj(total))
        utils.print_list(total_cost, fields, field_labels, sortby=None)
Exemplo n.º 21
0
def do_module_set_priority(cc, args):
    '''Set module priority.'''
    try:
        module = cc.modules.get(module_id=args.name)
        module.set_priority(args.priority)
    except exceptions.NotFound:
        raise exc.CommandError('Module not found: %s' % args.name)
    else:
        field_labels = ['Module', 'Enabled', 'Priority']
        fields = ['module_id', 'enabled', 'priority']
        modules = [cc.modules.get(module_id=args.name)]
        utils.print_list(modules, fields, field_labels,
                         sortby=0)
Exemplo n.º 22
0
def do_module_disable(cc, args):
    '''Disable a module.'''
    try:
        module = cc.modules.get(module_id=args.name)
        module.disable()
    except exc.HTTPNotFound:
        raise exc.CommandError('Modules not found: %s' % args.counter_name)
    else:
        field_labels = ['Module', 'Enabled']
        fields = ['module_id', 'enabled']
        modules = [cc.modules.get(module_id=args.name)]
        utils.print_list(modules, fields, field_labels,
                         sortby=0)
Exemplo n.º 23
0
def do_resource_rate_list(cc, args):
    resources_rate_dict = cc.rate_services.list_resource_rate(args.tenant,
                                 args.begin,
                                 args.end,
                                 args.service)

    field_labels = ['Resource Name', 'Type', 'ID', 'Status', 'Rate', 'Unit Price', 'Created Time']
    fields = ['resource_name', 'res_type', 'resource_id', 'status', 'rate', 'unit_price', 'created_time']
    resourcesRate = []
    for resourceRate in resources_rate_dict['resourcesRate']:
        resourcesRate.append(utils.Dict2Obj(resourceRate))
    
    print resources_rate_dict
    utils.print_list(resourcesRate, fields, field_labels, sortby=0)
Exemplo n.º 24
0
def do_resources_cost_list(cc, args):
    resources_rate_dict = cc.billings.list_resources_cost(args.tenant,
                                 args.billing_month,
                                 args.service,
                                 args.offset,
                                 args.limit)

    field_labels = ['Resource Name', 'Type', 'ID', 'Status', 'Rate', 'Unit Price', 'Created Time', 'Comment']
    fields = ['resource_name', 'res_type', 'resource_id', 'status', 'rate', 'unit_price', 'created_time', 'comment']
    resourcesRate = []
    for resourceRate in resources_rate_dict['resourcesRate']:
        resourcesRate.append(utils.Dict2Obj(resourceRate))
    
    utils.print_list(resourcesRate, fields, field_labels, sortby=0)
Exemplo n.º 25
0
def do_resource_rate_show(cc, args):
    resources_rate_dict = cc.rate_services.show_resource_rate(args.resource_id,
                                                              args.tenant,
                                                              args.begin,
                                                              args.end)

    field_labels = ['Begin', 'End', 'Rate', 'Qty', 'Unit', 'Unit Price', 'Comment']
    fields = ['begin', 'end', 'rate', 'qty', 'unit', 'unit_price', 'comment']
    
    resourcesUsageRate = []
    for resourceUsageRate in resources_rate_dict['resourcesUsageRate']:
        resourcesUsageRate.append(utils.Dict2Obj(resourceUsageRate))
    
    utils.print_list(resourcesUsageRate, fields, field_labels, sortby=0)
Exemplo n.º 26
0
def do_month_report_show(cc,args):
    month_reports = cc.billings.list_month_report(args.tenant,args.billing_month)
    field_labels = ['TenantID','TenantName','Qty','Rate','Res_Type','Month']
    fields = ['tenant_id','tenant_name','qty','rate','res_type','month']
    month_reports_obj = []
    for depart in month_reports['departs']:
        for month_report in depart['month_reports']:
		        for res_type in month_report['res_types']:
		            res_type['month'] = month_report['month']
		            res_type['tenant_name'] = depart['tenant_name']
		            res_type['tenant_id'] = depart['tenant_id']
		            month_reports_obj.append(utils.Dict2Obj(res_type))
    
    utils.print_list(month_reports_obj,fields,field_labels,sortby=5)
Exemplo n.º 27
0
def do_summary_get(cc, args):
    """Get summary report."""
    begin = utils.ts2dt(args.begin) if args.begin else None
    end = utils.ts2dt(args.end) if args.end else None
    summarys = cc.reportsummary.get_summary(tenant_id=args.summary_tenant_id,
                                            begin=begin,
                                            end=end,
                                            service=args.service,
                                            groupby=args.groupby,
                                            all_tenants=args.all_tenants)
    field_labels = [
        'Tenant ID', 'Resource Type', 'Rate', 'Begin Time', 'End Time'
    ]
    fields = ['tenant_id', 'res_type', 'rate', 'begin', 'end']
    utils.print_list(summarys, fields, field_labels, sortby=0)
Exemplo n.º 28
0
def do_resource_usage_cost_show(cc, args):
    resources_rate_dict = cc.billings.show_resource_usage_cost(args.resource_id,
                                                              args.tenant,
                                                              args.billing_month,
                                                              args.offset,
                                                              args.limit)

    field_labels = ['Begin', 'End', 'Rate', 'Qty', 'Unit', 'Unit Price', 'Comment']
    fields = ['begin', 'end', 'rate', 'qty', 'unit', 'unit_price', 'comment']
    
    resourcesUsageRate = []
    for resourceUsageRate in resources_rate_dict['resourcesUsageRate']:
        resourcesUsageRate.append(utils.Dict2Obj(resourceUsageRate))
    
    utils.print_list(resourcesUsageRate, fields, field_labels, sortby=0)
Exemplo n.º 29
0
def do_info_service_get(cc, args):
    '''Get service info.'''
    if args.name:
        try:
            services_info = [cc.service_info.get(service_id=args.name)]
        except exceptions.NotFound:
            raise exc.CommandError('Service not found: %s' % args.name)
    else:
        try:
            services_info = cc.service_info.list()
        except exceptions.NotFound:
            raise exc.CommandError('ServiceInfo not found')

    field_labels = ['Service', 'Metadata', 'Unit']
    fields = ['service_id', 'metadata', 'unit']
    utils.print_list(services_info, fields, field_labels, sortby=0)
Exemplo n.º 30
0
def do_hashmap_mapping_list(cc, args={}):
    """List mappings."""
    if args.service_id is None and args.field_id is None:
        raise exc.CommandError("Provide either service-id or field-id")
    try:
        mappings = cc.hashmap.mappings.list(service_id=args.service_id,
                                            field_id=args.field_id,
                                            group_id=args.group_id)
    except exc.HTTPNotFound:
        raise exc.CommandError('Mapping not found: %s' % args.counter_name)
    else:
        field_labels = ['Mapping id', 'Value', 'Cost',
                        'Type', 'Field id',
                        'Service id', 'Group id']
        fields = ['mapping_id', 'value', 'cost',
                  'type', 'field_id',
                  'service_id', 'group_id']
        utils.print_list(mappings, fields, field_labels,
                         sortby=0)
Exemplo n.º 31
0
def do_hashmap_mapping_list(cc, args={}):
    """List mappings."""
    if args.service_id is None and args.field_id is None:
        raise exc.CommandError("Provide either service-id or field-id")
    try:
        mappings = cc.hashmap.mappings.list(service_id=args.service_id,
                                            field_id=args.field_id,
                                            group_id=args.group_id)
    except exc.HTTPNotFound:
        raise exc.CommandError('Mapping not found: %s' % args.counter_name)
    else:
        field_labels = [
            'Mapping id', 'Value', 'Cost', 'Type', 'Field id', 'Service id',
            'Group id'
        ]
        fields = [
            'mapping_id', 'value', 'cost', 'type', 'field_id', 'service_id',
            'group_id'
        ]
        utils.print_list(mappings, fields, field_labels, sortby=0)
Exemplo n.º 32
0
def do_hashmap_threshold_list(cc, args={}):
    """List thresholds."""
    if (args.group_id is None and
       args.service_id is None and args.field_id is None):
        raise exc.CommandError("Provide either group-id, service-id or "
                               "field-id")
    try:
        thresholds = cc.hashmap.thresholds.list(service_id=args.service_id,
                                                field_id=args.field_id,
                                                group_id=args.group_id,
                                                no_group=args.no_group)
    except exc.HTTPNotFound:
        raise exc.CommandError('Threshold not found: %s' % args.counter_name)
    else:
        field_labels = ['Threshold id', 'Level', 'Cost',
                        'Type', 'Field id',
                        'Service id', 'Group id']
        fields = ['threshold_id', 'level', 'cost',
                  'map_type', 'field_id',
                  'service_id', 'group_id']
        utils.print_list(thresholds, fields, field_labels, sortby=0)
Exemplo n.º 33
0
def do_hashmap_threshold_list(cc, args={}):
    """List thresholds."""
    if (args.group_id is None and
       args.service_id is None and args.field_id is None):
        raise exc.CommandError("Provide either group-id, service-id or "
                               "field-id")
    try:
        thresholds = cc.hashmap.thresholds.list(service_id=args.service_id,
                                                field_id=args.field_id,
                                                group_id=args.group_id,
                                                no_group=args.no_group)
    except exceptions.NotFound:
        raise exc.CommandError('Thresholds not found')
    else:
        field_labels = ['Threshold id', 'Level', 'Cost',
                        'Type', 'Field id',
                        'Service id', 'Group id', 'Tenant id']
        fields = ['threshold_id', 'level', 'cost',
                  'type', 'field_id',
                  'service_id', 'group_id', 'tenant_id']
        utils.print_list(thresholds, fields, field_labels, sortby=0)
Exemplo n.º 34
0
def do_collector_mapping_list(cc, args):
    """List collector mapping."""
    data = cc.collector.mappings.list(collector=args.collector)
    fields = ['service', 'collector']
    fields_labels = ['Service', 'Collector']
    utils.print_list(data, fields, fields_labels, sortby=0)
Exemplo n.º 35
0
def do_collector_mapping_list(cc, args):
    """List collector mapping."""
    data = cc.collector.mappings.list(collector=args.collector)
    fields = ['service', 'collector']
    fields_labels = ['Service', 'Collector']
    utils.print_list(data, fields, fields_labels, sortby=0)