@staticmethod
def _change_encryption(rest, encryption, ssl):
    (node_data, err) = rest.pools('nodes')
    encryption_disable = ('off' if (encryption == 'on') else 'on')
    if (err and (err[0] == '"unknown pool"')):
        (_, err) = rest.enable_external_listener(encryption=encryption)
        _exit_if_errors(err)
        (_, err) = rest.setup_net_config(encryption=encryption)
        _exit_if_errors(err)
        (_, err) = rest.disable_unused_external_listeners(encryption=encryption_disable)
        _exit_if_errors(err)
        _success(f'Switched node-to-node encryption {encryption}')
        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, encryption=encryption)
        _exit_if_errors(err)
        hosts.append(host)
    for h in hosts:
        (_, err) = rest.setup_net_config(host=h, encryption=encryption)
        _exit_if_errors(err)
        print(f'Turned {encryption} encryption for node: {h}')
    for h in hosts:
        (_, err) = rest.disable_unused_external_listeners(host=h, encryption=encryption_disable)
        _exit_if_errors(err)
    _success(f'Switched node-to-node encryption {encryption}')
@staticmethod
def _change_encryption(rest, encryption, ssl):
    (node_data, err) = rest.pools('nodes')
    encryption_disable = ('off' if (encryption == 'on') else 'on')
    if (err and (err[0] == '"unknown pool"')):
        (_, err) = rest.enable_external_listener(encryption=encryption)
        _exit_if_errors(err)
        (_, err) = rest.setup_net_config(encryption=encryption)
        _exit_if_errors(err)
        (_, err) = rest.disable_unused_external_listeners(encryption=encryption_disable)
        _exit_if_errors(err)
        _success(f'Switched node-to-node encryption {encryption}')
        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, encryption=encryption)
        _exit_if_errors(err)
        hosts.append(host)
    for h in hosts:
        (_, err) = rest.setup_net_config(host=h, encryption=encryption)
        _exit_if_errors(err)
        print(f'Turned {encryption} encryption for node: {h}')
    for h in hosts:
        (_, err) = rest.disable_unused_external_listeners(host=h, encryption=encryption_disable)
        _exit_if_errors(err)
    _success(f'Switched node-to-node encryption {encryption}')