MCPcopy Create free account
hub / github.com/retspen/webvirtcloud / _ipVersionToLen

Function _ipVersionToLen

vrtManager/IPy.py:1129–1149  ·  view source on GitHub ↗

Return number of bits in address for a certain IP version. >>> _ipVersionToLen(4) 32 >>> _ipVersionToLen(6) 128 >>> _ipVersionToLen(5) Traceback (most recent call last): File " ", line 1, in ? File "IPy.py", line 1076, in _ipVersionToLen raise Value

(version)

Source from the content-addressed store, hash-verified

1127
1128
1129def _ipVersionToLen(version):
1130 """Return number of bits in address for a certain IP version.
1131
1132 >>> _ipVersionToLen(4)
1133 32
1134 >>> _ipVersionToLen(6)
1135 128
1136 >>> _ipVersionToLen(5)
1137 Traceback (most recent call last):
1138 File "<stdin>", line 1, in ?
1139 File "IPy.py", line 1076, in _ipVersionToLen
1140 raise ValueError, "only IPv4 and IPv6 supported"
1141 ValueError: only IPv4 and IPv6 supported
1142 """
1143
1144 if version == 4:
1145 return 32
1146 elif version == 6:
1147 return 128
1148 else:
1149 raise ValueError, "only IPv4 and IPv6 supported"
1150
1151
1152def _countFollowingZeros(l):

Callers 2

_checkPrefixFunction · 0.85
_prefixlenToNetmaskFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected