Make set/unset commands in network return normally when nothing specified
set/unset commands should ends up normally instead of raising an exception when nothing is specified to modify. The main reason is: When nothing is specified, the command sets/unsets nothing, which is a normal behavior, and ends up normally. No API call fails. No error happens. This patch also adds a releasenote for both network, and volume commands that fix patch has been merged. Change-Id: I78c348066078decd350417a431f3b8bea8fcf9ef Partial-bug: #1588588
This commit is contained in:
parent
84506a6b71
commit
e3270cdfd8
@ -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)
|
||||
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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 = [
|
||||
|
@ -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):
|
||||
|
@ -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):
|
||||
|
||||
|
@ -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):
|
||||
|
@ -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(
|
||||
|
@ -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 = [
|
||||
|
6
releasenotes/notes/bug-1588588-39927ef06ca35730.yaml
Normal file
6
releasenotes/notes/bug-1588588-39927ef06ca35730.yaml
Normal file
@ -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 <https://bugs.launchpad.net/python-openstackclient/+bug/1588588>`_]
|
Loading…
Reference in New Issue
Block a user