INNER CODE UNIT · Python
parse_vip
LINBIT/linstor-server · scripts/linstor-controller-ha-setup.py:103
def parse_vip(value):
"""--vip as (address, prefix), or None. Validated here rather than by
drbd-reactor, which would only complain once the promoter runs."""
if not value:
return None
if "/" not in value:
die("--vip needs a prefix length, e.g. " + value + "/24")
address, _, prefix = value.partition("/")
try:
socket.inet_aton(address)
except OSError:
die("--vip: '" + address + "' is not an IPv4 address")
if not prefix.isdigit() or not 0 < int(prefix) <= 32:
die("--vip: '" + prefix + "' is not a valid prefix length (1-32)")
return address, int(prefix)
def split_nodes(value):