Blame SOURCES/bz1180390-Stop-deleted-resource-before-removing-its-constraint.patch

337c54
From 0bc8f7923904bb171faac052c6f3881b48ddd21c Mon Sep 17 00:00:00 2001
337c54
From: Tomas Jelinek <tojeline@redhat.com>
337c54
Date: Fri, 9 Jan 2015 12:49:13 +0100
337c54
Subject: [PATCH] Stop deleted resource before removing its constraints
337c54
337c54
Removing constraints referencing a resource when the resource
337c54
is still running can cause the resource to be moved to other node.
337c54
---
337c54
 pcs/resource.py | 16 ++++++++--------
337c54
 1 file changed, 8 insertions(+), 8 deletions(-)
337c54
337c54
diff --git a/pcs/resource.py b/pcs/resource.py
337c54
index 6c8b723..db96eb9 100644
337c54
--- a/pcs/resource.py
337c54
+++ b/pcs/resource.py
337c54
@@ -1717,6 +1717,14 @@ def resource_remove(resource_id, output = True):
337c54
     if (group != ""):
337c54
         num_resources_in_group = len(parseString(group).documentElement.getElementsByTagName("primitive"))
337c54
 
337c54
+    if not "--force" in utils.pcs_options and not utils.usefile and not utils.is_resource_started(resource_id, 0, True)[0]:
337c54
+        sys.stdout.write("Attempting to stop: "+ resource_id + "...")
337c54
+        sys.stdout.flush()
337c54
+        resource_disable([resource_id])
337c54
+        if not utils.is_resource_started(resource_id, 15, True)[0]:
337c54
+            utils.err("Unable to stop: %s before deleting (re-run with --force to force deletion)" % resource_id)
337c54
+        print "Stopped"
337c54
+
337c54
     constraint.remove_constraints_containing(resource_id,output)
337c54
     resource_el = utils.dom_get_resource(dom, resource_id)
337c54
     if resource_el:
337c54
@@ -1728,14 +1736,6 @@ def resource_remove(resource_id, output = True):
337c54
             utils.replace_cib_configuration(dom)
337c54
             dom = utils.get_cib_dom()
337c54
 
337c54
-    if not "--force" in utils.pcs_options and not utils.usefile and not utils.is_resource_started(resource_id, 0, True)[0]:
337c54
-        sys.stdout.write("Attempting to stop: "+ resource_id + "...")
337c54
-        sys.stdout.flush()
337c54
-        resource_disable([resource_id])
337c54
-        if not utils.is_resource_started(resource_id, 15, True)[0]:
337c54
-            utils.err("Unable to stop: %s before deleting (re-run with --force to force deletion)" % resource_id)
337c54
-        print "Stopped"
337c54
-
337c54
     if (group == "" or num_resources_in_group > 1):
337c54
         master_xpath = '//master/primitive[@id="'+resource_id+'"]/..'
337c54
         clone_xpath = '//clone/primitive[@id="'+resource_id+'"]/..'
337c54
-- 
337c54
1.9.1
337c54