Skip to content
Snippets Groups Projects
Commit 5f30ea3f authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

netutils: Normalize all FQDNs


Addresses issue 147. Only the hostnames resolved using
“netutils.Hostname($name)” were normalized, but those returned by the
class method “GetSysName” weren't.

Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarHelga Velroyen <helgav@google.com>
parent 814e1e23
No related branches found
No related tags found
No related merge requests found
......@@ -167,7 +167,7 @@ class Hostname:
@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
......@@ -177,8 +177,8 @@ class Hostname:
"""
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.
......@@ -192,11 +192,13 @@ class Hostname:
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):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment