Module _ncs.ha
Low level module for connecting to NCS HA subsystem.
This module is used to connect to the NCS High Availability (HA) subsystem. NCS can replicate the configuration data on several nodes in a cluster. The purpose of this API is to manage the HA functionality. The details on usage of the HA API are described in the chapter High availability in the User Guide.
This documentation should be read together with the confd_lib_ha(3) man page.
Functions
def bemaster(sock, mynodeid)
-
Instruct a HA node to be master and also give the node a name.
Keyword arguments:
- sock – a previously connected HA socket
- mynodeid – name of the node (Value or string)
def benone(sock)
-
Instruct a node to resume the initial state, i.e. neither master nor slave.
Keyword arguments:
- sock – a previously connected HA socket
def berelay(sock)
-
Instruct an established HA slave node to be a relay for other slaves.
Keyword arguments:
- sock – a previously connected HA socket
def beslave(sock, mynodeid, masterid, masterip, waitreply)
-
Instruct a NCS HA node to be slave with a named master. If waitreply is True the function is synchronous and it will hang until the node has initialized its CDB database. This may mean that the CDB database is copied in its entirety from the master. If False, we do not wait for the reply, but it is possible to use a notifications socket and get notified asynchronously via a HA_INFO_BESLAVE_RESULT notification. In both cases, it is also possible to use a notifications socket and get notified asynchronously when CDB at the slave is initialized.
Keyword arguments:
- sock – a previously connected HA socket
- mynodeid – name of this slave node (Value or string)
- masterid – name of the master node (Value or string)
- masterip – ip address of the master node
- waitreply – synchronous or not (bool)
def connect(sock, token, ip, port, pstr)
-
Connect a HA socket which can be used to control a NCS HA node. The token is a secret string that must be shared by all participants in the cluster. There can only be one HA socket towards NCS. A new call to ha_connect() makes NCS close the previous connection and reset the token to the new value.
Keyword arguments:
- sock – a Python socket instance
- token – secret string
- ip – the ip address if socket is AF_INET or AF_INET6 (optional)
- port – the port if socket is AF_INET or AF_INET6 (optional)
- pstr – a filename if socket is AF_UNIX (optional).
def slave_dead(sock, nodeid)
-
This function must be used by the application to inform NCS HA subsystem that another node which is possibly connected to NCS is dead.
Keyword arguments:
- sock – a previously connected HA socket
- nodeid – name of the node (Value or string)
def status(sock)
-
Query a ConfD HA node for its status.
Returns a 2-tuple of the HA status of the node in the format (State,[list_of_nodes]) where 'list_of_nodes' is the master/slave(s) connected with node.
Keyword arguments:
- sock – a previously connected HA socket