pacemaker/crm_deleteunmanaged.patch
Tim Serong 0440703030 - Upgrade to 1.1.6.
- PE: Demote from Master does not clear previous errors
- crmd: Prevent secondary DC fencing resulting from CIB updates
  that are lost due to elections
- crmd: Log duplicate DC detection as a WARNING not ERROR
- crmd: Bug lf#2632 - Correctly handle nodes that return faster
  than stonith
- Core: Treat GNUTLS_E_UNEXPECTED_PACKET_LENGTH as normal
  termination of a TLS session
- cib: Call gnutls_bye() and shutdown() when disconnecting from
  remote TLS connections
- cib: Remove disconnected remote connections from mainloop
- cib: Attempt a graceful sign-off for remote TLS connections
- Core: Ensure there is sufficient space for EOS when building
  short-form option strings (prevents segfault)
- Core: Fix variable expansion in pkg-config files
- PE: Resolve memory leak reported by valgrind
- PE: Fix memory leak for re-allocated resources reported by
  valgrind
- PE: Improve the merging with template's operations
- crmd: Allow nodes to fence themselves if they're the last one
  standing (lf#2584)
- stonith: Add an API call for listing installed agents
- stonith: Allow the fencing history to be queried
- stonith: Ensure completed operations are recorded as such in
  the history
- stonith: Support --quiet to display just the seconds since
  epoch at which a node was last shot
- stonith: Serialize actions for a given device
- stonith: Add missing entries to stonith_error2string() (missing

OBS-URL: https://build.opensuse.org/package/show/network:ha-clustering:Factory/pacemaker?expand=0&rev=18
2011-09-20 14:36:23 +00:00

101 lines
3.6 KiB
Diff

# HG changeset patch
# User Dejan Muhamedagic <dejan@hello-penguin.com>
# Date 1313755383 -7200
# Node ID e8ea8fb95f310997995576ee831693b0d3b2736a
# Parent 0abb257259ed722abaa32a237c3c284c08ec0737
Medium: Shell: enable removal of unmanaged resources (bnc#696506)
diff --git a/shell/modules/cibconfig.py b/shell/modules/cibconfig.py
--- a/shell/modules/cibconfig.py
+++ b/shell/modules/cibconfig.py
@@ -2303,7 +2303,7 @@ class CibFactory(Singleton):
no_object_err(obj_id)
rc = False
continue
- if is_rsc_running(obj_id):
+ if is_rsc_managed(obj_id) and is_rsc_running(obj_id):
common_err("resource %s is running, can't delete it" % obj_id)
rc = False
else:
diff --git a/shell/modules/xmlutil.py b/shell/modules/xmlutil.py
--- a/shell/modules/xmlutil.py
+++ b/shell/modules/xmlutil.py
@@ -178,6 +178,34 @@ def shadowfile(name):
def shadow2doc(name):
return file2doc(shadowfile(name))
+def is_xs_boolean_true(bool):
+ return bool.lower() in ("true","1")
+def is_rsc_managed(id):
+ if not is_live_cib():
+ return False
+ rsc_node = rsc2node(id)
+ if not rsc_node:
+ return False
+ prop_node = get_properties_node(get_conf_elem(cibdump2doc("crm_config"), "crm_config"))
+ # maintenance-mode, if true, overrides all
+ attr = get_attr_value(prop_node, "maintenance-mode")
+ if attr and is_xs_boolean_true(attr):
+ return False
+ # then check the rsc is-managed meta attribute
+ rsc_meta_node = get_rsc_meta_node(rsc_node)
+ attr = get_attr_value(rsc_meta_node, "is-managed")
+ if attr:
+ return is_xs_boolean_true(attr)
+ # then rsc_defaults is-managed attribute
+ rsc_dflt_node = get_rscop_defaults_meta_node(get_conf_elem(cibdump2doc("rsc_defaults"), "rsc_defaults"))
+ attr = get_attr_value(rsc_dflt_node, "is-managed")
+ if attr:
+ return is_xs_boolean_true(attr)
+ # finally the is-managed-default property
+ attr = get_attr_value(prop_node, "is-managed-default")
+ if attr:
+ return is_xs_boolean_true(attr)
+ return True
def is_rsc_running(id):
if not is_live_cib():
return False
@@ -691,12 +719,20 @@ def silly_constraint(c_node,rsc_id):
def get_rsc_children_ids(node):
return [x.getAttribute("id") \
for x in node.childNodes if is_child_rsc(x)]
-def get_rscop_defaults_meta_node(node):
+def get_child_nvset_node(node, attr_set = "meta_attributes"):
+ if not node:
+ return None
for c in node.childNodes:
- if not is_element(c) or c.tagName != "meta_attributes":
+ if not is_element(c) or c.tagName != attr_set:
continue
return c
return None
+def get_rscop_defaults_meta_node(node):
+ return get_child_nvset_node(node)
+def get_rsc_meta_node(node):
+ return get_child_nvset_node(node)
+def get_properties_node(node):
+ return get_child_nvset_node(node, attr_set = "cluster_property_set")
def new_cib():
doc = xml.dom.minidom.Document()
@@ -727,12 +763,19 @@ def new_cib_element(node,tagname,id_pfx)
node.appendChild(newnode)
return newnode
def get_attr_in_set(node,attr):
+ if not node:
+ return None
for c in node.childNodes:
if not is_element(c):
continue
if c.tagName == "nvpair" and c.getAttribute("name") == attr:
return c
return None
+def get_attr_value(node,attr):
+ n = get_attr_in_set(node,attr)
+ if not n:
+ return None
+ return n.getAttribute("value")
def set_attr(node,attr,value):
'''
Set an attribute in the attribute set.