HAE
index
/usr/lib/sca/python/HAE.py

Supportconfig Analysis Library for HAE python patterns
 
Library of functions for creating python patterns specific to 
High Availability Extension (HAE) clustering

 
Modules
       
Core
re

 
Functions
       
getClusterConfig()
Gets cluster configuration information from the cibadmin -Q output or cib.xml if the node is not connected to the cluster. It includes information from the <cib> and <cluster_property_set> tags.
 
Args:           None
Returns:        Dictionary with keys
        connected-to-cluster (Boolean) - True if the node is connected to the cluster, and False if not
        *All other key:value pairs are derived from the cluster configuration file itself
Example:
 
CLUSTER = HAE.getClusterConfig()
if 'stonith-enabled' in CLUSTER:
        if "true" in CLUSTER['stonith-enabled']:
                Core.updateStatus(Core.IGNORE, "Stonith is enabled for the cluster")
        else:
                Core.updateStatus(Core.WARN, "Stonith is disabled for the cluster")
else:
        Core.updateStatus(Core.WARN, "Stonith is disabled by default for the cluster")
getConfigCTDB()
Gets the /etc/sysconfig/ctdb configuration file information.
 
Args:           None
Returns:        Dictionary with keys
        *All key:value pairs are derived from the configuration file itself. All key names are changed to uppercase. All values are left as is.
Example:
 
CTDB = HAE.getConfigCTDB()
if 'CTDB_START_AS_DISABLED' in CTDB:
        if "yes" in CTDB['CTDB_START_AS_DISABLED']:
                Core.updateStatus(Core.IGNORE, "CTDB Starting disabled")
        else:
                Core.updateStatus(Core.WARN, "CTDB Starting enabled")
else:
        Core.updateStatus(Core.ERROR, "Missing CTDB_START_AS_DISABLED, ignoring test")
getConfigCorosync()
Gets Corosync configuration information from /etc/corosync/corosync.conf. All values are forced to lowercase.
 
Args:           None
Returns:        Dictionary with keys and lists
        *All key:value pairs are derived from the cluster configuration file itself. The totem interfaces are a list of dictionaries within the totem dictionary.
Example:
 
COROSYNC = HAE.getConfigCorosync()
BINDADDRS = {}
DUP_BINDADDRS = {}
for I in range(0, len(COROSYNC['totem']['interface'])):
        ADDR = COROSYNC['totem']['interface'][I]['bindnetaddr']
        if ADDR in BINDADDRS:
                # There is a duplicate bind net address key, add the duplicate to the list
                DUP_BINDADDRS[ADDR] = True
        else:
                # The address is not a duplicate, add it to the list of bind net addresses to check
                BINDADDRS[ADDR] = True
if( len(DUP_BINDADDRS) > 0 ):
        Core.updateStatus(Core.CRIT, "Detected Duplicate Corosync Bind Addresses: " + " ".join(DUP_BINDADDRS.keys()))
else:
        Core.updateStatus(Core.IGNORE, "All Corosync Bind Addresses are Unique")
getNodeInfo()
Gets cluster node information from the cibadmin -Q output or cib.xml if the node is not connected to the cluster. It includes information from the <node> and <node_state> tags. Only key/value pairs within the <node_state> tag itself are included, not tags below <node_state>.
 
Args:           None
Returns:        List of Node Dictionaries with keys
        *All key:value pairs are derived from the configuration file itself.
Example:
 
STANDBY_NODES = []
NODES = HAE.getNodeInfo()
for I in range(0, len(NODES)):
        # If the standby key exists in the node dictionary, proceed
        if "standby" in NODES[I]:
                if 'on' in NODES[I]['standby']:
                        STANDBY_NODES.append(NODES[I]['uname'])
if( len(STANDBY_NODES) > 0 ):
        Core.updateStatus(Core.WARN, "Node(s) in standby mode: " + " ".join(STANDBY_NODES))
else:
        Core.updateStatus(Core.IGNORE, "Node(s) in standby mode: None")
getSBDInfo()
Gets split brain detection partition information. Gathers information from the sbd dump command and the /etc/sysconfig/sbd file. SBD partitions with invalid sbd dump output are ignored.
 
Args:           None
Returns:        List of SBD Dictionaries with keys
        SBD_DEVICE (String) - The /etc/sysconfig/sbd SDB_DEVICE variable. This value applies to all and is stored with each sbd device.
        SBD_OPTS (String) - The /etc/sysconfig/sbd SBD_OPTS variable
        Version (Int) - The SDB header version string
        Slots (Int) - The number of SDB slots
        Sector_Size (Int) - The SBD sector size
        Watchdog (Int) - The SBD watchdog timeout
        Allocate (Int) - The SBD allocate timeout
        Loop (Int) - The SBD loop timeout
        MsgWait (Int) - The SBD msgwait timeout
Example:
 
SBD = HAE.getSBDInfo()
MSG_WAIT_MIN = 300
MSG_WAIT_OVERALL = MSG_WAIT_MIN
# Find the smallest msgwait value among the SBD partitions
for I in range(0, len(SBD)):
        if( SBD[I]['MsgWait'] < MSG_WAIT_OVERALL ):
                MSG_WAIT_OVERALL = SBD[I]['MsgWait']
# See if the smallest msgwait is less than the minimum required
if ( MSG_WAIT_OVERALL < MSG_WAIT_MIN ):
        Core.updateStatus(Core.REC, "Consider changing your msgwait time")
else:
        Core.updateStatus(Core.IGNORE, "The msgwait is sufficient")
haeConnected()
Determines if the node is connected to the HAE cluster.
 
Args:           None
Returns:        True if connected, False if disconnected
Example:
 
if HAE.haeConnected():
        Core.updateStatus(Core.IGNORE, "Node connected to HAE Cluster")
else:
        Core.updateStatus(Core.WARN, "Node is disconnected, start HAE cluster services")
haeEnabled()
Determines if an HAE cluster is enabled on the node based on a corosysnc.conf file.
 
Args:           None
Returns:        True if enabled, False if disabled
Example:
 
if HAE.haeEnabled():
        Core.updateStatus(Core.IGNORE, "HAE Cluster enabled")
else:
        Core.updateStatus(Core.WARN, "HAE Cluster disabled")