compute: Workaround bug #2089821

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

Also fixed conflicts in openstackclient/compute/v2/server.py added by
ece30e8f70

Change-Id: I9f4c5964dc0546215474c92db567966ffad68a1a
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Related-bug: #2089821
(cherry picked from commit 22b30b99ce)
This commit is contained in:
Stephen Finucane
2024-12-09 13:32:15 +00:00
committed by Ilia Petrov
parent 8390467304
commit f9cc9013ae
2 changed files with 10 additions and 6 deletions

View File

@@ -701,7 +701,10 @@ class AddServerSecurityGroup(command.Command):
security_group = compute_v2.find_security_group(
compute_client, parsed_args.group
)['name']
compute_client.add_security_group_to_server(server, security_group)
compute_client.add_security_group_to_server(
server,
{'name': security_group},
)
class AddServerVolume(command.ShowOne):
@@ -4039,7 +4042,8 @@ class RemoveServerSecurityGroup(command.Command):
compute_client, parsed_args.group
)['name']
compute_client.remove_security_group_from_server(
server, security_group
server,
{'name': security_group},
)

View File

@@ -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'}
)
mock_find_nova_net_sg.assert_called_once_with(
self.compute_sdk_client, 'fake_sg'
@@ -1207,7 +1207,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)
@@ -7394,7 +7394,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'
@@ -7415,7 +7415,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)