projects
/
ganeti-local
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add RAPI resource for instance console
[ganeti-local]
/
lib
/
netutils.py
diff --git
a/lib/netutils.py
b/lib/netutils.py
index
509329e
..
9dbf97b
100644
(file)
--- a/
lib/netutils.py
+++ b/
lib/netutils.py
@@
-71,7
+71,7
@@
def GetHostname(name=None, family=None):
@param family: AF_INET | AF_INET6 | None
@rtype: L{Hostname}
@return: Hostname object
@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:
"""
try:
@@
-425,7
+425,7
@@
class IP4Address(IPAddress):
"""Get integer value of IPv4 address.
@type address: str
"""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
@rtype: int
@return: integer value of given IP address
@@
-465,7
+465,7
@@
class IP6Address(IPAddress):
"""Get integer value of IPv6 address.
@type address: str
"""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
@rtype: int
@return: integer value of given IP address
@@
-490,15
+490,21
@@
class IP6Address(IPAddress):
return address_int
return address_int
-def FormatAddress(family, address):
+def FormatAddress(address, family=None):
"""Format a socket address
"""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 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
if family == socket.AF_UNIX and len(address) == 3:
return "pid=%s, uid=%s, gid=%s" % address