This enables the hostname seen by other code through to
be changed through the environment variable “GANETI_HOSTNAME”.
---
lib/netutils.py | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/lib/netutils.py b/lib/netutils.py
index 42f8e8b..48d0f98 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)
--
1.7.6