netaddr.ip.glob.IPGlob

Package netaddr :: Package ip :: Module glob :: Class IPGlob |
[hide private]
[frames] | no frames]

# Class IPGlob

     object --+
              |
         BaseIP --+
                  |
     object --+   |
              |   |
    IPListMixin --+
                  |
            IPRange --+
                      |
                     IPGlob

Represents an IP address range using a glob-style syntax (x.x.x-y.*).

Individual octets can be represented using the following shortcuts :

1. `*` - the asterisk octet (represents values 0 through 255)
2. `'x-y'` - the hyphenated octet (represents values x through y)

A few basic rules also apply :

1. x must always be greater than y, therefore :
   - x can only be 0 through 254
   - y can only be 1 through 255
2. only one hyphenated octet per IP glob is allowed
3. only asterisks are permitted after a hyphenated octet

Example IP globs :

       '192.0.2.1'       #   a single address
       '192.0.2.0-31'    #   32 addresses
       '192.0.2.*'       #   256 addresses
       '192.0.2-3.*'     #   512 addresses
       '192.0-1.*.*'   #   131,072 addresses
       '*.*.*.*'           #   the whole IPv4 address space

# Aside

IP glob ranges are not directly equivalent to CIDR blocks. They can represent address ranges that do not fall on strict bit mask boundaries. They are suitable for use in configuration files, being more obvious and readable than their CIDR counterparts, especially for admins and end users with little or no networking knowledge or experience.

All CIDR addresses can always be represented as IP globs but the reverse is not always true.

Instance Methods | [hide private]
__init__(self, ipglob) Constructor. |
__getstate__(self) Returns: Pickled state of an `IPGlob` object. |
__setstate__(self, state) |
_get_glob(self) |
_set_glob(self, ipglob) |
__str__(self) Returns: IP glob in common representational format. |
__repr__(self) Returns: Python statement to create an equivalent object |
Inherited from `object`: `__delattr__`, `__format__`, `__getattribute__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__setattr__`, `__sizeof__`, `__subclasshook__`
Inherited from IPRange
cidrs(self) The list of CIDR addresses found within the lower and upper bound addresses of this IPRange. |
key(self) Returns: A key tuple used to uniquely identify this IPRange. |
sort_key(self) Returns: A key tuple used to compare and sort this IPRange correctly. |
Inherited from BaseIP
__eq__(self, other) Returns: `True` if this IPAddress or IPNetwork object is equivalent to `other`, `False` otherwise. |
__ge__(self, other) Returns: `True` if this IPAddress or IPNetwork object is greater than or equal to `other`, `False` otherwise. |
__gt__(self, other) Returns: `True` if this IPAddress or IPNetwork object is greater than `other`, `False` otherwise. |
__hash__(self) Returns: A hash value uniquely indentifying this IP object. |
__le__(self, other) Returns: `True` if this IPAddress or IPNetwork object is less than or equal to `other`, `False` otherwise. |
__lt__(self, other) Returns: `True` if this IPAddress or IPNetwork object is less than `other`, `False` otherwise. |
__ne__(self, other) Returns: `True` if this IPAddress or IPNetwork object is not equivalent to `other`, `False` otherwise. |
_set_value(self, value) |
is_ipv4_compat(self) Returns: `True` if this IP is IPv4-mapped IPv6 address, `False` otherwise. |
is_ipv4_mapped(self) Returns: `True` if this IP is IPv4-compatible IPv6 address, `False` otherwise. |
is_link_local(self) Returns: `True` if this IP is link-local address `False` otherwise. |
is_loopback(self) Returns: `True` if this IP is loopback address (not for network transmission), `False` otherwise. |
is_multicast(self) Returns: `True` if this IP is multicast, `False` otherwise |
is_private(self) Returns: `True` if this IP is for internal/private use only (i.e. |
is_reserved(self) Returns: `True` if this IP is in IANA reserved range, `False` otherwise. |
is_unicast(self) Returns: `True` if this IP is unicast, `False` otherwise |
Inherited from IPListMixin
__bool__(self) Ranged IP objects always represent a sequence of at least one IP address and are therefore always True in the boolean context. |
__contains__(self, other) Returns: `True` if other falls within the boundary of this one, `False` otherwise. |
__getitem__(self, index) Returns: The IP address(es) in this IPNetwork object referenced by index or slice. |
__iter__(self) Returns: An iterator providing access to all IPAddress objects within range represented by this ranged IP object. |
__len__(self) Returns: the number of IP addresses in this ranged IP object. |
__nonzero__(self) Ranged IP objects always represent a sequence of at least one IP address and are therefore always True in the boolean context. |

Properties | [hide private]
| glob an arbitrary IP address range in glob format.
| _glob
Inherited from `object`: `__class__`
Inherited from IPRange
| _end
| _start
| first The integer value of first IP address in this IPRange object.
| last The integer value of last IP address in this IPRange object.
Inherited from BaseIP
| _module
| _value
| info A record dict containing IANA registration details for this IP address if available, None otherwise.
| value a positive integer representing the value of IP address/subnet.
| version the IP protocol version represented by this IP object.
Inherited from IPListMixin
| size The total number of IP addresses within this ranged IP object.

Method Details | [hide private]

### __init__(self, ipglob) (Constructor) |
Constructor. Parameters: `start` - an IPv4 or IPv6 address that forms the lower boundary of this IP range. `end` - an IPv4 or IPv6 address that forms the upper boundary of this IP range. `flags` - (optional) decides which rules are applied to the interpretation of the start and end values. Supported constants are INET_PTON and ZEROFILL. See the netaddr.core docs for further details. Overrides: object.__init__ (inherited documentation)

### __getstate__(self) |
Returns: Pickled state of an `IPGlob` object. Overrides: IPRange.__getstate__

### __setstate__(self, state) |
Parameters: `state` - data used to unpickle a pickled `IPGlob` object. Overrides: IPRange.__setstate__

### __str__(self) (Informal representation operator) |
str(x) Returns: IP glob in common representational format. Overrides: object.__str__

### __repr__(self) (Representation operator) |
repr(x) Returns: Python statement to create an equivalent object Overrides: object.__repr__

Property Details | [hide private]

### glob an arbitrary IP address range in glob format. Get Method: _get_glob(self) Set Method: _set_glob(self, ipglob)