Skip to content
Snippets Groups Projects
Commit e91b297c authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

netutils: Use virtual hostname if set


This enables the hostname seen by other code through Hostname.GetFqdn to
be changed through the environment variable “GANETI_HOSTNAME”.

Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarRené Nussbaumer <rn@google.com>
parent 8c37d618
No related branches found
No related tags found
No related merge requests found
......@@ -38,6 +38,7 @@ import logging
from ganeti import constants
from ganeti import errors
from ganeti import utils
from ganeti import vcluster
# Structure definition for getsockopt(SOL_SOCKET, SO_PEERCRED, ...):
# struct ucred { pid_t pid; uid_t uid; gid_t gid; };
......@@ -189,7 +190,11 @@ class Hostname:
"""
if hostname is None:
return socket.getfqdn()
virtfqdn = vcluster.GetVirtualHostname()
if virtfqdn:
return virtfqdn
else:
return socket.getfqdn()
else:
return socket.getfqdn(hostname)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment