class IPAddress(object):
Known subclasses: ganeti.netutils.IP4Address, ganeti.netutils.IP6Address
Class that represents an IP address.
| Class Method | |
Determine whether an address is within a network. |
| Class Method | |
Determine whether it is a loopback address. |
| Class Method | |
Validate a IP address. |
| Class Method | |
Check if the current host has the the given IP address. |
| Class Method | |
Validate a netmask suffix in CIDR notation. |
| Static Method | |
Get the address family of the given address. |
| Static Method | |
Convert an IP version to the corresponding IP address family. |
| Static Method | |
Return the IPAddress subclass for the given IP family. |
| Static Method | |
Return the IPAddress subclass for the given IP version. |
| Static Method | |
Convert an IP address family to the corresponding IP version. |
| Class Variable | family |
Undocumented |
| Class Variable | iplen |
Undocumented |
| Class Variable | loopback |
Undocumented |
| Static Method | _ |
Abstract method to please pylint. |
Determine whether an address is within a network.
| Parameters | |
| cidr:string | Network in CIDR notation, e.g. '192.0.2.0/24', '2001:db8::/64' |
| address:str | IP address |
| Returns | |
| bool | True if address is in cidr, False otherwise |
Determine whether it is a loopback address.
| Parameters | |
| address:str | IP address to be checked |
| Returns | |
| bool | True if loopback, False otherwise |
Validate a IP address.
| Parameters | |
| address:str | IP address to be checked |
| Returns | |
| bool | True if valid, False otherwise |
Check if the current host has the the given IP address.
This is done by trying to bind the given address. We return True if we succeed or false if a socket.error is raised.
| Parameters | |
| address:str | IP address to be checked |
| Returns | |
| bool | True if we own the address, False otherwise |
Validate a netmask suffix in CIDR notation.
| Parameters | |
| netmask:int | netmask suffix to validate |
| Returns | |
| bool | True if valid, False otherwise |
Get the address family of the given address.
| Parameters | |
| address:str | ip address whose family will be returned |
| Returns | |
| int | socket.AF_INET or socket.AF_INET6 |
| Raises | |
errors.GenericError | for invalid addresses |
Convert an IP version to the corresponding IP address family.
| Parameters | |
| version:int | IP version, one of constants.IP4_VERSION or constants.IP6_VERSION |
| Returns | |
| an int containing the IP address family, one of socket.AF_INET or socket.AF_INET6 | |
| Raises | |
errors.ProgrammerError | for unknown IP versions |
Return the IPAddress subclass for the given IP family.
| Parameters | |
| family | IP family (one of socket.AF_INET or socket.AF_INET6 |
| Returns | |
a subclass of netutils.IPAddress | |
| Raises | |
errors.ProgrammerError | for unknowo IP versions |
Return the IPAddress subclass for the given IP version.
| Parameters | |
| version:int | IP version, one of constants.IP4_VERSION or constants.IP6_VERSION |
| Returns | |
a subclass of netutils.IPAddress | |
| Raises | |
errors.ProgrammerError | for unknowo IP versions |
Convert an IP address family to the corresponding IP version.
| Parameters | |
| family:int | IP address family, one of socket.AF_INET or socket.AF_INET6 |
| Returns | |
an int containing the IP version, one of constants.IP4_VERSION or constants.IP6_VERSION | |
| Raises | |
errors.ProgrammerError | for unknown families |
ganeti.netutils.IP4Address, ganeti.netutils.IP6AddressAbstract method to please pylint.