From e91b297c4eafd3b389ca390c844f5d74ef0ede61 Mon Sep 17 00:00:00 2001 From: Michael Hanselmann <hansmi@google.com> Date: Thu, 20 Sep 2012 18:50:56 +0200 Subject: [PATCH] netutils: Use virtual hostname if set MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This enables the hostname seen by other code through Hostname.GetFqdn to be changed through the environment variable βGANETI_HOSTNAMEβ. Signed-off-by: Michael Hanselmann <hansmi@google.com> Reviewed-by: RenΓ© Nussbaumer <rn@google.com> --- lib/netutils.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/netutils.py b/lib/netutils.py index 42f8e8ba1..48d0f98b8 100644 --- a/lib/netutils.py +++ b/lib/netutils.py @@ -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) -- GitLab