Adds server show in helpers

adds a server show method in integrated_helpers. This helps us refresh
the server object. Also replaced wait_for_state_change with server_show
in _attach_volumes method, which was used with same objective.

Related-Bug: #2033601

Change-Id: If25755f0196b9d886097f3a7e61e87d09d1547f1
This commit is contained in:
Amit Uniyal 2023-09-02 07:59:24 +00:00
parent 0318016ea4
commit dabf90e0de
1 changed files with 9 additions and 2 deletions

View File

@ -493,6 +493,14 @@ class InstanceHelperMixin:
self.notifier.wait_for_versioned_notifications('instance.reboot.end')
return self._wait_for_state_change(server, expected_state)
def _show_server(self, server):
"""This method is to retrieve fresh copy of target server object
"""
try:
return self.api.get_server(server['id'])
except api_client.OpenStackApiNotFoundException:
return server
def _attach_interface(self, server, port_uuid):
"""attach a neutron port to a server."""
body = {
@ -654,10 +662,9 @@ class InstanceHelperMixin:
# wait for each vol to get attached
self._wait_for_volume_attach(server['id'], vol_id)
# here server is already in an active state
# this is just to refresh server object
# so attached volumes can be shown in server
return self._wait_for_state_change(server, expected_status='ACTIVE')
return self._show_server(server)
def _create_vol_attachments_by_cinder(
self, volume_id, server, new_attachments=1):