Skip to content

Commit ada6abb

Browse files
Jenkinsopenstack-gerrit
authored andcommitted
Merge "Make set/unset commands in network return normally when nothing specified"
2 parents 087d4a3 + e3270cd commit ada6abb

13 files changed

Lines changed: 56 additions & 38 deletions

File tree

openstackclient/network/v2/address_scope.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,6 @@ def take_action(self, parsed_args):
200200
attrs['shared'] = True
201201
if parsed_args.no_share:
202202
attrs['shared'] = False
203-
if attrs == {}:
204-
msg = _("Nothing specified to be set.")
205-
raise exceptions.CommandError(msg)
206203
client.update_address_scope(obj, **attrs)
207204

208205

openstackclient/network/v2/network.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
"""Network action implementations"""
1515

1616
from openstackclient.common import command
17-
from openstackclient.common import exceptions
1817
from openstackclient.common import utils
1918
from openstackclient.i18n import _
2019
from openstackclient.identity import common as identity_common
@@ -434,10 +433,6 @@ def take_action(self, parsed_args):
434433
obj = client.find_network(parsed_args.network, ignore_missing=False)
435434

436435
attrs = _get_attrs(self.app.client_manager, parsed_args)
437-
if attrs == {}:
438-
msg = _("Nothing specified to be set")
439-
raise exceptions.CommandError(msg)
440-
441436
client.update_network(obj, **attrs)
442437

443438

openstackclient/network/v2/port.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -426,9 +426,6 @@ def take_action(self, parsed_args):
426426
elif parsed_args.no_fixed_ip:
427427
attrs['fixed_ips'] = []
428428

429-
if attrs == {}:
430-
msg = _("Nothing specified to be set")
431-
raise exceptions.CommandError(msg)
432429
client.update_port(obj, **attrs)
433430

434431

openstackclient/network/v2/router.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import logging
1919

2020
from openstackclient.common import command
21-
from openstackclient.common import exceptions
2221
from openstackclient.common import parseractions
2322
from openstackclient.common import utils
2423
from openstackclient.i18n import _
@@ -426,10 +425,6 @@ def take_action(self, parsed_args):
426425
route['nexthop'] = route.pop('gateway')
427426
attrs['routes'] = obj.routes + parsed_args.routes
428427

429-
if attrs == {}:
430-
msg = _("Nothing specified to be set")
431-
raise exceptions.CommandError(msg)
432-
433428
client.update_router(obj, **attrs)
434429

435430

openstackclient/network/v2/subnet.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -373,9 +373,6 @@ def take_action(self, parsed_args):
373373
obj = client.find_subnet(parsed_args.subnet, ignore_missing=False)
374374
attrs = _get_attrs(self.app.client_manager, parsed_args,
375375
is_create=False)
376-
if not attrs:
377-
msg = "Nothing specified to be set"
378-
raise exceptions.CommandError(msg)
379376
if 'dns_nameservers' in attrs:
380377
attrs['dns_nameservers'] += obj.dns_nameservers
381378
if 'host_routes' in attrs:

openstackclient/network/v2/subnet_pool.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
"""Subnet pool action implementations"""
1515

1616
from openstackclient.common import command
17-
from openstackclient.common import exceptions
1817
from openstackclient.common import parseractions
1918
from openstackclient.common import utils
2019
from openstackclient.i18n import _
@@ -286,9 +285,6 @@ def take_action(self, parsed_args):
286285
ignore_missing=False)
287286

288287
attrs = _get_attrs(self.app.client_manager, parsed_args)
289-
if attrs == {}:
290-
msg = _("Nothing specified to be set")
291-
raise exceptions.CommandError(msg)
292288

293289
# Existing prefixes must be a subset of the new prefixes.
294290
if 'prefixes' in attrs:

openstackclient/tests/network/v2/test_address_scope.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,8 +313,12 @@ def test_set_nothing(self):
313313
]
314314

315315
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
316-
self.assertRaises(exceptions.CommandError, self.cmd.take_action,
317-
parsed_args)
316+
result = self.cmd.take_action(parsed_args)
317+
318+
attrs = {}
319+
self.network.update_address_scope.assert_called_with(
320+
self._address_scope, **attrs)
321+
self.assertIsNone(result)
318322

319323
def test_set_name_and_share(self):
320324
arglist = [

openstackclient/tests/network/v2/test_network.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -609,8 +609,12 @@ def test_set_nothing(self):
609609
verifylist = [('network', self._network.name), ]
610610

611611
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
612-
self.assertRaises(exceptions.CommandError, self.cmd.take_action,
613-
parsed_args)
612+
result = self.cmd.take_action(parsed_args)
613+
614+
attrs = {}
615+
self.network.update_network.assert_called_once_with(
616+
self._network, **attrs)
617+
self.assertIsNone(result)
614618

615619

616620
class TestShowNetwork(TestNetwork):

openstackclient/tests/network/v2/test_port.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,21 @@ def test_set_that(self):
426426
self.network.update_port.assert_called_once_with(self._port, **attrs)
427427
self.assertIsNone(result)
428428

429+
def test_set_nothing(self):
430+
arglist = [
431+
self._port.name,
432+
]
433+
verifylist = [
434+
('port', self._port.name),
435+
]
436+
437+
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
438+
result = self.cmd.take_action(parsed_args)
439+
440+
attrs = {}
441+
self.network.update_port.assert_called_once_with(self._port, **attrs)
442+
self.assertIsNone(result)
443+
429444

430445
class TestShowPort(TestPort):
431446

openstackclient/tests/network/v2/test_router.py

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

1414
import mock
1515

16-
from openstackclient.common import exceptions
1716
from openstackclient.common import utils as osc_utils
1817
from openstackclient.network.v2 import router
1918
from openstackclient.tests.network.v2 import fakes as network_fakes
@@ -568,12 +567,20 @@ def test_set_route_clear_routes(self):
568567
self.cmd, arglist, verifylist)
569568

570569
def test_set_nothing(self):
571-
arglist = [self._router.name, ]
572-
verifylist = [('router', self._router.name), ]
570+
arglist = [
571+
self._router.name,
572+
]
573+
verifylist = [
574+
('router', self._router.name),
575+
]
573576

574577
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
575-
self.assertRaises(exceptions.CommandError, self.cmd.take_action,
576-
parsed_args)
578+
result = self.cmd.take_action(parsed_args)
579+
580+
attrs = {}
581+
self.network.update_router.assert_called_once_with(
582+
self._router, **attrs)
583+
self.assertIsNone(result)
577584

578585

579586
class TestShowRouter(TestRouter):

0 commit comments

Comments
 (0)