remove remainder argument

Bug #1160203

Change-Id: I01c6aed18ccd7fe61a5ea4562c79d47222175147
This commit is contained in:
gongysh
2013-03-26 14:50:35 +08:00
parent bed337389d
commit 661aea13c1
2 changed files with 16 additions and 23 deletions

View File

@@ -119,14 +119,6 @@ def add_sorting_argument(parser):
choices=['asc', 'desc'])
def add_extra_argument(parser, name, _help):
parser.add_argument(
name,
nargs=argparse.REMAINDER,
help=_help + ': --key1 [type=int|bool|...] value '
'[--key2 [type=int|bool|...] value ...]')
def is_number(s):
try:
float(s) # for int, long and float
@@ -446,8 +438,6 @@ class ListCommand(QuantumCommand, lister.Lister):
def get_parser(self, prog_name):
parser = super(ListCommand, self).get_parser(prog_name)
add_show_list_common_argument(parser)
if self.unknown_parts_flag:
add_extra_argument(parser, 'filter_specs', 'filters options')
if self.pagination_support:
add_pagination_argument(parser)
if self.sorting_support:
@@ -456,8 +446,6 @@ class ListCommand(QuantumCommand, lister.Lister):
def args2search_opts(self, parsed_args):
search_opts = {}
if self.unknown_parts_flag:
search_opts = parse_args_to_dict(parsed_args.filter_specs)
fields = parsed_args.fields
if parsed_args.fields:
search_opts.update({'fields': fields})

View File

@@ -176,9 +176,6 @@ class UpdateQuota(QuantumCommand, show.ShowOne):
parser.add_argument(
'--security-group-rule', metavar='security_group_rules',
help='the limit of security groups rules')
quantumv20.add_extra_argument(
parser, 'value_specs',
'new values for the %s' % self.resource)
return parser
def _validate_int(self, name, value):
@@ -190,10 +187,7 @@ class UpdateQuota(QuantumCommand, show.ShowOne):
raise exceptions.QuantumClientException(message=message)
return return_value
def get_data(self, parsed_args):
self.log.debug('run(%s)' % parsed_args)
quantum_client = self.get_client()
quantum_client.format = parsed_args.request_format
def args2body(self, parsed_args):
quota = {}
for resource in ('network', 'subnet', 'port', 'router', 'floatingip',
'security_group', 'security_group_rule'):
@@ -201,14 +195,25 @@ class UpdateQuota(QuantumCommand, show.ShowOne):
quota[resource] = self._validate_int(
resource,
getattr(parsed_args, resource))
value_specs = parsed_args.value_specs
if value_specs:
quota.update(quantumv20.parse_args_to_dict(value_specs))
return {self.resource: quota}
def get_data(self, parsed_args):
self.log.debug('run(%s)' % parsed_args)
quantum_client = self.get_client()
quantum_client.format = parsed_args.request_format
_extra_values = quantumv20.parse_args_to_dict(self.values_specs)
quantumv20._merge_args(self, parsed_args, _extra_values,
self.values_specs)
body = self.args2body(parsed_args)
if self.resource in body:
body[self.resource].update(_extra_values)
else:
body[self.resource] = _extra_values
obj_updator = getattr(quantum_client,
"update_%s" % self.resource)
tenant_id = get_tenant_id(parsed_args.tenant_id,
quantum_client)
data = obj_updator(tenant_id, {self.resource: quota})
data = obj_updator(tenant_id, body)
if self.resource in data:
for k, v in data[self.resource].iteritems():
if isinstance(v, list):