Skip to content

Commit 5895768

Browse files
committed
test_host_evacuate: check for IP in xenstore first
This can show when after migration an IP address has been published to Xenstore, but XAPI misses it nevertheless.
1 parent bbeb7cb commit 5895768

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Diff for: lib/vm.py

+16
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,21 @@ def reboot(self, force=False, verify=False):
7171
self.wait_for_vm_running_and_ssh_up()
7272
return ret
7373

74+
def try_get_ip_xenstore(self):
75+
domid = self.param_get("dom-id")
76+
residence_host = self.get_residence_host()
77+
result = residence_host.ssh(
78+
["xenstore", "read", f"/local/domain/{domid}/attr/vif/0/ipv4/0"],
79+
check=False, simple_output=False)
80+
81+
# An IP that starts with 169.254. is not a real routable IP.
82+
# VMs may return such an IP before they get an actual one from DHCP.
83+
if result.returncode != 0 or result.stdout.startswith('169.254.'):
84+
return False
85+
else:
86+
logging.info("Xenstore VM IP: %s" % result.stdout.rstrip())
87+
return True
88+
7489
def try_get_and_store_ip(self):
7590
ip = self.param_get('networks', '0/ip', accept_unknown_key=True)
7691

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

0 commit comments

Comments
 (0)