From abfcd7810cb5937060fd9ae290f07a48226c9ced Mon Sep 17 00:00:00 2001 From: Reedip Date: Wed, 16 Nov 2016 14:22:44 +0530 Subject: Introduce overwrite functionality in ``osc subnet set`` The overwrite functionality allows user to overwrite the dns-nameservers of a specific subnet. Change-Id: I421808a3bdeb4565668f627b7929c4762cf40212 partially-implements: blueprint allow-overwrite-set-options partially-implements: blueprint network-commands-options --- openstackclient/network/v2/subnet.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'openstackclient/network') diff --git a/openstackclient/network/v2/subnet.py b/openstackclient/network/v2/subnet.py index f1ecb5a7..dc504b32 100644 --- a/openstackclient/network/v2/subnet.py +++ b/openstackclient/network/v2/subnet.py @@ -84,6 +84,15 @@ def _get_common_parse_arguments(parser, is_create=True): help=_("DNS server for this subnet " "(repeat option to set multiple DNS servers)") ) + + if not is_create: + parser.add_argument( + '--no-dns-nameservers', + action='store_true', + help=_("Clear existing information of DNS Nameservers. " + "Specify both --dns-nameserver and --no-dns-nameserver " + "to overwrite the current DNS Nameserver information.") + ) parser.add_argument( '--host-route', metavar='destination=,gateway=', @@ -532,7 +541,10 @@ class SetSubnet(command.Command): attrs = _get_attrs(self.app.client_manager, parsed_args, is_create=False) if 'dns_nameservers' in attrs: - attrs['dns_nameservers'] += obj.dns_nameservers + if not parsed_args.no_dns_nameservers: + attrs['dns_nameservers'] += obj.dns_nameservers + elif parsed_args.no_dns_nameservers: + attrs['dns_nameservers'] = [] if 'host_routes' in attrs: if not parsed_args.no_host_route: attrs['host_routes'] += obj.host_routes -- cgit v1.2.1