Skip to content

Commit

Permalink
Fix: CTS: update for new alerts syntax
Browse files Browse the repository at this point in the history
At this point, CTS still uses its own --notification-agent and
--notification-recipient options, and thus only supports one alert script,
but it will create the CIB using the new alerts XML syntax.
  • Loading branch information
kgaillot committed Apr 22, 2016
1 parent f1b2712 commit 0c84e67
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 7 deletions.
13 changes: 8 additions & 5 deletions cts/CIB.py
Original file line number Diff line number Diff line change
Expand Up @@ -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!!"

Expand All @@ -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()
Expand Down Expand Up @@ -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):
Expand Down
19 changes: 19 additions & 0 deletions cts/cib_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions cts/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 0c84e67

Please sign in to comment.