[Pacemaker] [PATCH cts] add a wrapper function for "Pat:They_Stopped"

Angus Salkeld asalkeld at redhat.com
Mon Feb 15 23:34:44 UTC 2010


On Tue, 2010-02-16 at 00:06 +0100, Andrew Beekhof wrote:
> On Mon, Feb 15, 2010 at 11:58 PM, Angus Salkeld <asalkeld at redhat.com> wrote:
> > Hi
> >
> > I am using CTS for testing corosync (no pacemaker) and need this
> > as corosync doesn't know about hostnames only ip addresses.
> >
> > So in my Corosync class I can do the following:
> >
> >    def getPatTheyStopped (self, other, node):
> >        node_ip = socket.gethostbyname (node)
> >        return self["Pat:They_stopped"] %(other, node_ip)
> 
> I suspect you'll probably want this elsewhere too... perhaps we want
> something more like:
> 
> patterns.append(self.CM["Pat:They_stopped"] %(other,
> self.CM.key_for_node(node)))
> 
> where self.CM.key_for_node() does whatever mapping is needed.

Good idea. Here is a better patch.

-Angus

diff -Nur Pacemaker-1-0-3043c9539eca/cts/CTS.py Pacemaker-1-0-1ddefe5f1353/cts/CTS.py
--- Pacemaker-1-0-3043c9539eca/cts/CTS.py	2010-02-16 07:12:09.000000000 +1100
+++ Pacemaker-1-0-1ddefe5f1353/cts/CTS.py	2010-02-16 10:13:18.338818764 +1100
@@ -404,6 +404,9 @@
         self.ShouldBeStatus={}
         self.ns = NodeStatus(self.Env)
 
+    def key_for_node(self, node):
+        return node
+
     def errorstoignore(self):
         '''Return list of errors which are 'normal' and should be ignored'''
         return []
diff -Nur Pacemaker-1-0-3043c9539eca/cts/CTStests.py Pacemaker-1-0-1ddefe5f1353/cts/CTStests.py
--- Pacemaker-1-0-3043c9539eca/cts/CTStests.py	2010-02-16 07:12:09.000000000 +1100
+++ Pacemaker-1-0-1ddefe5f1353/cts/CTStests.py	2010-02-16 10:27:54.343789269 +1100
@@ -490,7 +490,7 @@
         # NOTE: This wont work if we have multiple partitions
         for other in self.CM.Env["nodes"]:
             if self.CM.ShouldBeStatus[other] == "up" and other != node:
-                patterns.append(self.CM["Pat:They_stopped"] %(other, node))
+                patterns.append(self.CM["Pat:They_stopped"] %(other, self.CM.key_for_node(node)))
                 #self.debug("Checking %s will notice %s left"%(other, node))
                 
         watch = CTS.LogWatcher(
@@ -1398,7 +1398,7 @@
             # Make sure the node goes down and then comes back up if it should reboot...
             for other in self.CM.Env["nodes"]:
                 if other != node:
-                    self.patterns.append(self.CM["Pat:They_stopped"] %(other, node))
+                    self.patterns.append(self.CM["Pat:They_stopped"] %(other, self.CM.key_for_node(node)))
             self.patterns.append(self.CM["Pat:Slave_started"] % node)
             self.patterns.append(self.CM["Pat:Local_started"] % node)
 
@@ -2019,7 +2019,7 @@
             else:
                 for stopping in stopset:
                     if self.CM.ShouldBeStatus[stopping] == "up":
-                        watchpats.append(self.CM["Pat:They_stopped"] % (node, stopping))
+                        watchpats.append(self.CM["Pat:They_stopped"] % (node, self.CM.key_for_node(stopping)))
                 
         if len(watchpats) == 0:
             return self.skipped()

-------------- next part --------------
A non-text attachment was scrubbed...
Name: cts-they-stopped.patch
Type: text/x-patch
Size: 2259 bytes
Desc: not available
URL: <https://lists.clusterlabs.org/pipermail/pacemaker/attachments/20100216/47c3030b/attachment-0002.bin>


More information about the Pacemaker mailing list