[Libvirt-cim] [PATCH 01/10] live.full_hostname: Adjust mechanism to get FQDN

John Ferlan jferlan at redhat.com
Fri May 9 10:26:37 UTC 2014


<...snip...>

> I got an interesting result if I changed the hostname when system
> starting the first time.
> 
>>>> import socket
>>>> print socket.getfqdn()
> zBX.testing
>>>> print socket.gethostname()
> zBX.testing
>>>> print socket.gethostbyaddr(socket.gethostname())
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> socket.gaierror: [Errno -2] Name or service not known
> 

gethostbyaddr() (and byname) need to do name server lookups - see the
name service switch configuration (nsswitch.conf).

How/where did you set "zBX.testing" as the hostname?

I would get the same result if I use:

>>> print socket.gethostbyaddr("zBX.testing")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
socket.gaierror: [Errno -2] Name or service not known
>>>


John

> But my /etc/hosts was not changed (just as default),
> 
>   # cat /etc/hosts
>   127.0.0.1   localhost localhost.localdomain localhost4
> localhost4.localdomain4
>   ::1         localhost localhost.localdomain localhost6
> localhost6.localdomain6
> 
>   Just the system with default hostname was changed from
> localhost.localdomain into
> others could happened that. If we use getfqdn() that situation would not
> occur. But
> I still don't know the reason why the error happened.
> 
> Thanks,
>   Xu Wang




More information about the Libvirt-cim mailing list