INNER CODE UNIT · Python
local_node
LINBIT/linstor-server · scripts/linstor-controller-ha-setup.py:210
def local_node(cluster_nodes=None):
"""This node's name as LINSTOR knows it.
Node names are whatever was registered: short on some clusters, fully
qualified on others. Match the local hostname against the cluster's own
list rather than assuming one form -- stripping the domain unconditionally
makes this node look unregistered on an FQDN cluster.
"""
host = socket.gethostname()
short = host.split(".")[0]
if cluster_nodes:
for candidate in (host, short):
if candidate in cluster_nodes:
return candidate
# same host registered under another spelling
for node in cluster_nodes:
if node.split(".")[0] == short:
return node