@staticmethod
def _set(rest, ipv6, ssl):
    (ip_fam, ip_fam_disable) = (('ipv6', 'ipv4') if ipv6 else ('ipv4', 'ipv6'))
    (node_data, err) = rest.pools('nodes')
    if (err and (err[0] == '"unknown pool"')):
        (_, err) = rest.enable_external_listener(ipfamily=ip_fam)
        _exit_if_errors(err)
        (_, err) = rest.setup_net_config(ipfamily=ip_fam)
        _exit_if_errors(err)
        (_, err) = rest.disable_unused_external_listeners(ipfamily=ip_fam_disable)
        _exit_if_errors(err)
        _success('Switched IP family of the cluster')
        return
    _exit_if_errors(err)
    hosts = []
    for n in node_data['nodes']:
        host = f"http://{n['hostname']}"
        if ssl:
            addr = host.rsplit(':', 1)[0]
            host = f"https://{addr}:{n['ports']['httpsMgmt']}"
        (_, err) = rest.enable_external_listener(host=host, ipfamily=ip_fam)
        _exit_if_errors(err)
        hosts.append(host)
    for h in hosts:
        (_, err) = rest.setup_net_config(host=h, ipfamily=ip_fam)
        _exit_if_errors(err)
        print(f'Switched IP family for node: {h}')
    for h in hosts:
        (_, err) = rest.disable_unused_external_listeners(host=h, ipfamily=ip_fam_disable)
        _exit_if_errors(err)
    _success('Switched IP family of the cluster')
@staticmethod
def _set(rest, ipv6, ssl):
    (ip_fam, ip_fam_disable) = (('ipv6', 'ipv4') if ipv6 else ('ipv4', 'ipv6'))
    (node_data, err) = rest.pools('nodes')
    if (err and (err[0] == '"unknown pool"')):
        (_, err) = rest.enable_external_listener(ipfamily=ip_fam)
        _exit_if_errors(err)
        (_, err) = rest.setup_net_config(ipfamily=ip_fam)
        _exit_if_errors(err)
        (_, err) = rest.disable_unused_external_listeners(ipfamily=ip_fam_disable)
        _exit_if_errors(err)
        _success('Switched IP family of the cluster')
        return
    _exit_if_errors(err)
    hosts = []
    for n in node_data['nodes']:
        host = f"http://{n['hostname']}"
        if ssl:
            addr = host.rsplit(':', 1)[0]
            host = f"https://{addr}:{n['ports']['httpsMgmt']}"
        (_, err) = rest.enable_external_listener(host=host, ipfamily=ip_fam)
        _exit_if_errors(err)
        hosts.append(host)
    for h in hosts:
        (_, err) = rest.setup_net_config(host=h, ipfamily=ip_fam)
        _exit_if_errors(err)
        print(f'Switched IP family for node: {h}')
    for h in hosts:
        (_, err) = rest.disable_unused_external_listeners(host=h, ipfamily=ip_fam_disable)
        _exit_if_errors(err)
    _success('Switched IP family of the cluster')