SAPHanaSR.py(7)

NAME
SAPHanaSR.py - Provider for SAP HANA srHook method srConnectionChanged().

DESCRIPTION
SAPHanaSR.py can be used to provide a script for the SAP HANA srHook method srConnectionChanged(). The SAP HANA nameserver provides a Python-based API ("HA/DR providers"), which is called at important points of the host auto-failover and system replication takeover process. These so called hooks can be used for arbitrary operations that need to be executed. The method srConnectionChanged() is called on the master nameserver as soon as one of the replicating services loses or establishes the system replication connection. This method is called only once.

SUPPORTED PARAMETERS
The "HA/DR providers" API accepts the following parameters for the ha_dr_provider_SAPHanaSR section:

provider = SAPHanaSR

path = /usr/share/SAPHanaSR-ScaleOut

execution_order = [ INTEGER ]

The "HA/DR providers" API accepts the following parameter for the trace section:

ha_dr_saphanasr = [ info | debug ]

The SAPHanaController and SAPHana RA recognize the effecting system replication status via attributes in the CIB properties section. The SAP System Indentifier (sid) is given in lower case. See REQUIREMENTS section below for supported API versions and scenarios. For old SAPHanaSR-ScaleOut the SAPHanaSR.py provides one global attribute among the SAPHanaSR properties:

hana_<sid>_glob_srHook = [ SOK | SFAIL | SWAIT ]

Note: SAPHanaSR Scale-Up comes with a differnt SAPHanaSR.py that provides site-specific attributes. For SAPHanaSR-ScaleOut site-specific attributes see SAPHanaSrMultiTarget.py(7).

RETURN CODES
0 Successful program execution.
>0 Usage, syntax or execution errors.

EXAMPLES

* Simple example for permission in /etc/sudoers. HANA 1.0 Scale-Out, SID is SLE.

    # SAPHanaSR-ScaleOut old-style needs for the srHook script.
    sleadm ALL=(ALL) NOPASSWD: /usr/sbin/crm_attribute -n hana_sle_glob_srHook -v *

* Example for looking up the sudo permission for the srHook script.
All related files (/etc/sudoers and /etc/sudoers.d/*) are scanned. Example SID is HA1.

    # sudo -U ha1adm -l | grep "NOPASSWD.*crm_attribute.*hana_"

* Example for entry in SAP HANA global configuration /hana/shared/$SID/global/hdb/custom/config/global.ini
This file is needed at both sites. The HANA has to be stopped before the files can be edited.

    [ha_dr_provider_SAPHanaSR]
    provider = SAPHanaSR
    path = /usr/share/SAPHanaSR-ScaleOut/
    execution_order = 1
    [trace]
    ha_dr_saphanasr = info

* Example for creating the optional SAPHanaSR python object file manually. SID is SLE.

    # mkdir -p /hana/shared/srhook
    # chown sleadm.sapsys /hana/shared/srhook
    # su - sleadm
    # cd /hana/shared/srhook
    # python -m py_compile /usr/share/SAPHanaSR-ScaleOut/SAPHanaSR.py
    # ls -l SAPHanaSR.pyc

* Example for checking the system log for srHook setting HANA system replication status in the CIB properties section.

    # grep "sudo.*crm_attribute.*srHook" /var/log/messages

* Example for checking the HANA tracefiles for srConnectionChanged() events.

    # su - sleadm
    ~> cdtrace
    ~> grep SAPHanaSR.srConnectionChanged.*called nameserver_*.trc
    ~> grep crm_attribute.*SAPHanaSR nameserver_*.trc
    # exit

FILES

/usr/share/SAPHanaSR-ScaleOut/SAPHanaSR.py
     the hook provider, delivered with the RPM

/hana/shared/srhook/SAPHanaSR.pyc
     the hook provider, if pre-compiled for the particular HANA (optional)

/hana/shared/$SID/global/hdb/custom/config/global.ini
     the on-disk representation of HANA global system configuration

/etc/sudoers , /etc/sudoers.d/
     the sudo permissions configuration

/usr/sap/$SID/HDB$nr/$host/trace/
     the directory with HANA trace files

REQUIREMENTS
1. SAP HANA starting with version 1.0 SPS11 patch level 112.02. Older versions do not provide the srHook method srConnectionChanged(). With the mentioned HANA versions uni-directional chained system replication is possible. See SAPHanaSR-ScaleOut(7) for supported API versions and scenarios.

2. The user <sid>adm needs execution permission as user root for the command crm_attribute.

3. The hook provider needs to be added to the HANA global configuration, in memory and on disk (in persistence).

4. If the hook provider should be pre-compiled, the particular Python version that comes with SAP HANA has to be used.

5. The Linux cluster needs to be up and running to allow HA/DR provider events being written into CIB attributes. The current HANA SR status might differ from CIB srHook attribute after cluster maintenance.

BUGS
Global and site-specific properties for HANA SR status can not be used at same time.
In case of any problem, please use your favourite SAP support process to open a request for the component BC-OP-LNX-SUSE. Please report any other feedback and suggestions to feedback@suse.com.

SEE ALSO
SAPHanaSR-ScaleOut(7) , SAPHanaSrMultiTarget.py(7) , ocf_suse_SAPHanaTopology(7) , ocf_suse_SAPHanaController(7) , SAPHanaSR-monitor(8) , SAPHanaSR-manageAttr(8) , SAPHanaSR-showAttr(8) , crm_attribute(8) , sudo(8) , sudoers(5) , python(8) ,
https://documentation.suse.com/sbp/all/?context=sles-sap ,
https://documentation.suse.com/sles-sap/ ,
https://www.susecon.com/doc/2015/sessions/TUT19921.pdf ,
https://www.susecon.com/doc/2016/sessions/TUT90846.pdf ,
https://www.susecon.com/archive-2020.html
http://help.sap.com/saphelp_hanaplatform/helpdata/en/13/67c8fdefaa4808a7485b09815ae0f3/content.htm ,
http://help.sap.com/saphelp_hanaplatform/helpdata/en/5d/f2e766549a405e95de4c5d7f2efc2d/content.htm ,
http://help.sap.com/saphelp_hanaplatform/helpdata/en/12/00ab8ef0c54c54be2d0e7f5327f7ed/content.htm?frameset=/en/13/67c8fdefaa4808a7485b09815ae0f3/frameset.htm&current_toc=/en/00/0ca1e3486640ef8b884cdf1a050fbb/plain.htm&node_id=413 ,
https://help.sap.com/saphelp_hanaplatform/helpdata/en/3f/1a6a7dc31049409e1a9f9108d73d51/content.htm

AUTHORS
F.Herschel, L.Pinne.

COPYRIGHT
(c) 2015-2016 SUSE Linux GmbH, Germany.
(c) 2017-2021 SUSE LLC
SAPHanaSR.py comes with ABSOLUTELY NO WARRANTY.
For details see the GNU General Public License at http://www.gnu.org/licenses/gpl.html