compute: Workaround bug #2089821

By passing a dict instead of a single value, we force SDK to populate
the correct attribute on the object.

Change-Id: I9f4c5964dc0546215474c92db567966ffad68a1a
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Related-bug: #2089821
This commit is contained in:
Stephen Finucane 2024-12-09 13:32:15 +00:00
parent ecc744a4fd
commit 22b30b99ce
2 changed files with 8 additions and 6 deletions
openstackclient
compute/v2
tests/unit/compute/v2

@ -714,7 +714,8 @@ class AddServerSecurityGroup(command.Command):
for security_group in security_groups:
try:
compute_client.add_security_group_to_server(
server, security_group
server,
{'name': security_group},
)
except sdk_exceptions.HttpException as e:
errors += 1
@ -4083,7 +4084,8 @@ class RemoveServerSecurityGroup(command.Command):
for security_group in security_groups:
try:
compute_client.remove_security_group_from_server(
server, security_group
server,
{'name': security_group},
)
except sdk_exceptions.HttpException as e:
errors += 1

@ -1165,7 +1165,7 @@ class TestServerAddSecurityGroup(compute_fakes.TestComputev2):
self.server.id, ignore_missing=False
)
self.compute_sdk_client.add_security_group_to_server.assert_called_once_with(
self.server, 'fake_sg'
self.server, {'name': 'fake_sg'}
)
mock_find_nova_net_sg.assert_called_once_with(
self.compute_sdk_client, 'fake_sg'
@ -1186,7 +1186,7 @@ class TestServerAddSecurityGroup(compute_fakes.TestComputev2):
self.server.id, ignore_missing=False
)
self.compute_sdk_client.add_security_group_to_server.assert_called_once_with(
self.server, 'fake_sg'
self.server, {'name': 'fake_sg'}
)
self.assertIsNone(result)
@ -7400,7 +7400,7 @@ class TestServerRemoveSecurityGroup(TestServer):
self.server.id, ignore_missing=False
)
self.compute_sdk_client.remove_security_group_from_server.assert_called_once_with(
self.server, 'fake_sg'
self.server, {'name': 'fake_sg'}
)
mock_find_nova_net_sg.assert_called_once_with(
self.compute_sdk_client, 'fake_sg'
@ -7421,7 +7421,7 @@ class TestServerRemoveSecurityGroup(TestServer):
self.server.id, ignore_missing=False
)
self.compute_sdk_client.remove_security_group_from_server.assert_called_once_with(
self.server, 'fake_sg'
self.server, {'name': 'fake_sg'}
)
self.assertIsNone(result)