
Rather than default to socket.gethostbyaddr(socket.gethostname())[0] to get full_hostname(), go through a sequence of steps to get a more correct result NOTE: See http://www.redhat.com/archives/libvirt-cim/2013-November/msg00082.html for more details and history. Signed-off-by: John Ferlan <jferlan@redhat.com> --- lib/VirtLib/live.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/VirtLib/live.py b/lib/VirtLib/live.py index c929e71..e9cafc1 100644 --- a/lib/VirtLib/live.py +++ b/lib/VirtLib/live.py @@ -100,6 +100,11 @@ def hostname(server): return out def full_hostname(server): - """To return the fully qualifiec domain name(FQDN) of the system""" - - return socket.gethostbyaddr(socket.gethostname())[0] + """To return the fully qualified domain name(FQDN) of the system""" + + if socket.getfqdn().find('.') >= 0: + return socket.getfqdn() + elif socket.gethostname().find('.') >= 0: + return socket.gethostname() + else: + return socket.gethostbyaddr(server)[1][0] -- 1.8.5.3