YP-HA Interface
The High Availability features in the netconfd-pro server can be accessed from the yp-system library.
There are two functions that call be called from the “init1” or “init2” phases in the yp-system library initialization. They can also be called from an agt_timer callback function during system run time.
Normally when the server running with YP-HA enabled (--ha-enabled=true), the server will wait until it is told which HA role should be used (active or standby). The :--ha-initial-active CLI parameter can be used to hard-wire the YA role in the configuration. This should only be used for debugging. In production networks, the HA management system should signal all the HA role changes to the server.
agt_ha_role_t
The 'agt_ha_role_t' is an enumeration specifying the different YP-HA roles.
YP-HA Interface Functions
The YP-HA role can be set from internal API functions of from the DB-API subsystem interface, using the “yp-ha-role” message.
agt_yp_ha_get_role
The 'agt_yp_ha_get_role' function is used to retrieve the current YP-HA role used by the server.
-
agt_ha_role_t agt_yp_ha_get_role(void)
Get the YP-HA server role for this server.
- Returns:
server role enum
agt_yp_ha_be_active
The 'agt_yp_ha_be_active' function is used to tell the server to be the active server in the YP-HA protocol.
-
status_t agt_yp_ha_be_active(void)
Put this server in YP-HA Active mode.
- Returns:
status
agt_yp_ha_be_standby
The 'agt_yp_ha_be_standby' function is used to tell the server to be a standby server in the YP-HA protocol.
-
status_t agt_yp_ha_be_standby(const xmlChar *new_server_id)
Put this server in YP-HA Standby mode.
- Parameters:
new_server_id -- server-id of the new active server
- Returns:
status NO_ERR if this server able to enter YP-HA Standby mode
agt_yp_ha_be_none
The 'agt_yp_ha_be_none' function is used to tell the server to leave its current YP-HA role, go offline, and wait for a new YP-HA role to be set.
-
status_t agt_yp_ha_be_none(void)
Put this server in WAIT_ROLE state.
- Returns:
status
DB-API <yp-ha-role> Event Message
The DB-API service has a new utility function to set the YP-HA role on the local server.
The <yp-ha-mode> message is sent from a subsystem to the main server. It has 2 variants. Either the “go-active” or the “go-standby” variant is sent.
container yp-ha-mode {
description
"Message type: subsys-event;
Purpose: send mode change event to the server
Expected Response Message: none";
choice action {
mandatory true;
leaf go-active {
type empty;
description "Become the YP-HA active server";
}
container go-standby {
description "Become a YP-HA standby server";
leaf new-active {
type string;
mandatory true;
description
"Server name of the active server to use";
}
}
}
} // container yp-ha-mode
Example message to set the YP-HA Active mode:
<?xml version="1.0" encoding="UTF-8"?>
<ycontrol xmlns="http://yumaworks.com/ns/yumaworks-ycontrol">
<message-id>2</message-id>
<message-type>subsys-event</message-type>
<server-id>ha-1</server-id>
<subsys-id>subsys1</subsys-id>
<service-id>db-api</service-id>
<payload>
<db-api xmlns="http://yumaworks.com/ns/yumaworks-db-api">
<yp-ha-mode>
<go-active/>
</yp-ha-mode>
</db-api>
</payload>
</ycontrol>