@param name: hostname or None
"""
- self.name = self.GetNormalizedName(self.GetFqdn(name))
+ self.name = self.GetFqdn(name)
self.ip = self.GetIP(self.name, family=family)
@classmethod
"""
return cls.GetFqdn()
- @staticmethod
- def GetFqdn(hostname=None):
+ @classmethod
+ def GetFqdn(cls, hostname=None):
"""Return fqdn.
If hostname is None the system's fqdn is returned.
if hostname is None:
virtfqdn = vcluster.GetVirtualHostname()
if virtfqdn:
- return virtfqdn
+ result = virtfqdn
else:
- return socket.getfqdn()
+ result = socket.getfqdn()
else:
- return socket.getfqdn(hostname)
+ result = socket.getfqdn(hostname)
+
+ return cls.GetNormalizedName(result)
@staticmethod
def GetIP(hostname, family=None):
try:
return result[0][4][0]
except IndexError, err:
- raise errors.ResolverError("Unknown error in getaddrinfo(): %s" % err)
+ # we don't have here an actual error code, it's just that the
+ # data type returned by getaddrinfo is not what we expected;
+ # let's keep the same format in the exception arguments with a
+ # dummy error code
+ raise errors.ResolverError(hostname, 0,
+ "Unknown error in getaddrinfo(): %s" % err)
@classmethod
def GetNormalizedName(cls, hostname):