Skip to content

Commit 3d7772e

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Partially Revert "Add command to unset information from Subnet-pools""
2 parents 1ea988e + a5865b1 commit 3d7772e

3 files changed

Lines changed: 1 addition & 63 deletions

File tree

doc/source/cli/command-objects/subnet-pool.rst

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -292,15 +292,9 @@ Unset subnet pool properties
292292
.. code:: bash
293293
294294
openstack subnet pool unset
295-
[--pool-prefix <pool-prefix> [...]]
296295
[--tag <tag> | --all-tag]
297296
<subnet-pool>
298297
299-
.. option:: --pool-prefix <pool-prefix>
300-
301-
Remove subnet pool prefixes (in CIDR notation).
302-
(repeat option to unset multiple prefixes).
303-
304298
.. option:: --tag <tag>
305299
306300
Tag to be removed from the subnet pool

openstackclient/network/v2/subnet_pool.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
"""Subnet pool action implementations"""
1515

16-
import copy
1716
import logging
1817

1918
from osc_lib.cli import parseractions
@@ -442,14 +441,6 @@ class UnsetSubnetPool(command.Command):
442441

443442
def get_parser(self, prog_name):
444443
parser = super(UnsetSubnetPool, self).get_parser(prog_name)
445-
parser.add_argument(
446-
'--pool-prefix',
447-
metavar='<pool-prefix>',
448-
action='append',
449-
dest='prefixes',
450-
help=_('Remove subnet pool prefixes (in CIDR notation). '
451-
'(repeat option to unset multiple prefixes).'),
452-
)
453444
parser.add_argument(
454445
'subnet_pool',
455446
metavar="<subnet-pool>",
@@ -462,19 +453,5 @@ def take_action(self, parsed_args):
462453
client = self.app.client_manager.network
463454
obj = client.find_subnet_pool(
464455
parsed_args.subnet_pool, ignore_missing=False)
465-
tmp_prefixes = copy.deepcopy(obj.prefixes)
466-
attrs = {}
467-
if parsed_args.prefixes:
468-
for prefix in parsed_args.prefixes:
469-
try:
470-
tmp_prefixes.remove(prefix)
471-
except ValueError:
472-
msg = _(
473-
"Subnet pool does not "
474-
"contain prefix %s") % prefix
475-
raise exceptions.CommandError(msg)
476-
attrs['prefixes'] = tmp_prefixes
477-
if attrs:
478-
client.update_subnet_pool(obj, **attrs)
479456
# tags is a subresource and it needs to be updated separately.
480457
_tag.update_tags_for_unset(client, obj, parsed_args)

openstackclient/tests/unit/network/v2/test_subnet_pool.py

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,47 +1016,14 @@ class TestUnsetSubnetPool(TestSubnetPool):
10161016
def setUp(self):
10171017
super(TestUnsetSubnetPool, self).setUp()
10181018
self._subnetpool = network_fakes.FakeSubnetPool.create_one_subnet_pool(
1019-
{'prefixes': ['10.0.10.0/24', '10.1.10.0/24',
1020-
'10.2.10.0/24'],
1021-
'tags': ['green', 'red']})
1019+
{'tags': ['green', 'red']})
10221020
self.network.find_subnet_pool = mock.Mock(
10231021
return_value=self._subnetpool)
10241022
self.network.update_subnet_pool = mock.Mock(return_value=None)
10251023
self.network.set_tags = mock.Mock(return_value=None)
10261024
# Get the command object to test
10271025
self.cmd = subnet_pool.UnsetSubnetPool(self.app, self.namespace)
10281026

1029-
def test_unset_subnet_pool(self):
1030-
arglist = [
1031-
'--pool-prefix', '10.0.10.0/24',
1032-
'--pool-prefix', '10.1.10.0/24',
1033-
self._subnetpool.name,
1034-
]
1035-
verifylist = [
1036-
('prefixes', ['10.0.10.0/24', '10.1.10.0/24']),
1037-
('subnet_pool', self._subnetpool.name),
1038-
]
1039-
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
1040-
result = self.cmd.take_action(parsed_args)
1041-
attrs = {'prefixes': ['10.2.10.0/24']}
1042-
self.network.update_subnet_pool.assert_called_once_with(
1043-
self._subnetpool, **attrs)
1044-
self.assertIsNone(result)
1045-
1046-
def test_unset_subnet_pool_prefix_not_existent(self):
1047-
arglist = [
1048-
'--pool-prefix', '10.100.1.1/25',
1049-
self._subnetpool.name,
1050-
]
1051-
verifylist = [
1052-
('prefixes', ['10.100.1.1/25']),
1053-
('subnet_pool', self._subnetpool.name),
1054-
]
1055-
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
1056-
self.assertRaises(exceptions.CommandError,
1057-
self.cmd.take_action,
1058-
parsed_args)
1059-
10601027
def _test_unset_tags(self, with_tags=True):
10611028
if with_tags:
10621029
arglist = ['--tag', 'red', '--tag', 'blue']

0 commit comments

Comments
 (0)