[Cluster-devel] cluster/rgmanager/src/daemons resrules.c
lhh at sourceware.org
lhh at sourceware.org
Fri Oct 20 20:29:40 UTC 2006
CVSROOT: /cvs/cluster
Module name: cluster
Branch: RHEL4
Changes by: lhh at sourceware.org 2006-10-20 20:29:40
Modified files:
rgmanager/src/daemons: resrules.c
Log message:
Compatibility fix for resource agents between linux-cluster and linux-ha
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/resrules.c.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.9.2.2&r2=1.9.2.3
--- cluster/rgmanager/src/daemons/resrules.c 2005/03/21 22:01:30 1.9.2.2
+++ cluster/rgmanager/src/daemons/resrules.c 2006/10/20 20:29:39 1.9.2.3
@@ -19,10 +19,10 @@
#include <libxml/parser.h>
#include <libxml/xmlmemory.h>
#include <libxml/xpath.h>
-#include <magma.h>
#include <ccs.h>
#include <stdlib.h>
#include <stdio.h>
+#include <string.h>
#include <resgroup.h>
#include <sys/types.h>
#include <sys/stat.h>
@@ -53,12 +53,6 @@
newrule->rr_type);
return -1;
}
- if (newrule->rr_root && curr->rr_root) {
- fprintf(stderr, "Error storing %s: root "
- "resource type %s exists already\n",
- newrule->rr_type, curr->rr_type);
- return -1;
- }
} while (!list_done(rulelist, curr));
@@ -186,30 +180,6 @@
}
-/**
- Get and store the root attribute.
-
- @param doc Pre-parsed XML document pointer.
- @param ctx Pre-allocated XML XPath context pointer.
- @param base XPath prefix to search
- @param rr Resource rule to store new information in.
- */
-void
-_get_root(xmlDocPtr doc, xmlXPathContextPtr ctx, char *base,
- resource_rule_t *rr)
-{
- char xpath[256];
- char *ret = NULL;
-
- snprintf(xpath, sizeof(xpath), "%s/attributes/@root", base);
- ret = xpath_get_one(doc, ctx, xpath);
- if (ret) {
- rr->rr_root = 1;
- free(ret);
- }
-}
-
-
int
expand_time(char *val)
{
@@ -356,8 +326,6 @@
free(act);
} while (1);
-
-
}
@@ -426,6 +394,48 @@
/**
+ Take the first unique + required attr and call it the 'primary' attr
+ for rgmanager. If there's no primary, index 0 becomes the primary attr.
+ */
+int
+choose_primary(resource_attr_t *attrs)
+{
+ int x = 0, primary = 0;
+ int flags;
+ char *name, *val;
+
+ if (!attrs)
+ return 0;
+
+ for (x = 0; attrs[x].ra_name; x++) {
+
+ if ((attrs[x].ra_flags & (RA_UNIQUE | RA_REQUIRED)) ==
+ (RA_UNIQUE | RA_REQUIRED)) {
+ primary = x;
+ break;
+ }
+ }
+
+ if (primary != 0) {
+ flags = attrs[primary].ra_flags | RA_PRIMARY;
+ name = attrs[primary].ra_name;
+ val = attrs[primary].ra_value;
+
+ attrs[primary].ra_flags = attrs[0].ra_flags;
+ attrs[primary].ra_name = attrs[0].ra_name;
+ attrs[primary].ra_value = attrs[0].ra_value;
+
+ attrs[0].ra_flags = flags;
+ attrs[0].ra_name = name;
+ attrs[0].ra_value = val;
+ } else {
+ attrs[0].ra_flags |= RA_PRIMARY;
+ }
+
+ return 0;
+}
+
+/**
Store a child type in the child array of a resource rule.
XXX Could be rewritten to use list macros.
@@ -487,10 +497,7 @@
{
int x;
- printf("Resource Rules for \"%s\"", rr->rr_type);
- if (rr->rr_root)
- printf(" [ROOT]");
- printf("\n");
+ printf("Resource Rules for \"%s\"\n", rr->rr_type);
if (rr->rr_version)
printf("OCF API Version: %s\n", rr->rr_version);
@@ -551,7 +558,7 @@
children:
- printf("Recognized child resource types:\n");
+ printf("Explicitly defined child resource types:\n");
if (!rr->rr_childtypes) {
printf(" - None -\n\n");
return;
@@ -697,6 +704,9 @@
store_attribute(&rr->rr_attrs, attrname, ret, flags);
}
+ if (!primary_found)
+ choose_primary(rr->rr_attrs);
+
return 0;
}
@@ -918,12 +928,11 @@
snprintf(base, sizeof(base),
"/resource-agent[%d]/special[@tag=\"rgmanager\"]",
ruleid);
- _get_root(doc, ctx, base, rr);
_get_maxparents(doc, ctx, base, rr);
rr->rr_agent = strdup(filename);
/*
- Second, add the allowable-children fields
+ Second, add the children fields
*/
_get_childtypes(doc, ctx, base, rr);
@@ -991,6 +1000,10 @@
fn = basename(de->d_name);
if (!fn)
continue;
+
+ if ((fn != NULL) && (strlen(fn) > 0) &&
+ (fn[strlen(fn)-1] == '~'))
+ continue;
snprintf(path, sizeof(path), "%s/%s",
rpath, de->d_name);
More information about the Cluster-devel
mailing list