Skip to content

Commit 79731cc

Browse files
committed
lib/host: improve logging on wait_for
Signed-off-by: Olivier Hoareau <olivier.hoareau@vates.tech>
1 parent 5df45e7 commit 79731cc

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

lib/host.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ def xo_server_reconnect(self) -> None:
366366
wait_for(self.xo_server_connected, timeout_secs=10)
367367
# wait for XO to know about the host. Apparently a connected server status
368368
# is not enough to guarantee that the host object exists yet.
369-
wait_for(lambda: xo_object_exists(self.uuid), "Wait for XO to know about HOST %s" % self.uuid)
369+
wait_for(lambda: xo_object_exists(self.uuid), f"[{self}] Wait for XO to know about HOST {self.uuid}")
370370

371371
@staticmethod
372372
def vm_cache_key(uri: str) -> str:
@@ -403,7 +403,7 @@ def import_vm(self, uri: str, sr_uuid: str | None = None, use_cache: bool = Fals
403403
vm.param_clear('name-description')
404404
if uri.startswith("clone+start"):
405405
vm.start()
406-
wait_for(vm.is_running, "Wait for VM running")
406+
wait_for(vm.is_running, f"[{self}] Wait for VM running ({vm.uuid})")
407407
else:
408408
vm = self.cached_vm(uri, sr_uuid)
409409
if vm:
@@ -560,29 +560,29 @@ def restart_toolstack(self, verify: bool = False) -> None:
560560
def wait_for_host_down(self, timeout_secs: int = 2 * 60) -> None:
561561
wait_for_not(
562562
lambda: commands.local_cmd(["ping", "-c1", self.hostname_or_ip], check=False).returncode == 0,
563-
"Wait for host down",
563+
f"[{self}] Wait for host down",
564564
timeout_secs=timeout_secs,
565565
retry_delay_secs=2,
566566
)
567567

568568
def wait_for_host_up(self, timeout_secs: int = 10 * 60) -> None:
569569
wait_for(
570570
lambda: commands.local_cmd(["ping", "-c1", self.hostname_or_ip], check=False).returncode == 0,
571-
"Wait for host up",
571+
f"[{self}] Wait for host up",
572572
timeout_secs=timeout_secs,
573573
retry_delay_secs=10,
574574
)
575575

576576
def wait_for_ssh_reachable(self, timeout_secs: int = 10 * 60) -> None:
577577
wait_for(
578578
lambda: commands.local_cmd(["nc", "-zw5", self.hostname_or_ip, "22"], check=False).returncode == 0,
579-
"Wait for ssh up on host",
579+
f"[{self}] Wait for ssh up on host",
580580
timeout_secs=timeout_secs,
581581
retry_delay_secs=5
582582
)
583583

584584
def wait_for_xapi_enabled(self, timeout_secs: int = 30 * 60) -> None:
585-
logging.info(f"Wait for XAPI to complete initialization on {self.hostname_or_ip}")
585+
logging.info(f"[{self}] Wait for XAPI to complete initialization")
586586
self.ssh(f"xapi-wait-init-complete {timeout_secs}")
587587
assert self.is_enabled()
588588

@@ -894,7 +894,7 @@ def sr_create(self, sr_type: str, label: str, device_config: dict[str, str], sha
894894
sr_uuid = self.xe('sr-create', params)
895895
sr = SR(sr_uuid, self.pool)
896896
if verify:
897-
wait_for(sr.exists, "Wait for SR to exist")
897+
wait_for(sr.exists, f"[{self}] Wait for SR {sr_uuid} to exist")
898898
return sr
899899

900900
def is_master(self) -> bool:

0 commit comments

Comments
 (0)