Update server details before getting fixed IP
If the validation.connect_method is set to "fixed" then the ssh/ping validation fails in get_server_ip() on: addresses = server['addresses'][CONF.validation.network_for_ssh] KeyError: 'addresses' It seems that addresses information is not available in the initial response upon server creation, from the compute API ref: "Servers with status BUILD hide their addresses information." The fix saves the returned full server response when waiting for the server to become ACTIVE. Such response includes the Fixed IP address (once the server is ACTIVE) and can be used for checking the connection to the server later. Change-Id: I1addbb52320deaa9e268eceb5dbd83f6da6c6f6a
This commit is contained in:
parent
ee6eebea9b
commit
ca5ddb4fe0
|
@ -298,11 +298,11 @@ def create_test_server(clients, validatable=False, validation_resources=None,
|
|||
if multiple_create_request:
|
||||
# Get servers created which name match with name param.
|
||||
body_servers = clients.servers_client.list_servers()
|
||||
servers = \
|
||||
created_servers = \
|
||||
[s for s in body_servers['servers'] if s['name'].startswith(name)]
|
||||
else:
|
||||
body = rest_client.ResponseBody(body.response, body['server'])
|
||||
servers = [body]
|
||||
created_servers = [body]
|
||||
|
||||
if wait_until:
|
||||
|
||||
|
@ -314,11 +314,19 @@ def create_test_server(clients, validatable=False, validation_resources=None,
|
|||
wait_until_extra = wait_until
|
||||
wait_until = 'ACTIVE'
|
||||
|
||||
for server in servers:
|
||||
try:
|
||||
waiters.wait_for_server_status(
|
||||
servers = []
|
||||
try:
|
||||
# Wait for server to be in active state and populate servers list
|
||||
# with those full server response so that we will have addresses
|
||||
# field present in server which is needed to be used for wait for
|
||||
# ssh
|
||||
for server in created_servers:
|
||||
server = waiters.wait_for_server_status(
|
||||
clients.servers_client, server['id'], wait_until,
|
||||
request_id=request_id)
|
||||
servers.append(server)
|
||||
|
||||
for server in servers:
|
||||
if CONF.validation.run_validation and validatable:
|
||||
if CONF.validation.connect_method == 'floating':
|
||||
_setup_validation_fip(
|
||||
|
@ -329,31 +337,31 @@ def create_test_server(clients, validatable=False, validation_resources=None,
|
|||
server, clients, tenant_network,
|
||||
validatable, validation_resources,
|
||||
wait_until_extra, False)
|
||||
except Exception:
|
||||
with excutils.save_and_reraise_exception():
|
||||
for server in created_servers:
|
||||
try:
|
||||
clients.servers_client.delete_server(
|
||||
server['id'])
|
||||
except Exception:
|
||||
LOG.exception('Deleting server %s failed',
|
||||
server['id'])
|
||||
for server in created_servers:
|
||||
# NOTE(artom) If the servers were booted with volumes
|
||||
# and with delete_on_termination=False we need to wait
|
||||
# for the servers to go away before proceeding with
|
||||
# cleanup, otherwise we'll attempt to delete the
|
||||
# volumes while they're still attached to servers that
|
||||
# are in the process of being deleted.
|
||||
try:
|
||||
waiters.wait_for_server_termination(
|
||||
clients.servers_client, server['id'])
|
||||
except Exception:
|
||||
LOG.exception('Server %s failed to delete in time',
|
||||
server['id'])
|
||||
return body, servers
|
||||
|
||||
except Exception:
|
||||
with excutils.save_and_reraise_exception():
|
||||
for server in servers:
|
||||
try:
|
||||
clients.servers_client.delete_server(
|
||||
server['id'])
|
||||
except Exception:
|
||||
LOG.exception('Deleting server %s failed',
|
||||
server['id'])
|
||||
for server in servers:
|
||||
# NOTE(artom) If the servers were booted with volumes
|
||||
# and with delete_on_termination=False we need to wait
|
||||
# for the servers to go away before proceeding with
|
||||
# cleanup, otherwise we'll attempt to delete the
|
||||
# volumes while they're still attached to servers that
|
||||
# are in the process of being deleted.
|
||||
try:
|
||||
waiters.wait_for_server_termination(
|
||||
clients.servers_client, server['id'])
|
||||
except Exception:
|
||||
LOG.exception('Server %s failed to delete in time',
|
||||
server['id'])
|
||||
|
||||
return body, servers
|
||||
return body, created_servers
|
||||
|
||||
|
||||
def shelve_server(servers_client, server_id, force_shelve_offload=False):
|
||||
|
|
|
@ -49,19 +49,19 @@ def wait_for_server_status(client, server_id, status, ready_wait=True,
|
|||
# between the UNKNOWN->ACTIVE transition.
|
||||
# TODO(afazekas): enumerate and validate the stable status set
|
||||
if status == 'BUILD' and server_status != 'UNKNOWN':
|
||||
return
|
||||
return body
|
||||
if server_status == status:
|
||||
if ready_wait:
|
||||
if status == 'BUILD':
|
||||
return
|
||||
return body
|
||||
# NOTE(afazekas): The instance is in "ready for action state"
|
||||
# when no task in progress
|
||||
if task_state is None:
|
||||
# without state api extension 3 sec usually enough
|
||||
time.sleep(CONF.compute.ready_wait)
|
||||
return
|
||||
return body
|
||||
else:
|
||||
return
|
||||
return body
|
||||
|
||||
time.sleep(client.build_interval)
|
||||
body = client.show_server(server_id)['server']
|
||||
|
|
Loading…
Reference in New Issue