summaryrefslogtreecommitdiff
path: root/openstackclient
diff options
context:
space:
mode:
authorBernard Cafarelli <bcafarel@redhat.com>2018-09-04 17:52:46 +0200
committerBernard Cafarelli <bcafarel@redhat.com>2018-09-05 10:45:37 +0200
commita5865b176304b92736a71cd6ad2dd1199c588ba5 (patch)
treea2aaf7ffbd2ce73af57ba2d495b1b1e97ff3806a /openstackclient
parent0461b7ce0c23f7aebb60ee362d1d89cfa38abe4b (diff)
downloadpython-openstackclient-a5865b176304b92736a71cd6ad2dd1199c588ba5.tar.gz
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
Diffstat (limited to 'openstackclient')
-rw-r--r--openstackclient/network/v2/subnet_pool.py23
-rw-r--r--openstackclient/tests/unit/network/v2/test_subnet_pool.py35
2 files changed, 1 insertions, 57 deletions
diff --git a/openstackclient/network/v2/subnet_pool.py b/openstackclient/network/v2/subnet_pool.py
index a5839868..d8541069 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
@@ -441,14 +440,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>",
help=_("Subnet pool to modify (name or ID)")
@@ -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 81f0278f..3d8f1028 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']