Return a mapping of process name -> preferred display hostname for endpoint
rendering in the UI.
These values are cosmetic only. The controller's advertised endpoint remains
the authoritative connect address.
Returns:
| Type |
Description |
dict[str, str]
|
dict[str, str]: Mapping from process name to preferred display hostname.
|
Source code in drunc/unified_shell/context.py
| def get_endpoint_display_host_overrides(self) -> dict[str, str]:
"""
Return a mapping of process name -> preferred display hostname for endpoint
rendering in the UI.
These values are cosmetic only. The controller's advertised endpoint remains
the authoritative connect address.
Returns:
dict[str, str]: Mapping from process name to preferred display hostname.
"""
# The PM driver may not be registered if the user connected directly to a
# controller without going through the process manager (e.g. standalone boot).
# In that case hostname overrides are unavailable and we fall back to
# get_hostname_smart in the endpoint rendering path.
pm_driver = self.get_driver("process_manager", quiet_fail=True)
if not pm_driver:
return {}
if not self.session_name:
raise RuntimeError("session name must be set before querying process list")
query = ProcessQuery(names=[".*"], session=self.session_name)
try:
proc_list = pm_driver.ps(query)
except (ServerUnreachable, ServerTimeout, grpc.RpcError):
return {}
overrides: dict[str, str] = {}
for proc in proc_list.values:
metadata = proc.process_description.metadata
proc_name = getattr(metadata, "name", "")
host_name = getattr(metadata, "hostname", "")
if not proc_name or not host_name:
continue
overrides[proc_name] = host_name
return overrides
|