diff --git a/cts/CIB.py.in b/cts/CIB.py.in index d425c5da0e..462c40db8e 100644 --- a/cts/CIB.py.in +++ b/cts/CIB.py.in @@ -1,249 +1,276 @@ #!@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 = ''' ''' ipaddr_template = ''' ''' hb_ipaddr_template = ''' ''' lsb_resource = ''' ''' dummy_resource_template = ''' ''' clustermon_resource_template = ''' ''' clustermon_location_constraint = ''' ''' master_slave_resource = ''' ''' resource_group_template = '''%s %s %s''' per_node_constraint_template = ''' - - - + ''' + + pingd_resource_template = """ + + + + + + + + + + + + + + + + + + """ + + pingd_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 # fencing resource nodelist = "" num_nodes = 0 for node in self.CM.Env["nodes"]: nodelist += node + " " num_nodes = num_nodes + 1 no_quorum = "stop" if num_nodes < 3: no_quorum = "ignore" self.CM.debug("Cluster only has %d nodes, ignoring quorum" % num_nodes) #make up crm config cib_options = self.cib_option_template % (CM.Env["DoFencing"], no_quorum) #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 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() ip1_rsc = self.ipaddr_template % ("r"+ip1, ip1, ip1, ip1, ip1, ip1) ip2_rsc = self.hb_ipaddr_template % ("r"+ip2, ip2, ip2, ip2, ip2) ip3_rsc = self.ipaddr_template % ("r"+ip3, ip3, ip3, ip3, ip3, ip3) resources += self.resource_group_template % (ip1_rsc, ip2_rsc, ip3_rsc) # lsb resource resources += self.lsb_resource # Mirgator - resources += self.dummy_resource_template % \ - ("migrator", "migrator", "migrator", "migrator") + resources += self.dummy_resource_template % ("migrator", "migrator", "migrator", "migrator") constraints += """""" constraints += """""" # per node resource fields = string.split(self.CM.Env["IPBase"], '.') for node in self.CM.Env["nodes"]: ip = self.NextIP() per_node_resources = self.ipaddr_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) + per_node_constraint = self.per_node_constraint_template % (node, "rsc_"+node, node) resources += per_node_resources constraints += per_node_constraint + # Ping the test master + resources += self.pingd_resource_template % os.uname()[1] + + # Require conectivity to run + constraints += self.pingd_constraint_template % ("master-1", "master-1", "m", "Started", "m", 1) + if CM.Env["DoFencing"]: stonith_resource = self.stonith_resource_template % \ (self.CM.Env["reset"].stonithtype, self.CM.Env["reset"].configName, self.CM.Env["reset"].configValue) resources += stonith_resource #master slave resource resources += self.master_slave_resource % (num_nodes, 1, 1, 1) # generate cib self.cts_cib = self.cib_template % (cib_options, resources, constraints) def cib(self): return self.cts_cib