@param family: AF_INET | AF_INET6 | None
@rtype: L{Hostname}
@return: Hostname object
- @raise: errors.OpPrereqError
+ @raise errors.OpPrereqError: in case of errors in resolving
"""
try:
to it.
@type target: str
- @param target: the IP or hostname to ping
+ @param target: the IP to ping
@type port: int
@param port: the port to connect to
@type timeout: int
"""Get integer value of IPv4 address.
@type address: str
- @param: IPv6 address
+ @param address: IPv6 address
@rtype: int
@return: integer value of given IP address
"""Get integer value of IPv6 address.
@type address: str
- @param: IPv6 address
+ @param address: IPv6 address
@rtype: int
@return: integer value of given IP address
return address_int
-def FormatAddress(family, address):
+def FormatAddress(address, family=None):
"""Format a socket address
- @type family: integer
- @param family: socket family (one of socket.AF_*)
@type address: family specific (usually tuple)
@param address: address, as reported by this class
+ @type family: integer
+ @param family: socket family (one of socket.AF_*) or None
"""
+ if family is None:
+ try:
+ family = IPAddress.GetAddressFamily(address[0])
+ except errors.IPAddressError:
+ raise errors.ParameterError(address)
+
if family == socket.AF_UNIX and len(address) == 3:
return "pid=%s, uid=%s, gid=%s" % address