diff --git a/cts/CIB.py b/cts/CIB.py index e9386b5f544..b723cf0b2c6 100644 --- a/cts/CIB.py +++ b/cts/CIB.py @@ -312,10 +312,6 @@ def contents(self, target=None): o["no-quorum-policy"] = no_quorum o["expected-quorum-votes"] = self.num_nodes - if self.Factory.rsh.exists_on_all(self.CM.Env["notification-agent"], self.CM.Env["nodes"]): - o["notification-agent"] = self.CM.Env["notification-agent"] - o["notification-recipient"] = self.CM.Env["notification-recipient"] - if self.CM.Env["DoBSC"] == 1: o["ident-string"] = "Linux-HA TEST configuration file - REMOVEME!!" @@ -325,6 +321,13 @@ def contents(self, target=None): if stn is not None: stn.commit() + # Add an alerts section if possible + if self.Factory.rsh.exists_on_all(self.CM.Env["notification-agent"], self.CM.Env["nodes"]): + alerts = Alerts(self.Factory) + alerts.add_alert(self.CM.Env["notification-agent"], + self.CM.Env["notification-recipient"]) + alerts.commit() + # Add resources? if self.CM.Env["CIBResource"] == 1: self.add_resources() @@ -451,7 +454,7 @@ class CIB12(CIB11): class CIB20(CIB11): feature_set = "3.0" - version = "pacemaker-2.4" + version = "pacemaker-2.5" #class HASI(CIB10): # def add_resources(self): diff --git a/cts/cib_xml.py b/cts/cib_xml.py index 1f924f35f98..c7c56fe51a0 100644 --- a/cts/cib_xml.py +++ b/cts/cib_xml.py @@ -117,6 +117,25 @@ def commit(self): self._run("modify", self.show(), "crm_config", "--allow-create") +class Alerts(XmlBase): + def __init__(self, Factory): + XmlBase.__init__(self, Factory, "alerts", None) + self.alert_count = 0 + + def add_alert(self, path, recipient): + self.alert_count = self.alert_count + 1 + alert = XmlBase(self.Factory, "alert", "alert-%d" % self.alert_count, + path=path) + recipient1 = XmlBase(self.Factory, "recipient", + "alert-%d-recipient-1" % self.alert_count, + value=recipient) + alert.add_child(recipient1) + self.add_child(alert) + + def commit(self): + self._run("modify", self.show(), "configuration", "--allow-create") + + class Expression(XmlBase): def __init__(self, Factory, name, attr, op, value=None): XmlBase.__init__(self, Factory, "expression", name, attribute=attr, operation=op) diff --git a/cts/environment.py b/cts/environment.py index c9db4bf3714..19e4180ea86 100644 --- a/cts/environment.py +++ b/cts/environment.py @@ -670,8 +670,8 @@ def usage(self, arg, status=1): print("\t [--stonith-type type]") print("\t [--stonith-args name=value]") print("\t [--bsc]") - print("\t [--notification-agent path] script to configure for Pacemaker notifications") - print("\t [--notification-recipient r] recipient to pass to notification agent") + print("\t [--notification-agent path] script to configure for Pacemaker alerts") + print("\t [--notification-recipient r] recipient to pass to alert script") print("\t [--no-loop-tests] dont run looping/time-based tests") print("\t [--no-unsafe-tests] dont run tests that are unsafe for use with ocfs2/drbd") print("\t [--valgrind-tests] include tests using valgrind")