MCPcopy Index your code
hub / github.com/retspen/webvirtcloud / len

Method len

vrtManager/IPy.py:492–508  ·  view source on GitHub ↗

Return the length of a subnet. >>> print IP('195.185.1.0/28').len() 16 >>> print IP('195.185.1.0/24').len() 256

(self)

Source from the content-addressed store, hash-verified

490 raise ValueError, "only IPv4 and IPv6 supported"
491
492 def len(self):
493 """Return the length of a subnet.
494
495 >>> print IP('195.185.1.0/28').len()
496 16
497 >>> print IP('195.185.1.0/24').len()
498 256
499 """
500
501 if self._ipversion == 4:
502 locallen = 32 - self._prefixlen
503 elif self._ipversion == 6:
504 locallen = 128 - self._prefixlen
505 else:
506 raise ValueError, "only IPv4 and IPv6 supported"
507
508 return 2L ** locallen
509
510
511 def __nonzero__(self):

Callers 9

broadcastMethod · 0.95
_printPrefixMethod · 0.95
__len__Method · 0.95
__getitem__Method · 0.95
__contains__Method · 0.95
overlapsMethod · 0.95
network_sizeFunction · 0.80
reverseNamesMethod · 0.80
reverseNameMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected