Fix CLI threshold command

- Threshold commands now use 'type' API field instead of 'map_type'
- change CLI option from "-m, --map-type" to "-t, --type" (same as mapping commands option)
- change short option for threshold-id to "-i"

Change-Id: I8c0f6b135bdc206ce1fc3ea14debd8d2cafc9ea7
Closes-Bug: #1619150
This commit is contained in:
Maxime Cottret
2016-09-01 11:12:37 +02:00
parent 9554c9e440
commit a6093c5a36

View File

@@ -287,7 +287,7 @@ def common_hashmap_threshold_arguments(create=False):
@utils.arg('-c', '--cost', @utils.arg('-c', '--cost',
help='Threshold cost', help='Threshold cost',
required=create) required=create)
@utils.arg('-m', '--map-type', @utils.arg('-t', '--type',
help='Threshold type (flat, rate)', help='Threshold type (flat, rate)',
required=False) required=False)
@utils.arg('-g', '--group-id', @utils.arg('-g', '--group-id',
@@ -315,7 +315,7 @@ def do_hashmap_threshold_create(cc, args={}):
arg_to_field_mapping = { arg_to_field_mapping = {
'level': 'level', 'level': 'level',
'cost': 'cost', 'cost': 'cost',
'map_type': 'map_type', 'type': 'type',
'service_id': 'service_id', 'service_id': 'service_id',
'field_id': 'field_id', 'field_id': 'field_id',
'group_id': 'group_id', 'group_id': 'group_id',
@@ -330,7 +330,7 @@ def do_hashmap_threshold_create(cc, args={}):
utils.print_dict(out.to_dict()) utils.print_dict(out.to_dict())
@utils.arg('-t', '--threshold-id', @utils.arg('-i', '--threshold-id',
help='Threshold id', help='Threshold id',
required=True) required=True)
@common_hashmap_threshold_arguments() @common_hashmap_threshold_arguments()
@@ -340,7 +340,7 @@ def do_hashmap_threshold_update(cc, args={}):
'threshold_id': 'threshold_id', 'threshold_id': 'threshold_id',
'cost': 'cost', 'cost': 'cost',
'level': 'level', 'level': 'level',
'map_type': 'map_type', 'type': 'type',
'group_id': 'group_id', 'group_id': 'group_id',
'project_id': 'tenant_id', 'project_id': 'tenant_id',
} }
@@ -389,12 +389,12 @@ def do_hashmap_threshold_list(cc, args={}):
'Type', 'Field id', 'Type', 'Field id',
'Service id', 'Group id', 'Tenant id'] 'Service id', 'Group id', 'Tenant id']
fields = ['threshold_id', 'level', 'cost', fields = ['threshold_id', 'level', 'cost',
'map_type', 'field_id', 'type', 'field_id',
'service_id', 'group_id', 'tenant_id'] 'service_id', 'group_id', 'tenant_id']
utils.print_list(thresholds, fields, field_labels, sortby=0) utils.print_list(thresholds, fields, field_labels, sortby=0)
@utils.arg('-t', '--threshold-id', @utils.arg('-i', '--threshold-id',
help='Threshold uuid', help='Threshold uuid',
required=True) required=True)
def do_hashmap_threshold_delete(cc, args={}): def do_hashmap_threshold_delete(cc, args={}):
@@ -405,7 +405,7 @@ def do_hashmap_threshold_delete(cc, args={}):
raise exc.CommandError('Threshold not found: %s' % args.threshold_id) raise exc.CommandError('Threshold not found: %s' % args.threshold_id)
@utils.arg('-t', '--threshold-id', @utils.arg('-i', '--threshold-id',
help='Threshold uuid', help='Threshold uuid',
required=True) required=True)
def do_hashmap_threshold_get(cc, args={}): def do_hashmap_threshold_get(cc, args={}):
@@ -417,7 +417,7 @@ def do_hashmap_threshold_get(cc, args={}):
utils.print_dict(threshold.to_dict()) utils.print_dict(threshold.to_dict())
@utils.arg('-t', '--threshold-id', @utils.arg('-i', '--threshold-id',
help='Threshold uuid', help='Threshold uuid',
required=True) required=True)
def do_hashmap_threshold_group(cc, args={}): def do_hashmap_threshold_group(cc, args={}):