From a5865b176304b92736a71cd6ad2dd1199c588ba5 Mon Sep 17 00:00:00 2001 From: Bernard Cafarelli Date: Tue, 4 Sep 2018 17:52:46 +0200 Subject: [PATCH] Partially Revert "Add command to unset information from Subnet-pools" We do not support removing a prefix from a subnet pool, only updating with a larger prefix (which is handled by the set command) This reverts commit 063c722a110031883e9615064092644de6df8da2. Change-Id: I11224fbdb94dc1caef42a8a64cbcebaf1dc542fe Story: #1670230 Task: #13697 --- .../cli/command-objects/subnet-pool.rst | 6 ---- openstackclient/network/v2/subnet_pool.py | 23 ------------ .../tests/unit/network/v2/test_subnet_pool.py | 35 +------------------ 3 files changed, 1 insertion(+), 63 deletions(-) diff --git a/doc/source/cli/command-objects/subnet-pool.rst b/doc/source/cli/command-objects/subnet-pool.rst index 0cff4d7f56..4606881b54 100644 --- a/doc/source/cli/command-objects/subnet-pool.rst +++ b/doc/source/cli/command-objects/subnet-pool.rst @@ -292,15 +292,9 @@ Unset subnet pool properties .. code:: bash openstack subnet pool unset - [--pool-prefix [...]] [--tag | --all-tag] -.. option:: --pool-prefix - - Remove subnet pool prefixes (in CIDR notation). - (repeat option to unset multiple prefixes). - .. option:: --tag Tag to be removed from the subnet pool diff --git a/openstackclient/network/v2/subnet_pool.py b/openstackclient/network/v2/subnet_pool.py index a583986856..d85410691a 100644 --- a/openstackclient/network/v2/subnet_pool.py +++ b/openstackclient/network/v2/subnet_pool.py @@ -13,7 +13,6 @@ """Subnet pool action implementations""" -import copy import logging from osc_lib.cli import parseractions @@ -440,14 +439,6 @@ class UnsetSubnetPool(command.Command): def get_parser(self, prog_name): parser = super(UnsetSubnetPool, self).get_parser(prog_name) - parser.add_argument( - '--pool-prefix', - metavar='', - action='append', - dest='prefixes', - help=_('Remove subnet pool prefixes (in CIDR notation). ' - '(repeat option to unset multiple prefixes).'), - ) parser.add_argument( 'subnet_pool', metavar="", @@ -460,19 +451,5 @@ class UnsetSubnetPool(command.Command): client = self.app.client_manager.network obj = client.find_subnet_pool( parsed_args.subnet_pool, ignore_missing=False) - tmp_prefixes = copy.deepcopy(obj.prefixes) - attrs = {} - if parsed_args.prefixes: - for prefix in parsed_args.prefixes: - try: - tmp_prefixes.remove(prefix) - except ValueError: - msg = _( - "Subnet pool does not " - "contain prefix %s") % prefix - raise exceptions.CommandError(msg) - attrs['prefixes'] = tmp_prefixes - if attrs: - client.update_subnet_pool(obj, **attrs) # tags is a subresource and it needs to be updated separately. _tag.update_tags_for_unset(client, obj, parsed_args) diff --git a/openstackclient/tests/unit/network/v2/test_subnet_pool.py b/openstackclient/tests/unit/network/v2/test_subnet_pool.py index 81f0278f26..3d8f1028e6 100644 --- a/openstackclient/tests/unit/network/v2/test_subnet_pool.py +++ b/openstackclient/tests/unit/network/v2/test_subnet_pool.py @@ -1016,9 +1016,7 @@ class TestUnsetSubnetPool(TestSubnetPool): def setUp(self): super(TestUnsetSubnetPool, self).setUp() self._subnetpool = network_fakes.FakeSubnetPool.create_one_subnet_pool( - {'prefixes': ['10.0.10.0/24', '10.1.10.0/24', - '10.2.10.0/24'], - 'tags': ['green', 'red']}) + {'tags': ['green', 'red']}) self.network.find_subnet_pool = mock.Mock( return_value=self._subnetpool) self.network.update_subnet_pool = mock.Mock(return_value=None) @@ -1026,37 +1024,6 @@ class TestUnsetSubnetPool(TestSubnetPool): # Get the command object to test self.cmd = subnet_pool.UnsetSubnetPool(self.app, self.namespace) - def test_unset_subnet_pool(self): - arglist = [ - '--pool-prefix', '10.0.10.0/24', - '--pool-prefix', '10.1.10.0/24', - self._subnetpool.name, - ] - verifylist = [ - ('prefixes', ['10.0.10.0/24', '10.1.10.0/24']), - ('subnet_pool', self._subnetpool.name), - ] - parsed_args = self.check_parser(self.cmd, arglist, verifylist) - result = self.cmd.take_action(parsed_args) - attrs = {'prefixes': ['10.2.10.0/24']} - self.network.update_subnet_pool.assert_called_once_with( - self._subnetpool, **attrs) - self.assertIsNone(result) - - def test_unset_subnet_pool_prefix_not_existent(self): - arglist = [ - '--pool-prefix', '10.100.1.1/25', - self._subnetpool.name, - ] - verifylist = [ - ('prefixes', ['10.100.1.1/25']), - ('subnet_pool', self._subnetpool.name), - ] - parsed_args = self.check_parser(self.cmd, arglist, verifylist) - self.assertRaises(exceptions.CommandError, - self.cmd.take_action, - parsed_args) - def _test_unset_tags(self, with_tags=True): if with_tags: arglist = ['--tag', 'red', '--tag', 'blue']