-
Notifications
You must be signed in to change notification settings - Fork 21
/
SAPHana
executable file
·3001 lines (2890 loc) · 119 KB
/
SAPHana
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
#
# SAPHana
#
# Description: Manages two SAP HANA Databases in System Replication
# Planned: do also manage scale-out scenarios
# currently the SAPHana is dependent of the analysis of
# SAPHanaTopology
# For supported scenarios please read the README file provided
# in the same software package (rpm)
#
##############################################################################
#
# SAPHana
# Author: Fabian Herschel, November 2013
# Support: linux@sap.com
# License: GNU General Public License (GPL)
# Copyright: (c) 2013,2014 SUSE Linux Products GmbH
# Copyright: (c) 2015-2024 SUSE LLC
#
# An example usage:
# See usage() function below for more details...
#
# OCF instance parameters:
# OCF_RESKEY_SID
# OCF_RESKEY_InstanceNumber
# OCF_RESKEY_DIR_EXECUTABLE (optional, well known directories will be searched by default)
# OCF_RESKEY_DIR_PROFILE (optional, well known directories will be searched by default)
# OCF_RESKEY_INSTANCE_PROFILE (optional, well known directories will be searched by default)
# OCF_RESKEY_PREFER_SITE_TAKEOVER (optional, default is no)
# OCF_RESKEY_DUPLICATE_PRIMARY_TIMEOUT (optional, time difference needed between two last-primary-tiemstampe (lpt))
# new instance parameter for the RA
# OCF_RESKEY_REMOVE_SAP_SOCKETS (optional, default is true)
# OCF_RESKEY_SAPHanaFilter (outdated, replaced by cluster property hana_${sid}_glob_filter)
#
# HANA must support the following commands:
# hdbnsutil -sr_stateConfiguration (unsure, if this means >= SPS110, SPS111 or SPS10x)
# hdbnsutil -sr_takeover
# hdbnsutil -sr_register
# landscapeHostConfiguration.py
# systemReplicationStatus.py (>= SPS090)
#
#######################################################################
SAPHanaVersion="0.162.3"
#
# Initialization:
: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
#
#######################################################################
#
log_attributes=false
if ocf_is_true "$log_attributes"; then
log_attr_file="/var/log/fhATTRIBUTES"
else
log_attr_file="/dev/null"
fi
HANA_STATE_PRIMARY=0
HANA_STATE_SECONDARY=1
HANA_STATE_STANDALONE=2
HANA_STATE_DEFECT=3
HANA_STD_ACTION_TIMEOUT=3600
debug_attributes=0
SH=/bin/sh
#
# function: super_ocf_log - wrapper function for ocf log in order catch usual logging into super log
# params: LOG_MESSAGE
# globals: SAPHanaFilter
function super_ocf_log() {
local level="$1"
local message="$2"
local skip=1
local mtype=""
local shf="${SAPHanaFilter:-all}"
#ocf_log "info" "super_ocf_log: f:$shf l:$level m:$message"
# message levels: (dbg)|info|warn|err|error
# message types: (ACT|RA|FLOW|DBG|LPA|DEC|DBG2...
case "$level" in
debug | dbg | warn | err | error ) skip=0
;;
info )
case "$shf" in
all) skip=0
;;
none )
skip=1
;;
* ) mtype=${message%% *}
mtype=${mtype%:}
[[ ${shf} == *${mtype}* ]] && skip=0 || skip=1
;;
esac
;;
esac
if [ $skip -eq 0 ]; then
ocf_log "$level" "$message"
fi
}
#
# function: saphana_usage - short usage info
# params: -
# globals: $0(r)
#
function saphana_usage() {
super_ocf_log info "FLOW ${FUNCNAME[0]} ($*)"
local rc=0
methods=$(saphana_methods)
methods=$(echo $methods | tr ' ' '|')
echo " usage: $0 ($methods)
$0 manages two SAP HANA databases (scale-up) in system replication.
The 'start' operation starts the HANA instance or bring the \"clone instance\" to a WAITING status
The 'stop' operation stops the HANA instance
The 'status' operation reports whether the HANA instance is running
The 'monitor' operation reports whether the HANA instance seems to be working in multi-state it also needs to check the system replication status
The 'promote' operation either runs a takeover for a secondary or a just-nothing for a primary
The 'demote' operation nearly does nothing and just mark the instance as demoted
The 'notify' operation always returns SUCCESS
The 'validate-all' operation reports whether the parameters are valid
The 'methods' operation reports on the methods $0 supports
The 'reload' operation allows to adapt resource parameters
"
return $rc
}
function backup_global_and_nameserver() {
super_ocf_log info "FLOW ${FUNCNAME[0]} ($*)"
local rc=0
cp /hana/shared/${SID}/global/hdb/custom/config/global.ini /hana/shared/${SID}/global/hdb/custom/config/global.ini.$(date +"%s")
cp /hana/shared/${SID}/global/hdb/custom/config/nameserver.ini /hana/shared/${SID}/global/hdb/custom/config/nameserver.ini.$(date +"%s")
super_ocf_log info "FLOW ${FUNCNAME[0]} rc=$rc"
return $rc
}
#
# function: saphana_meta_data - print resource agent meta-data for cluster
# params: -
# globals: -
#
function saphana_meta_data() {
super_ocf_log info "FLOW ${FUNCNAME[0]} ($*)"
local rc=0
echo '<?xml version="1.0"?>
<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
<resource-agent name="SAPHana" version="'$SAPHanaVersion'">
<version>1.0</version>
<shortdesc lang="en">Manages two SAP HANA database systems in system replication (SR).</shortdesc>
<longdesc lang="en">
The SAPHanaSR resource agent manages two SAP HANA database systems which are configured
in system replication. SAPHana supports Scale-Up scenarios.
Managing the two SAP HANA database systems means that the resource agent controls the start/stop of the
instances. In addition the resource agent is able to monitor the SAP HANA databases to check their
availability on landscape host configuration level. For this monitoring the resource agent relies on interfaces
provided by SAP. A third task of the resource agent is to also check the synchronisation status
of the two SAP HANA databases. If the synchronisation is not "SOK", then the cluster avoids to
failover to the secondary side, if the primary fails. This is to improve the data consistency.
The resource agent uses the following four interfaces provided by SAP:
1. sapcontrol/sapstartsrv
The interface sapcontrol/sapstartsrv is used to start/stop a HANA database instance/system
2. landscapeHostConfiguration
The interface is used to monitor a HANA system. The python script is named landscapeHostConfiguration.py.
landscapeHostConfiguration.py has some detailed output about HANA system status
and node roles. For our monitor the overall status is relevant. This overall
status is reported by the return code of the script:
0: Internal Fatal, 1: ERROR, 2: WARNING, 3: INFO, 4: OK
The SAPHana resource agent will interpret return codes 0 as FATAL, 1 as not-running or ERROR and and returncodes 2+3+4 as RUNNING.
3. hdbnsutil
The interface hdbnsutil is used to check the "topology" of the system replication as well as the current configuration
(primary/secondary) of a SAP HANA database instance. A second task of the interface is the possibility to run a
system replication takeover (sr_takeover) or to register a former primary to a newer one (sr_register).
4. hdbsql / systemReplicationStatus
Interface is SQL query into HANA (system replication table). The hdbsql query will be replaced by a python script
"systemReplicationStatus.py" in SAP HANA SPS8 or 9.
As long as we need to use hdbsql you need to set up secure store users for linux user root to be able to
access the SAP HANA database. You need to configure a secure store user key "SAPHANA'${SID}'SR" which can connect the SAP
HANA database:
5. saphostctrl
The interface saphostctrl uses the function ListInstances to figure out the virtual host name of the
SAP HANA instance. This is the hostname used during the HANA installation.
</longdesc>
<parameters>
<parameter name="SID" unique="0" required="1">
<longdesc lang="en">SAP System Identifier (SID) like "SLE" or "HAE"</longdesc>
<shortdesc lang="en">SAP System Identifier (SID)</shortdesc>
<content type="string" default="" />
</parameter>
<parameter name="InstanceNumber" unique="0" required="1">
<longdesc lang="en">SAP instance number like "00" or "07"</longdesc>
<shortdesc lang="en">SAP instance number</shortdesc>
<content type="string" default="" />
</parameter>
<parameter name="PREFER_SITE_TAKEOVER" unique="0" required="0">
<longdesc lang="en">Should cluster/RA prefer to switchover to secondary instance instead of restarting primary locally? Default="false"
no: Do prefer restart locally
yes: Do prefer takeover to remote site
never: Do never run a sr_takeover (promote) at the secondary side. THIS VALUE IS CURRENTLY NOT SUPPORTED.
</longdesc>
<shortdesc lang="en">Local or site recover preferred?</shortdesc>
<content type="string" default="false" />
</parameter>
<parameter name="REMOVE_SAP_SOCKETS" unique="0" required="0">
<longdesc lang="en">Should the RA remove the unix domain sockets related to sapstartsrv before (re-)starting sapstartsrv ? Default="true"
no: Do not remove the sockets, try chown/chgrp instead
yes: Do remove the sockets
</longdesc>
<shortdesc lang="en">Remove unix domain sockets related to sapstartsrv?</shortdesc>
<content type="boolean" default="true" />
</parameter>
<parameter name="AUTOMATED_REGISTER" unique="0" required="0">
<shortdesc lang="en">Define, if a former primary should automatically be registered.</shortdesc>
<longdesc lang="en">The parameter AUTOMATED_REGISTER defines, whether a former primary instance should
be registered automatically by the resource agent during cluster/resource start, if the DUPLICATE_PRIMARY_TIMEOUT is expired... TDB
</longdesc>
<content type="boolean" default="false" />
</parameter>
<parameter name="DUPLICATE_PRIMARY_TIMEOUT" unique="0" required="0">
<shortdesc lang="en">Time difference needed between to primary time stamps, if a dual-primary situation occurs</shortdesc>
<longdesc lang="en">Time difference needed between to primary time stamps,
if a dual-primary situation occurs. If the time difference is
less than the time gap, then the cluster holds one or both instances in a "WAITING" status. This is to give an admin
a chance to react on a failover. A failed former primary will be registered after the time difference is passed. After
this registration to the new primary all data will be overwritten by the system replication.
</longdesc>
<content type="string" default="7200" />
</parameter>
<parameter name="HANA_CALL_TIMEOUT" unique="0" required="0">
<shortdesc lang="en">Define timeout how long a call to HANA to receive information can take.</shortdesc>
<longdesc lang="en">Define timeout how long a call to HANA to receive information can take. This could be eg landscapeHostConfiguration.py.
There are some specific calls to HANA which have their own timeout values. For example the takeover command does not timeout (inf).
If the timeout is reached, the return code will be 124. If you increase the timeouts for HANA calls you should also adjust the operation timeouts
of your cluster resources.
</longdesc>
<content type="string" default="60" />
</parameter>
<parameter name="DIR_EXECUTABLE" unique="0" required="0">
<longdesc lang="en">The full qualified path where to find sapstartsrv and sapcontrol. Specify this parameter, if you have changed the SAP kernel directory location after the default SAP installation.</longdesc>
<shortdesc lang="en">Path of sapstartsrv and sapcontrol</shortdesc>
<content type="string" default="" />
</parameter>
<parameter name="DIR_PROFILE" unique="0" required="0">
<longdesc lang="en">The full qualified path where to find the SAP START profile. Specify this parameter, if you have changed the SAP profile directory location after the default SAP installation.</longdesc>
<shortdesc lang="en">Path of start profile</shortdesc>
<content type="string" default="" />
</parameter>
<parameter name="INSTANCE_PROFILE" unique="1" required="0">
<longdesc lang="en">The name of the SAP HANA instance profile. Specify this parameter, if you have changed the name of the SAP HANA instance profile after the default SAP installation. Normally you do not need to set this parameter.</longdesc>
<shortdesc lang="en">HANA instance profile name</shortdesc>
<content type="string" default="" />
</parameter>
<parameter name="SAPHanaFilter" unique="0" required="0">
<shortdesc lang="en">OUTDATED PARAMETER</shortdesc>
<longdesc lang="en">OUTDATED PARAMETER</longdesc>
<content type="string" default="" />
</parameter>
</parameters>
<actions>
<action name="start" timeout="3600" />
<action name="stop" timeout="3600" />
<action name="status" timeout="60" />
<action name="monitor" depth="0" timeout="700" interval="120" />
<action name="monitor" depth="0" timeout="700" interval="121" role="Slave" />
<action name="monitor" depth="0" timeout="700" interval="119" role="Master" />
<action name="promote" timeout="3600" />
<action name="demote" timeout="320" />
<action name="validate-all" timeout="5" />
<action name="meta-data" timeout="5" />
<action name="methods" timeout="5" />
<action name="reload" timeout="5" />
</actions>
</resource-agent>'
super_ocf_log info "FLOW ${FUNCNAME[0]} rc=$rc"
return $rc
}
#
# function: saphana_methods - report supported cluster methods
# params: -
# globals: -
# methods: What methods/operations do we support?
#
function saphana_methods() {
super_ocf_log info "FLOW ${FUNCNAME[0]} ($*)"
local rc=0 m
for m in start stop status monitor promote demote notify validate-all methods meta-data usage reload; do
echo "$m"
done
super_ocf_log info "FLOW ${FUNCNAME[0]} rc=$rc"
return $rc
}
#
# function: dequote - filter: remove quotes (") from stdin
# params: -
# globals: -
function dequote()
{
local rc=0; tr -d '"'; return $rc
}
# function: version: compare two HANA version strings
function ver_lt() {
ocf_version_cmp $1 $2
test $? -eq 0 && return 0 || return 1
}
function ver_le() {
ocf_version_cmp $1 $2
test $? -eq 0 -o $? -eq 1 && return 0 || return 1
}
function ver_gt() {
ocf_version_cmp $1 $2
test $? -eq 2 && return 0 || return 1
}
function ver_ge() {
ocf_version_cmp $1 $2
test $? -eq 2 -o $? -eq 1 && return 0 || return 1
}
#
# function: version: compare two HANA version strings
#
function version() {
if [ $# -eq 3 ]; then
case "$2" in
LE | le | "<=" ) ver_le $1 $3;;
LT | lt | "<" ) ver_lt $1 $3;;
GE | ge | ">=" ) ver_ge $1 $3;;
GT | gt | ">" ) ver_gt $1 $3;;
* ) return 1;
esac
elif [ $# -ge 5 ]; then
version $1 $2 $3 && shift 2 && version $*
else
return 1;
fi
}
#
# function: remoteHost2remoteNode - convert a SAP remoteHost to the cluster node name
# params: remoteHost
# globals: ATTR_NAME_HANA_VHOST[*]
#
function remoteHost2remoteNode()
{
super_ocf_log info "FLOW ${FUNCNAME[0]} ($*)"
local -a clusterNodes=()
local cl=""
local vHost=""
local remoteHost="$1"
local remoteNode=""
local rc=1
for cl in ${otherNodes[@]}; do
vHost=$(get_hana_attribute $cl "${ATTR_NAME_HANA_VHOST[@]}" "$cl")
if [ "$vHost" = "$remoteHost" ]; then # we found the correct node
remoteNode=$cl
rc=0
fi
done
if [ -n "$remoteNode" ]; then
echo "$remoteNode"
fi
super_ocf_log info "FLOW ${FUNCNAME[0]} rc=$rc"
return $rc
}
# function: get_action_timeout
# output: action timeout
#
# timeOut = max(3600, 95%(actionTimeOut))
#
function get_action_timeout() {
super_ocf_log info "FLOW ${FUNCNAME[0]} ($*)"
# $OCF_RESKEY_CRM_meta_timeout is the timeout of the current running action in ms
local actionTimeOut="$OCF_RESKEY_CRM_meta_timeout"
local stdTimeOut="$HANA_STD_ACTION_TIMEOUT"
local actTimeOutPercent=95 # 95% to left 5% for the rest of the resource agent action
if [ -z "$actionTimeOut" ]; then
actionTimeOut="$stdTimeOut"
else
# actionTimeOut in seconds
((actionTimeOut = actionTimeOut/1000))
fi
# 95%(actionTimeOut)
((timeout = actionTimeOut * actTimeOutPercent/100))
# max(3600, 95%(actionTimeOut))
if [ -z "$timeout" ] || [ "$timeout" -lt "$stdTimeOut" ]; then
timeout=$stdTimeOut
fi
super_ocf_log info "actionTimeout: action timeout was '$actionTimeOut', now changed to '$timeout'"
super_ocf_log info "FLOW $FUNCNAME"
echo $timeout
}
#
# function: is_clone - report, if resource is configured as a clone (also multi-state)
# params: -
# globals: OCF_*(r)
# descript: is_clone : find out if we are configured to run in a multi-state configuration
# rc: 0: it is a clone, 1: it is not a clone
#
# DONE: PRIO2: For the first shipment (scale-out) we need to limit the clones to 2
#
function is_clone() {
super_ocf_log info "FLOW ${FUNCNAME[0]} ($*)"
local rc=0
#
# is a clone config?
#
if [ -n "$OCF_RESKEY_CRM_meta_clone_max" ] \
&& [ "$OCF_RESKEY_CRM_meta_clone_max" -gt 0 ]; then
#
# yes it is a clone config - check, if its configured well
#
if [ "$OCF_RESKEY_CRM_meta_clone_node_max" -ne 1 ] || \
[ "$OCF_RESKEY_CRM_meta_clone_max" -ne 2 ] || \
[ "$OCF_RESKEY_CRM_meta_master_node_max" -ne 1 ] || \
[ "$OCF_RESKEY_CRM_meta_master_max" -ne 1 ]; then
super_ocf_log err "ACT: Clone options misconfigured. (expect: clone_max=2,clone_node_max=1,master_node_max=1,master_max=1)"
exit $OCF_ERR_CONFIGURED
fi
rc=0;
else
rc=1;
fi
super_ocf_log info "FLOW ${FUNCNAME[0]} rc=$rc"
return $rc
}
#
# function: get_hana_attribute
# params: NODE ATTR [STORE]
# globals: -
# output: attribute value
#
function get_hana_attribute()
{
super_ocf_log info "FLOW ${FUNCNAME[0]} ($*)"
local rc=0
local attr_node=$1
local attr_name=$2
local attr_store=${3:-reboot} # DONE: PRIO5 get this (optional) from parameter
local attr_default=${4:-}
local dstr
local attr_val=""
dstr=$(date)
case "$attr_store" in
reboot | forever )
if ocf_is_true "$log_attributes"; then
echo "$dstr: SAPHana: crm_attribute -N ${attr_node} -G -n \"$attr_name\" -l $attr_store -q" >> $log_attr_file
fi
crm_attribute -N ${attr_node} -G -n "$attr_name" -l $attr_store -q -d "$attr_default" 2>>$log_attr_file; rc=$?
;;
props )
if ocf_is_true "$log_attributes"; then
echo "$dstr: SAPHana: crm_attribute -G -n \"$attr_name\" -t crm_config -q" >> $log_attr_file
fi
crm_attribute -G -n "$attr_name" -t crm_config -q -d "$attr_default" 2>>$log_attr_file; rc=$?
;;
esac
super_ocf_log info "FLOW ${FUNCNAME[0]} rc=$rc"
return $rc
}
#
# function: set_hana_attribute - set the multi-state status of a node
# params: NODE VALUE ATTR [STORE [DEFAULT]]
# globals: -
#
function set_hana_attribute()
{
super_ocf_log info "FLOW ${FUNCNAME[0]} ($*)"
local attr_node=$1
local attr_value=$2
local attr_name=$3
local attr_store=${4:-reboot} # DONE: PRIO5 get this (optional) from parameter
local attr_default=${5:-}
local rc=1
local attr_old=""
attr_old=$(get_hana_attribute $attr_node $attr_name $attr_store $attr_default); get_rc=$?
if [ "$attr_old" != "$attr_value" ]; then
super_ocf_log debug "DBG: SET attribute $attr_name for node ${attr_node} to ${attr_value} former ($attr_old) get_rc=$get_rc "
dstr=$(date)
case "$attr_store" in
reboot | forever )
if ocf_is_true "$log_attributes"; then
echo "$dstr: SAPHana: crm_attribute -N $attr_node -v \"$attr_value\" -n \"$attr_name\" -l $attr_store" >> $log_attr_file
fi
crm_attribute -N $attr_node -v "$attr_value" -n "$attr_name" -l $attr_store 2>>$log_attr_file; rc=$?
;;
props )
if ocf_is_true "$log_attributes"; then
echo "$dstr: SAPHana: crm_attribute -v \"$attr_value\" -n \"$attr_name\" -t crm_config -s SAPHanaSR" >> $log_attr_file
fi
crm_attribute -v "$attr_value" -n "$attr_name" -t crm_config -s SAPHanaSR 2>>$log_attr_file; rc=$?
;;
esac
else
super_ocf_log debug "DBG: LET attribute $attr_name for node ${attr_node} still be ${attr_value}"
rc=0
fi
super_ocf_log info "FLOW ${FUNCNAME[0]} rc=$rc"
return $rc
}
#
# function: assert - quickly go out of here with minimal error/return code handling and log
# params: MESSAGE
# globals: OCF_*(r)
#
function assert() {
super_ocf_log info "FLOW ${FUNCNAME[0]} ($*)"
local err_msg=$1
local default_rc=$OCF_NOT_RUNNING
# DONE: Check, if we need to distinguish between probe and others
if ocf_is_probe; then
default_exit=$OCF_NOT_RUNNING
else
default_exit=$OCF_ERR_CONFIGURED
fi
if [ "$ACTION" = "stop" ]; then
cleanup_instance
exit $OCF_SUCCESS
fi
super_ocf_log err "ACT: $err_msg"
exit $OCF_NOT_RUNNING
}
#
# function: set_crm_master - set the crm master score of the local node
# params: SCORE
# globals: HA_SBIN_DIR(r), OCF_RESOURCE_INSTANCE(r)
#
function set_crm_master()
{
super_ocf_log info "FLOW ${FUNCNAME[0]} ($*)"
local rc=0
local score=0
if [ -n "$1" ]; then
score=$1
fi
# DONE: PRIO2: Only adjust master if value is really different (try to check that)
oldscore=$(${HA_SBIN_DIR}/crm_master -G -q -l reboot)
if [ "$oldscore" != "$score" ]; then
dstr=$(date)
if ocf_is_true "$log_attributes"; then
echo "$dstr: SAPHana: crm_master -v $score -l reboot " >> $log_attr_file
fi
super_ocf_log debug "DBG: SET crm master: $score (old: $oldscore)"
${HA_SBIN_DIR}/crm_master -v $score -l reboot; rc=$?
else
super_ocf_log debug "DBG: LET crm master: $score"
rc=0
fi
super_ocf_log info "FLOW ${FUNCNAME[0]} rc=$rc"
return $rc
}
#
# function: scoring_crm_master - score instance due to role and sync match (table SCORING_TABLE)
# params: NODE_ROLES NODE_SYNC_STATUS
# globals: SCORING_TABLE[@],
#
scoring_crm_master()
{
super_ocf_log info "FLOW ${FUNCNAME[0]} ($*)"
local roles="$1"
local sync="$2"
local myScore=''
for scan in "${SCORING_TABLE[@]}"; do
# $scan needs "" to prevent globbing, as the scoring tables include '.*'
read rolePatt syncPatt score < <(echo "$scan")
if [[ "$roles" =~ $rolePatt ]] ; then
# $syncPatt must NOT have "" for correct matching
if [[ "$sync" =~ $syncPatt ]] ; then
super_ocf_log info "DEC: scoring_crm_master: roles($roles) are matching pattern ($rolePatt)"
super_ocf_log info "DEC: scoring_crm_master: sync($sync) is matching syncPattern ($syncPatt)"
super_ocf_log info "DEC: scoring_crm_master: set score $score"
myScore=$score
break
fi
fi
done
super_ocf_log debug "DBG: scoring_crm_master adjust score $myScore"
# DONE: PRIO1: DO Not Score, If we did not found our role/sync at this moment - bsc#919925
if [ -n "$myScore" ]; then
set_crm_master $myScore
fi
}
#
# function: get_crm_master - get the crm master score of the local node
# params: -
# globals: HA_SBIN_DIR(r)
#
function get_crm_master()
{
super_ocf_log info "FLOW ${FUNCNAME[0]} ($*)"
local rc=0
${HA_SBIN_DIR}/crm_master -G -q -l reboot; rc=$?
super_ocf_log info "FLOW ${FUNCNAME[0]} rc=$rc"
return $rc
}
#
# function: HANA_CALL
# params: timeout-in-seconds cmd-line
# globals: sid(r), SID(r), InstanceName(r)
#
function HANA_CALL()
{
#
# TODO: PRIO 5: remove 'su - ${sidadm} later, when SAP HANA resoled issue with
# root-user-called hdbnsutil -sr_state (which creates root-owned shared memory file in /var/lib/hdb/SID/shmgrp)
# would hdbnsutil -sr_stateConfiguration also create such a shared memory file?
# TODO: PRIO 5: Maybe make "su" optional by a parameter
local timeOut=0
local onTimeOut=""
local rc=0
local use_su=1 # Default to be changed later (see TODO above)
local pre_cmd=""
local cmd=""
local pre_script=''
local output=""
while [ $# -gt 0 ]; do
case "$1" in
--timeout ) timeOut=$2; shift;;
--use-su ) use_su=1;;
--on-timeout ) onTimeOut="$2"; shift;;
--cmd ) shift; cmd="$*"; break;;
esac
shift
done
if [ $use_su -eq 1 ]; then
pre_cmd="su - ${sid}adm -c"
[[ $cmd == python* ]] && pre_script=": [$$]; cd $DIR_EXECUTABLE/python_support" || pre_script=": [$$]"
else
# as root user we need the library path to the SAP kernel to be able to call sapcontrol
# check, if we already added DIR_EXECUTABLE at the beginning of LD_LIBRARY_PATH
if [ "${LD_LIBRARY_PATH%%*:}" != "$DIR_EXECUTABLE" ]
then
MY_LD_LIBRARY_PATH=$DIR_EXECUTABLE${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH
fi
pre_cmd="bash -c"
pre_script="LD_LIBRARY_PATH=$MY_LD_LIBRARY_PATH; export LD_LIBRARY_PATH"
fi
case $timeOut in
0 | inf )
output=$($pre_cmd "$pre_script; $cmd"); rc=$?
;;
* )
errExt=$(date '+%s%N')_${sid}adm
su_err_log=${SAPHanaSR_RUN}/HANA_CALL_SU_RA_${errExt}
cmd_out_log=${SAPHanaSR_RUN}/HANA_CALL_CMD_RA_OUT_${errExt}
cmd_err_log=${SAPHanaSR_RUN}/HANA_CALL_CMD_RA_${errExt}
output=$(timeout --foreground -s 9 "$timeOut" $pre_cmd "($pre_script; timeout -s 9 $timeOut $cmd > $cmd_out_log) >& $cmd_err_log" 2>"$su_err_log"); rc=$?
output=$(if [ -f "$cmd_out_log" ]; then cat "$cmd_out_log"; rm -f "$cmd_out_log"; fi)
suErr=$(if [ -f "$su_err_log" ]; then cat "$su_err_log"; rm -f "$su_err_log"; else echo "NA"; fi)
cmdErr=$(if [ -f "$cmd_err_log" ]; then cat "$cmd_err_log"; rm -f "$cmd_err_log"; else echo "NA"; fi)
super_ocf_log debug "DBG: RA ==== action HANA_CALL (cmd is '$cmd', rc is '$rc', stderr from su is '$suErr', stderr from cmd is '$cmdErr') ===="
# on rc=1 - retry to improve the behavior in AD environments
if [ $rc -eq 1 ]; then
super_ocf_log warn "RA: HANA_CALL stderr from command '$pre_cmd' is '$suErr', stderr from command '$cmd' is '$cmdErr'"
if [ "$cmdErr" == "NA" ]; then
# seems something was going wrong with the 'pre_cmd' (su)
super_ocf_log warn "DEC: HANA_CALL returned '1' for command '$pre_cmd'. Retry once."
output=$(timeout --foreground -s 9 "$timeOut" $pre_cmd "$pre_script; timeout -s 9 $timeOut $cmd"); rc=$?
fi
fi
#
# on timeout ...
#
if [ $rc -eq 124 ]; then
super_ocf_log warn "RA: HANA_CALL timed out after $timeOut seconds running command '$cmd'"
fi
if [ $rc -eq 124 -a -n "$onTimeOut" ]; then
local second_output=""
second_output=$($pre_cmd "$pre_script; $onTimeOut");
fi
;;
esac
super_ocf_log debug "DBG: HANA_CALL '$cmd' rc=$rc output=$output"
echo "$output"
return $rc;
}
#
# function get_SRHOOK_plain
# fetches site specific Hook SR status ONLY
# globals: ATTR_NAME_HANA_SRHOOK[@](r)
# locals: ATTR[@], my_sync, get_sr_name
#
function get_SRHOOK_plain()
{
local -a ATTR my_sync
local get_sr_name="$1"
ATTR=("${ATTR_NAME_HANA_SRHOOK[@]}"); ATTR[0]="${ATTR[0]}_$get_sr_name"
my_sync=$(get_hana_attribute "X" "${ATTR[@]}")
super_ocf_log info "DEC: ${ATTR[0]}=$my_sync"
echo "$my_sync"
return 0
}
#
# function get_SRHOOK
# fetches site specific Hook SR status or (as fallback) the polling-attribute
# params: site-name site-host
# globals: ATTR_NAME_HANA_SRHOOK[@](r), ATTR_NAME_HANA_SYNC_STATUS[@](r)
# locals: ATTR[@], my_sync, get_sr_name, get_sr_host
#
function get_SRHOOK()
{
local -a ATTR my_sync
local get_sr_name="$1"
local get_sr_host="$2"
ATTR=("${ATTR_NAME_HANA_SRHOOK[@]}"); ATTR[0]="${ATTR[0]}_$get_sr_name"
my_sync=$(get_hana_attribute "X" "${ATTR[@]}")
super_ocf_log info "DEC: ${ATTR[0]}=$my_sync"
if [ -z "$my_sync" -o "$my_sync" = "SWAIT" ]; then
my_sync=$(get_hana_attribute "$get_sr_host" "${ATTR_NAME_HANA_SYNC_STATUS[@]}")
super_ocf_log info "DEC: ${ATTR[0]} is empty or SWAIT. Take polling attribute: ${ATTR_NAME_HANA_SYNC_STATUS[0]}=$my_sync"
fi
if [ -z "$my_sync" ]; then # be pesimistic, if we could not determine the SR attribute
my_sync="SFAIL"
fi
super_ocf_log info "DEC: Finally get_SRHOOK()=$my_sync"
echo "$my_sync"
return 0
}
#
# function set_SRHOOK - sets the site specific Hook SR status
# params: site-name, value
# globals: ATTR_NAME_HANA_SRHOOK[@](r), ATTR_NAME_HANA_SYNC_STATUS[@](r)
# locals: ATTR[@], my_sync, get_sr_name
# SAPHanaSR Scale-Up already uses multi-target aware SR Hook attribute there is not global fallback attribute
#
function set_SRHOOK()
{
local -a ATTR my_sync old_sync
local get_sr_name="$1"
local value="$2"
ATTR=("${ATTR_NAME_HANA_SRHOOK[@]}"); ATTR[0]="${ATTR[0]}_$get_sr_name"
set_hana_attribute "X" "$value" "${ATTR[@]}"
return 0
}
#
# function set_SRHOOK_PRIM - sets the site specific Hook SR status
# params: site-name, value
# globals: ATTR_NAME_HANA_SRHOOK[@](r), ATTR_NAME_HANA_SYNC_STATUS[@](r)
# locals: ATTR[@], my_sync, get_sr_name
# SAPHanaSR Scale-Up already uses multi-target aware SR Hook attribute there is not global fallback attribute
#
function set_SRHOOK_PRIM()
{
local lastSrHook
local lastRemSrHook
# to be backward compatible only set the site attribute, if the local or remote site attribute is already used (set) in the past
lastSrHook=$(get_SRHOOK_plain "$sr_name")
lastRemSrHook=$(get_SRHOOK_plain "$remSR_name")
if [ -n "${lastSrHook}${lastRemSrHook}" ]; then
# reset srHook attribute to PRIM as we found either local or remore srHook attribute
set_SRHOOK "$sr_name" "PRIM"
fi
}
#
# function: saphana_init - initialize variables for the resource agent
# params: InstanceName
# globals: OCF_*(r), SID(w), sid(rw), sidadm(w), InstanceName(w), InstanceNr(w), SAPVIRHOST(w), PreferSiteTakeover(w),
# globals: sr_name(w), remoteHost(w), otherNodes(w), remSR_name(w)
# globals: ATTR_NAME_HANA_SYNC_STATUS(w), ATTR_NAME_HANA_CLONE_STATE(w)
# globals: DIR_EXECUTABLE(w), SAPSTARTSRV(w), SAPCONTROL(w), DIR_PROFILE(w), SAPSTARTPROFILE(w), LD_LIBRARY_PATH(w), PATH(w)
# globals: LPA_DIRECTORY(w), SIDInstanceName(w), remoteNode(w), hdbSrQueryTimeout(w)
# globals: NODENAME(w), vNAME(w), hdbver(w),
# saphana_init : Define global variables with default values, if optional parameters are not set
#
function saphana_init() {
super_ocf_log info "FLOW ${FUNCNAME[0]} ($*)"
local rc=$OCF_SUCCESS
local clN
SYSTEMCTL="/usr/bin/systemctl"
# local site
# two parameter models (for transition only)
# OLD: InstanceName
# NEW: SID InstanceNumber
NODENAME=$(crm_node -n)
SID=$OCF_RESKEY_SID
InstanceNr=$OCF_RESKEY_InstanceNumber
SIDInstanceName="${SID}_HDB${InstanceNr}"
InstanceName="HDB${InstanceNr}"
export SAPSYSTEMNAME=$SID
HANA_CALL_TIMEOUT="${OCF_RESKEY_HANA_CALL_TIMEOUT:-60}"
super_ocf_log debug "DBG: Used new method to get SID ($SID) and InstanceNr ($InstanceNr)"
sid="${SID,,}"
sidadm="${sid}adm"
# create subdirectory in /run
SAPHanaSR_RUN="/run/SAPHanaSR_${sid}"
mkdir -p $SAPHanaSR_RUN
chown $sidadm $SAPHanaSR_RUN
# TODO PRIO3: Do we need a parameter for the RA to be able to adjust hdbSrQueryTimeout?
hdbSrQueryTimeout=180
# DONE: PRIO4: SAPVIRHOST might be different to NODENAME
# DONE: PRIO1: ASK: Is the output format of ListInstances fix? Could we take that as an API? Answer: Yes
# try to catch: Inst Info : LNX - 42 - lv9041 - 740, patch 36, changelist 1444691
# We rely on the following format: SID is word#4, SYSNR is word#6, vHost is word#8
if [ -e /usr/sap/hostctrl/exe/saphostctrl ]; then
vName=$(/usr/sap/hostctrl/exe/saphostctrl -function ListInstances \
| awk '$4 == SID && $6 == SYSNR { print $8 }' SID=$SID SYSNR=$InstanceNr 2>/dev/null )
super_ocf_log debug "DBG: ListInstances: $(/usr/sap/hostctrl/exe/saphostctrl -function ListInstances)"
else
super_ocf_log error "ERR: SAPHOSTAGENT is not installed at /usr/sap/hostctrl/exe (saphostctrl missing)"
fi
if [ -z "$vName" ]; then
#
# if saphostctrl does not know the answer, try to fallback to attribute provided by SAPHanaTopology
#
vName=$(get_hana_attribute "${NODENAME}" "${ATTR_NAME_HANA_VHOST[@]}" "$NODENAME");
fi
if [ -z "$vName" ]; then # last fallback if we are not able to figure out the virtual host name
vName="$NODENAME"
fi
SAPVIRHOST=${vName}
PreferSiteTakeover="$OCF_RESKEY_PREFER_SITE_TAKEOVER"
AUTOMATED_REGISTER="${OCF_RESKEY_AUTOMATED_REGISTER:-false}"
RemoveSAPSockets="${OCF_RESKEY_REMOVE_SAP_SOCKETS:-true}"
LPA_DIRECTORY=/var/lib/SAPHanaRA
LPA_ATTR=("lpa_${sid}_lpt" "forever")
super_ocf_log debug "DBG: SID=$SID, sid=$sid, SIDInstanceName=$SIDInstanceName, InstanceName=$InstanceName, InstanceNr=$InstanceNr, SAPVIRHOST=$SAPVIRHOST"
ocf_env=$(env | grep 'OCF_RESKEY_CRM')
super_ocf_log debug "DBG: OCF: $ocf_env"
#
ATTR_NAME_HANA_SYNC_STATUS=("hana_${sid}_sync_state" "reboot") # SOK, SFAIL, UNKNOWN?
ATTR_NAME_HANA_PRIMARY_AT=("hana_${sid}_primary_at" "reboot") # Not used so far
ATTR_NAME_HANA_CLONE_STATE=("hana_${sid}_clone_state" "reboot") # UKNOWN?, DEMOTED, PROMOTED
ATTR_NAME_HANA_REMOTEHOST=("hana_${sid}_remoteHost" "forever")
ATTR_NAME_HANA_SITE=("hana_${sid}_site" "forever")
ATTR_NAME_HANA_ROLES=("hana_${sid}_roles" "reboot")
ATTR_NAME_HANA_SRMODE=("hana_${sid}_srmode" "forever")
ATTR_NAME_HANA_VHOST=("hana_${sid}_vhost" "forever")
ATTR_NAME_HANA_STATUS=("hana_${sid}_status" "reboot")
ATTR_NAME_HANA_OPERATION_MODE=("hana_${sid}_op_mode" "forever")
ATTR_NAME_HANA_SRACTION=("hana_${sid}_sra" "reboot") # Marks, if cluster in a phase requesting a takeover (T) or registration (R)
ATTR_NAME_HANA_SRACTION_HISTORY=("hana_${sid}_srah" "reboot") # Marks, if cluster in a phase requesting a takeover (T) or registration (R)
#
# new "central" attributes
#
ATTR_NAME_HANA_FILTER=("hana_${sid}_glob_filter" "props" "ra-act-dec-lpa")
SAPHanaFilter=$(get_hana_attribute "X" "${ATTR_NAME_HANA_FILTER[@]}")
#
# SITE based attributes
#
ATTR_NAME_HANA_SRHOOK=("hana_${sid}_site_srHook" "props") # external triggered SOK, SFAIL
#
# TODO: PRIO4: Table for non-preferred-site-takeover
#
SCORING_TABLE_PREFERRED_SITE_TAKEOVER=(
"[234]*:P:[^:]*:master .* 150"
"[234]*:P:master .* 140"
"[015-9]*:P:[^:]*:master .* 90"
"[0-9]*:P:[^:]*:slave .* 60"
"[234]*:P:[^:]*:[?:-] .* 0"
"[015-9]*:P:[^:]*:[?:-] .* -1"
"[234]*:S:[^:]*:master SOK 100"
"[234]*:S:[^:]*:master PRIM 100"
"[015-9]*:S:[^:]*:master SOK 80"
"[0-9]*:S:[^:]*:master SFAIL -INFINITY"
"[0-9]*:S:[^:]*:slave SOK 10"
"[0-9]*:S:[^:]*:slave SFAIL -INFINITY"
"[234]*:S:[^:]*:[?:-] .* 0"
"[015-9]*:S:[^:]*:[?:-] .* -1"
".* .* -1"
)
SCORING_TABLE_PREFERRED_LOCAL_RESTART=(
"[0-9]*:P:[^:]*:master .* 150"
"[0-9]*:P:[^:]*:.* .* 140"
"[0-9]*:S:[^:]*:master SOK 100"
"[0-9]*:S:[^:]*:master PRIM 100"
"[0-9]*:S:[^:]*:master SFAIL -INFINITY"
"[0-9]*:S:[^:]*:slave SOK 10"
"[0-9]*:S:[^:]*:slave SFAIL -INFINITY"
"[015-9]*:S:[^:]*:[?:-] .* -1"
"[234]*:S:[^:]*:[?:-] .* -1"
".* .* -1"
)
SCORING_TABLE_PREFERRED_NEVER=(
"[234]*:P:[^:]*:master .* 150"
"[015-9]*:P:[^:]*:master .* 90"
"[0-9]*:P:[^:]*:.* .* -INFINITY"
"[0-9]*:S:[^:]*:.* .* -INFINITY"
".* .* -INFINITY"
)
if ocf_is_true $PreferSiteTakeover; then
SCORING_TABLE=("${SCORING_TABLE_PREFERRED_SITE_TAKEOVER[@]}")
else
case "$PreferSiteTakeover" in
never|NEVER|Never )
SCORING_TABLE=("${SCORING_TABLE_PREFERRED_NEVER[@]}")
;;
* )
SCORING_TABLE=("${SCORING_TABLE_PREFERRED_LOCAL_RESTART[@]}")
;;
esac
fi
#
DUPLICATE_PRIMARY_TIMEOUT="${OCF_RESKEY_DUPLICATE_PRIMARY_TIMEOUT:-7200}"
super_ocf_log debug "DBG: DUPLICATE_PRIMARY_TIMEOUT=$DUPLICATE_PRIMARY_TIMEOUT"
#
# Determine list of other cluster nodes and store in otherNodes variable
otherNodes=()
case $(crm_attribute --type crm_config --name cluster-infrastructure -q) in
*corosync* ) otherNodes=($(crm_node -l | awk '{ if ($2 != me) { print $2 }}' me="${NODENAME}"));;
*openais* ) otherNodes=($(crm_node -l | awk '$3 == "member" { if ($2 != me) { print $2 }}' me="${NODENAME}"));;
*cman* ) otherNodes=($(crm_node -l | awk '{for (i=1; i<=NF; i++) { if ($i != me) { print $i }}}' me="${NODENAME}"));;
esac
#
#
#
remoteHost=$(get_hana_attribute "${NODENAME}" "${ATTR_NAME_HANA_REMOTEHOST[@]}");
if [ -z "$remoteHost" ]; then
if [ "${#otherNodes[@]}" -eq 1 ]; then # we are a 2 node cluster, lets assume the other is the remote-host
remoteNode="${otherNodes[0]}"
remoteHost=$(get_hana_attribute "$remoteNode" "${ATTR_NAME_HANA_VHOST[@]}" "$remoteNode");
super_ocf_log debug "DBG: auto-guess remoteHost=$remoteHost"
else
super_ocf_log debug "DBG: Could not auto-guess remoteHost out of list (${otherNodes[@]})"
fi
else
#
# search cluster node which vhost is equal remoteHost
#
remoteNode=$(remoteHost2remoteNode "$remoteHost")
# TODO: PRIO5: catch rc!=0
fi
# ATTR_NAME_HANA_SITE
sr_name=$(get_hana_attribute "${NODENAME}" "${ATTR_NAME_HANA_SITE[@]}");
sr_mode=$(get_hana_attribute "${NODENAME}" "${ATTR_NAME_HANA_SRMODE[@]}")
if [ -z "$sr_mode" ]; then
sr_mode="sync"
fi
if [ -n "$remoteNode" ]; then
remSR_name=$(get_hana_attribute "${remoteNode}" "${ATTR_NAME_HANA_SITE[@]}");
else
for clN in "${otherNodes[@]}"; do
nodeSite=$(get_hana_attribute "$clN" "${ATTR_NAME_HANA_SITE[@]}")
if [ -n "$nodeSite" -a "$nodeSite" != "$sr_name" ]; then
remSite="$nodeSite"
remSR_name="${remSite%%:*}"
remSR_id="${remSite#*:}"
fi
done
fi
super_ocf_log debug "DBG: sr_name=$sr_name, remoteHost=$remoteHost, remoteNode=$remoteNode, sr_mode=$sr_mode"
# optional OCF parameters, we try to guess which directories are correct
if [ -z "$OCF_RESKEY_DIR_EXECUTABLE" ]
then
if have_binary /usr/sap/$SID/$InstanceName/exe/sapstartsrv && have_binary /usr/sap/$SID/$InstanceName/exe/sapcontrol
then
DIR_EXECUTABLE="/usr/sap/$SID/$InstanceName/exe"
fi
else
if have_binary "$OCF_RESKEY_DIR_EXECUTABLE/sapstartsrv" && have_binary "$OCF_RESKEY_DIR_EXECUTABLE/sapcontrol"
then
DIR_EXECUTABLE="$OCF_RESKEY_DIR_EXECUTABLE"
fi
fi
SAPSTARTSRV="$DIR_EXECUTABLE/sapstartsrv"
SAPCONTROL="$DIR_EXECUTABLE/sapcontrol"
[ -z "$DIR_EXECUTABLE" ] && assert "Cannot find sapstartsrv and sapcontrol executable, please set DIR_EXECUTABLE parameter!"
DIR_PROFILE="${OCF_RESKEY_DIR_PROFILE:-/usr/sap/$SID/SYS/profile}"
# check, if the following fall-back is ok, or if there could be multiple profiles matching this pattern
if [ -n "${SAPVIRHOST}" ]; then
SAPSTARTPROFILE="$DIR_PROFILE/${OCF_RESKEY_INSTANCE_PROFILE:-${SID}_${InstanceName}_${SAPVIRHOST}}"
else