diff --git a/cts/CIB.py.in b/cts/CIB.py.in index c370c8793d..ae24ac67e3 100644 --- a/cts/CIB.py.in +++ b/cts/CIB.py.in @@ -1,277 +1,272 @@ #!@PYTHON@ '''CTS: Cluster Testing System: CIB generator ''' __copyright__=''' Author: Jia Ming Pan Copyright (C) 2006 International Business Machines ''' from UserDict import UserDict import sys, time, types, syslog, os, struct, string, signal, traceback from CTS import ClusterManager from CM_hb import HeartbeatCM class CIB: cib_option_template = ''' ''' dc_ipaddr_resource_template = ''' ''' clustermon_resource_template = ''' ''' dc_ipaddr_location_constraint = ''' ''' clustermon_location_constraint = ''' ''' lsb_resource = ''' ''' master_slave_resource = ''' - + - - - - - ''' resource_group_template = ''' ''' per_node_resource_template = ''' ''' per_node_constraint_template = ''' ''' stonith_resource_template = """ """ cib_template =''' %s %s %s ''' def NextIP(self): fields = string.split(self.CM.Env["IPBase"], '.') fields[3] = str(int(fields[3])+1) ip = string.join(fields, '.') self.CM.Env["IPBase"]=ip return ip def __init__(self, CM): self.CM = CM #make up crm config cib_options = self.cib_option_template % CM.Env["DoFencing"] #create resources and their constraints resources = "" constraints = "" if self.CM.Env["DoBSC"] == 1: cib_options = cib_options + ''' ''' if self.CM.Env["CIBResource"] != 1: # generate cib self.cts_cib = self.cib_template % (cib_options, resources, constraints) return self.CM.log("Enabling DC resource") resources += self.dc_ipaddr_resource_template % self.CM.Env["IPBase"] constraints += self.dc_ipaddr_location_constraint if self.CM.cluster_monitor == 1: resources += self.clustermon_resource_template constraints += self.clustermon_location_constraint ip1=self.NextIP() ip2=self.NextIP() ip3=self.NextIP() resources += self.resource_group_template % (ip1, ip1, ip1, ip1, ip2, ip2, ip2, ip2, ip3, ip3, ip3, ip3) # lsb resource resources += self.lsb_resource # per node resource fields = string.split(self.CM.Env["IPBase"], '.') for node in self.CM.Env["nodes"]: ip = self.NextIP() per_node_resources = self.per_node_resource_template % \ ("rsc_"+node, "rsc_"+node, "rsc_"+node, "rsc_"+node, "rsc_"+node, ip) per_node_constraint = self.per_node_constraint_template % \ ("rsc_"+node, "rsc_"+node, "rsc_"+node, "rsc_"+node, node) resources += per_node_resources constraints += per_node_constraint # fencing resource nodelist = "" len = 0 for node in self.CM.Env["nodes"]: nodelist += node + " " len = len + 1 stonith_resource = self.stonith_resource_template % (len, nodelist) resources += stonith_resource #master slave resource resources += self.master_slave_resource % (2*len, 2, len, 1) # generate cib self.cts_cib = self.cib_template % (cib_options, resources, constraints) def cib(self): return self.cts_cib diff --git a/cts/OCFMSDummy.in b/cts/OCFMSDummy.in deleted file mode 100755 index 9c4e1ae87f..0000000000 --- a/cts/OCFMSDummy.in +++ /dev/null @@ -1,234 +0,0 @@ -#!/bin/sh -# -# License: GNU General Public License (GPL) -# Support: linux-ha@lists.linux-ha.org -# -# -# WARNING: this script is for CTS testing only. -# -# This script support master-slave operations -# - -. @hb_libdir@/ocf-shellfuncs - -AWK=gawk -GREP=grep -PS="ps -o pid= -o args= -C " - -CRM_MASTER="/usr/sbin/crm_master" -#DUMMY_RESOURCE=@OCF_RA_DIR@/heartbeat/OCFMSDummy -DUMMY_RESOURCE=@libdir@/heartbeat/cts/OCFMSDummy - -start_delay=1 - -stop_delay=1 -monitor_delay=1 -promote_delay=1 -demote_delay=1 -notify_delay=1 - -do_cmd() { - local cmd="$*" - ocf_log debug "$RESOURCE: Calling $cmd" - local cmd_out=$($cmd 2>&1) - ret=$? - - if [ $ret -ne 0 ]; then - ocf_log err "$RESOURCE: Called $cmd" - ocf_log err "$RESOURCE: Exit code $ret" - ocf_log err "$RESOURCE: Command output: $cmd_out" - else - ocf_log debug "$RESOURCE: Exit code $ret" - ocf_log debug "$RESOURCE: Command output: $cmd_out" - fi - - echo $cmd_out - return $ret -} - - -dummy_get_status() { - instance=$1 - basename=`basename $DUMMY_RESOURCE` - result=`$PS $basename` - echo $result | $GREP -e "$basename.*#$instance" >/dev/null - running=$? - - if [ ! $running -eq 0 ]; then - ocf_log info "status: instance #$instance not running" - return $OCF_NOT_RUNNING - fi - echo $result | $GREP -e "master #$instance" >/dev/null - state=$? - - - if [ $state -eq 0 ]; then # master - ocf_log info "status: instance #$instance is running as master" - return $OCF_RUNNING_MASTER - else # slave - ocf_log info "status: instance #$instance is running as slave" - return $OCF_SUCCESS - fi -} - - -do_start_resource () { - instance=$1 - request_state=$2 - #stop resource - do_stop_resource $instance - #execute resource - $DUMMY_RESOURCE $request_state "#$instance" & - return $OCF_SUCCESS -} - -# stop, delete instance from the file -do_stop_resource () { - tmp=`mktemp` - instance=$1 - basename=`basename $DUMMY_RESOURCE` - $PS $basename > $tmp - pids=`$GREP -e "$basename.*#$instance" $tmp | $AWK '{print $1}'` - rm -f $tmp - - for pid in $pids; do - ocf_log info "trying to kill pid $pid (instance #$instance)" - kill -9 $pid - done - return $OCF_SUCCESS -} - -do_change_state() { - instance=$1 - request_state=$2 - ocf_log info "before state changed: " - dummy_get_status $instance - # not running, can't promote - if [ $? -eq $OCF_NOT_RUNNING ] ;then - ocf_log info "instance #$instance not running, can't change state" - return $OCF_ERROR; - fi - do_stop_resource $instance - do_start_resource $instance $request_state - rc=$? - ocf_log info "after state changed: " - dummy_get_status $instance - return $rc -} - - -dummy_start() { - ocf_log info "start instance #$OCF_RESKEY_CRM_meta_clone slave" - do_start_resource $OCF_RESKEY_CRM_meta_clone "slave" - if [ $OCF_RESKEY_CRM_meta_clone -eq 0 ]; then - do_cmd $CRM_MASTER -v 1000 - fi - sleep $start_delay - return $OCF_SUCCESS -} - -dummy_stop() { - touch $DUMMY_RESOURCE - ocf_log info "stop instance #$OCF_RESKEY_CRM_meta_clone" - do_stop_resource $OCF_RESKEY_CRM_meta_clone - rc=$? - sleep $stop_delay - return $rc -} - -dummy_monitor() { - ocf_log info "monitor instance #$OCF_RESKEY_CRM_meta_clone" - dummy_get_status $OCF_RESKEY_CRM_meta_clone - rc=$? - sleep $monitor_delay - return $rc -} - -dummy_promote() { - ocf_log info "promote instance #$OCF_RESKEY_CRM_meta_clone" - do_change_state $OCF_RESKEY_CRM_meta_clone "master" - rc=$? - sleep $promote_delay - return $rc -} - -dummy_demote() { - ocf_log info "demote instance #$OCF_RESKEY_CRM_meta_clone" - do_change_state $OCF_RESKEY_CRM_meta_clone "slave" - rc=$? - sleep $demote_delay - return $rc -} - -dummy_notify() { - ocf_log info "notify instance #$OCF_RESKEY_CRM_meta_clone" - touch $DUMMY_RESOURCE - sleep $notify_delay - local n_type="$OCF_RESKEY_CRM_meta_notify_type" - local n_op="$OCF_RESKEY_CRM_meta_notify_operation" - set -- $n_active_resource - local n_active="$#" - set -- $notify_stop_resource - local n_stop="$#" - set -- $notify_start_resource - local n_start="$#" - - ocf_log debug "$RESOURCE notify: $n_type for $n_op - counts: active $n_active - starting $n_start - stopping $n_stop" - case $n_type in - pre) - case $n_op in - promote) # TODO: - # Resist promotion of the other side in case we - # are already primary - though the CRM should - # not even attempt that. - ;; - esac - ;; - post) - case $n_op in - start) - ;; - # TODO: Does "fence" actually happen? - stop|fence) - # This MUST be a notification for the other side - # having been stopped, because for sure we won't - # receive one for ourselves being stopped ;-) - # So to allow continuing with freeze_io, we need - # to explicitly disconnect. - ;; - monitor) - # TODO: We don't get notifications for failed - # monitors yet. - ;; - esac - ;; - esac - return $OCF_SUCCESS -} - - -dummy_resource_run_loop (){ - while [ 1 ]; do - sleep 3 - done -} - -usage () -{ - echo "OCFMSDummy start|stop|monitor|promote|demote|notify" -} -case $__OCF_ACTION in - start) dummy_start ;; - stop) dummy_stop ;; - monitor) dummy_monitor ;; - promote) dummy_promote ;; - demote) dummy_demote ;; - notify) dummy_notify ;; - -# not RA operations -# master and slave are resource operations. - master) dummy_resource_run_loop ;; - slave) dummy_resource_run_loop ;; - *) usage $__OCF_ACTION - exit $OCF_ERR_ARGS ;; -esac