summaryrefslogtreecommitdiff
path: root/openstackclient
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2016-09-17 02:04:50 +0000
committerGerrit Code Review <review@openstack.org>2016-09-17 02:04:50 +0000
commit7e990ba1e2ae0ecb804287212797ebad84d7b56b (patch)
tree09cc9514101790091267dd26abf1c209b34dd7e1 /openstackclient
parente6b09eef0c02f2671ef263df61d193533e65d024 (diff)
parent7cba0ed671a1771d082da969a95ca0b4f4b9dafe (diff)
downloadpython-openstackclient-7e990ba1e2ae0ecb804287212797ebad84d7b56b.tar.gz
Merge "Doc, help and message updates for port unset"
Diffstat (limited to 'openstackclient')
-rw-r--r--openstackclient/network/v2/subnet.py57
1 files changed, 24 insertions, 33 deletions
diff --git a/openstackclient/network/v2/subnet.py b/openstackclient/network/v2/subnet.py
index 6feb8aa0..f1c7d15d 100644
--- a/openstackclient/network/v2/subnet.py
+++ b/openstackclient/network/v2/subnet.py
@@ -28,9 +28,14 @@ from openstackclient.identity import common as identity_common
LOG = logging.getLogger(__name__)
-def _update_arguments(obj_list, parsed_args_list):
+def _update_arguments(obj_list, parsed_args_list, option):
for item in parsed_args_list:
- obj_list.remove(item)
+ try:
+ obj_list.remove(item)
+ except ValueError:
+ msg = (_("Subnet does not contain %(option)s %(value)s") %
+ {'option': option, 'value': item})
+ raise exceptions.CommandError(msg)
def _format_allocation_pools(data):
@@ -493,9 +498,9 @@ class UnsetSubnet(command.Command):
dest='allocation_pools',
action=parseractions.MultiKeyValueAction,
required_keys=['start', 'end'],
- help=_('Allocation pool to be removed from this subnet '
- 'e.g.: start=192.168.199.2,end=192.168.199.254 '
- '(repeat option to unset multiple Allocation pools)')
+ help=_('Allocation pool IP addresses to be removed from this '
+ 'subnet e.g.: start=192.168.199.2,end=192.168.199.254 '
+ '(repeat option to unset multiple allocation pools)')
)
parser.add_argument(
'--dns-nameserver',
@@ -503,7 +508,7 @@ class UnsetSubnet(command.Command):
action='append',
dest='dns_nameservers',
help=_('DNS server to be removed from this subnet '
- '(repeat option to set multiple DNS servers)')
+ '(repeat option to unset multiple DNS servers)')
)
parser.add_argument(
'--host-route',
@@ -540,39 +545,25 @@ class UnsetSubnet(command.Command):
tmp_obj = copy.deepcopy(obj)
attrs = {}
if parsed_args.dns_nameservers:
- try:
- _update_arguments(tmp_obj.dns_nameservers,
- parsed_args.dns_nameservers)
- except ValueError as error:
- msg = (_("%s not in dns-nameservers") % str(error))
- raise exceptions.CommandError(msg)
+ _update_arguments(tmp_obj.dns_nameservers,
+ parsed_args.dns_nameservers,
+ 'dns-nameserver')
attrs['dns_nameservers'] = tmp_obj.dns_nameservers
if parsed_args.host_routes:
- try:
- _update_arguments(
- tmp_obj.host_routes,
- convert_entries_to_nexthop(parsed_args.host_routes))
- except ValueError as error:
- msg = (_("Subnet does not have %s in host-routes") %
- str(error))
- raise exceptions.CommandError(msg)
+ _update_arguments(
+ tmp_obj.host_routes,
+ convert_entries_to_nexthop(parsed_args.host_routes),
+ 'host-route')
attrs['host_routes'] = tmp_obj.host_routes
if parsed_args.allocation_pools:
- try:
- _update_arguments(tmp_obj.allocation_pools,
- parsed_args.allocation_pools)
- except ValueError as error:
- msg = (_("Subnet does not have %s in allocation-pools") %
- str(error))
- raise exceptions.CommandError(msg)
+ _update_arguments(tmp_obj.allocation_pools,
+ parsed_args.allocation_pools,
+ 'allocation-pool')
attrs['allocation_pools'] = tmp_obj.allocation_pools
if parsed_args.service_types:
- try:
- _update_arguments(tmp_obj.service_types,
- parsed_args.service_types)
- except ValueError as error:
- msg = (_("%s not in service-types") % str(error))
- raise exceptions.CommandError(msg)
+ _update_arguments(tmp_obj.service_types,
+ parsed_args.service_types,
+ 'service-type')
attrs['service_types'] = tmp_obj.service_types
if attrs:
client.update_subnet(obj, **attrs)