def disconnect_floating_ip(ctx, server_client, **kwargs):
    floating_ip_client = get_floating_ip_client(ctx)
    ip = ctx.target.instance.runtime_properties['floating_ip_address']
    floating_ip = floating_ip_client.get_by_ip(ip)
    if floating_ip is None:
        raise RuntimeError(
            "Cannot connect floating IP to the server"
            " - floating IP doesn't exist: {0}"
            .format(ip))
    server_client.disconnect_floating_ip(floating_ip)
def connect_floating_ip(ctx, server_client, **kwargs):
    ctx.logger.info("Try to connect floating IP")
    server = get_server_by_context(server_client, ctx.source.instance)
    if server is None:
        raise RuntimeError(
            "Cannot connect floating IP to the server"
            " - server doesn't exist for node: {0}"
            .format(ctx.instance.id))
    floating_ip_client = get_floating_ip_client(ctx)
    ip = ctx.target.instance.runtime_properties['floating_ip_address']
    floating_ip = floating_ip_client.get_by_ip(ip)
    if floating_ip is None:
        raise RuntimeError(
            "Cannot connect floating IP to the server"
            " - floating IP doesn't exist: {0}"
            .format(ip))
    ctx.logger.info("Connect floating IP method called:"
                    " server - {0}, IP - {1}"
                    .format(server.name, floating_ip.ip))
    server_client.connect_floating_ip(server, floating_ip)