Package onep :: Package core :: Package util :: Module HostIpCheck :: Class HostIpCheck
[frames] | no frames]

Class HostIpCheck



Use this to check for a valid ipv4, ipv6 or hostname string.
Examples:  
HostIpCheck('1.1.1.1').is_ipv4()       -- check for valid ipv4
                      .is_ipv6()       -- check for valid ipv6
                      .is_hostname()   -- check for valid hostname
                      .is_valid()      -- check for valid hostname or ip
                      .is_ipaddress()  -- check for valid ip address

Instance Methods
 
__init__(self, argument, address_space=None)
x.__init__(...) initializes x; see help(type(x)) for signature
 
address_space(self)
 
is_ipv4(self)
Check if argument is a valid ipv4.
 
is_ipv6(self)
Check if argument is a valid ipv6.
 
is_hostname(self)
Check if argument is a valid hostname.
 
is_valid(self)
Check if argument is a valid hostname, ipv4 or ipv6.
 
is_ipaddress(self)
Check for valid ipv4 or ipv6 address
 
__eq__(self, other)
Check if host ip address equals other

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

Static Methods
 
len2mask(len)
Convert a bit length to a dotted netmask (aka.
 
mask2len(mask)
Convert network submask to prefix length
 
ipv4_validate_mask(mask)
Validate IPv4 subnetmask is valid
 
calc_mask(address)
string
len2mask6(prefix_length)
Convert an IPv6 prefix length to string representation.
Properties

Inherited from object: __class__

Method Details

__init__(self, argument, address_space=None)
(Constructor)

 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

len2mask(len)
Static Method

 

Convert a bit length to a dotted netmask (aka. CIDR to netmask)

len2mask6(prefix_length)
Static Method

 

Convert an IPv6 prefix length to string representation.

Example:

>>> len2mask6(64)
'ffff:ffff:ffff:ffff:0000:0000:0000:0000'
>>>
Parameters:
  • prefix_length (int) - Integer between 0 - 128
Returns: string
prefix length in string format