Commit f3044516 authored by Manuel Franceschini's avatar Manuel Franceschini
Browse files

Make Hostname object always intialize its name to fqdn

This patch restores the behaviour of Hostname (previously known as
HostInfo) to always use fqdn. This was broken due to the fact that the
now used getaddrinfo does not return an fqdn in contrast to

This patch adds Hostname.GetFqdn() which is always used when
initializing a Hostname object.

A problem this solves is when adding a node and not using its fqdn, node
verify won't complain.
Signed-off-by: default avatarManuel Franceschini <>
Reviewed-by: default avatarMichael Hanselmann <>
parent edcd876b
......@@ -98,20 +98,32 @@ class Hostname:
@param name: hostname or None
if name is None:
name = self.GetSysName() = self.GetNormalizedName(name) = self.GetNormalizedName(self.GetFqdn(name))
self.ip = self.GetIP(, family=family)
def GetSysName(cls):
"""Legacy method the get the current system's name.
return cls.GetFqdn()
def GetSysName():
"""Return the current system's name.
def GetFqdn(hostname=None):
"""Return fqdn.
This is simply a wrapper over C{socket.gethostname()}.
If hostname is None the system's fqdn is returned.
@type hostname: str
@param hostname: name to be fqdn'ed
@rtype: str
@return: fqdn of given name, if it exists, unmodified name otherwise
return socket.gethostname()
if hostname is None:
return socket.getfqdn()
return socket.getfqdn(hostname)
def GetIP(hostname, family=None):
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment