Trees | Indices | Help |
|
---|
|
|
|||
IpAddressError | |||
InvalidIPRangeError Attempted to parse an invalid IP range. |
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|
|||
__doc__ = """IpU
|
|||
IP_DELIM = '..'
|
|||
INTERFACE_DELIM = '...'
|
|
SNMP provides a 16-byte index to table items, where the index represents the IPv6 address. Return an empty string or the canonicalized IPv6 address. >>> bytesToCanonIpv6( ['254','128','0','0','0','0','0','0','2','80','86','255','254','138','46','210']) 'fe80::250:56ff:fe8a:2ed2' >>> bytesToCanonIpv6( ['253','0','0','0','0','0','0','0','0','0','0','0','10','175','210','5']) 'fd00::aaf:d205' >>> bytesToCanonIpv6( ['hello','world']) '' >>> bytesToCanonIpv6( ['253','0','0','0','0','0','0','0','0','0','0','0','10','175','210','5']) 'fd00::aaf:d205' |
Check that an IPv4 address is valid. Return true or raise an exception(!) >>> checkip('10.10.20.5') True >>> try: checkip(10) ... except IpAddressError, ex: print ex 10 is an invalid address >>> try: checkip('10') ... except IpAddressError, ex: print ex 10 is an invalid address >>> try: checkip('10.10.20.500') ... except IpAddressError, ex: print ex 10.10.20.500 is an invalid address >>> checkip('10.10.20.0') True >>> checkip('10.10.20.255') True |
Convert a string IP to a decimal representation easier for calculating netmasks etc. Deprecated in favour of ipToDecimal() |
Convert a string IP to a decimal representation easier for calculating netmasks etc. >>> ipToDecimal('10.10.20.5') 168432645L >>> try: ipToDecimal('10.10.20.500') ... except IpAddressError, ex: print ex 10.10.20.500 is an invalid address |
Get just the IP address from an CIDR string like 1.1.1.1/24 >>> ipFromIpMask('1.1.1.1') '1.1.1.1' >>> ipFromIpMask('1.1.1.1/24') '1.1.1.1' |
Convert a numeric IP address to a string Deprecated in favour of decimalIpToStr() |
Convert a decimal IP address (as returned by ipToDecimal) to a regular IPv4 dotted quad address. >>> decimalIpToStr(ipToDecimal('10.23.44.57')) '10.23.44.57' |
Convert hex netbits (0xff000000) to decimal netmask (8) >>> hexToBits("0xff000000") 8 >>> hexToBits("0xffffff00") 24 |
Converts a netmask represented in hex to octets represented in decimal. >>> hexToMask("0xffffff00") '255.255.255.0' >>> hexToMask("0xffffffff") '255.255.255.255' >>> hexToMask("0x00000000") '0.0.0.0' >>> hexToMask("trash") '255.255.255.255' |
Convert string rep of netmask to number of bits >>> maskToBits('255.255.255.255') 32 >>> maskToBits('255.255.224.0') 19 >>> maskToBits('0.0.0.0') 0 |
Convert integer number of netbits to a decimal number Deprecated in favour of bitsToDecimalMask() |
Convert integer number of netbits to a decimal number >>> bitsToDecimalMask(32) 4294967295L >>> bitsToDecimalMask(19) 4294959104L >>> bitsToDecimalMask(0) 0L |
Convert netbits into a dotted-quad subnetmask >>> bitsToMask(12) '255.240.0.0' >>> bitsToMask(0) '0.0.0.0' >>> bitsToMask(32) '255.255.255.255' |
Get network address of IP as string netmask as in the form 255.255.255.0 >>> getnet('10.12.25.33', 24) 168564992L >>> getnet('10.12.25.33', '255.255.255.0') 168564992L |
Return network number as string >>> netFromIpAndNet('10.12.25.33', 24) '10.12.25.0' >>> netFromIpAndNet('250.12.25.33', 1) '128.0.0.0' >>> netFromIpAndNet('10.12.25.33', 16) '10.12.0.0' >>> netFromIpAndNet('10.12.25.33', 32) '10.12.25.33' |
Look up an IP based on the name passed in. We use gethostbyname to make sure that we use /etc/hosts as mentioned above. This hasn't been tested. |
Look up an IP based on the name passed in, synchronously. Not using socket.gethostbyname() because it does not support IPv6. preferredIpVersion should equal something like socket.AF_INET or socket.AF_INET6 |
Turn a string specifying an IP range into a list of IPs.
|
Given a string representing the lower limit of a subnet, return decimal representations of the first and last IP of that subnet. 0 is considered to define the beginning of a subnet, so x.x.x.0 represents a /24, x.x.0.0 represents a /16, etc. An octet of 0 followed by a non-zero octet, of course, is not considered to define a lower limit. >>> map(decimalIpToStr, getSubnetBounds('10.1.1.0')) ['10.1.1.0', '10.1.1.255'] >>> map(decimalIpToStr, getSubnetBounds('10.1.1.1')) ['10.1.1.1', '10.1.1.1'] >>> map(decimalIpToStr, getSubnetBounds('10.0.1.0')) ['10.0.1.0', '10.0.1.255'] >>> map(decimalIpToStr, getSubnetBounds('0.0.0.0')) ['0.0.0.0', '255.255.255.255'] >>> map(decimalIpToStr, getSubnetBounds('10.0.0.0')) ['10.0.0.0', '10.255.255.255'] >>> map(decimalIpToStr, getSubnetBounds('100.0.0.0')) ['100.0.0.0', '100.255.255.255'] >>> map(decimalIpToStr, getSubnetBounds('::100.0.0.0')) ['100.0.0.0', '100.255.255.255'] |
Given a partially formed IP address this will return a complete Ip address with four octets with the invalid or missing entries replaced by 0 @param ip partially formed ip (will strip out alpha characters) @return valid IP address field >>> from Products.ZenUtils.IpUtil import ensureIp >>> ensureIp('20') '20.0.0.0' >>> ensureIp('2000') '0.0.0.0' >>> ensureIp('10.175.X') '10.175.0.0' >>> ensureIp('10.0.1') '10.0.1.0' >>> |
|
__doc__
|
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1.1812 on Tue Oct 11 12:51:17 2011 | http://epydoc.sourceforge.net |