Integrating custom workflows with Address Manager Failover Monitoring - Platform - BlueCat Gateway - 25.3.0

Gateway Administration Guide

ft:locale
en-US
Product name
BlueCat Gateway
Version
25.3.0

(This information applies only when authenticating Gateway with BlueCat Address Manager.)

The Address Manager Failover Monitoring feature lets Gateway authenticate with an Address Manager failover replication cluster, automatically signing in to a standby Address Manager instance should the primary Address Manager server fail.

Developers can build custom workflows to leverage this feature to maintain the Gateway user session after a failover event, allowing workflows that rely on Address Manager to continue to function without manual intervention.

Primary Address Manager URL

While Failover Monitoring is active, Gateway stores the primary address in the following parameter:

app.platform.failover_monitoring_manager.primary_url

Custom workflows that use Gateway's REST API can access this parameter to get the URL of the current primary Address Manager server in the replication cluster. They can then use this information to dynamically adapt to failover events.

Sample custom workflow code

The following code illustrates how to use the app.platform.failover_monitoring_manager.primary_url parameter to handle failover events in a custom workflow.

"""
REST example workflow
"""
from __future__ import annotations
from bluecat import route
from bluecat.gateway.decorators import api_exc_handler, require_permission
from flask import g, jsonify, current_app
from main_app import app
def get_configurations_v1(client):
    """Using a client to BAM REST API v1 produce a list of the names of the configurations."""
    data = client.get_entities(0, "Configuration", 0, 1000)
    return [configuration["name"] for configuration in data]
def get_configurations_v2(client):
    """Using a client to BAM REST API v2 produce a list of the names of the configurations."""
    data = client.http_get(
        "/configurations",
        params={"fields": "id,name"},
        headers={"Accept": "application/json"},
    )
    return [configuration["name"] for configuration in data["data"]]
@route(app, "/failover_rest_endpoints/get_configurations")
@require_permission("failover_rest_endpoints")
@api_exc_handler(default_message="Unable to retrieve configurations from Address Manager")
def get_configurations():
    """Gets the configurations details from BAM
    :return: Returns configurations data as a JSON response
    """
    platform = current_app.platform
    if g.user.bam_api.v1:
        configurations = get_configurations_v1(g.user.bam_api.v1)
    else:
        configurations = get_configurations_v2(g.user.bam_api.v2)
    data = {
        "primary_url": platform.failover_monitoring_manager.primary_url,
        "failover_monitoring_state": platform.failover_monitoring_manager.monitoring_state,
        "configurations": configurations,
    }
    return jsonify(data)