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

Class Hostname

source code


Class implementing resolver and hostname functionality.

Instance Methods [hide private]
 
__init__(self, name=None, family=None)
Initialize the host name object.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Methods [hide private]
 
GetSysName(cls)
Legacy method the get the current system's name.
source code
str
GetFqdn(cls, hostname=None)
Return fqdn.
source code
 
GetNormalizedName(cls, hostname)
Validate and normalize the given hostname.
source code
Static Methods [hide private]
str
GetIP(hostname, family=None)
Return IP address of given hostname.
source code
Class Variables [hide private]
  _VALID_NAME_RE = re.compile("^[a-z0-9._-]{1,255}$")
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, name=None, family=None)
(Constructor)

source code 

Initialize the host name object.

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

Parameters:
  • family (int) - AF_INET | AF_INET6 | None
  • name (str) - hostname or None
Overrides: object.__init__

GetFqdn(cls, hostname=None)
Class Method

source code 

Return fqdn.

If hostname is None the system's fqdn is returned.

Parameters:
  • hostname (str) - name to be fqdn'ed
Returns: str
fqdn of given name, if it exists, unmodified name otherwise

GetIP(hostname, family=None)
Static Method

source code 

Return IP address of given hostname.

Supports both IPv4 and IPv6.

Parameters:
  • hostname (str) - hostname to look up
  • family (int) - AF_INET | AF_INET6 | None
Returns: str
IP address
Raises:

GetNormalizedName(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