diff --git a/openstackclient/network/v2/address_scope.py b/openstackclient/network/v2/address_scope.py index ffd987ce5f..40a0b8f692 100644 --- a/openstackclient/network/v2/address_scope.py +++ b/openstackclient/network/v2/address_scope.py @@ -200,9 +200,6 @@ class SetAddressScope(command.Command): attrs['shared'] = True if parsed_args.no_share: attrs['shared'] = False - if attrs == {}: - msg = _("Nothing specified to be set.") - raise exceptions.CommandError(msg) client.update_address_scope(obj, **attrs) diff --git a/openstackclient/network/v2/network.py b/openstackclient/network/v2/network.py index bf01e2ec71..87e65dad11 100644 --- a/openstackclient/network/v2/network.py +++ b/openstackclient/network/v2/network.py @@ -14,7 +14,6 @@ """Network action implementations""" from openstackclient.common import command -from openstackclient.common import exceptions from openstackclient.common import utils from openstackclient.i18n import _ from openstackclient.identity import common as identity_common @@ -434,10 +433,6 @@ class SetNetwork(command.Command): obj = client.find_network(parsed_args.network, ignore_missing=False) attrs = _get_attrs(self.app.client_manager, parsed_args) - if attrs == {}: - msg = _("Nothing specified to be set") - raise exceptions.CommandError(msg) - client.update_network(obj, **attrs) diff --git a/openstackclient/network/v2/port.py b/openstackclient/network/v2/port.py index 1a69d16c73..bc9321d14d 100644 --- a/openstackclient/network/v2/port.py +++ b/openstackclient/network/v2/port.py @@ -426,9 +426,6 @@ class SetPort(command.Command): elif parsed_args.no_fixed_ip: attrs['fixed_ips'] = [] - if attrs == {}: - msg = _("Nothing specified to be set") - raise exceptions.CommandError(msg) client.update_port(obj, **attrs) diff --git a/openstackclient/network/v2/router.py b/openstackclient/network/v2/router.py index 310f67406f..60908294a0 100644 --- a/openstackclient/network/v2/router.py +++ b/openstackclient/network/v2/router.py @@ -18,7 +18,6 @@ import json import logging from openstackclient.common import command -from openstackclient.common import exceptions from openstackclient.common import parseractions from openstackclient.common import utils from openstackclient.i18n import _ @@ -426,10 +425,6 @@ class SetRouter(command.Command): route['nexthop'] = route.pop('gateway') attrs['routes'] = obj.routes + parsed_args.routes - if attrs == {}: - msg = _("Nothing specified to be set") - raise exceptions.CommandError(msg) - client.update_router(obj, **attrs) diff --git a/openstackclient/network/v2/subnet.py b/openstackclient/network/v2/subnet.py index e7e1be99c1..8e378c7e19 100644 --- a/openstackclient/network/v2/subnet.py +++ b/openstackclient/network/v2/subnet.py @@ -373,9 +373,6 @@ class SetSubnet(command.Command): obj = client.find_subnet(parsed_args.subnet, ignore_missing=False) attrs = _get_attrs(self.app.client_manager, parsed_args, is_create=False) - if not attrs: - msg = "Nothing specified to be set" - raise exceptions.CommandError(msg) if 'dns_nameservers' in attrs: attrs['dns_nameservers'] += obj.dns_nameservers if 'host_routes' in attrs: diff --git a/openstackclient/network/v2/subnet_pool.py b/openstackclient/network/v2/subnet_pool.py index a1a94426dd..17f1e97ddc 100644 --- a/openstackclient/network/v2/subnet_pool.py +++ b/openstackclient/network/v2/subnet_pool.py @@ -14,7 +14,6 @@ """Subnet pool action implementations""" from openstackclient.common import command -from openstackclient.common import exceptions from openstackclient.common import parseractions from openstackclient.common import utils from openstackclient.i18n import _ @@ -286,9 +285,6 @@ class SetSubnetPool(command.Command): ignore_missing=False) attrs = _get_attrs(self.app.client_manager, parsed_args) - if attrs == {}: - msg = _("Nothing specified to be set") - raise exceptions.CommandError(msg) # Existing prefixes must be a subset of the new prefixes. if 'prefixes' in attrs: diff --git a/openstackclient/tests/network/v2/test_address_scope.py b/openstackclient/tests/network/v2/test_address_scope.py index b4f4fa885f..d02f01ca24 100644 --- a/openstackclient/tests/network/v2/test_address_scope.py +++ b/openstackclient/tests/network/v2/test_address_scope.py @@ -313,8 +313,12 @@ class TestSetAddressScope(TestAddressScope): ] parsed_args = self.check_parser(self.cmd, arglist, verifylist) - self.assertRaises(exceptions.CommandError, self.cmd.take_action, - parsed_args) + result = self.cmd.take_action(parsed_args) + + attrs = {} + self.network.update_address_scope.assert_called_with( + self._address_scope, **attrs) + self.assertIsNone(result) def test_set_name_and_share(self): arglist = [ diff --git a/openstackclient/tests/network/v2/test_network.py b/openstackclient/tests/network/v2/test_network.py index ba810f1649..509259a8ed 100644 --- a/openstackclient/tests/network/v2/test_network.py +++ b/openstackclient/tests/network/v2/test_network.py @@ -609,8 +609,12 @@ class TestSetNetwork(TestNetwork): verifylist = [('network', self._network.name), ] parsed_args = self.check_parser(self.cmd, arglist, verifylist) - self.assertRaises(exceptions.CommandError, self.cmd.take_action, - parsed_args) + result = self.cmd.take_action(parsed_args) + + attrs = {} + self.network.update_network.assert_called_once_with( + self._network, **attrs) + self.assertIsNone(result) class TestShowNetwork(TestNetwork): diff --git a/openstackclient/tests/network/v2/test_port.py b/openstackclient/tests/network/v2/test_port.py index dd98a6371e..628a5d52cb 100644 --- a/openstackclient/tests/network/v2/test_port.py +++ b/openstackclient/tests/network/v2/test_port.py @@ -426,6 +426,21 @@ class TestSetPort(TestPort): self.network.update_port.assert_called_once_with(self._port, **attrs) self.assertIsNone(result) + def test_set_nothing(self): + arglist = [ + self._port.name, + ] + verifylist = [ + ('port', self._port.name), + ] + + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + result = self.cmd.take_action(parsed_args) + + attrs = {} + self.network.update_port.assert_called_once_with(self._port, **attrs) + self.assertIsNone(result) + class TestShowPort(TestPort): diff --git a/openstackclient/tests/network/v2/test_router.py b/openstackclient/tests/network/v2/test_router.py index 99b41d2dc4..b25381ef3e 100644 --- a/openstackclient/tests/network/v2/test_router.py +++ b/openstackclient/tests/network/v2/test_router.py @@ -13,7 +13,6 @@ import mock -from openstackclient.common import exceptions from openstackclient.common import utils as osc_utils from openstackclient.network.v2 import router from openstackclient.tests.network.v2 import fakes as network_fakes @@ -568,12 +567,20 @@ class TestSetRouter(TestRouter): self.cmd, arglist, verifylist) def test_set_nothing(self): - arglist = [self._router.name, ] - verifylist = [('router', self._router.name), ] + arglist = [ + self._router.name, + ] + verifylist = [ + ('router', self._router.name), + ] parsed_args = self.check_parser(self.cmd, arglist, verifylist) - self.assertRaises(exceptions.CommandError, self.cmd.take_action, - parsed_args) + result = self.cmd.take_action(parsed_args) + + attrs = {} + self.network.update_router.assert_called_once_with( + self._router, **attrs) + self.assertIsNone(result) class TestShowRouter(TestRouter): diff --git a/openstackclient/tests/network/v2/test_subnet.py b/openstackclient/tests/network/v2/test_subnet.py index 22c288f9f1..25684d63e0 100644 --- a/openstackclient/tests/network/v2/test_subnet.py +++ b/openstackclient/tests/network/v2/test_subnet.py @@ -14,7 +14,6 @@ import copy import mock -from openstackclient.common import exceptions from openstackclient.common import utils from openstackclient.network.v2 import subnet as subnet_v2 from openstackclient.tests import fakes @@ -549,8 +548,11 @@ class TestSetSubnet(TestSubnet): verifylist = [('subnet', self._subnet.name)] parsed_args = self.check_parser(self.cmd, arglist, verifylist) - self.assertRaises(exceptions.CommandError, self.cmd.take_action, - parsed_args) + result = self.cmd.take_action(parsed_args) + + attrs = {} + self.network.update_subnet.assert_called_with(self._subnet, **attrs) + self.assertIsNone(result) def test_append_options(self): _testsubnet = network_fakes.FakeSubnet.create_one_subnet( diff --git a/openstackclient/tests/network/v2/test_subnet_pool.py b/openstackclient/tests/network/v2/test_subnet_pool.py index de12c9e9df..f7bb5895c3 100644 --- a/openstackclient/tests/network/v2/test_subnet_pool.py +++ b/openstackclient/tests/network/v2/test_subnet_pool.py @@ -15,7 +15,6 @@ import argparse import copy import mock -from openstackclient.common import exceptions from openstackclient.common import utils from openstackclient.network.v2 import subnet_pool from openstackclient.tests import fakes @@ -443,10 +442,14 @@ class TestSetSubnetPool(TestSubnetPool): def test_set_nothing(self): arglist = [self._subnet_pool.name, ] verifylist = [('subnet_pool', self._subnet_pool.name), ] - parsed_args = self.check_parser(self.cmd, arglist, verifylist) - self.assertRaises(exceptions.CommandError, self.cmd.take_action, - parsed_args) + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + result = self.cmd.take_action(parsed_args) + + attrs = {} + self.network.update_subnet_pool.assert_called_once_with( + self._subnet_pool, **attrs) + self.assertIsNone(result) def test_set_len_negative(self): arglist = [ diff --git a/releasenotes/notes/bug-1588588-39927ef06ca35730.yaml b/releasenotes/notes/bug-1588588-39927ef06ca35730.yaml new file mode 100644 index 0000000000..440bb7d31c --- /dev/null +++ b/releasenotes/notes/bug-1588588-39927ef06ca35730.yaml @@ -0,0 +1,6 @@ +--- +upgrade: + - All ``set`` and ``unset`` commands in network and volume now return + normally when nothing specified to modify. This will become the default + behavior of OSC ``set`` and ``unset`` commands. + [Bug `1588588 `_]