@@ -71,6 +71,21 @@ def reboot(self, force=False, verify=False):
71
71
self .wait_for_vm_running_and_ssh_up ()
72
72
return ret
73
73
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
+
74
89
def try_get_and_store_ip (self ):
75
90
ip = self .param_get ('networks' , '0/ip' , accept_unknown_key = True )
76
91
@@ -123,6 +138,7 @@ def wait_for_os_booted(self):
123
138
# waiting for the IP:
124
139
# - allows to make sure the OS actually started (on VMs that have the management agent)
125
140
# - 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" )
126
142
wait_for (self .try_get_and_store_ip , "Wait for VM IP" )
127
143
# now wait also for the management agent to have started
128
144
wait_for (self .is_management_agent_up , "Wait for management agent up" )
0 commit comments