Package ganeti :: Module netutils :: Class HostInfo
[hide private]
[frames] | no frames]

Class HostInfo

source code

Class implementing resolver and hostname functionality

Instance Methods [hide private]
 
__init__(self, name=None)
Initialize the host name object.
source code
 
ShortName(self)
Returns the hostname without domain.
source code
Class Methods [hide private]
 
NormalizeName(cls, hostname)
Validate and normalize the given hostname.
source code
Static Methods [hide private]
 
SysName()
Return the current system's name.
source code
tuple
LookupHostname(hostname)
Look up hostname
source code
Class Variables [hide private]
  _VALID_NAME_RE = re.compile("^[a-z0-9._-]{1,255}$")
Method Details [hide private]

__init__(self, name=None)
(Constructor)

source code 

Initialize the host name object.

If the name argument is not passed, it will use this system's name.

SysName()
Static Method

source code 

Return the current system's name.

This is simply a wrapper over socket.gethostname().

LookupHostname(hostname)
Static Method

source code 

Look up hostname

Parameters:
  • hostname (str) - hostname to look up
Returns: tuple
a tuple (name, aliases, ipaddrs) as returned by socket.gethostbyname_ex
Raises:

NormalizeName(cls, hostname)
Class Method

source code 

Validate and normalize the given hostname.

Raises:

Attention: the validation is a bit more relaxed than the standards require; most importantly, we allow underscores in names