Use /servers/detail endpoint in find_server proxy method

Currently, find_server will return the objects with different
fields filled in depending on whether the term provided is an id or a
name. This patch, in the same vein of [0], changes the find_server
method so it uses the /servers/detail endpoint to find servers in the
case of a name being provided. This ensures that the method fills in all
fields in every case.

[0] https://review.opendev.org/c/openstack/openstacksdk/+/854293

Change-Id: If8306f879361f872a1a87d589c756d9ae2435449
This commit is contained in:
Rafael Castillo 2022-09-15 17:08:02 -07:00
parent 44089c11d6
commit 25ec686c5b
5 changed files with 22 additions and 13 deletions

View File

@ -660,7 +660,8 @@ class Proxy(proxy.Proxy):
:returns: One :class:`~openstack.compute.v2.server.Server` or None
"""
return self._find(_server.Server, name_or_id,
ignore_missing=ignore_missing)
ignore_missing=ignore_missing,
list_base_path='/servers/detail')
def get_server(self, server):
"""Get a single server

View File

@ -38,7 +38,7 @@ class TestDeleteServer(base.TestCase):
status_code=404),
dict(method='GET',
uri=self.get_mock_url(
'compute', 'public', append=['servers'],
'compute', 'public', append=['servers', 'detail'],
qs_elements=['name=daffy']),
json={'servers': [server]}),
dict(method='DELETE',
@ -61,7 +61,7 @@ class TestDeleteServer(base.TestCase):
status_code=404),
dict(method='GET',
uri=self.get_mock_url(
'compute', 'public', append=['servers'],
'compute', 'public', append=['servers', 'detail'],
qs_elements=['name=tweety']),
json={'servers': []}),
])
@ -78,7 +78,7 @@ class TestDeleteServer(base.TestCase):
status_code=404),
dict(method='GET',
uri=self.get_mock_url(
'compute', 'public', append=['servers'],
'compute', 'public', append=['servers', 'detail'],
qs_elements=['name=speedy']),
json={'servers': []}),
])
@ -98,7 +98,7 @@ class TestDeleteServer(base.TestCase):
status_code=404),
dict(method='GET',
uri=self.get_mock_url(
'compute', 'public', append=['servers'],
'compute', 'public', append=['servers', 'detail'],
qs_elements=['name=wily']),
json={'servers': [server]}),
dict(method='DELETE',
@ -130,7 +130,7 @@ class TestDeleteServer(base.TestCase):
status_code=404),
dict(method='GET',
uri=self.get_mock_url(
'compute', 'public', append=['servers'],
'compute', 'public', append=['servers', 'detail'],
qs_elements=['name=speedy']),
json={'servers': [server]}),
dict(method='DELETE',
@ -167,7 +167,7 @@ class TestDeleteServer(base.TestCase):
status_code=404),
dict(method='GET',
uri=self.get_mock_url(
'compute', 'public', append=['servers'],
'compute', 'public', append=['servers', 'detail'],
qs_elements=['name=porky']),
json={'servers': [server]}),
dict(method='DELETE',
@ -193,7 +193,7 @@ class TestDeleteServer(base.TestCase):
status_code=404),
dict(method='GET',
uri=self.get_mock_url(
'compute', 'public', append=['servers'],
'compute', 'public', append=['servers', 'detail'],
qs_elements=['name=porky']),
json={'servers': [server]}),
dict(method='GET',
@ -246,7 +246,7 @@ class TestDeleteServer(base.TestCase):
status_code=404),
dict(method='GET',
uri=self.get_mock_url(
'compute', 'public', append=['servers'],
'compute', 'public', append=['servers', 'detail'],
qs_elements=['name=porky']),
json={'servers': [server]}),
dict(method='GET',
@ -283,7 +283,7 @@ class TestDeleteServer(base.TestCase):
status_code=404),
dict(method='GET',
uri=self.get_mock_url(
'compute', 'public', append=['servers'],
'compute', 'public', append=['servers', 'detail'],
qs_elements=['name=porky']),
json={'servers': [server]}),
dict(method='GET',

View File

@ -48,7 +48,7 @@ class TestUpdateServer(base.TestCase):
status_code=404),
dict(method='GET',
uri=self.get_mock_url(
'compute', 'public', append=['servers'],
'compute', 'public', append=['servers', 'detail'],
qs_elements=['name=%s' % self.server_name]),
json={'servers': [self.fake_server]}),
dict(method='PUT',
@ -80,7 +80,7 @@ class TestUpdateServer(base.TestCase):
status_code=404),
dict(method='GET',
uri=self.get_mock_url(
'compute', 'public', append=['servers'],
'compute', 'public', append=['servers', 'detail'],
qs_elements=['name=%s' % self.server_name]),
json={'servers': [self.fake_server]}),
dict(method='PUT',

View File

@ -668,7 +668,11 @@ class TestCompute(TestComputeProxy):
expected_args=[self.proxy])
def test_server_find(self):
self.verify_find(self.proxy.find_server, server.Server)
self.verify_find(
self.proxy.find_server,
server.Server,
expected_kwargs={'list_base_path': '/servers/detail'},
)
def test_server_get(self):
self.verify_get(self.proxy.get_server, server.Server)

View File

@ -0,0 +1,4 @@
---
fixes:
- |
Make sure find_server returns server details when looking up by name.