Пример #1
0
def do_pyscripts_script_get(cc, args={}):
    """Get script."""
    try:
        script = cc.pyscripts.scripts.get(script_id=args.script_id)
    except exceptions.NotFound:
        raise exc.CommandError('Script not found: %s' % args.script_id)
    utils.print_dict(script.to_dict())
Пример #2
0
def do_pyscripts_script_get(cc, args={}):
    """Get script."""
    try:
        script = cc.pyscripts.scripts.get(script_id=args.script_id)
    except exc.HTTPNotFound:
        raise exc.CommandError('Script not found: %s' % args.script_id)
    utils.print_dict(script.to_dict())
def do_resource_usage_cost_count(cc, args):
    resource_usage_count = cc.billings.count_resource_usage_cost(args.resource_id,
                                                              args.tenant,
                                                              args.billing_month)

    count_dict = {'resource_usage_count': resource_usage_count}
    utils.print_dict(count_dict)
def do_resources_cost_count(cc, args):
    resources_count = cc.billings.count_resources_cost(args.tenant,
                                 args.billing_month,
                                 args.service)
    resources_count_dict = {'resources_count': resources_count}

    utils.print_dict(resources_count_dict)
Пример #5
0
def do_hashmap_threshold_group(cc, args={}):
    """Get a threshold group."""
    try:
        threshold = cc.hashmap.thresholds.group(threshold_id=args.threshold_id)
    except exc.HTTPNotFound:
        raise exc.CommandError('Threshold not found: %s' % args.threshold_id)
    utils.print_dict(threshold.to_dict())
def do_hashmap_threshold_group(cc, args={}):
    """Get a threshold group."""
    try:
        threshold = cc.hashmap.thresholds.group(threshold_id=args.threshold_id)
    except exc.HTTPNotFound:
        raise exc.CommandError('Threshold not found: %s' % args.threshold_id)
    utils.print_dict(threshold.to_dict())
Пример #7
0
def do_pyscripts_script_create(cc, args={}):
    """Create a script."""
    script_args = {'name': args.name}
    if args.file:
        with open(args.file) as fp:
            script_args['data'] = fp.read()
    out = cc.pyscripts.scripts.create(**script_args)
    utils.print_dict(out.to_dict())
Пример #8
0
def do_total_get(cc, args):
    """Get total reports."""
    begin = utils.ts2dt(args.begin) if args.begin else None
    end = utils.ts2dt(args.end) if args.end else None
    total = cc.reports.get_total(tenant_id=args.total_tenant_id,
                                 begin=begin,
                                 end=end)
    utils.print_dict({'Total': total or 0.0})
Пример #9
0
def do_pyscripts_script_create(cc, args={}):
    """Create a script."""
    script_args = {'name': args.name}
    if args.file:
        with open(args.file) as fp:
            script_args['data'] = fp.read()
    out = cc.pyscripts.scripts.create(**script_args)
    utils.print_dict(out.to_dict())
Пример #10
0
def do_total_get(cc, args):
    """Get total reports."""
    begin = utils.ts2dt(args.begin) if args.begin else None
    end = utils.ts2dt(args.end) if args.end else None
    total = cc.reports.get_total(tenant_id=args.total_tenant_id,
                                 begin=begin,
                                 end=end,
                                 service=args.service)
    utils.print_dict({'Total': total or 0.0})
Пример #11
0
def do_hashmap_field_create(cc, args={}):
    """Create a field."""
    arg_to_field_mapping = {'name': 'name', 'service_id': 'service_id'}
    fields = {}
    for k, v in vars(args).items():
        if k in arg_to_field_mapping:
            if v is not None:
                fields[arg_to_field_mapping.get(k, k)] = v
    out = cc.hashmap.fields.create(**fields)
    utils.print_dict(out.to_dict())
def do_hashmap_group_create(cc, args={}):
    """Create a group."""
    arg_to_field_mapping = {
        'name': 'name',
    }
    fields = {}
    for k, v in vars(args).items():
        if k in arg_to_field_mapping:
            if v is not None:
                fields[arg_to_field_mapping.get(k, k)] = v
    group = cc.hashmap.groups.create(**fields)
    utils.print_dict(group.to_dict())
Пример #13
0
def do_hashmap_group_create(cc, args={}):
    """Create a group."""
    arg_to_field_mapping = {
        'name': 'name',
    }
    fields = {}
    for k, v in vars(args).items():
        if k in arg_to_field_mapping:
            if v is not None:
                fields[arg_to_field_mapping.get(k, k)] = v
    group = cc.hashmap.groups.create(**fields)
    utils.print_dict(group.to_dict())
def do_hashmap_service_create(cc, args={}):
    """Create a service."""
    arg_to_field_mapping = {
        'name': 'name'
    }
    fields = {}
    for k, v in vars(args).items():
        if k in arg_to_field_mapping:
            if v is not None:
                fields[arg_to_field_mapping.get(k, k)] = v
    out = cc.hashmap.services.create(**fields)
    utils.print_dict(out.to_dict())
def do_pricing_version_create(cc, args={}):
    """Create a pricing version."""
    arg_to_field_mapping = {
        'billing_month': 'effective_billing_month',

    }
    fields = {}
    for k, v in vars(args).items():
        if k in arg_to_field_mapping:
            if v is not None:
                fields[arg_to_field_mapping.get(k, k)] = v
    out = cc.common.pricing_vers.create(**fields)
    utils.print_dict(out.to_dict())
def do_pricing_create(cc, args={}):
    """Create a pricing information."""
    arg_to_field_mapping = {
        'resource_type': 'res_type',
        'charging_key': 'charging_key',
        'charging_key_id': 'charging_key_id',
        'unit_price': 'unit_price',
        'time_based': 'time_based',
        'pricing_version': 'version'
    }
    fields = {}
    for k, v in vars(args).items():
        if k in arg_to_field_mapping:
            if v is not None:
                fields[arg_to_field_mapping.get(k, k)] = v
    out = cc.common.pricing_infos.create(**fields)
    utils.print_dict(out.to_dict())
def do_hashmap_threshold_create(cc, args={}):
    """Create a ampping."""
    arg_to_field_mapping = {
        'level': 'level',
        'cost': 'cost',
        'map_type': 'map_type',
        'service_id': 'service_id',
        'field_id': 'field_id',
        'group_id': 'group_id',
    }
    fields = {}
    for k, v in vars(args).items():
        if k in arg_to_field_mapping:
            if v is not None:
                fields[arg_to_field_mapping.get(k, k)] = v
    out = cc.hashmap.thresholds.create(**fields)
    utils.print_dict(out.to_dict())
Пример #18
0
def do_hashmap_threshold_create(cc, args={}):
    """Create a mapping."""
    arg_to_field_mapping = {
        'level': 'level',
        'cost': 'cost',
        'map_type': 'map_type',
        'service_id': 'service_id',
        'field_id': 'field_id',
        'group_id': 'group_id',
    }
    fields = {}
    for k, v in vars(args).items():
        if k in arg_to_field_mapping:
            if v is not None:
                fields[arg_to_field_mapping.get(k, k)] = v
    out = cc.hashmap.thresholds.create(**fields)
    utils.print_dict(out.to_dict())
Пример #19
0
def do_hashmap_mapping_create(cc, args={}):
    """Create a mapping."""
    arg_to_field_mapping = {
        'cost': 'cost',
        'value': 'value',
        'type': 'type',
        'service_id': 'service_id',
        'field_id': 'field_id',
        'group_id': 'group_id',
        'project_id': 'tenant_id',
    }
    fields = {}
    for k, v in vars(args).items():
        if k in arg_to_field_mapping:
            if v is not None:
                fields[arg_to_field_mapping.get(k, k)] = v
    out = cc.hashmap.mappings.create(**fields)
    utils.print_dict(out.to_dict())
Пример #20
0
def do_collector_state_disable(cc, args):
    """Disable collector state."""
    new_state = cc.collector.states.update(name=args.name, enabled=False)
    utils.print_dict(new_state.to_dict())
Пример #21
0
def do_collector_state_get(cc, args):
    """Show collector state."""
    data = cc.collector.states.get(state_id=args.name)
    utils.print_dict(data.to_dict())
Пример #22
0
def do_collector_mapping_create(cc, args):
    """Create collector mapping."""
    out = cc.collector.mappings.create(service=args.service,
                                       collector=args.collector)
    utils.print_dict(out.to_dict())
Пример #23
0
def do_collector_mapping_get(cc, args):
    """Show collector mapping detail."""
    data = cc.collector.mappings.get(mapping_id=args.service)
    utils.print_dict(data.to_dict())
def do_collector_state_enable(cc, args):
    new_state = cc.collector.states.update(name=args.name, enabled=True)
    utils.print_dict(new_state.to_dict())
Пример #25
0
def do_collector_mapping_get(cc, args):
    """Show collector mapping detail."""
    data = cc.collector.mappings.get(mapping_id=args.service)
    utils.print_dict(data.to_dict())
Пример #26
0
def do_collector_mapping_create(cc, args):
    """Create collector mapping."""
    out = cc.collector.mappings.create(service=args.service,
                                       collector=args.collector)
    utils.print_dict(out.to_dict())
Пример #27
0
def do_collector_state_get(cc, args):
    """Show collector state."""
    data = cc.collector.states.get(state_id=args.name)
    utils.print_dict(data.to_dict())
Пример #28
0
def do_info_config_get(cc, args):
    '''Get cloudkitty configuration.'''
    utils.print_dict(cc.config.get_config(), dict_property="Section")
Пример #29
0
def do_collector_state_disable(cc, args):
    """Disable collector state."""
    new_state = cc.collector.states.update(name=args.name, enabled=False)
    utils.print_dict(new_state.to_dict())
def do_collector_mapping_get(cc, args):
    data = cc.collector.mappings.get(mapping_id=args.service)
    utils.print_dict(data.to_dict())