Skip to content

Commit

Permalink
test_host_evacuate: check for IP in xenstore first
Browse files Browse the repository at this point in the history
This can show when after migration an IP address has been published to
Xenstore, but XAPI misses it nevertheless.
  • Loading branch information
ydirson committed Jan 11, 2024
1 parent bbeb7cb commit 5895768
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,21 @@ def reboot(self, force=False, verify=False):
self.wait_for_vm_running_and_ssh_up()
return ret

def try_get_ip_xenstore(self):
domid = self.param_get("dom-id")
residence_host = self.get_residence_host()
result = residence_host.ssh(
["xenstore", "read", f"/local/domain/{domid}/attr/vif/0/ipv4/0"],
check=False, simple_output=False)

# An IP that starts with 169.254. is not a real routable IP.
# VMs may return such an IP before they get an actual one from DHCP.
if result.returncode != 0 or result.stdout.startswith('169.254.'):
return False
else:
logging.info("Xenstore VM IP: %s" % result.stdout.rstrip())
return True

def try_get_and_store_ip(self):
ip = self.param_get('networks', '0/ip', accept_unknown_key=True)

Expand Down Expand Up @@ -123,6 +138,7 @@ def wait_for_os_booted(self):
# waiting for the IP:
# - allows to make sure the OS actually started (on VMs that have the management agent)
# - allows to store the IP for future use in the VM object
wait_for(self.try_get_ip_xenstore, "Wait for Xenstore VM IP")
wait_for(self.try_get_and_store_ip, "Wait for VM IP")
# now wait also for the management agent to have started
wait_for(self.is_management_agent_up, "Wait for management agent up")
Expand Down

0 comments on commit 5895768

Please sign in to comment.