Skip to content

Commit 859bfaf

Browse files
author
Tang Chen
committed
Make SetSecurityGroup inherit from cliff.Command
set/unset comamnd classes should inherit from cliff.Command class. Change-Id: Ie28711ac8823dc9eb13cf83877864ca436b928bc Partial-Bug: 1546065
1 parent f37eda3 commit 859bfaf

4 files changed

Lines changed: 27 additions & 17 deletions

File tree

doc/source/backwards-incompatible.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,18 @@ List of Backwards Incompatible Changes
126126
* Bug: https://bugs.launchpad.net/python-openstackclient/+bug/1546065
127127
* Commit: https://review.openstack.org/#/c/280663/
128128

129+
10. `security group set` commands will no longer return the modified resource
130+
131+
Previously, modifying a security group would result in the new security group
132+
being displayed to the user. To keep things consistent with other `set`
133+
commands, we will no longer be showing the modified resource.
134+
135+
* In favor of: Use `set` then `show`
136+
* As of: NA
137+
* Removed in: NA
138+
* Bug: https://bugs.launchpad.net/python-openstackclient/+bug/1546065
139+
* Commit: https://review.openstack.org/#/c/281087/
140+
129141
For Developers
130142
==============
131143

functional/tests/network/v2/test_security_group.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,9 @@ def setUpClass(cls):
3232
@classmethod
3333
def tearDownClass(cls):
3434
# Rename test
35-
opts = cls.get_show_opts(cls.FIELDS)
3635
raw_output = cls.openstack('security group set --name ' +
37-
cls.OTHER_NAME + ' ' + cls.NAME + opts)
38-
cls.assertOutput(cls.OTHER_NAME + "\n", raw_output)
36+
cls.OTHER_NAME + ' ' + cls.NAME)
37+
cls.assertOutput('', raw_output)
3938
# Delete test
4039
raw_output = cls.openstack('security group delete ' + cls.OTHER_NAME)
4140
cls.assertOutput('', raw_output)
@@ -46,10 +45,14 @@ def test_security_group_list(self):
4645
self.assertIn(self.NAME, raw_output)
4746

4847
def test_security_group_set(self):
49-
opts = self.get_show_opts(['description', 'name'])
50-
raw_output = self.openstack('security group set --description NSA ' +
51-
self.NAME + opts)
52-
self.assertEqual("NSA\n" + self.NAME + "\n", raw_output)
48+
raw_output = self.openstack(
49+
'security group set --description NSA ' + self.NAME
50+
)
51+
self.assertEqual('', raw_output)
52+
53+
opts = self.get_show_opts(['description'])
54+
raw_output = self.openstack('security group show ' + self.NAME + opts)
55+
self.assertEqual("NSA\n", raw_output)
5356

5457
def test_security_group_show(self):
5558
opts = self.get_show_opts(self.FIELDS)

openstackclient/compute/v2/security_group.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ def take_action(self, parsed_args):
271271
) for s in rules))
272272

273273

274-
class SetSecurityGroup(command.ShowOne):
274+
class SetSecurityGroup(command.Command):
275275
"""Set security group properties"""
276276

277277
def get_parser(self, prog_name):
@@ -294,7 +294,6 @@ def get_parser(self, prog_name):
294294
return parser
295295

296296
def take_action(self, parsed_args):
297-
298297
compute_client = self.app.client_manager.compute
299298
data = utils.find_resource(
300299
compute_client.security_groups,
@@ -306,17 +305,11 @@ def take_action(self, parsed_args):
306305
if parsed_args.description:
307306
data.description = parsed_args.description
308307

309-
info = {}
310-
info.update(compute_client.security_groups.update(
308+
compute_client.security_groups.update(
311309
data,
312310
data.name,
313311
data.description,
314-
)._info)
315-
316-
if info:
317-
return zip(*sorted(six.iteritems(info)))
318-
else:
319-
return ({}, {})
312+
)
320313

321314

322315
class ShowSecurityGroup(command.ShowOne):

releasenotes/notes/bug-1546065-41d09ffbd8606513.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
fixes:
33
- Command ``flavor set/unset`` now outputs nothing.
44
[Bug `1546065 <https://bugs.launchpad.net/python-openstackclient/+bug/1546065>`_]
5+
- Command ``security group set`` now outputs nothing.
6+
[Bug `1546065 <https://bugs.launchpad.net/python-openstackclient/+bug/1546065>`_]

0 commit comments

Comments
 (0)