yumapro  20.10-12
YumaPro SDK
agt_yp_ha_active.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016 - 2021, YumaWorks, Inc., All Rights Reserved.
3  *
4  * Unless required by applicable law or agreed to in writing,
5  * software distributed under the License is distributed on an
6  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
7  * KIND, either express or implied. See the License for the
8  * specific language governing permissions and limitations
9  * under the License.
10  */
11 #ifdef WITH_YP_HA
12 #ifndef _H_agt_yp_ha_active
13 #define _H_agt_yp_ha_active
14 
15 /* FILE: agt_yp_ha_active.h
16 *********************************************************************
17 * *
18 * P U R P O S E *
19 * *
20 *********************************************************************/
21 
28 /*********************************************************************
29 * *
30 * C H A N G E H I S T O R Y *
31 * *
32 *********************************************************************
33 
34 date init comment
35 ----------------------------------------------------------------------
36 06-feb-16 abb Begun
37 */
38 
39 #ifndef _H_agt_yp_ha
40 #include "agt_yp_ha.h"
41 #endif
42 
43 #ifndef _H_status_enum
44 #include "status_enum.h"
45 #endif
46 
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
50 
51 /********************************************************************
52 * *
53 * C O N S T A N T S *
54 * *
55 *********************************************************************/
56 
57 /********************************************************************
58 * *
59 * T Y P E S *
60 * *
61 *********************************************************************/
62 
63 
64 /********************************************************************
65 * *
66 * F U N C T I O N S *
67 * *
68 *********************************************************************/
69 
70 
71 
90 extern status_t
91  agt_yp_ha_active_setup (yp_ha_service_t *ha_serv);
92 
93 
100 extern status_t
101  agt_yp_ha_active_go (yp_ha_service_t *ha_serv);
102 
103 
109 extern void
110  agt_yp_ha_active_stop (yp_ha_service_t *ha_serv);
111 
112 
118 extern void
119  agt_yp_ha_active_init (yp_ha_service_t *ha_serv);
120 
121 
127 extern void
128  agt_yp_ha_active_cleanup (yp_ha_service_t *ha_serv);
129 
130 
137 extern void
138  agt_yp_ha_active_cleanup_server (yp_ha_service_t *ha_serv,
139  yp_ha_server_t *ha_server);
140 
141 
150 extern status_t
151  agt_yp_ha_active_config_update (yp_ha_service_t *ha_serv,
152  rpc_msg_t *msg,
153  agt_cfg_transaction_t *txcb);
154 
155 
162 extern status_t
163  agt_yp_ha_active_nvstore (yp_ha_service_t *ha_serv);
164 
165 
177 extern void
178  agt_yp_ha_active_mod_event (yp_ha_service_t *ha_serv,
179  const xmlChar *name,
180  const xmlChar *revision,
181  val_value_t *inputval,
182  boolean is_module,
183  boolean is_load);
184 
185 
196 extern status_t
197  agt_yp_ha_active_get_config_info (yp_ha_service_t *ha_serv,
198  ncx_transaction_id_t *config_id,
199  const xmlChar **config_stamp);
200 
201 
205 #ifdef __cplusplus
206 } /* end extern 'C' */
207 #endif
208 
209 #endif /* _H_agt_yp_ha_active */
210 #endif // WITH_YP_HA
ERR_NCX_SKIPPED
@ ERR_NCX_SKIPPED
2001
Definition: status_enum.h:551
xml_strlen
uint32 xml_strlen(const xmlChar *str)
Get the String len for xmlChar.
Definition: xml_util.c:1406
cfg.h
agt_not_go_active
void agt_not_go_active(void)
Enable active notification subscriptions.
Definition: agt_not.c:6511
agt_ses.h
Server Session Management.
agt_util.h
Utility Functions for NCX Server method routines.
tstamp.h
Timestamp utilities.
xml_strdup
xmlChar * xml_strdup(const xmlChar *copyFrom)
String duplicate for xmlChar.
Definition: xml_util.c:1553
val_fast_replace_string
status_t val_fast_replace_string(const xmlChar *str, uint32 stringlen, val_value_t *copy)
Replace a specified val_value_t struct with a string type Reuse everything – just set the val->v....
Definition: val.c:8139
val_find_child
val_value_t * val_find_child(const val_value_t *parent, const xmlChar *modname, const xmlChar *childname)
Find the first instance of the specified child node.
Definition: val.c:8560
VAL_NSID
#define VAL_NSID(V)
Access the namespace ID.
Definition: val.h:396
ERR_NCX_DEF_NOT_FOUND
@ ERR_NCX_DEF_NOT_FOUND
250
Definition: status_enum.h:289
yang_patch_free_cb
void yang_patch_free_cb(yang_patch_cb_t *pcb)
Free a YANG Patch control block.
Definition: yang_patch.c:214
log_error
void log_error(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_ERROR log entry.
AGT_YP_HA
#define AGT_YP_HA
YP-HA service name for YControl.
Definition: agt.h:418
val.h
Value Node Basic Support.
HA_STATE_BE_ACTIVE
@ HA_STATE_BE_ACTIVE
in process of becoming active server
Definition: agt_yp_ha.h:120
agt_yp_ha_find_server
yp_ha_server_t * agt_yp_ha_find_server(const xmlChar *server_name)
Find a server record.
Definition: agt_yp_ha.c:1070
status_enum.h
global error status code enumerations
YCONTROL_MSGBODY_ERROR
@ YCONTROL_MSGBODY_ERROR
error message
Definition: ycontrol_types.h:96
log_debug3
void void void void void void void void void void void log_debug3(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_DEBUG3 log entry.
ncx_num.h
NCX Module Library Number Utility Functions.
YCONTROL_MSG_SUBSYS_REQUEST
@ YCONTROL_MSG_SUBSYS_REQUEST
subsystem-request sent from subsystem to server
Definition: ycontrol_types.h:81
agt_ycontrol_unregister_service
void agt_ycontrol_unregister_service(const xmlChar *service_name)
un-register a callback for 1 YControl service type
Definition: agt_ycontrol.c:1785
agt_ses_go_active
void agt_ses_go_active(void)
Activate MGMT sessions because YP-HA mode is active.
Definition: agt_ses.c:2302
agt_yp_ha_active_init
void agt_yp_ha_active_init(yp_ha_service_t *ha_serv)
Initialize the YP-HA Active module.
Definition: agt_yp_ha_active.c:2018
YCONTROL_MSGBODY_OK
@ YCONTROL_MSGBODY_OK
OK message.
Definition: ycontrol_types.h:90
op.h
NETCONF protocol operations.
VAL_NAME
#define VAL_NAME(V)
Access the value name.
Definition: val.h:399
ncxconst.h
Contains NCX constants.
agt_yp_ha_active_go
status_t agt_yp_ha_active_go(yp_ha_service_t *ha_serv)
Go into YP-HA Active server mode.
Definition: agt_yp_ha_active.c:1906
agt_not.h
NETCONF Notifications DM module support.
cfg_get_root
val_value_t * cfg_get_root(ncx_cfg_t cfgid)
Get the config root for the specified config.
Definition: cfg.c:3240
AGT_HA_ROLE_ACTIVE
@ AGT_HA_ROLE_ACTIVE
HA active role.
Definition: agt.h:687
val_find_next_child
val_value_t * val_find_next_child(const val_value_t *parent, const xmlChar *modname, const xmlChar *childname, const val_value_t *curchild)
Find the next instance of the specified child node.
Definition: val.c:8748
log_info
void void void void void log_info(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_INFO log entry.
val_remove_child
void val_remove_child(val_value_t *child)
Remove a child value node from its parent value node.
Definition: val.c:8316
ERR_NCX_MISSING_PARM
@ ERR_NCX_MISSING_PARM
233
Definition: status_enum.h:272
agt_ycontrol_send_ok
status_t agt_ycontrol_send_ok(ses_cb_t *scb, const xmlChar *service_id, uint32 msgid)
Send a ycontrol OK message.
Definition: agt_ycontrol.c:1518
log_debug2
void void void void void void void void void log_debug2(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_DEBUG2 log entry.
agt_ycontrol_get_scb
ses_cb_t * agt_ycontrol_get_scb(const xmlChar *subsys_id)
Get the session control block for the specified subsys ID.
Definition: agt_ycontrol.c:1944
NO_ERR
@ NO_ERR
000
Definition: status_enum.h:188
cfg_get_last_ch_time
const xmlChar * cfg_get_last_ch_time(cfg_template_t *cfg)
Get the last-modified timestamp.
Definition: cfg.c:2896
agt_get_server_key
const xmlChar * agt_get_server_key(void)
Get the ha-server-key string.
Definition: agt.c:4717
agt_ycontrol_register_service_ex
status_t agt_ycontrol_register_service_ex(const xmlChar *service_name, agt_ycontrol_service_fn_t service_fn, agt_ycontrol_subsys_gone_fn_t subsys_gone_fn)
Register a YControl service layer (extended)
Definition: agt_ycontrol.c:1746
val_add_child
void val_add_child(val_value_t *child, val_value_t *parent)
Add a child (deprecated: use val_child_add instead)
Definition: val.c:8231
agt_make_yang_patch_cb
yang_patch_cb_t * agt_make_yang_patch_cb(const xmlChar *patch_id, const xmlChar *the_comment, const xmlChar *patch_root, agt_cfg_transaction_t *txcb, uint32 included_changes)
Make a yang_patch_cb for a YANG Patch conventional datastore on-change update.
Definition: agt_util.c:7046
val_dump_value
void val_dump_value(val_value_t *val, int32 startindent, log_debug_t lvl)
Printf the specified val_value_t struct to the logfile, or stdout if none set Uses conf file format (...
Definition: val.c:5688
log_debug4
void void void void void void void void void void void void void log_debug4(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_DEBUG4 log entry.
ERR_NCX_OPERATION_FAILED
@ ERR_NCX_OPERATION_FAILED
274
Definition: status_enum.h:315
agt_ycontrol_send_error
status_t agt_ycontrol_send_error(ses_cb_t *scb, const xmlChar *service_id, uint32 msgid, status_t res, const xmlChar *errstr)
Send a ycontrol error message.
Definition: agt_ycontrol.c:1455
LOGDEBUG2
#define LOGDEBUG2
Check if at least log-level=debug2.
Definition: log.h:292
agt_make_empty_leaf
val_value_t * agt_make_empty_leaf(obj_template_t *parentobj, const xmlChar *modname, const xmlChar *leafname, boolean boolval, status_t *res)
make a val_value_t struct for a specified leaf or leaf-list (NCX_BT_EMPTY)
Definition: agt_util.c:5932
log_warn
void void void log_warn(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_WARN log entry.
ERR_INTERNAL_VAL
@ ERR_INTERNAL_VAL
004
Definition: status_enum.h:194
agt_not_go_standby
void agt_not_go_standby(void)
Exit active notification subscription mode and disable notifications.
Definition: agt_not.c:6525
val_util.h
Value Node Utilities.
ERR_NCX_INVALID_VALUE
@ ERR_NCX_INVALID_VALUE
258
Definition: status_enum.h:299
agt_make_leaf2
val_value_t * agt_make_leaf2(obj_template_t *parentobj, const xmlChar *modname, const xmlChar *leafname, const xmlChar *leafstrval, status_t *res)
make a val_value_t struct for a specified leaf or leaf-list
Definition: agt_util.c:5545
NCX_CFGID_STARTUP
@ NCX_CFGID_STARTUP
startup datastore
Definition: ncxtypes.h:386
agt_cfg_txid_in_progress
ncx_transaction_id_t agt_cfg_txid_in_progress(ncx_cfg_t cfgid)
Return the ID of the current transaction ID in progress.
Definition: agt_cfg.c:1479
ERR_INTERNAL_MEM
@ ERR_INTERNAL_MEM
003
Definition: status_enum.h:193
get_error_string
const char * get_error_string(status_t res)
Get the error message for a specific internal error.
Definition: status.c:239
agt_check_load_config
status_t agt_check_load_config(agt_ha_role_t ha_role)
Check if the boot-time load-config should be done because it was deferred while waiting for the YP-HA...
Definition: agt.c:4897
agt_yp_ha_get_service_cb
yp_ha_service_t * agt_yp_ha_get_service_cb(void)
Get the YP-HA service control block for this server.
Definition: agt_yp_ha.c:1006
tstamp_time2datetime
void tstamp_time2datetime(time_t *timerec, xmlChar *buff)
Convert the specified time_t to a YANG data-and-time format.
Definition: tstamp.c:457
log_debug
void void void void void void void log_debug(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_DEBUG log entry.
typ.h
Parameter Type Handler.
NCX_CFGID_RUNNING
@ NCX_CFGID_RUNNING
running datastore (no value for not set!)
Definition: ncxtypes.h:384
yangconst.h
Contains YANG constants separated to prevent H file include loops.
yang_patch.h
YANG Patch Media Type.
dlq_nextEntry
#define dlq_nextEntry(nodeP)
get the next queue entry after the current entry
Definition: dlq.h:265
agt.h
Multi-Protocol Network Management Server.
agt_ses_go_standby
void agt_ses_go_standby(void)
Deactivate MGMT sessions because YP-HA mode is standby.
Definition: agt_ses.c:2317
VAL_UINT64
#define VAL_UINT64(V)
Access the value as an uint64 ONLY if NCX_BT_UINT64.
Definition: val.h:503
HA_STATE_WAIT_ROLE
@ HA_STATE_WAIT_ROLE
waiting for HA role
Definition: agt_yp_ha.h:117
agt_yp_ha_active_nvstore
status_t agt_yp_ha_active_nvstore(yp_ha_service_t *ha_serv)
Do an <nvstore> command to the standby servers.
Definition: agt_yp_ha_active.c:2096
ERR_NCX_NOT_FOUND
@ ERR_NCX_NOT_FOUND
225
Definition: status_enum.h:264
yang_patch_to_value
val_value_t * yang_patch_to_value(obj_template_t *patch_obj, yang_patch_cb_t *pcb, status_t *res)
Convert a YANG Patch control block to a val_value_t tree.
Definition: yang_patch.c:846
cfg_get_last_txid
ncx_transaction_id_t cfg_get_last_txid(cfg_template_t *cfg)
Get the last good transaction ID.
Definition: cfg.c:2914
ERR_NCX_OPERATION_NOT_SUPPORTED
@ ERR_NCX_OPERATION_NOT_SUPPORTED
273
Definition: status_enum.h:314
NCX_MAX_NUMLEN
#define NCX_MAX_NUMLEN
max number len to use for static buffer allocation only
Definition: ncxconst.h:136
obj_get_mod_name
const xmlChar * obj_get_mod_name(const obj_template_t *obj)
Get the module name for this object.
Definition: obj.c:12176
agt_yp_ha_active_cleanup_server
void agt_yp_ha_active_cleanup_server(yp_ha_service_t *ha_serv, yp_ha_server_t *ha_server)
Cleanup the YP-HA Active Server subsystem record.
Definition: agt_yp_ha_active.c:2048
obj_find_child
obj_template_t * obj_find_child(obj_template_t *obj, const xmlChar *modname, const xmlChar *objname)
Find a child object with the specified Qname.
Definition: obj.c:6116
agt_ycontrol_remove_subsys
void agt_ycontrol_remove_subsys(ses_id_t sid, const xmlChar *subsys_id)
Remove a subsystem connection to the ycontrol manager because the connection was closed or shutting d...
Definition: agt_ycontrol.c:1871
YCONTROL_MSG_SERVER_EVENT
@ YCONTROL_MSG_SERVER_EVENT
server-event sent from server to subsystem
Definition: ycontrol_types.h:69
xml_strcmp
int xml_strcmp(const xmlChar *s1, const xmlChar *s2)
String compare for xmlChar.
Definition: xml_util.c:1746
ycontrol_msg_cmn.h
YControl Message Utilities.
LOGDEBUG4
#define LOGDEBUG4
Check if at least log-level=debug4.
Definition: log.h:302
log.h
NCX System Logging Manager.
agt_push.h
Server PUSH support.
LOGDEBUG
#define LOGDEBUG
Check if at least log-level=debug.
Definition: log.h:287
agt_yp_ha_active_setup
status_t agt_yp_ha_active_setup(yp_ha_service_t *ha_serv)
One time pre-init YP-HA Active mode.
Definition: agt_yp_ha_active.c:1880
rpc_err.h
NETCONF protocol standard error definitions.
YCONTROL_MSG_SUBSYS_EVENT
@ YCONTROL_MSG_SUBSYS_EVENT
subsystem-event sent from subsystem to server
Definition: ycontrol_types.h:78
val_clone_config_save
val_value_t * val_clone_config_save(const val_value_t *val, status_t *res)
Clone a specified val_value_t struct and sub-trees filter for config only for saving to NVRAM.
Definition: val.c:7941
agt_cfg.h
Manage Server configuration edit transactions.
agt_make_uint64_leaf2
val_value_t * agt_make_uint64_leaf2(obj_template_t *parentobj, const xmlChar *modname, const xmlChar *leafname, uint64 leafval, status_t *res)
make a val_value_t struct for a specified leaf or leaf-list
Definition: agt_util.c:5715
val_get_first_child
val_value_t * val_get_first_child(const val_value_t *parent)
Get the first child node.
Definition: val.c:8477
agt_yp_ha_active_stop
void agt_yp_ha_active_stop(yp_ha_service_t *ha_serv)
Exit from YP-HA Active server mode.
Definition: agt_yp_ha_active.c:1981
agt_yp_ha_active_cleanup
void agt_yp_ha_active_cleanup(yp_ha_service_t *ha_serv)
Cleanup the YP-HA Active module.
Definition: agt_yp_ha_active.c:2032
xml_strcpy
uint32 xml_strcpy(xmlChar *copyTo, const xmlChar *copyFrom)
String copy for xmlChar.
Definition: xml_util.c:1486
agt_yp_ha_active_mod_event
void agt_yp_ha_active_mod_event(yp_ha_service_t *ha_serv, const xmlChar *name, const xmlChar *revision, val_value_t *inputval, boolean is_module, boolean is_load)
Generate a module event.
Definition: agt_yp_ha_active.c:2118
agt_yp_ha_active.h
YumaPro High Availability module (YP-HA). HA Active Mode.
dlq_firstEntry
#define dlq_firstEntry(listP)
get the first entry in the queue list
Definition: dlq.h:337
val_new_value
val_value_t * val_new_value(void)
Malloc and initialize the fields in a val_value_t.
Definition: val.c:2697
ERR_NCX_ACCESS_DENIED
@ ERR_NCX_ACCESS_DENIED
267
Definition: status_enum.h:308
VAL_OBJ
#define VAL_OBJ(V)
Access the object template.
Definition: val.h:381
ncx.h
YANG module utility functions.
agt_ycontrol_send_payload
status_t agt_ycontrol_send_payload(ses_cb_t *scb, const xmlChar *service_id, uint32 *msgid, ycontrol_msgtype_t msgtype, val_value_t *service_payload, boolean with_ywattrs)
Send the subsystem <ycontrol> message to the sevice manager on the specified session,...
Definition: agt_ycontrol.c:1312
agt_yp_ha_active_config_update
status_t agt_yp_ha_active_config_update(yp_ha_service_t *ha_serv, rpc_msg_t *msg, agt_cfg_transaction_t *txcb)
Do a config update in the active role.
Definition: agt_yp_ha_active.c:2073
agt_yp_ha.h
YumaPro High Availability module (YP-HA)
obj.h
Data Object Support.
cfg_get_config_id
cfg_template_t * cfg_get_config_id(ncx_cfg_t cfgid)
Get the config struct from its ID.
Definition: cfg.c:1530
TSTAMP_MIN_SIZE
#define TSTAMP_MIN_SIZE
normal minimum buffer size for a tstamp buffer
Definition: tstamp.h:67
SES_MY_SID
#define SES_MY_SID(S)
get session-id
Definition: ses.h:105
agt_ycontrol.h
Handle the YumaPro Control Protocol <ycontrol> (top-level) element.
val_init_from_template
void val_init_from_template(val_value_t *val, struct obj_template_t_ *obj)
Initialize a value node from its object template.
YCONTROL_MSG_SUBSYS_RESPONSE
@ YCONTROL_MSG_SUBSYS_RESPONSE
subsystem-response sent from subsystem to server
Definition: ycontrol_types.h:84
AGT_PUSH_DEF_INCLUDED_CHANGES
#define AGT_PUSH_DEF_INCLUDED_CHANGES
the excluded-changeds leaf-list set is stored as an inverted uint8 bitset
Definition: agt_push.h:117
YCONTROL_MSGBODY_PAYLOAD
@ YCONTROL_MSGBODY_PAYLOAD
payload message
Definition: ycontrol_types.h:93
VAL_STR
#define VAL_STR(V)
Access the value as a string ONLY if typ_is_string() is true.
Definition: val.h:464
agt_timer.h
Handle timer services for the server.
SET_ERROR
#define SET_ERROR(E)
macro SET_ERROR
Definition: status_enum.h:103
agt_callhome_init2
status_t agt_callhome_init2(void)
Initialize the Callhome module (Init phase II)
Definition: agt_callhome.c:605
val_free_value
void val_free_value(val_value_t *val)
Scrub the memory in a val_value_t by freeing all the sub-fields and then freeing the entire struct it...
Definition: val.c:2842
status.h
Global error messages for status code enumerations.
dlq.h
dlq provides general double-linked list and queue support:
HA_STATE_ACTIVE
@ HA_STATE_ACTIVE
active server role
Definition: agt_yp_ha.h:123
agt_callhome.h
IETF CallHome reverse connection support.
LOGDEBUG3
#define LOGDEBUG3
Check if at least log-level=debug3.
Definition: log.h:297
agt_yp_ha_active_get_config_info
status_t agt_yp_ha_active_get_config_info(yp_ha_service_t *ha_serv, ncx_transaction_id_t *config_id, const xmlChar **config_stamp)
Get the config ID and timestamp info.
Definition: agt_yp_ha_active.c:2164
ncx_transaction_id_t
uint64 ncx_transaction_id_t
transaction is scoped to single session write operation on a config
Definition: ncxtypes.h:548