Merge "Partially Revert "Add command to unset information from Subnet-pools""

This commit is contained in:
Zuul 2019-02-27 22:15:47 +00:00 committed by Gerrit Code Review
commit 3d7772e34a
3 changed files with 1 additions and 63 deletions

View File

@ -292,15 +292,9 @@ Unset subnet pool properties
.. code:: bash
openstack subnet pool unset
[--pool-prefix <pool-prefix> [...]]
[--tag <tag> | --all-tag]
<subnet-pool>
.. option:: --pool-prefix <pool-prefix>
Remove subnet pool prefixes (in CIDR notation).
(repeat option to unset multiple prefixes).
.. option:: --tag <tag>
Tag to be removed from the subnet pool

View File

@ -13,7 +13,6 @@
"""Subnet pool action implementations"""
import copy
import logging
from osc_lib.cli import parseractions
@ -442,14 +441,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='<pool-prefix>',
action='append',
dest='prefixes',
help=_('Remove subnet pool prefixes (in CIDR notation). '
'(repeat option to unset multiple prefixes).'),
)
parser.add_argument(
'subnet_pool',
metavar="<subnet-pool>",
@ -462,19 +453,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)

View File

@ -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']