Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP test_host_evacuate: check for IP in xenstore first #182

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")
stormi marked this conversation as resolved.
Show resolved Hide resolved
# now wait also for the management agent to have started
wait_for(self.is_management_agent_up, "Wait for management agent up")
Expand Down
Loading