|
|
60de42 |
From 94a4c58f675d163085a055f59fd6c3a2c9f57c43 Mon Sep 17 00:00:00 2001
|
|
|
60de42 |
From: Ken Gaillot <kgaillot@redhat.com>
|
|
|
60de42 |
Date: Mon, 27 Feb 2017 14:17:01 -0600
|
|
|
60de42 |
Subject: [PATCH 01/10] Fix: libservices: ensure completed ops aren't on
|
|
|
60de42 |
blocked ops list
|
|
|
60de42 |
|
|
|
60de42 |
This refactors removal of a completed operation from the in-flight ops list
|
|
|
60de42 |
into a new internal function services_untrack_op(), which allows the
|
|
|
60de42 |
in-flight ops list and handle_blocked_ops() to be static to services.c.
|
|
|
60de42 |
|
|
|
60de42 |
The new function also ensures the op isn't on the blocked ops list,
|
|
|
60de42 |
which could otherwise result in a use-after-free bug.
|
|
|
60de42 |
---
|
|
|
60de42 |
lib/services/services.c | 23 +++++++++++++++++++++--
|
|
|
60de42 |
lib/services/services_linux.c | 7 +------
|
|
|
60de42 |
lib/services/services_private.h | 2 +-
|
|
|
60de42 |
3 files changed, 23 insertions(+), 9 deletions(-)
|
|
|
60de42 |
|
|
|
60de42 |
diff --git a/lib/services/services.c b/lib/services/services.c
|
|
|
60de42 |
index 0b535e6..90a2181 100644
|
|
|
60de42 |
--- a/lib/services/services.c
|
|
|
60de42 |
+++ b/lib/services/services.c
|
|
|
60de42 |
@@ -44,7 +44,9 @@ static GHashTable *recurring_actions = NULL;
|
|
|
60de42 |
static GList *blocked_ops = NULL;
|
|
|
60de42 |
|
|
|
60de42 |
/* ops currently active (in-flight) */
|
|
|
60de42 |
-GList *inflight_ops = NULL;
|
|
|
60de42 |
+static GList *inflight_ops = NULL;
|
|
|
60de42 |
+
|
|
|
60de42 |
+static void handle_blocked_ops(void);
|
|
|
60de42 |
|
|
|
60de42 |
svc_action_t *
|
|
|
60de42 |
services_action_create(const char *name, const char *action, int interval, int timeout)
|
|
|
60de42 |
@@ -605,6 +607,23 @@ services_add_inflight_op(svc_action_t * op)
|
|
|
60de42 |
}
|
|
|
60de42 |
}
|
|
|
60de42 |
|
|
|
60de42 |
+/*!
|
|
|
60de42 |
+ * \internal
|
|
|
60de42 |
+ * \brief Stop tracking an operation that completed
|
|
|
60de42 |
+ *
|
|
|
60de42 |
+ * \param[in] op Operation to stop tracking
|
|
|
60de42 |
+ */
|
|
|
60de42 |
+void
|
|
|
60de42 |
+services_untrack_op(svc_action_t *op)
|
|
|
60de42 |
+{
|
|
|
60de42 |
+ /* Op is no longer in-flight or blocked */
|
|
|
60de42 |
+ inflight_ops = g_list_remove(inflight_ops, op);
|
|
|
60de42 |
+ blocked_ops = g_list_remove(blocked_ops, op);
|
|
|
60de42 |
+
|
|
|
60de42 |
+ /* Op is no longer blocking other ops, so check if any need to run */
|
|
|
60de42 |
+ handle_blocked_ops();
|
|
|
60de42 |
+}
|
|
|
60de42 |
+
|
|
|
60de42 |
gboolean
|
|
|
60de42 |
services_action_async(svc_action_t * op, void (*action_callback) (svc_action_t *))
|
|
|
60de42 |
{
|
|
|
60de42 |
@@ -649,7 +668,7 @@ is_op_blocked(const char *rsc)
|
|
|
60de42 |
return FALSE;
|
|
|
60de42 |
}
|
|
|
60de42 |
|
|
|
60de42 |
-void
|
|
|
60de42 |
+static void
|
|
|
60de42 |
handle_blocked_ops(void)
|
|
|
60de42 |
{
|
|
|
60de42 |
GList *executed_ops = NULL;
|
|
|
60de42 |
diff --git a/lib/services/services_linux.c b/lib/services/services_linux.c
|
|
|
60de42 |
index adfefaa..1fe3ec1 100644
|
|
|
60de42 |
--- a/lib/services/services_linux.c
|
|
|
60de42 |
+++ b/lib/services/services_linux.c
|
|
|
60de42 |
@@ -36,9 +36,6 @@
|
|
|
60de42 |
# include "crm/common/cib_secrets.h"
|
|
|
60de42 |
#endif
|
|
|
60de42 |
|
|
|
60de42 |
-/* ops currently active (in-flight) */
|
|
|
60de42 |
-extern GList *inflight_ops;
|
|
|
60de42 |
-
|
|
|
60de42 |
static inline void
|
|
|
60de42 |
set_fd_opts(int fd, int opts)
|
|
|
60de42 |
{
|
|
|
60de42 |
@@ -248,9 +245,7 @@ operation_finalize(svc_action_t * op)
|
|
|
60de42 |
|
|
|
60de42 |
op->pid = 0;
|
|
|
60de42 |
|
|
|
60de42 |
- inflight_ops = g_list_remove(inflight_ops, op);
|
|
|
60de42 |
-
|
|
|
60de42 |
- handle_blocked_ops();
|
|
|
60de42 |
+ services_untrack_op(op);
|
|
|
60de42 |
|
|
|
60de42 |
if (!recurring && op->synchronous == FALSE) {
|
|
|
60de42 |
/*
|
|
|
60de42 |
diff --git a/lib/services/services_private.h b/lib/services/services_private.h
|
|
|
60de42 |
index ec9e1c4..a949592 100644
|
|
|
60de42 |
--- a/lib/services/services_private.h
|
|
|
60de42 |
+++ b/lib/services/services_private.h
|
|
|
60de42 |
@@ -76,7 +76,7 @@ G_GNUC_INTERNAL
|
|
|
60de42 |
void services_add_inflight_op(svc_action_t *op);
|
|
|
60de42 |
|
|
|
60de42 |
G_GNUC_INTERNAL
|
|
|
60de42 |
-void handle_blocked_ops(void);
|
|
|
60de42 |
+void services_untrack_op(svc_action_t *op);
|
|
|
60de42 |
|
|
|
60de42 |
G_GNUC_INTERNAL
|
|
|
60de42 |
gboolean is_op_blocked(const char *rsc);
|
|
|
60de42 |
--
|
|
|
60de42 |
1.8.3.1
|
|
|
60de42 |
|
|
|
60de42 |
|
|
|
60de42 |
From b938c47740a456d0057438e4f5e6029d0e084587 Mon Sep 17 00:00:00 2001
|
|
|
60de42 |
From: Ken Gaillot <kgaillot@redhat.com>
|
|
|
60de42 |
Date: Mon, 27 Feb 2017 14:20:05 -0600
|
|
|
60de42 |
Subject: [PATCH 02/10] Refactor: libservices: dynamically allocate operation
|
|
|
60de42 |
key
|
|
|
60de42 |
|
|
|
60de42 |
reduces code duplication, and avoids memory over-allocation
|
|
|
60de42 |
---
|
|
|
60de42 |
lib/services/services.c | 18 ++++++------------
|
|
|
60de42 |
1 file changed, 6 insertions(+), 12 deletions(-)
|
|
|
60de42 |
|
|
|
60de42 |
diff --git a/lib/services/services.c b/lib/services/services.c
|
|
|
60de42 |
index 90a2181..4020b7d 100644
|
|
|
60de42 |
--- a/lib/services/services.c
|
|
|
60de42 |
+++ b/lib/services/services.c
|
|
|
60de42 |
@@ -149,10 +149,7 @@ resources_action_create(const char *name, const char *standard, const char *prov
|
|
|
60de42 |
op->agent = strdup(agent);
|
|
|
60de42 |
op->sequence = ++operations;
|
|
|
60de42 |
op->flags = flags;
|
|
|
60de42 |
-
|
|
|
60de42 |
- if (asprintf(&op->id, "%s_%s_%d", name, action, interval) == -1) {
|
|
|
60de42 |
- goto return_error;
|
|
|
60de42 |
- }
|
|
|
60de42 |
+ op->id = generate_op_key(name, action, interval);
|
|
|
60de42 |
|
|
|
60de42 |
if (strcasecmp(op->standard, "service") == 0) {
|
|
|
60de42 |
const char *expanded = resources_find_service_class(op->agent);
|
|
|
60de42 |
@@ -467,11 +464,10 @@ gboolean
|
|
|
60de42 |
services_action_cancel(const char *name, const char *action, int interval)
|
|
|
60de42 |
{
|
|
|
60de42 |
svc_action_t *op = NULL;
|
|
|
60de42 |
- char id[512];
|
|
|
60de42 |
-
|
|
|
60de42 |
- snprintf(id, sizeof(id), "%s_%s_%d", name, action, interval);
|
|
|
60de42 |
+ char *id = generate_op_key(name, action, interval);
|
|
|
60de42 |
|
|
|
60de42 |
if (!(op = g_hash_table_lookup(recurring_actions, id))) {
|
|
|
60de42 |
+ free(id);
|
|
|
60de42 |
return FALSE;
|
|
|
60de42 |
}
|
|
|
60de42 |
|
|
|
60de42 |
@@ -494,10 +490,12 @@ services_action_cancel(const char *name, const char *action, int interval)
|
|
|
60de42 |
/* even though the early termination failed,
|
|
|
60de42 |
* the op will be marked as cancelled once it completes. */
|
|
|
60de42 |
crm_err("Termination of %s (pid=%d) failed", id, op->pid);
|
|
|
60de42 |
+ free(id);
|
|
|
60de42 |
return FALSE;
|
|
|
60de42 |
}
|
|
|
60de42 |
}
|
|
|
60de42 |
|
|
|
60de42 |
+ free(id);
|
|
|
60de42 |
return TRUE;
|
|
|
60de42 |
}
|
|
|
60de42 |
|
|
|
60de42 |
@@ -505,11 +503,7 @@ gboolean
|
|
|
60de42 |
services_action_kick(const char *name, const char *action, int interval /* ms */)
|
|
|
60de42 |
{
|
|
|
60de42 |
svc_action_t * op = NULL;
|
|
|
60de42 |
- char *id = NULL;
|
|
|
60de42 |
-
|
|
|
60de42 |
- if (asprintf(&id, "%s_%s_%d", name, action, interval) == -1) {
|
|
|
60de42 |
- return FALSE;
|
|
|
60de42 |
- }
|
|
|
60de42 |
+ char *id = generate_op_key(name, action, interval);
|
|
|
60de42 |
|
|
|
60de42 |
op = g_hash_table_lookup(recurring_actions, id);
|
|
|
60de42 |
free(id);
|
|
|
60de42 |
--
|
|
|
60de42 |
1.8.3.1
|
|
|
60de42 |
|
|
|
60de42 |
|
|
|
60de42 |
From 933d46ef20591757301784773a37e06b78906584 Mon Sep 17 00:00:00 2001
|
|
|
60de42 |
From: Ken Gaillot <kgaillot@redhat.com>
|
|
|
60de42 |
Date: Mon, 27 Feb 2017 14:28:36 -0600
|
|
|
60de42 |
Subject: [PATCH 03/10] Fix: libservices: prevent use-after-free when freeing
|
|
|
60de42 |
an operation
|
|
|
60de42 |
|
|
|
60de42 |
---
|
|
|
60de42 |
lib/services/services.c | 10 ++++++++++
|
|
|
60de42 |
1 file changed, 10 insertions(+)
|
|
|
60de42 |
|
|
|
60de42 |
diff --git a/lib/services/services.c b/lib/services/services.c
|
|
|
60de42 |
index 4020b7d..78a0781 100644
|
|
|
60de42 |
--- a/lib/services/services.c
|
|
|
60de42 |
+++ b/lib/services/services.c
|
|
|
60de42 |
@@ -410,6 +410,16 @@ services_action_free(svc_action_t * op)
|
|
|
60de42 |
return;
|
|
|
60de42 |
}
|
|
|
60de42 |
|
|
|
60de42 |
+ /* The operation should be removed from all tracking lists by this point.
|
|
|
60de42 |
+ * If it's not, we have a bug somewhere, so bail. That may lead to a
|
|
|
60de42 |
+ * memory leak, but it's better than a use-after-free segmentation fault.
|
|
|
60de42 |
+ */
|
|
|
60de42 |
+ CRM_CHECK(g_list_find(inflight_ops, op) == NULL, return);
|
|
|
60de42 |
+ CRM_CHECK(g_list_find(blocked_ops, op) == NULL, return);
|
|
|
60de42 |
+ CRM_CHECK((recurring_actions == NULL)
|
|
|
60de42 |
+ || (g_hash_table_lookup(recurring_actions, op->id) == NULL),
|
|
|
60de42 |
+ return);
|
|
|
60de42 |
+
|
|
|
60de42 |
services_action_cleanup(op);
|
|
|
60de42 |
|
|
|
60de42 |
if (op->opaque->repeat_timer) {
|
|
|
60de42 |
--
|
|
|
60de42 |
1.8.3.1
|
|
|
60de42 |
|
|
|
60de42 |
|
|
|
60de42 |
From dc36d4375c049024a6f9e4d2277a3e6444fad05b Mon Sep 17 00:00:00 2001
|
|
|
60de42 |
From: Ken Gaillot <kgaillot@redhat.com>
|
|
|
60de42 |
Date: Tue, 28 Feb 2017 15:41:10 -0600
|
|
|
60de42 |
Subject: [PATCH 04/10] Refactor: libservices: handle in-flight case first when
|
|
|
60de42 |
cancelling an operation
|
|
|
60de42 |
|
|
|
60de42 |
will make next bugfix easier
|
|
|
60de42 |
---
|
|
|
60de42 |
lib/services/services.c | 65 ++++++++++++++++++++++++++++++++-----------------
|
|
|
60de42 |
1 file changed, 42 insertions(+), 23 deletions(-)
|
|
|
60de42 |
|
|
|
60de42 |
diff --git a/lib/services/services.c b/lib/services/services.c
|
|
|
60de42 |
index 78a0781..dba4e66 100644
|
|
|
60de42 |
--- a/lib/services/services.c
|
|
|
60de42 |
+++ b/lib/services/services.c
|
|
|
60de42 |
@@ -470,43 +470,62 @@ cancel_recurring_action(svc_action_t * op)
|
|
|
60de42 |
return TRUE;
|
|
|
60de42 |
}
|
|
|
60de42 |
|
|
|
60de42 |
+/*!
|
|
|
60de42 |
+ * \brief Cancel a recurring action
|
|
|
60de42 |
+ *
|
|
|
60de42 |
+ * \param[in] name Name of resource that operation is for
|
|
|
60de42 |
+ * \param[in] action Name of operation to cancel
|
|
|
60de42 |
+ * \param[in] interval Interval of operation to cancel
|
|
|
60de42 |
+ *
|
|
|
60de42 |
+ * \return TRUE if action was successfully cancelled, FALSE otherwise
|
|
|
60de42 |
+ */
|
|
|
60de42 |
gboolean
|
|
|
60de42 |
services_action_cancel(const char *name, const char *action, int interval)
|
|
|
60de42 |
{
|
|
|
60de42 |
- svc_action_t *op = NULL;
|
|
|
60de42 |
+ gboolean cancelled = FALSE;
|
|
|
60de42 |
char *id = generate_op_key(name, action, interval);
|
|
|
60de42 |
+ svc_action_t *op = g_hash_table_lookup(recurring_actions, id);
|
|
|
60de42 |
|
|
|
60de42 |
- if (!(op = g_hash_table_lookup(recurring_actions, id))) {
|
|
|
60de42 |
- free(id);
|
|
|
60de42 |
- return FALSE;
|
|
|
60de42 |
+ /* We can only cancel a recurring action */
|
|
|
60de42 |
+ if (op == NULL) {
|
|
|
60de42 |
+ goto done;
|
|
|
60de42 |
}
|
|
|
60de42 |
|
|
|
60de42 |
- /* Always kill the recurring timer */
|
|
|
60de42 |
+ /* Tell operation_finalize() not to reschedule the operation */
|
|
|
60de42 |
+ op->cancel = TRUE;
|
|
|
60de42 |
+
|
|
|
60de42 |
+ /* Stop tracking it as a recurring operation, and stop its timer */
|
|
|
60de42 |
cancel_recurring_action(op);
|
|
|
60de42 |
|
|
|
60de42 |
- if (op->pid == 0) {
|
|
|
60de42 |
- op->status = PCMK_LRM_OP_CANCELLED;
|
|
|
60de42 |
- if (op->opaque->callback) {
|
|
|
60de42 |
- op->opaque->callback(op);
|
|
|
60de42 |
+ /* If the op has a PID, it's an in-flight child process, so kill it.
|
|
|
60de42 |
+ *
|
|
|
60de42 |
+ * Whether the kill succeeds or fails, the main loop will send the op to
|
|
|
60de42 |
+ * operation_finished() (and thus operation_finalize()) when the process
|
|
|
60de42 |
+ * goes away.
|
|
|
60de42 |
+ */
|
|
|
60de42 |
+ if (op->pid != 0) {
|
|
|
60de42 |
+ crm_info("Terminating in-flight op %s (pid %d) early because it was cancelled",
|
|
|
60de42 |
+ id, op->pid);
|
|
|
60de42 |
+ cancelled = mainloop_child_kill(op->pid);
|
|
|
60de42 |
+ if (cancelled == FALSE) {
|
|
|
60de42 |
+ crm_err("Termination of %s (pid %d) failed", id, op->pid);
|
|
|
60de42 |
}
|
|
|
60de42 |
+ goto done;
|
|
|
60de42 |
+ }
|
|
|
60de42 |
|
|
|
60de42 |
- blocked_ops = g_list_remove(blocked_ops, op);
|
|
|
60de42 |
- services_action_free(op);
|
|
|
60de42 |
-
|
|
|
60de42 |
- } else {
|
|
|
60de42 |
- crm_info("Cancelling in-flight op: performing early termination of %s (pid=%d)", id, op->pid);
|
|
|
60de42 |
- op->cancel = 1;
|
|
|
60de42 |
- if (mainloop_child_kill(op->pid) == FALSE) {
|
|
|
60de42 |
- /* even though the early termination failed,
|
|
|
60de42 |
- * the op will be marked as cancelled once it completes. */
|
|
|
60de42 |
- crm_err("Termination of %s (pid=%d) failed", id, op->pid);
|
|
|
60de42 |
- free(id);
|
|
|
60de42 |
- return FALSE;
|
|
|
60de42 |
- }
|
|
|
60de42 |
+ /* Otherwise, operation is not in-flight, just report as cancelled */
|
|
|
60de42 |
+ op->status = PCMK_LRM_OP_CANCELLED;
|
|
|
60de42 |
+ if (op->opaque->callback) {
|
|
|
60de42 |
+ op->opaque->callback(op);
|
|
|
60de42 |
}
|
|
|
60de42 |
|
|
|
60de42 |
+ blocked_ops = g_list_remove(blocked_ops, op);
|
|
|
60de42 |
+ services_action_free(op);
|
|
|
60de42 |
+ cancelled = TRUE;
|
|
|
60de42 |
+
|
|
|
60de42 |
+done:
|
|
|
60de42 |
free(id);
|
|
|
60de42 |
- return TRUE;
|
|
|
60de42 |
+ return cancelled;
|
|
|
60de42 |
}
|
|
|
60de42 |
|
|
|
60de42 |
gboolean
|
|
|
60de42 |
--
|
|
|
60de42 |
1.8.3.1
|
|
|
60de42 |
|
|
|
60de42 |
|
|
|
60de42 |
From deabcc5a6aa93dadf0b20364715b559a5b9848ac Mon Sep 17 00:00:00 2001
|
|
|
60de42 |
From: Ken Gaillot <kgaillot@redhat.com>
|
|
|
60de42 |
Date: Tue, 28 Feb 2017 15:48:11 -0600
|
|
|
60de42 |
Subject: [PATCH 05/10] Fix: libservices: properly cancel in-flight
|
|
|
60de42 |
systemd/upstart op
|
|
|
60de42 |
|
|
|
60de42 |
---
|
|
|
60de42 |
lib/services/services.c | 27 +++++++++++++++++++++++++++
|
|
|
60de42 |
1 file changed, 27 insertions(+)
|
|
|
60de42 |
|
|
|
60de42 |
diff --git a/lib/services/services.c b/lib/services/services.c
|
|
|
60de42 |
index dba4e66..4aa4c01 100644
|
|
|
60de42 |
--- a/lib/services/services.c
|
|
|
60de42 |
+++ b/lib/services/services.c
|
|
|
60de42 |
@@ -89,6 +89,21 @@ resources_find_service_class(const char *agent)
|
|
|
60de42 |
return NULL;
|
|
|
60de42 |
}
|
|
|
60de42 |
|
|
|
60de42 |
+/*!
|
|
|
60de42 |
+ * \internal
|
|
|
60de42 |
+ * \brief Check whether op is in-flight systemd or upstart op
|
|
|
60de42 |
+ *
|
|
|
60de42 |
+ * \param[in] op Operation to check
|
|
|
60de42 |
+ *
|
|
|
60de42 |
+ * \return TRUE if op is in-flight systemd or upstart op
|
|
|
60de42 |
+ */
|
|
|
60de42 |
+static inline gboolean
|
|
|
60de42 |
+inflight_systemd_or_upstart(svc_action_t *op)
|
|
|
60de42 |
+{
|
|
|
60de42 |
+ return (safe_str_eq(op->standard, "systemd")
|
|
|
60de42 |
+ || safe_str_eq(op->standard, "upstart"))
|
|
|
60de42 |
+ && (g_list_find(inflight_ops, op) != NULL);
|
|
|
60de42 |
+}
|
|
|
60de42 |
|
|
|
60de42 |
svc_action_t *
|
|
|
60de42 |
resources_action_create(const char *name, const char *standard, const char *provider,
|
|
|
60de42 |
@@ -513,6 +528,18 @@ services_action_cancel(const char *name, const char *action, int interval)
|
|
|
60de42 |
goto done;
|
|
|
60de42 |
}
|
|
|
60de42 |
|
|
|
60de42 |
+ /* In-flight systemd and upstart ops don't have a pid. The relevant handlers
|
|
|
60de42 |
+ * will call operation_finalize() when the operation completes.
|
|
|
60de42 |
+ * @TODO: Can we request early termination, maybe using
|
|
|
60de42 |
+ * dbus_pending_call_cancel()?
|
|
|
60de42 |
+ */
|
|
|
60de42 |
+ if (inflight_systemd_or_upstart(op)) {
|
|
|
60de42 |
+ crm_info("Will cancel %s op %s when in-flight instance completes",
|
|
|
60de42 |
+ op->standard, op->id);
|
|
|
60de42 |
+ cancelled = FALSE;
|
|
|
60de42 |
+ goto done;
|
|
|
60de42 |
+ }
|
|
|
60de42 |
+
|
|
|
60de42 |
/* Otherwise, operation is not in-flight, just report as cancelled */
|
|
|
60de42 |
op->status = PCMK_LRM_OP_CANCELLED;
|
|
|
60de42 |
if (op->opaque->callback) {
|
|
|
60de42 |
--
|
|
|
60de42 |
1.8.3.1
|
|
|
60de42 |
|
|
|
60de42 |
|
|
|
60de42 |
From b85037b75255061a41d0ec3fd9b64f271351b43e Mon Sep 17 00:00:00 2001
|
|
|
60de42 |
From: Ken Gaillot <kgaillot@redhat.com>
|
|
|
60de42 |
Date: Tue, 28 Feb 2017 16:43:52 -0600
|
|
|
60de42 |
Subject: [PATCH 06/10] Fix: libservices: properly detect in-flight
|
|
|
60de42 |
systemd/upstart ops when kicking
|
|
|
60de42 |
|
|
|
60de42 |
---
|
|
|
60de42 |
lib/services/services.c | 3 ++-
|
|
|
60de42 |
1 file changed, 2 insertions(+), 1 deletion(-)
|
|
|
60de42 |
|
|
|
60de42 |
diff --git a/lib/services/services.c b/lib/services/services.c
|
|
|
60de42 |
index 4aa4c01..b41517d 100644
|
|
|
60de42 |
--- a/lib/services/services.c
|
|
|
60de42 |
+++ b/lib/services/services.c
|
|
|
60de42 |
@@ -568,7 +568,8 @@ services_action_kick(const char *name, const char *action, int interval /* ms */
|
|
|
60de42 |
return FALSE;
|
|
|
60de42 |
}
|
|
|
60de42 |
|
|
|
60de42 |
- if (op->pid) {
|
|
|
60de42 |
+
|
|
|
60de42 |
+ if (op->pid || inflight_systemd_or_upstart(op)) {
|
|
|
60de42 |
return TRUE;
|
|
|
60de42 |
} else {
|
|
|
60de42 |
if (op->opaque->repeat_timer) {
|
|
|
60de42 |
--
|
|
|
60de42 |
1.8.3.1
|
|
|
60de42 |
|
|
|
60de42 |
|
|
|
60de42 |
From 55be77356d9253c46a1ddebefd6f403366209281 Mon Sep 17 00:00:00 2001
|
|
|
60de42 |
From: Ken Gaillot <kgaillot@redhat.com>
|
|
|
60de42 |
Date: Tue, 28 Feb 2017 18:37:23 -0600
|
|
|
60de42 |
Subject: [PATCH 07/10] Log: libservices: improve error messages when creating
|
|
|
60de42 |
operation
|
|
|
60de42 |
|
|
|
60de42 |
---
|
|
|
60de42 |
lib/services/services.c | 21 +++++++++++----------
|
|
|
60de42 |
1 file changed, 11 insertions(+), 10 deletions(-)
|
|
|
60de42 |
|
|
|
60de42 |
diff --git a/lib/services/services.c b/lib/services/services.c
|
|
|
60de42 |
index b41517d..e089717 100644
|
|
|
60de42 |
--- a/lib/services/services.c
|
|
|
60de42 |
+++ b/lib/services/services.c
|
|
|
60de42 |
@@ -118,27 +118,27 @@ resources_action_create(const char *name, const char *standard, const char *prov
|
|
|
60de42 |
*/
|
|
|
60de42 |
|
|
|
60de42 |
if (crm_strlen_zero(name)) {
|
|
|
60de42 |
- crm_err("A service or resource action must have a name.");
|
|
|
60de42 |
+ crm_err("Cannot create operation without resource name");
|
|
|
60de42 |
goto return_error;
|
|
|
60de42 |
}
|
|
|
60de42 |
|
|
|
60de42 |
if (crm_strlen_zero(standard)) {
|
|
|
60de42 |
- crm_err("A service action must have a valid standard.");
|
|
|
60de42 |
+ crm_err("Cannot create operation for %s without resource class", name);
|
|
|
60de42 |
goto return_error;
|
|
|
60de42 |
}
|
|
|
60de42 |
|
|
|
60de42 |
if (!strcasecmp(standard, "ocf") && crm_strlen_zero(provider)) {
|
|
|
60de42 |
- crm_err("An OCF resource action must have a provider.");
|
|
|
60de42 |
+ crm_err("Cannot create OCF operation for %s without provider", name);
|
|
|
60de42 |
goto return_error;
|
|
|
60de42 |
}
|
|
|
60de42 |
|
|
|
60de42 |
if (crm_strlen_zero(agent)) {
|
|
|
60de42 |
- crm_err("A service or resource action must have an agent.");
|
|
|
60de42 |
+ crm_err("Cannot create operation for %s without agent name", name);
|
|
|
60de42 |
goto return_error;
|
|
|
60de42 |
}
|
|
|
60de42 |
|
|
|
60de42 |
if (crm_strlen_zero(action)) {
|
|
|
60de42 |
- crm_err("A service or resource action must specify an action.");
|
|
|
60de42 |
+ crm_err("Cannot create operation for %s without operation name", name);
|
|
|
60de42 |
goto return_error;
|
|
|
60de42 |
}
|
|
|
60de42 |
|
|
|
60de42 |
@@ -170,12 +170,13 @@ resources_action_create(const char *name, const char *standard, const char *prov
|
|
|
60de42 |
const char *expanded = resources_find_service_class(op->agent);
|
|
|
60de42 |
|
|
|
60de42 |
if(expanded) {
|
|
|
60de42 |
- crm_debug("Found a %s agent for %s/%s", expanded, op->rsc, op->agent);
|
|
|
60de42 |
+ crm_debug("Found %s agent %s for %s", expanded, op->agent, op->rsc);
|
|
|
60de42 |
free(op->standard);
|
|
|
60de42 |
op->standard = strdup(expanded);
|
|
|
60de42 |
|
|
|
60de42 |
} else {
|
|
|
60de42 |
- crm_info("Cannot determine the standard for %s (%s)", op->rsc, op->agent);
|
|
|
60de42 |
+ crm_info("Assuming resource class lsb for agent %s for %s",
|
|
|
60de42 |
+ op->agent, op->rsc);
|
|
|
60de42 |
free(op->standard);
|
|
|
60de42 |
op->standard = strdup("lsb");
|
|
|
60de42 |
}
|
|
|
60de42 |
@@ -226,7 +227,7 @@ resources_action_create(const char *name, const char *standard, const char *prov
|
|
|
60de42 |
/* The "heartbeat" agent class only has positional arguments,
|
|
|
60de42 |
* which we keyed by their decimal position number. */
|
|
|
60de42 |
param_num = 1;
|
|
|
60de42 |
- for (index = 1; index <= MAX_ARGC - 3; index++ ) {
|
|
|
60de42 |
+ for (index = 1; index <= MAX_ARGC - 3; index++ ) {
|
|
|
60de42 |
snprintf(buf_tmp, sizeof(buf_tmp), "%d", index);
|
|
|
60de42 |
value_tmp = g_hash_table_lookup(params, buf_tmp);
|
|
|
60de42 |
if (value_tmp == NULL) {
|
|
|
60de42 |
@@ -237,8 +238,8 @@ resources_action_create(const char *name, const char *standard, const char *prov
|
|
|
60de42 |
op->opaque->args[param_num++] = strdup(value_tmp);
|
|
|
60de42 |
}
|
|
|
60de42 |
|
|
|
60de42 |
- /* Add operation code as the last argument, */
|
|
|
60de42 |
- /* and the teminating NULL pointer */
|
|
|
60de42 |
+ /* Add operation code as the last argument, */
|
|
|
60de42 |
+ /* and the teminating NULL pointer */
|
|
|
60de42 |
op->opaque->args[param_num++] = strdup(op->action);
|
|
|
60de42 |
op->opaque->args[param_num] = NULL;
|
|
|
60de42 |
#endif
|
|
|
60de42 |
--
|
|
|
60de42 |
1.8.3.1
|
|
|
60de42 |
|
|
|
60de42 |
|
|
|
60de42 |
From 121a3f219ff5a9ea07e271cb03d9c55af2d2ad1f Mon Sep 17 00:00:00 2001
|
|
|
60de42 |
From: Ken Gaillot <kgaillot@redhat.com>
|
|
|
60de42 |
Date: Tue, 28 Feb 2017 18:55:11 -0600
|
|
|
60de42 |
Subject: [PATCH 08/10] Refactor: libservices: functionize expanding resource
|
|
|
60de42 |
class, and remove dead code
|
|
|
60de42 |
|
|
|
60de42 |
---
|
|
|
60de42 |
include/crm/services.h | 1 +
|
|
|
60de42 |
lib/services/services.c | 75 ++++++++++++++++++++++++++++---------------------
|
|
|
60de42 |
2 files changed, 44 insertions(+), 32 deletions(-)
|
|
|
60de42 |
|
|
|
60de42 |
diff --git a/include/crm/services.h b/include/crm/services.h
|
|
|
60de42 |
index 05c8ebf..28bb76a 100644
|
|
|
60de42 |
--- a/include/crm/services.h
|
|
|
60de42 |
+++ b/include/crm/services.h
|
|
|
60de42 |
@@ -47,6 +47,7 @@ extern "C" {
|
|
|
60de42 |
# define SYSTEMCTL "/bin/systemctl"
|
|
|
60de42 |
# endif
|
|
|
60de42 |
|
|
|
60de42 |
+/* Deprecated and unused by Pacemaker, kept for API backward compatibility */
|
|
|
60de42 |
# ifndef SERVICE_SCRIPT
|
|
|
60de42 |
# define SERVICE_SCRIPT "/sbin/service"
|
|
|
60de42 |
# endif
|
|
|
60de42 |
diff --git a/lib/services/services.c b/lib/services/services.c
|
|
|
60de42 |
index e089717..3ffaeb6 100644
|
|
|
60de42 |
--- a/lib/services/services.c
|
|
|
60de42 |
+++ b/lib/services/services.c
|
|
|
60de42 |
@@ -105,6 +105,41 @@ inflight_systemd_or_upstart(svc_action_t *op)
|
|
|
60de42 |
&& (g_list_find(inflight_ops, op) != NULL);
|
|
|
60de42 |
}
|
|
|
60de42 |
|
|
|
60de42 |
+/*!
|
|
|
60de42 |
+ * \internal
|
|
|
60de42 |
+ * \brief Expand "service" alias to an actual resource class
|
|
|
60de42 |
+ *
|
|
|
60de42 |
+ * \param[in] rsc Resource name (for logging only)
|
|
|
60de42 |
+ * \param[in] standard Resource class as configured
|
|
|
60de42 |
+ * \param[in] agent Agent name to look for
|
|
|
60de42 |
+ *
|
|
|
60de42 |
+ * \return Newly allocated string with actual resource class
|
|
|
60de42 |
+ *
|
|
|
60de42 |
+ * \note The caller is responsible for calling free() on the result.
|
|
|
60de42 |
+ */
|
|
|
60de42 |
+static char *
|
|
|
60de42 |
+expand_resource_class(const char *rsc, const char *standard, const char *agent)
|
|
|
60de42 |
+{
|
|
|
60de42 |
+ char *expanded_class = NULL;
|
|
|
60de42 |
+
|
|
|
60de42 |
+ if (strcasecmp(standard, "service") == 0) {
|
|
|
60de42 |
+ const char *found_class = resources_find_service_class(agent);
|
|
|
60de42 |
+
|
|
|
60de42 |
+ if (found_class) {
|
|
|
60de42 |
+ crm_debug("Found %s agent %s for %s", found_class, agent, rsc);
|
|
|
60de42 |
+ expanded_class = strdup(found_class);
|
|
|
60de42 |
+ } else {
|
|
|
60de42 |
+ crm_info("Assuming resource class lsb for agent %s for %s",
|
|
|
60de42 |
+ agent, rsc);
|
|
|
60de42 |
+ expanded_class = strdup("lsb");
|
|
|
60de42 |
+ }
|
|
|
60de42 |
+ } else {
|
|
|
60de42 |
+ expanded_class = strdup(standard);
|
|
|
60de42 |
+ }
|
|
|
60de42 |
+ CRM_ASSERT(expanded_class);
|
|
|
60de42 |
+ return expanded_class;
|
|
|
60de42 |
+}
|
|
|
60de42 |
+
|
|
|
60de42 |
svc_action_t *
|
|
|
60de42 |
resources_action_create(const char *name, const char *standard, const char *provider,
|
|
|
60de42 |
const char *agent, const char *action, int interval, int timeout,
|
|
|
60de42 |
@@ -142,14 +177,6 @@ resources_action_create(const char *name, const char *standard, const char *prov
|
|
|
60de42 |
goto return_error;
|
|
|
60de42 |
}
|
|
|
60de42 |
|
|
|
60de42 |
- if (safe_str_eq(action, "monitor") && (
|
|
|
60de42 |
-#if SUPPORT_HEARTBEAT
|
|
|
60de42 |
- safe_str_eq(standard, "heartbeat") ||
|
|
|
60de42 |
-#endif
|
|
|
60de42 |
- safe_str_eq(standard, "lsb") || safe_str_eq(standard, "service"))) {
|
|
|
60de42 |
- action = "status";
|
|
|
60de42 |
- }
|
|
|
60de42 |
-
|
|
|
60de42 |
/*
|
|
|
60de42 |
* Sanity checks passed, proceed!
|
|
|
60de42 |
*/
|
|
|
60de42 |
@@ -157,31 +184,22 @@ resources_action_create(const char *name, const char *standard, const char *prov
|
|
|
60de42 |
op = calloc(1, sizeof(svc_action_t));
|
|
|
60de42 |
op->opaque = calloc(1, sizeof(svc_action_private_t));
|
|
|
60de42 |
op->rsc = strdup(name);
|
|
|
60de42 |
- op->action = strdup(action);
|
|
|
60de42 |
op->interval = interval;
|
|
|
60de42 |
op->timeout = timeout;
|
|
|
60de42 |
- op->standard = strdup(standard);
|
|
|
60de42 |
+ op->standard = expand_resource_class(name, standard, agent);
|
|
|
60de42 |
op->agent = strdup(agent);
|
|
|
60de42 |
op->sequence = ++operations;
|
|
|
60de42 |
op->flags = flags;
|
|
|
60de42 |
op->id = generate_op_key(name, action, interval);
|
|
|
60de42 |
|
|
|
60de42 |
- if (strcasecmp(op->standard, "service") == 0) {
|
|
|
60de42 |
- const char *expanded = resources_find_service_class(op->agent);
|
|
|
60de42 |
-
|
|
|
60de42 |
- if(expanded) {
|
|
|
60de42 |
- crm_debug("Found %s agent %s for %s", expanded, op->agent, op->rsc);
|
|
|
60de42 |
- free(op->standard);
|
|
|
60de42 |
- op->standard = strdup(expanded);
|
|
|
60de42 |
-
|
|
|
60de42 |
- } else {
|
|
|
60de42 |
- crm_info("Assuming resource class lsb for agent %s for %s",
|
|
|
60de42 |
- op->agent, op->rsc);
|
|
|
60de42 |
- free(op->standard);
|
|
|
60de42 |
- op->standard = strdup("lsb");
|
|
|
60de42 |
- }
|
|
|
60de42 |
- CRM_ASSERT(op->standard);
|
|
|
60de42 |
+ if (safe_str_eq(action, "monitor") && (
|
|
|
60de42 |
+#if SUPPORT_HEARTBEAT
|
|
|
60de42 |
+ safe_str_eq(op->standard, "heartbeat") ||
|
|
|
60de42 |
+#endif
|
|
|
60de42 |
+ safe_str_eq(op->standard, "lsb"))) {
|
|
|
60de42 |
+ action = "status";
|
|
|
60de42 |
}
|
|
|
60de42 |
+ op->action = strdup(action);
|
|
|
60de42 |
|
|
|
60de42 |
if (strcasecmp(op->standard, "ocf") == 0) {
|
|
|
60de42 |
op->provider = strdup(provider);
|
|
|
60de42 |
@@ -251,12 +269,6 @@ resources_action_create(const char *name, const char *standard, const char *prov
|
|
|
60de42 |
} else if (strcasecmp(op->standard, "upstart") == 0) {
|
|
|
60de42 |
op->opaque->exec = strdup("upstart-dbus");
|
|
|
60de42 |
#endif
|
|
|
60de42 |
- } else if (strcasecmp(op->standard, "service") == 0) {
|
|
|
60de42 |
- op->opaque->exec = strdup(SERVICE_SCRIPT);
|
|
|
60de42 |
- op->opaque->args[0] = strdup(SERVICE_SCRIPT);
|
|
|
60de42 |
- op->opaque->args[1] = strdup(agent);
|
|
|
60de42 |
- op->opaque->args[2] = strdup(action);
|
|
|
60de42 |
-
|
|
|
60de42 |
#if SUPPORT_NAGIOS
|
|
|
60de42 |
} else if (strcasecmp(op->standard, "nagios") == 0) {
|
|
|
60de42 |
int index = 0;
|
|
|
60de42 |
@@ -308,7 +320,6 @@ resources_action_create(const char *name, const char *standard, const char *prov
|
|
|
60de42 |
}
|
|
|
60de42 |
op->opaque->args[index] = NULL;
|
|
|
60de42 |
#endif
|
|
|
60de42 |
-
|
|
|
60de42 |
} else {
|
|
|
60de42 |
crm_err("Unknown resource standard: %s", op->standard);
|
|
|
60de42 |
services_action_free(op);
|
|
|
60de42 |
--
|
|
|
60de42 |
1.8.3.1
|
|
|
60de42 |
|
|
|
60de42 |
|
|
|
60de42 |
From 46c07e23d48806140cf12393b7867063630cdf30 Mon Sep 17 00:00:00 2001
|
|
|
60de42 |
From: Ken Gaillot <kgaillot@redhat.com>
|
|
|
60de42 |
Date: Tue, 28 Feb 2017 19:30:16 -0600
|
|
|
60de42 |
Subject: [PATCH 09/10] Refactor: various: use defined constants for resource
|
|
|
60de42 |
classes
|
|
|
60de42 |
|
|
|
60de42 |
ensures a typo won't compile
|
|
|
60de42 |
---
|
|
|
60de42 |
crmd/remote_lrmd_ra.c | 2 +-
|
|
|
60de42 |
fencing/main.c | 6 ++--
|
|
|
60de42 |
include/crm/services.h | 9 +++++
|
|
|
60de42 |
lib/lrmd/lrmd_client.c | 23 +++++++------
|
|
|
60de42 |
lib/pengine/complex.c | 2 +-
|
|
|
60de42 |
lib/pengine/native.c | 8 ++---
|
|
|
60de42 |
lib/pengine/remote.c | 3 +-
|
|
|
60de42 |
lib/pengine/unpack.c | 2 +-
|
|
|
60de42 |
lib/services/services.c | 79 ++++++++++++++++++++++++-------------------
|
|
|
60de42 |
lib/services/services_linux.c | 9 +++--
|
|
|
60de42 |
lrmd/lrmd.c | 44 +++++++++++++-----------
|
|
|
60de42 |
pengine/native.c | 2 +-
|
|
|
60de42 |
tools/crm_resource_print.c | 2 +-
|
|
|
60de42 |
tools/crm_resource_runtime.c | 2 +-
|
|
|
60de42 |
tools/fake_transition.c | 17 +++++-----
|
|
|
60de42 |
15 files changed, 119 insertions(+), 91 deletions(-)
|
|
|
60de42 |
|
|
|
60de42 |
diff --git a/crmd/remote_lrmd_ra.c b/crmd/remote_lrmd_ra.c
|
|
|
60de42 |
index eb995ea..e68d784 100644
|
|
|
60de42 |
--- a/crmd/remote_lrmd_ra.c
|
|
|
60de42 |
+++ b/crmd/remote_lrmd_ra.c
|
|
|
60de42 |
@@ -841,7 +841,7 @@ remote_ra_get_rsc_info(lrm_state_t * lrm_state, const char *rsc_id)
|
|
|
60de42 |
|
|
|
60de42 |
info->id = strdup(rsc_id);
|
|
|
60de42 |
info->type = strdup(REMOTE_LRMD_RA);
|
|
|
60de42 |
- info->class = strdup("ocf");
|
|
|
60de42 |
+ info->class = strdup(PCMK_RESOURCE_CLASS_OCF);
|
|
|
60de42 |
info->provider = strdup("pacemaker");
|
|
|
60de42 |
}
|
|
|
60de42 |
|
|
|
60de42 |
diff --git a/fencing/main.c b/fencing/main.c
|
|
|
60de42 |
index 95a1408..e6eb087 100644
|
|
|
60de42 |
--- a/fencing/main.c
|
|
|
60de42 |
+++ b/fencing/main.c
|
|
|
60de42 |
@@ -455,7 +455,7 @@ remove_cib_device(xmlXPathObjectPtr xpathObj)
|
|
|
60de42 |
standard = crm_element_value(match, XML_AGENT_ATTR_CLASS);
|
|
|
60de42 |
}
|
|
|
60de42 |
|
|
|
60de42 |
- if (safe_str_neq(standard, "stonith")) {
|
|
|
60de42 |
+ if (safe_str_neq(standard, PCMK_RESOURCE_CLASS_STONITH)) {
|
|
|
60de42 |
continue;
|
|
|
60de42 |
}
|
|
|
60de42 |
|
|
|
60de42 |
@@ -630,7 +630,7 @@ static void cib_device_update(resource_t *rsc, pe_working_set_t *data_set)
|
|
|
60de42 |
|
|
|
60de42 |
/* We only care about STONITH resources. */
|
|
|
60de42 |
rclass = crm_element_value(rsc->xml, XML_AGENT_ATTR_CLASS);
|
|
|
60de42 |
- if(safe_str_neq(rclass, "stonith")) {
|
|
|
60de42 |
+ if (safe_str_neq(rclass, PCMK_RESOURCE_CLASS_STONITH)) {
|
|
|
60de42 |
return;
|
|
|
60de42 |
}
|
|
|
60de42 |
|
|
|
60de42 |
@@ -848,7 +848,7 @@ update_cib_stonith_devices_v1(const char *event, xmlNode * msg)
|
|
|
60de42 |
rsc_id = crm_element_value(match, XML_ATTR_ID);
|
|
|
60de42 |
standard = crm_element_value(match, XML_AGENT_ATTR_CLASS);
|
|
|
60de42 |
|
|
|
60de42 |
- if (safe_str_neq(standard, "stonith")) {
|
|
|
60de42 |
+ if (safe_str_neq(standard, PCMK_RESOURCE_CLASS_STONITH)) {
|
|
|
60de42 |
continue;
|
|
|
60de42 |
}
|
|
|
60de42 |
|
|
|
60de42 |
diff --git a/include/crm/services.h b/include/crm/services.h
|
|
|
60de42 |
index 28bb76a..e1fae9b 100644
|
|
|
60de42 |
--- a/include/crm/services.h
|
|
|
60de42 |
+++ b/include/crm/services.h
|
|
|
60de42 |
@@ -52,6 +52,15 @@ extern "C" {
|
|
|
60de42 |
# define SERVICE_SCRIPT "/sbin/service"
|
|
|
60de42 |
# endif
|
|
|
60de42 |
|
|
|
60de42 |
+/* Known resource classes */
|
|
|
60de42 |
+#define PCMK_RESOURCE_CLASS_OCF "ocf"
|
|
|
60de42 |
+#define PCMK_RESOURCE_CLASS_SERVICE "service"
|
|
|
60de42 |
+#define PCMK_RESOURCE_CLASS_LSB "lsb"
|
|
|
60de42 |
+#define PCMK_RESOURCE_CLASS_SYSTEMD "systemd"
|
|
|
60de42 |
+#define PCMK_RESOURCE_CLASS_UPSTART "upstart"
|
|
|
60de42 |
+#define PCMK_RESOURCE_CLASS_HB "heartbeat"
|
|
|
60de42 |
+#define PCMK_RESOURCE_CLASS_NAGIOS "nagios"
|
|
|
60de42 |
+#define PCMK_RESOURCE_CLASS_STONITH "stonith"
|
|
|
60de42 |
|
|
|
60de42 |
/* This is the string passed in the OCF_EXIT_REASON_PREFIX
|
|
|
60de42 |
* environment variable. The stderr output that occurs
|
|
|
60de42 |
diff --git a/lib/lrmd/lrmd_client.c b/lib/lrmd/lrmd_client.c
|
|
|
60de42 |
index e009078..64b66b1 100644
|
|
|
60de42 |
--- a/lib/lrmd/lrmd_client.c
|
|
|
60de42 |
+++ b/lib/lrmd/lrmd_client.c
|
|
|
60de42 |
@@ -1438,7 +1438,7 @@ lrmd_api_register_rsc(lrmd_t * lrmd,
|
|
|
60de42 |
if (!class || !type || !rsc_id) {
|
|
|
60de42 |
return -EINVAL;
|
|
|
60de42 |
}
|
|
|
60de42 |
- if (safe_str_eq(class, "ocf") && !provider) {
|
|
|
60de42 |
+ if (safe_str_eq(class, PCMK_RESOURCE_CLASS_OCF) && !provider) {
|
|
|
60de42 |
return -EINVAL;
|
|
|
60de42 |
}
|
|
|
60de42 |
|
|
|
60de42 |
@@ -1525,7 +1525,7 @@ lrmd_api_get_rsc_info(lrmd_t * lrmd, const char *rsc_id, enum lrmd_call_options
|
|
|
60de42 |
if (!class || !type) {
|
|
|
60de42 |
free_xml(output);
|
|
|
60de42 |
return NULL;
|
|
|
60de42 |
- } else if (safe_str_eq(class, "ocf") && !provider) {
|
|
|
60de42 |
+ } else if (safe_str_eq(class, PCMK_RESOURCE_CLASS_OCF) && !provider) {
|
|
|
60de42 |
free_xml(output);
|
|
|
60de42 |
return NULL;
|
|
|
60de42 |
}
|
|
|
60de42 |
@@ -1969,20 +1969,20 @@ lrmd_api_get_metadata(lrmd_t * lrmd,
|
|
|
60de42 |
return -EINVAL;
|
|
|
60de42 |
}
|
|
|
60de42 |
|
|
|
60de42 |
- if (safe_str_eq(class, "service")) {
|
|
|
60de42 |
+ if (safe_str_eq(class, PCMK_RESOURCE_CLASS_SERVICE)) {
|
|
|
60de42 |
class = resources_find_service_class(type);
|
|
|
60de42 |
}
|
|
|
60de42 |
|
|
|
60de42 |
- if (safe_str_eq(class, "stonith")) {
|
|
|
60de42 |
+ if (safe_str_eq(class, PCMK_RESOURCE_CLASS_STONITH)) {
|
|
|
60de42 |
return stonith_get_metadata(provider, type, output);
|
|
|
60de42 |
- } else if (safe_str_eq(class, "lsb")) {
|
|
|
60de42 |
+ } else if (safe_str_eq(class, PCMK_RESOURCE_CLASS_LSB)) {
|
|
|
60de42 |
return lsb_get_metadata(type, output);
|
|
|
60de42 |
#if SUPPORT_NAGIOS
|
|
|
60de42 |
- } else if (safe_str_eq(class, "nagios")) {
|
|
|
60de42 |
+ } else if (safe_str_eq(class, PCMK_RESOURCE_CLASS_NAGIOS)) {
|
|
|
60de42 |
return nagios_get_metadata(type, output);
|
|
|
60de42 |
#endif
|
|
|
60de42 |
#if SUPPORT_HEARTBEAT
|
|
|
60de42 |
- } else if (safe_str_eq(class, "heartbeat")) {
|
|
|
60de42 |
+ } else if (safe_str_eq(class, PCMK_RESOURCE_CLASS_HB)) {
|
|
|
60de42 |
return heartbeat_get_metadata(type, output);
|
|
|
60de42 |
#endif
|
|
|
60de42 |
}
|
|
|
60de42 |
@@ -2073,7 +2073,7 @@ lrmd_api_list_agents(lrmd_t * lrmd, lrmd_list_t ** resources, const char *class,
|
|
|
60de42 |
{
|
|
|
60de42 |
int rc = 0;
|
|
|
60de42 |
|
|
|
60de42 |
- if (safe_str_eq(class, "stonith")) {
|
|
|
60de42 |
+ if (safe_str_eq(class, PCMK_RESOURCE_CLASS_STONITH)) {
|
|
|
60de42 |
rc += list_stonith_agents(resources);
|
|
|
60de42 |
|
|
|
60de42 |
} else {
|
|
|
60de42 |
@@ -2124,11 +2124,12 @@ lrmd_api_list_ocf_providers(lrmd_t * lrmd, const char *agent, lrmd_list_t ** pro
|
|
|
60de42 |
GList *ocf_providers = NULL;
|
|
|
60de42 |
GListPtr gIter = NULL;
|
|
|
60de42 |
|
|
|
60de42 |
- ocf_providers = resources_list_providers("ocf");
|
|
|
60de42 |
+ ocf_providers = resources_list_providers(PCMK_RESOURCE_CLASS_OCF);
|
|
|
60de42 |
|
|
|
60de42 |
for (gIter = ocf_providers; gIter != NULL; gIter = gIter->next) {
|
|
|
60de42 |
provider = gIter->data;
|
|
|
60de42 |
- if (!agent || does_provider_have_agent(agent, provider, "ocf")) {
|
|
|
60de42 |
+ if (!agent || does_provider_have_agent(agent, provider,
|
|
|
60de42 |
+ PCMK_RESOURCE_CLASS_OCF)) {
|
|
|
60de42 |
*providers = lrmd_list_add(*providers, (const char *)gIter->data);
|
|
|
60de42 |
rc++;
|
|
|
60de42 |
}
|
|
|
60de42 |
@@ -2153,7 +2154,7 @@ lrmd_api_list_standards(lrmd_t * lrmd, lrmd_list_t ** supported)
|
|
|
60de42 |
}
|
|
|
60de42 |
|
|
|
60de42 |
if (list_stonith_agents(NULL) > 0) {
|
|
|
60de42 |
- *supported = lrmd_list_add(*supported, "stonith");
|
|
|
60de42 |
+ *supported = lrmd_list_add(*supported, PCMK_RESOURCE_CLASS_STONITH);
|
|
|
60de42 |
rc++;
|
|
|
60de42 |
}
|
|
|
60de42 |
|
|
|
60de42 |
diff --git a/lib/pengine/complex.c b/lib/pengine/complex.c
|
|
|
60de42 |
index 7fe622f..a83929d 100644
|
|
|
60de42 |
--- a/lib/pengine/complex.c
|
|
|
60de42 |
+++ b/lib/pengine/complex.c
|
|
|
60de42 |
@@ -651,7 +651,7 @@ common_unpack(xmlNode * xml_obj, resource_t ** rsc,
|
|
|
60de42 |
}
|
|
|
60de42 |
}
|
|
|
60de42 |
|
|
|
60de42 |
- if (safe_str_eq(rclass, "stonith")) {
|
|
|
60de42 |
+ if (safe_str_eq(rclass, PCMK_RESOURCE_CLASS_STONITH)) {
|
|
|
60de42 |
set_bit(data_set->flags, pe_flag_have_stonith_resource);
|
|
|
60de42 |
set_bit((*rsc)->flags, pe_rsc_fence_device);
|
|
|
60de42 |
}
|
|
|
60de42 |
diff --git a/lib/pengine/native.c b/lib/pengine/native.c
|
|
|
60de42 |
index 11febf4..5f3cfc3 100644
|
|
|
60de42 |
--- a/lib/pengine/native.c
|
|
|
60de42 |
+++ b/lib/pengine/native.c
|
|
|
60de42 |
@@ -136,14 +136,14 @@ native_unpack(resource_t * rsc, pe_working_set_t * data_set)
|
|
|
60de42 |
|
|
|
60de42 |
if (is_set(rsc->flags, pe_rsc_unique) && rsc->parent) {
|
|
|
60de42 |
|
|
|
60de42 |
- if (safe_str_eq(class, "lsb")) {
|
|
|
60de42 |
+ if (safe_str_eq(class, PCMK_RESOURCE_CLASS_LSB)) {
|
|
|
60de42 |
resource_t *top = uber_parent(rsc);
|
|
|
60de42 |
|
|
|
60de42 |
force_non_unique_clone(top, rsc->id, data_set);
|
|
|
60de42 |
}
|
|
|
60de42 |
}
|
|
|
60de42 |
|
|
|
60de42 |
- if (safe_str_eq(class, "ocf") == FALSE) {
|
|
|
60de42 |
+ if (safe_str_eq(class, PCMK_RESOURCE_CLASS_OCF) == FALSE) {
|
|
|
60de42 |
const char *stateful = g_hash_table_lookup(parent->meta, "stateful");
|
|
|
60de42 |
|
|
|
60de42 |
if (safe_str_eq(stateful, XML_BOOLEAN_TRUE)) {
|
|
|
60de42 |
@@ -533,7 +533,7 @@ native_print(resource_t * rsc, const char *pre_text, long options, void *print_d
|
|
|
60de42 |
}
|
|
|
60de42 |
offset += snprintf(buffer + offset, LINE_MAX - offset, "%s", rsc_printable_id(rsc));
|
|
|
60de42 |
offset += snprintf(buffer + offset, LINE_MAX - offset, "\t(%s", class);
|
|
|
60de42 |
- if (safe_str_eq(class, "ocf")) {
|
|
|
60de42 |
+ if (safe_str_eq(class, PCMK_RESOURCE_CLASS_OCF)) {
|
|
|
60de42 |
const char *prov = crm_element_value(rsc->xml, XML_AGENT_ATTR_PROVIDER);
|
|
|
60de42 |
offset += snprintf(buffer + offset, LINE_MAX - offset, "::%s", prov);
|
|
|
60de42 |
}
|
|
|
60de42 |
@@ -799,7 +799,7 @@ get_rscs_brief(GListPtr rsc_list, GHashTable * rsc_table, GHashTable * active_ta
|
|
|
60de42 |
}
|
|
|
60de42 |
|
|
|
60de42 |
offset += snprintf(buffer + offset, LINE_MAX - offset, "%s", class);
|
|
|
60de42 |
- if (safe_str_eq(class, "ocf")) {
|
|
|
60de42 |
+ if (safe_str_eq(class, PCMK_RESOURCE_CLASS_OCF)) {
|
|
|
60de42 |
const char *prov = crm_element_value(rsc->xml, XML_AGENT_ATTR_PROVIDER);
|
|
|
60de42 |
offset += snprintf(buffer + offset, LINE_MAX - offset, "::%s", prov);
|
|
|
60de42 |
}
|
|
|
60de42 |
diff --git a/lib/pengine/remote.c b/lib/pengine/remote.c
|
|
|
60de42 |
index e8d9bab..c5a3eec 100644
|
|
|
60de42 |
--- a/lib/pengine/remote.c
|
|
|
60de42 |
+++ b/lib/pengine/remote.c
|
|
|
60de42 |
@@ -94,7 +94,8 @@ xml_contains_remote_node(xmlNode *xml)
|
|
|
60de42 |
const char *provider = crm_element_value(xml, XML_AGENT_ATTR_PROVIDER);
|
|
|
60de42 |
const char *agent = crm_element_value(xml, XML_ATTR_TYPE);
|
|
|
60de42 |
|
|
|
60de42 |
- if (safe_str_eq(agent, "remote") && safe_str_eq(provider, "pacemaker") && safe_str_eq(class, "ocf")) {
|
|
|
60de42 |
+ if (safe_str_eq(agent, "remote") && safe_str_eq(provider, "pacemaker")
|
|
|
60de42 |
+ && safe_str_eq(class, PCMK_RESOURCE_CLASS_OCF)) {
|
|
|
60de42 |
return TRUE;
|
|
|
60de42 |
}
|
|
|
60de42 |
return FALSE;
|
|
|
60de42 |
diff --git a/lib/pengine/unpack.c b/lib/pengine/unpack.c
|
|
|
60de42 |
index e0a3452..e6a8f58 100644
|
|
|
60de42 |
--- a/lib/pengine/unpack.c
|
|
|
60de42 |
+++ b/lib/pengine/unpack.c
|
|
|
60de42 |
@@ -422,7 +422,7 @@ expand_remote_rsc_meta(xmlNode *xml_obj, xmlNode *parent, GHashTable **rsc_name_
|
|
|
60de42 |
xml_rsc = create_xml_node(parent, XML_CIB_TAG_RESOURCE);
|
|
|
60de42 |
|
|
|
60de42 |
crm_xml_add(xml_rsc, XML_ATTR_ID, remote_name);
|
|
|
60de42 |
- crm_xml_add(xml_rsc, XML_AGENT_ATTR_CLASS, "ocf");
|
|
|
60de42 |
+ crm_xml_add(xml_rsc, XML_AGENT_ATTR_CLASS, PCMK_RESOURCE_CLASS_OCF);
|
|
|
60de42 |
crm_xml_add(xml_rsc, XML_AGENT_ATTR_PROVIDER, "pacemaker");
|
|
|
60de42 |
crm_xml_add(xml_rsc, XML_ATTR_TYPE, "remote");
|
|
|
60de42 |
|
|
|
60de42 |
diff --git a/lib/services/services.c b/lib/services/services.c
|
|
|
60de42 |
index 3ffaeb6..52d3b55 100644
|
|
|
60de42 |
--- a/lib/services/services.c
|
|
|
60de42 |
+++ b/lib/services/services.c
|
|
|
60de42 |
@@ -51,7 +51,8 @@ static void handle_blocked_ops(void);
|
|
|
60de42 |
svc_action_t *
|
|
|
60de42 |
services_action_create(const char *name, const char *action, int interval, int timeout)
|
|
|
60de42 |
{
|
|
|
60de42 |
- return resources_action_create(name, "lsb", NULL, name, action, interval, timeout, NULL, 0);
|
|
|
60de42 |
+ return resources_action_create(name, PCMK_RESOURCE_CLASS_LSB, NULL, name,
|
|
|
60de42 |
+ action, interval, timeout, NULL, 0);
|
|
|
60de42 |
}
|
|
|
60de42 |
|
|
|
60de42 |
const char *
|
|
|
60de42 |
@@ -70,20 +71,20 @@ resources_find_service_class(const char *agent)
|
|
|
60de42 |
rc = asprintf(&path, "%s/%s", LSB_ROOT_DIR, agent);
|
|
|
60de42 |
if (rc > 0 && stat(path, &st) == 0) {
|
|
|
60de42 |
free(path);
|
|
|
60de42 |
- return "lsb";
|
|
|
60de42 |
+ return PCMK_RESOURCE_CLASS_LSB;
|
|
|
60de42 |
}
|
|
|
60de42 |
free(path);
|
|
|
60de42 |
#endif
|
|
|
60de42 |
|
|
|
60de42 |
#if SUPPORT_SYSTEMD
|
|
|
60de42 |
if (systemd_unit_exists(agent)) {
|
|
|
60de42 |
- return "systemd";
|
|
|
60de42 |
+ return PCMK_RESOURCE_CLASS_SYSTEMD;
|
|
|
60de42 |
}
|
|
|
60de42 |
#endif
|
|
|
60de42 |
|
|
|
60de42 |
#if SUPPORT_UPSTART
|
|
|
60de42 |
if (upstart_job_exists(agent)) {
|
|
|
60de42 |
- return "upstart";
|
|
|
60de42 |
+ return PCMK_RESOURCE_CLASS_UPSTART;
|
|
|
60de42 |
}
|
|
|
60de42 |
#endif
|
|
|
60de42 |
return NULL;
|
|
|
60de42 |
@@ -100,8 +101,8 @@ resources_find_service_class(const char *agent)
|
|
|
60de42 |
static inline gboolean
|
|
|
60de42 |
inflight_systemd_or_upstart(svc_action_t *op)
|
|
|
60de42 |
{
|
|
|
60de42 |
- return (safe_str_eq(op->standard, "systemd")
|
|
|
60de42 |
- || safe_str_eq(op->standard, "upstart"))
|
|
|
60de42 |
+ return (safe_str_eq(op->standard, PCMK_RESOURCE_CLASS_SYSTEMD)
|
|
|
60de42 |
+ || safe_str_eq(op->standard, PCMK_RESOURCE_CLASS_UPSTART))
|
|
|
60de42 |
&& (g_list_find(inflight_ops, op) != NULL);
|
|
|
60de42 |
}
|
|
|
60de42 |
|
|
|
60de42 |
@@ -122,7 +123,7 @@ expand_resource_class(const char *rsc, const char *standard, const char *agent)
|
|
|
60de42 |
{
|
|
|
60de42 |
char *expanded_class = NULL;
|
|
|
60de42 |
|
|
|
60de42 |
- if (strcasecmp(standard, "service") == 0) {
|
|
|
60de42 |
+ if (strcasecmp(standard, PCMK_RESOURCE_CLASS_SERVICE) == 0) {
|
|
|
60de42 |
const char *found_class = resources_find_service_class(agent);
|
|
|
60de42 |
|
|
|
60de42 |
if (found_class) {
|
|
|
60de42 |
@@ -131,7 +132,7 @@ expand_resource_class(const char *rsc, const char *standard, const char *agent)
|
|
|
60de42 |
} else {
|
|
|
60de42 |
crm_info("Assuming resource class lsb for agent %s for %s",
|
|
|
60de42 |
agent, rsc);
|
|
|
60de42 |
- expanded_class = strdup("lsb");
|
|
|
60de42 |
+ expanded_class = strdup(PCMK_RESOURCE_CLASS_LSB);
|
|
|
60de42 |
}
|
|
|
60de42 |
} else {
|
|
|
60de42 |
expanded_class = strdup(standard);
|
|
|
60de42 |
@@ -162,7 +163,8 @@ resources_action_create(const char *name, const char *standard, const char *prov
|
|
|
60de42 |
goto return_error;
|
|
|
60de42 |
}
|
|
|
60de42 |
|
|
|
60de42 |
- if (!strcasecmp(standard, "ocf") && crm_strlen_zero(provider)) {
|
|
|
60de42 |
+ if (!strcasecmp(standard, PCMK_RESOURCE_CLASS_OCF)
|
|
|
60de42 |
+ && crm_strlen_zero(provider)) {
|
|
|
60de42 |
crm_err("Cannot create OCF operation for %s without provider", name);
|
|
|
60de42 |
goto return_error;
|
|
|
60de42 |
}
|
|
|
60de42 |
@@ -194,14 +196,14 @@ resources_action_create(const char *name, const char *standard, const char *prov
|
|
|
60de42 |
|
|
|
60de42 |
if (safe_str_eq(action, "monitor") && (
|
|
|
60de42 |
#if SUPPORT_HEARTBEAT
|
|
|
60de42 |
- safe_str_eq(op->standard, "heartbeat") ||
|
|
|
60de42 |
+ safe_str_eq(op->standard, PCMK_RESOURCE_CLASS_HB) ||
|
|
|
60de42 |
#endif
|
|
|
60de42 |
- safe_str_eq(op->standard, "lsb"))) {
|
|
|
60de42 |
+ safe_str_eq(op->standard, PCMK_RESOURCE_CLASS_LSB))) {
|
|
|
60de42 |
action = "status";
|
|
|
60de42 |
}
|
|
|
60de42 |
op->action = strdup(action);
|
|
|
60de42 |
|
|
|
60de42 |
- if (strcasecmp(op->standard, "ocf") == 0) {
|
|
|
60de42 |
+ if (strcasecmp(op->standard, PCMK_RESOURCE_CLASS_OCF) == 0) {
|
|
|
60de42 |
op->provider = strdup(provider);
|
|
|
60de42 |
op->params = params;
|
|
|
60de42 |
params = NULL;
|
|
|
60de42 |
@@ -213,7 +215,7 @@ resources_action_create(const char *name, const char *standard, const char *prov
|
|
|
60de42 |
op->opaque->args[0] = strdup(op->opaque->exec);
|
|
|
60de42 |
op->opaque->args[1] = strdup(action);
|
|
|
60de42 |
|
|
|
60de42 |
- } else if (strcasecmp(op->standard, "lsb") == 0) {
|
|
|
60de42 |
+ } else if (strcasecmp(op->standard, PCMK_RESOURCE_CLASS_LSB) == 0) {
|
|
|
60de42 |
if (op->agent[0] == '/') {
|
|
|
60de42 |
/* if given an absolute path, use that instead
|
|
|
60de42 |
* of tacking on the LSB_ROOT_DIR path to the front */
|
|
|
60de42 |
@@ -226,7 +228,7 @@ resources_action_create(const char *name, const char *standard, const char *prov
|
|
|
60de42 |
op->opaque->args[1] = strdup(op->action);
|
|
|
60de42 |
op->opaque->args[2] = NULL;
|
|
|
60de42 |
#if SUPPORT_HEARTBEAT
|
|
|
60de42 |
- } else if (strcasecmp(op->standard, "heartbeat") == 0) {
|
|
|
60de42 |
+ } else if (strcasecmp(op->standard, PCMK_RESOURCE_CLASS_HB) == 0) {
|
|
|
60de42 |
int index;
|
|
|
60de42 |
int param_num;
|
|
|
60de42 |
char buf_tmp[20];
|
|
|
60de42 |
@@ -262,15 +264,15 @@ resources_action_create(const char *name, const char *standard, const char *prov
|
|
|
60de42 |
op->opaque->args[param_num] = NULL;
|
|
|
60de42 |
#endif
|
|
|
60de42 |
#if SUPPORT_SYSTEMD
|
|
|
60de42 |
- } else if (strcasecmp(op->standard, "systemd") == 0) {
|
|
|
60de42 |
+ } else if (strcasecmp(op->standard, PCMK_RESOURCE_CLASS_SYSTEMD) == 0) {
|
|
|
60de42 |
op->opaque->exec = strdup("systemd-dbus");
|
|
|
60de42 |
#endif
|
|
|
60de42 |
#if SUPPORT_UPSTART
|
|
|
60de42 |
- } else if (strcasecmp(op->standard, "upstart") == 0) {
|
|
|
60de42 |
+ } else if (strcasecmp(op->standard, PCMK_RESOURCE_CLASS_UPSTART) == 0) {
|
|
|
60de42 |
op->opaque->exec = strdup("upstart-dbus");
|
|
|
60de42 |
#endif
|
|
|
60de42 |
#if SUPPORT_NAGIOS
|
|
|
60de42 |
- } else if (strcasecmp(op->standard, "nagios") == 0) {
|
|
|
60de42 |
+ } else if (strcasecmp(op->standard, PCMK_RESOURCE_CLASS_NAGIOS) == 0) {
|
|
|
60de42 |
int index = 0;
|
|
|
60de42 |
|
|
|
60de42 |
if (op->agent[0] == '/') {
|
|
|
60de42 |
@@ -637,11 +639,13 @@ inline static gboolean
|
|
|
60de42 |
action_exec_helper(svc_action_t * op)
|
|
|
60de42 |
{
|
|
|
60de42 |
/* Whether a/synchronous must be decided (op->synchronous) beforehand. */
|
|
|
60de42 |
- if (op->standard && strcasecmp(op->standard, "upstart") == 0) {
|
|
|
60de42 |
+ if (op->standard
|
|
|
60de42 |
+ && (strcasecmp(op->standard, PCMK_RESOURCE_CLASS_UPSTART) == 0)) {
|
|
|
60de42 |
#if SUPPORT_UPSTART
|
|
|
60de42 |
return upstart_job_exec(op);
|
|
|
60de42 |
#endif
|
|
|
60de42 |
- } else if (op->standard && strcasecmp(op->standard, "systemd") == 0) {
|
|
|
60de42 |
+ } else if (op->standard && strcasecmp(op->standard,
|
|
|
60de42 |
+ PCMK_RESOURCE_CLASS_SYSTEMD) == 0) {
|
|
|
60de42 |
#if SUPPORT_SYSTEMD
|
|
|
60de42 |
return systemd_unit_exec(op);
|
|
|
60de42 |
#endif
|
|
|
60de42 |
@@ -803,7 +807,7 @@ get_directory_list(const char *root, gboolean files, gboolean executable)
|
|
|
60de42 |
GList *
|
|
|
60de42 |
services_list(void)
|
|
|
60de42 |
{
|
|
|
60de42 |
- return resources_list_agents("lsb", NULL);
|
|
|
60de42 |
+ return resources_list_agents(PCMK_RESOURCE_CLASS_LSB, NULL);
|
|
|
60de42 |
}
|
|
|
60de42 |
|
|
|
60de42 |
#if SUPPORT_HEARTBEAT
|
|
|
60de42 |
@@ -820,14 +824,15 @@ resources_list_standards(void)
|
|
|
60de42 |
GList *standards = NULL;
|
|
|
60de42 |
GList *agents = NULL;
|
|
|
60de42 |
|
|
|
60de42 |
- standards = g_list_append(standards, strdup("ocf"));
|
|
|
60de42 |
- standards = g_list_append(standards, strdup("lsb"));
|
|
|
60de42 |
- standards = g_list_append(standards, strdup("service"));
|
|
|
60de42 |
+ standards = g_list_append(standards, strdup(PCMK_RESOURCE_CLASS_OCF));
|
|
|
60de42 |
+ standards = g_list_append(standards, strdup(PCMK_RESOURCE_CLASS_LSB));
|
|
|
60de42 |
+ standards = g_list_append(standards, strdup(PCMK_RESOURCE_CLASS_SERVICE));
|
|
|
60de42 |
|
|
|
60de42 |
#if SUPPORT_SYSTEMD
|
|
|
60de42 |
agents = systemd_unit_listall();
|
|
|
60de42 |
if (agents) {
|
|
|
60de42 |
- standards = g_list_append(standards, strdup("systemd"));
|
|
|
60de42 |
+ standards = g_list_append(standards,
|
|
|
60de42 |
+ strdup(PCMK_RESOURCE_CLASS_SYSTEMD));
|
|
|
60de42 |
g_list_free_full(agents, free);
|
|
|
60de42 |
}
|
|
|
60de42 |
#endif
|
|
|
60de42 |
@@ -835,7 +840,8 @@ resources_list_standards(void)
|
|
|
60de42 |
#if SUPPORT_UPSTART
|
|
|
60de42 |
agents = upstart_job_listall();
|
|
|
60de42 |
if (agents) {
|
|
|
60de42 |
- standards = g_list_append(standards, strdup("upstart"));
|
|
|
60de42 |
+ standards = g_list_append(standards,
|
|
|
60de42 |
+ strdup(PCMK_RESOURCE_CLASS_UPSTART));
|
|
|
60de42 |
g_list_free_full(agents, free);
|
|
|
60de42 |
}
|
|
|
60de42 |
#endif
|
|
|
60de42 |
@@ -843,13 +849,14 @@ resources_list_standards(void)
|
|
|
60de42 |
#if SUPPORT_NAGIOS
|
|
|
60de42 |
agents = resources_os_list_nagios_agents();
|
|
|
60de42 |
if (agents) {
|
|
|
60de42 |
- standards = g_list_append(standards, strdup("nagios"));
|
|
|
60de42 |
+ standards = g_list_append(standards,
|
|
|
60de42 |
+ strdup(PCMK_RESOURCE_CLASS_NAGIOS));
|
|
|
60de42 |
g_list_free_full(agents, free);
|
|
|
60de42 |
}
|
|
|
60de42 |
#endif
|
|
|
60de42 |
|
|
|
60de42 |
#if SUPPORT_HEARTBEAT
|
|
|
60de42 |
- standards = g_list_append(standards, strdup("heartbeat"));
|
|
|
60de42 |
+ standards = g_list_append(standards, strdup(PCMK_RESOURCE_CLASS_HB));
|
|
|
60de42 |
#endif
|
|
|
60de42 |
|
|
|
60de42 |
return standards;
|
|
|
60de42 |
@@ -858,7 +865,7 @@ resources_list_standards(void)
|
|
|
60de42 |
GList *
|
|
|
60de42 |
resources_list_providers(const char *standard)
|
|
|
60de42 |
{
|
|
|
60de42 |
- if (strcasecmp(standard, "ocf") == 0) {
|
|
|
60de42 |
+ if (strcasecmp(standard, PCMK_RESOURCE_CLASS_OCF) == 0) {
|
|
|
60de42 |
return resources_os_list_ocf_providers();
|
|
|
60de42 |
}
|
|
|
60de42 |
|
|
|
60de42 |
@@ -868,7 +875,9 @@ resources_list_providers(const char *standard)
|
|
|
60de42 |
GList *
|
|
|
60de42 |
resources_list_agents(const char *standard, const char *provider)
|
|
|
60de42 |
{
|
|
|
60de42 |
- if (standard == NULL || strcasecmp(standard, "service") == 0) {
|
|
|
60de42 |
+ if ((standard == NULL)
|
|
|
60de42 |
+ || (strcasecmp(standard, PCMK_RESOURCE_CLASS_SERVICE) == 0)) {
|
|
|
60de42 |
+
|
|
|
60de42 |
GList *tmp1;
|
|
|
60de42 |
GList *tmp2;
|
|
|
60de42 |
GList *result = resources_os_list_lsb_agents();
|
|
|
60de42 |
@@ -898,24 +907,24 @@ resources_list_agents(const char *standard, const char *provider)
|
|
|
60de42 |
|
|
|
60de42 |
return result;
|
|
|
60de42 |
|
|
|
60de42 |
- } else if (strcasecmp(standard, "ocf") == 0) {
|
|
|
60de42 |
+ } else if (strcasecmp(standard, PCMK_RESOURCE_CLASS_OCF) == 0) {
|
|
|
60de42 |
return resources_os_list_ocf_agents(provider);
|
|
|
60de42 |
- } else if (strcasecmp(standard, "lsb") == 0) {
|
|
|
60de42 |
+ } else if (strcasecmp(standard, PCMK_RESOURCE_CLASS_LSB) == 0) {
|
|
|
60de42 |
return resources_os_list_lsb_agents();
|
|
|
60de42 |
#if SUPPORT_HEARTBEAT
|
|
|
60de42 |
- } else if (strcasecmp(standard, "heartbeat") == 0) {
|
|
|
60de42 |
+ } else if (strcasecmp(standard, PCMK_RESOURCE_CLASS_HB) == 0) {
|
|
|
60de42 |
return resources_os_list_hb_agents();
|
|
|
60de42 |
#endif
|
|
|
60de42 |
#if SUPPORT_SYSTEMD
|
|
|
60de42 |
- } else if (strcasecmp(standard, "systemd") == 0) {
|
|
|
60de42 |
+ } else if (strcasecmp(standard, PCMK_RESOURCE_CLASS_SYSTEMD) == 0) {
|
|
|
60de42 |
return systemd_unit_listall();
|
|
|
60de42 |
#endif
|
|
|
60de42 |
#if SUPPORT_UPSTART
|
|
|
60de42 |
- } else if (strcasecmp(standard, "upstart") == 0) {
|
|
|
60de42 |
+ } else if (strcasecmp(standard, PCMK_RESOURCE_CLASS_UPSTART) == 0) {
|
|
|
60de42 |
return upstart_job_listall();
|
|
|
60de42 |
#endif
|
|
|
60de42 |
#if SUPPORT_NAGIOS
|
|
|
60de42 |
- } else if (strcasecmp(standard, "nagios") == 0) {
|
|
|
60de42 |
+ } else if (strcasecmp(standard, PCMK_RESOURCE_CLASS_NAGIOS) == 0) {
|
|
|
60de42 |
return resources_os_list_nagios_agents();
|
|
|
60de42 |
#endif
|
|
|
60de42 |
}
|
|
|
60de42 |
diff --git a/lib/services/services_linux.c b/lib/services/services_linux.c
|
|
|
60de42 |
index 1fe3ec1..c2ac43d 100644
|
|
|
60de42 |
--- a/lib/services/services_linux.c
|
|
|
60de42 |
+++ b/lib/services/services_linux.c
|
|
|
60de42 |
@@ -177,7 +177,8 @@ set_ocf_env_with_prefix(gpointer key, gpointer value, gpointer user_data)
|
|
|
60de42 |
static void
|
|
|
60de42 |
add_OCF_env_vars(svc_action_t * op)
|
|
|
60de42 |
{
|
|
|
60de42 |
- if (!op->standard || strcasecmp("ocf", op->standard) != 0) {
|
|
|
60de42 |
+ if ((op->standard == NULL)
|
|
|
60de42 |
+ || (strcasecmp(PCMK_RESOURCE_CLASS_OCF, op->standard) != 0)) {
|
|
|
60de42 |
return;
|
|
|
60de42 |
}
|
|
|
60de42 |
|
|
|
60de42 |
@@ -338,13 +339,15 @@ services_handle_exec_error(svc_action_t * op, int error)
|
|
|
60de42 |
int rc_not_installed, rc_insufficient_priv, rc_exec_error;
|
|
|
60de42 |
|
|
|
60de42 |
/* Mimic the return codes for each standard as that's what we'll convert back from in get_uniform_rc() */
|
|
|
60de42 |
- if (safe_str_eq(op->standard, "lsb") && safe_str_eq(op->action, "status")) {
|
|
|
60de42 |
+ if (safe_str_eq(op->standard, PCMK_RESOURCE_CLASS_LSB)
|
|
|
60de42 |
+ && safe_str_eq(op->action, "status")) {
|
|
|
60de42 |
+
|
|
|
60de42 |
rc_not_installed = PCMK_LSB_STATUS_NOT_INSTALLED;
|
|
|
60de42 |
rc_insufficient_priv = PCMK_LSB_STATUS_INSUFFICIENT_PRIV;
|
|
|
60de42 |
rc_exec_error = PCMK_LSB_STATUS_UNKNOWN;
|
|
|
60de42 |
|
|
|
60de42 |
#if SUPPORT_NAGIOS
|
|
|
60de42 |
- } else if (safe_str_eq(op->standard, "nagios")) {
|
|
|
60de42 |
+ } else if (safe_str_eq(op->standard, PCMK_RESOURCE_CLASS_NAGIOS)) {
|
|
|
60de42 |
rc_not_installed = NAGIOS_NOT_INSTALLED;
|
|
|
60de42 |
rc_insufficient_priv = NAGIOS_INSUFFICIENT_PRIV;
|
|
|
60de42 |
rc_exec_error = PCMK_OCF_EXEC_ERROR;
|
|
|
60de42 |
diff --git a/lrmd/lrmd.c b/lrmd/lrmd.c
|
|
|
60de42 |
index 724edb7..5669d34 100644
|
|
|
60de42 |
--- a/lrmd/lrmd.c
|
|
|
60de42 |
+++ b/lrmd/lrmd.c
|
|
|
60de42 |
@@ -139,8 +139,9 @@ static const char *
|
|
|
60de42 |
normalize_action_name(lrmd_rsc_t * rsc, const char *action)
|
|
|
60de42 |
{
|
|
|
60de42 |
if (safe_str_eq(action, "monitor") &&
|
|
|
60de42 |
- (safe_str_eq(rsc->class, "lsb") ||
|
|
|
60de42 |
- safe_str_eq(rsc->class, "service") || safe_str_eq(rsc->class, "systemd"))) {
|
|
|
60de42 |
+ (safe_str_eq(rsc->class, PCMK_RESOURCE_CLASS_LSB) ||
|
|
|
60de42 |
+ safe_str_eq(rsc->class, PCMK_RESOURCE_CLASS_SERVICE)
|
|
|
60de42 |
+ || safe_str_eq(rsc->class, PCMK_RESOURCE_CLASS_SYSTEMD))) {
|
|
|
60de42 |
return "status";
|
|
|
60de42 |
}
|
|
|
60de42 |
return action;
|
|
|
60de42 |
@@ -435,7 +436,7 @@ merge_dup:
|
|
|
60de42 |
cmd->userdata_str = NULL;
|
|
|
60de42 |
dup->call_id = cmd->call_id;
|
|
|
60de42 |
|
|
|
60de42 |
- if (safe_str_eq(rsc->class, "stonith")) {
|
|
|
60de42 |
+ if (safe_str_eq(rsc->class, PCMK_RESOURCE_CLASS_STONITH)) {
|
|
|
60de42 |
/* if we are waiting for the next interval, kick it off now */
|
|
|
60de42 |
if (dup_pending == TRUE) {
|
|
|
60de42 |
g_source_remove(cmd->stonith_recurring_id);
|
|
|
60de42 |
@@ -854,16 +855,16 @@ nagios2uniform_rc(const char *action, int rc)
|
|
|
60de42 |
static int
|
|
|
60de42 |
get_uniform_rc(const char *standard, const char *action, int rc)
|
|
|
60de42 |
{
|
|
|
60de42 |
- if (safe_str_eq(standard, "ocf")) {
|
|
|
60de42 |
+ if (safe_str_eq(standard, PCMK_RESOURCE_CLASS_OCF)) {
|
|
|
60de42 |
return ocf2uniform_rc(rc);
|
|
|
60de42 |
- } else if (safe_str_eq(standard, "stonith")) {
|
|
|
60de42 |
+ } else if (safe_str_eq(standard, PCMK_RESOURCE_CLASS_STONITH)) {
|
|
|
60de42 |
return stonith2uniform_rc(action, rc);
|
|
|
60de42 |
- } else if (safe_str_eq(standard, "systemd")) {
|
|
|
60de42 |
+ } else if (safe_str_eq(standard, PCMK_RESOURCE_CLASS_SYSTEMD)) {
|
|
|
60de42 |
return rc;
|
|
|
60de42 |
- } else if (safe_str_eq(standard, "upstart")) {
|
|
|
60de42 |
+ } else if (safe_str_eq(standard, PCMK_RESOURCE_CLASS_UPSTART)) {
|
|
|
60de42 |
return rc;
|
|
|
60de42 |
#if SUPPORT_NAGIOS
|
|
|
60de42 |
- } else if (safe_str_eq(standard, "nagios")) {
|
|
|
60de42 |
+ } else if (safe_str_eq(standard, PCMK_RESOURCE_CLASS_NAGIOS)) {
|
|
|
60de42 |
return nagios2uniform_rc(action, rc);
|
|
|
60de42 |
#endif
|
|
|
60de42 |
} else {
|
|
|
60de42 |
@@ -876,7 +877,7 @@ action_get_uniform_rc(svc_action_t * action)
|
|
|
60de42 |
{
|
|
|
60de42 |
lrmd_cmd_t *cmd = action->cb_data;
|
|
|
60de42 |
#if SUPPORT_HEARTBEAT
|
|
|
60de42 |
- if (safe_str_eq(action->standard, "heartbeat")) {
|
|
|
60de42 |
+ if (safe_str_eq(action->standard, PCMK_RESOURCE_CLASS_HB)) {
|
|
|
60de42 |
return hb2uniform_rc(cmd->action, action->rc, action->stdout_data);
|
|
|
60de42 |
}
|
|
|
60de42 |
#endif
|
|
|
60de42 |
@@ -991,13 +992,13 @@ action_complete(svc_action_t * action)
|
|
|
60de42 |
cmd->lrmd_op_status = action->status;
|
|
|
60de42 |
rsc = cmd->rsc_id ? g_hash_table_lookup(rsc_list, cmd->rsc_id) : NULL;
|
|
|
60de42 |
|
|
|
60de42 |
- if(rsc && safe_str_eq(rsc->class, "service")) {
|
|
|
60de42 |
+ if (rsc && safe_str_eq(rsc->class, PCMK_RESOURCE_CLASS_SERVICE)) {
|
|
|
60de42 |
rclass = resources_find_service_class(rsc->class);
|
|
|
60de42 |
} else if(rsc) {
|
|
|
60de42 |
rclass = rsc->class;
|
|
|
60de42 |
}
|
|
|
60de42 |
|
|
|
60de42 |
- if (safe_str_eq(rclass, "systemd")) {
|
|
|
60de42 |
+ if (safe_str_eq(rclass, PCMK_RESOURCE_CLASS_SYSTEMD)) {
|
|
|
60de42 |
if(cmd->exec_rc == PCMK_OCF_OK && safe_str_eq(cmd->action, "start")) {
|
|
|
60de42 |
/* systemd I curse thee!
|
|
|
60de42 |
*
|
|
|
60de42 |
@@ -1042,7 +1043,7 @@ action_complete(svc_action_t * action)
|
|
|
60de42 |
}
|
|
|
60de42 |
|
|
|
60de42 |
#if SUPPORT_NAGIOS
|
|
|
60de42 |
- if (rsc && safe_str_eq(rsc->class, "nagios")) {
|
|
|
60de42 |
+ if (rsc && safe_str_eq(rsc->class, PCMK_RESOURCE_CLASS_NAGIOS)) {
|
|
|
60de42 |
if (safe_str_eq(cmd->action, "monitor") &&
|
|
|
60de42 |
cmd->interval == 0 && cmd->exec_rc == PCMK_OCF_OK) {
|
|
|
60de42 |
/* Successfully executed --version for the nagios plugin */
|
|
|
60de42 |
@@ -1123,7 +1124,7 @@ stonith_action_complete(lrmd_cmd_t * cmd, int rc)
|
|
|
60de42 |
int recurring = cmd->interval;
|
|
|
60de42 |
lrmd_rsc_t *rsc = NULL;
|
|
|
60de42 |
|
|
|
60de42 |
- cmd->exec_rc = get_uniform_rc("stonith", cmd->action, rc);
|
|
|
60de42 |
+ cmd->exec_rc = get_uniform_rc(PCMK_RESOURCE_CLASS_STONITH, cmd->action, rc);
|
|
|
60de42 |
|
|
|
60de42 |
rsc = g_hash_table_lookup(rsc_list, cmd->rsc_id);
|
|
|
60de42 |
|
|
|
60de42 |
@@ -1184,7 +1185,7 @@ stonith_connection_failed(void)
|
|
|
60de42 |
|
|
|
60de42 |
g_hash_table_iter_init(&iter, rsc_list);
|
|
|
60de42 |
while (g_hash_table_iter_next(&iter, (gpointer *) & key, (gpointer *) & rsc)) {
|
|
|
60de42 |
- if (safe_str_eq(rsc->class, "stonith")) {
|
|
|
60de42 |
+ if (safe_str_eq(rsc->class, PCMK_RESOURCE_CLASS_STONITH)) {
|
|
|
60de42 |
if (rsc->active) {
|
|
|
60de42 |
cmd_list = g_list_append(cmd_list, rsc->active);
|
|
|
60de42 |
}
|
|
|
60de42 |
@@ -1219,7 +1220,8 @@ lrmd_rsc_execute_stonith(lrmd_rsc_t * rsc, lrmd_cmd_t * cmd)
|
|
|
60de42 |
stonith_t *stonith_api = get_stonith_connection();
|
|
|
60de42 |
|
|
|
60de42 |
if (!stonith_api) {
|
|
|
60de42 |
- cmd->exec_rc = get_uniform_rc("stonith", cmd->action, -ENOTCONN);
|
|
|
60de42 |
+ cmd->exec_rc = get_uniform_rc(PCMK_RESOURCE_CLASS_STONITH, cmd->action,
|
|
|
60de42 |
+ -ENOTCONN);
|
|
|
60de42 |
cmd->lrmd_op_status = PCMK_LRM_OP_ERROR;
|
|
|
60de42 |
cmd_finalize(cmd, rsc);
|
|
|
60de42 |
return -EUNATCH;
|
|
|
60de42 |
@@ -1302,7 +1304,9 @@ lrmd_rsc_execute_service_lib(lrmd_rsc_t * rsc, lrmd_cmd_t * cmd)
|
|
|
60de42 |
|
|
|
60de42 |
#if SUPPORT_NAGIOS
|
|
|
60de42 |
/* Recurring operations are cancelled anyway for a stop operation */
|
|
|
60de42 |
- if (safe_str_eq(rsc->class, "nagios") && safe_str_eq(cmd->action, "stop")) {
|
|
|
60de42 |
+ if (safe_str_eq(rsc->class, PCMK_RESOURCE_CLASS_NAGIOS)
|
|
|
60de42 |
+ && safe_str_eq(cmd->action, "stop")) {
|
|
|
60de42 |
+
|
|
|
60de42 |
cmd->exec_rc = PCMK_OCF_OK;
|
|
|
60de42 |
goto exec_done;
|
|
|
60de42 |
}
|
|
|
60de42 |
@@ -1320,7 +1324,7 @@ lrmd_rsc_execute_service_lib(lrmd_rsc_t * rsc, lrmd_cmd_t * cmd)
|
|
|
60de42 |
if (cmd->isolation_wrapper) {
|
|
|
60de42 |
g_hash_table_remove(params_copy, "CRM_meta_isolation_wrapper");
|
|
|
60de42 |
action = resources_action_create(rsc->rsc_id,
|
|
|
60de42 |
- "ocf",
|
|
|
60de42 |
+ PCMK_RESOURCE_CLASS_OCF,
|
|
|
60de42 |
LRMD_ISOLATION_PROVIDER,
|
|
|
60de42 |
cmd->isolation_wrapper,
|
|
|
60de42 |
cmd->action, /*action will be normalized in wrapper*/
|
|
|
60de42 |
@@ -1417,7 +1421,7 @@ lrmd_rsc_execute(lrmd_rsc_t * rsc)
|
|
|
60de42 |
|
|
|
60de42 |
log_execute(cmd);
|
|
|
60de42 |
|
|
|
60de42 |
- if (safe_str_eq(rsc->class, "stonith")) {
|
|
|
60de42 |
+ if (safe_str_eq(rsc->class, PCMK_RESOURCE_CLASS_STONITH)) {
|
|
|
60de42 |
lrmd_rsc_execute_stonith(rsc, cmd);
|
|
|
60de42 |
} else {
|
|
|
60de42 |
lrmd_rsc_execute_service_lib(rsc, cmd);
|
|
|
60de42 |
@@ -1437,7 +1441,7 @@ free_rsc(gpointer data)
|
|
|
60de42 |
{
|
|
|
60de42 |
GListPtr gIter = NULL;
|
|
|
60de42 |
lrmd_rsc_t *rsc = data;
|
|
|
60de42 |
- int is_stonith = safe_str_eq(rsc->class, "stonith");
|
|
|
60de42 |
+ int is_stonith = safe_str_eq(rsc->class, PCMK_RESOURCE_CLASS_STONITH);
|
|
|
60de42 |
|
|
|
60de42 |
gIter = rsc->pending_ops;
|
|
|
60de42 |
while (gIter != NULL) {
|
|
|
60de42 |
@@ -1679,7 +1683,7 @@ cancel_op(const char *rsc_id, const char *action, int interval)
|
|
|
60de42 |
}
|
|
|
60de42 |
}
|
|
|
60de42 |
|
|
|
60de42 |
- if (safe_str_eq(rsc->class, "stonith")) {
|
|
|
60de42 |
+ if (safe_str_eq(rsc->class, PCMK_RESOURCE_CLASS_STONITH)) {
|
|
|
60de42 |
/* The service library does not handle stonith operations.
|
|
|
60de42 |
* We have to handle recurring stonith operations ourselves. */
|
|
|
60de42 |
for (gIter = rsc->recurring_ops; gIter != NULL; gIter = gIter->next) {
|
|
|
60de42 |
diff --git a/pengine/native.c b/pengine/native.c
|
|
|
60de42 |
index 0c972ea..52eba4f 100644
|
|
|
60de42 |
--- a/pengine/native.c
|
|
|
60de42 |
+++ b/pengine/native.c
|
|
|
60de42 |
@@ -2701,7 +2701,7 @@ native_create_probe(resource_t * rsc, node_t * node, action_t * complete,
|
|
|
60de42 |
if (is_remote_node(node)) {
|
|
|
60de42 |
const char *class = crm_element_value(rsc->xml, XML_AGENT_ATTR_CLASS);
|
|
|
60de42 |
|
|
|
60de42 |
- if (safe_str_eq(class, "stonith")) {
|
|
|
60de42 |
+ if (safe_str_eq(class, PCMK_RESOURCE_CLASS_STONITH)) {
|
|
|
60de42 |
pe_rsc_trace(rsc, "Skipping probe for %s on node %s, remote-nodes do not run stonith agents.", rsc->id, node->details->id);
|
|
|
60de42 |
return FALSE;
|
|
|
60de42 |
} else if (rsc_contains_remote_node(data_set, rsc)) {
|
|
|
60de42 |
diff --git a/tools/crm_resource_print.c b/tools/crm_resource_print.c
|
|
|
60de42 |
index 5e84723..65841e5 100644
|
|
|
60de42 |
--- a/tools/crm_resource_print.c
|
|
|
60de42 |
+++ b/tools/crm_resource_print.c
|
|
|
60de42 |
@@ -69,7 +69,7 @@ cli_resource_print_cts(resource_t * rsc)
|
|
|
60de42 |
const char *rprov = crm_element_value(rsc->xml, XML_AGENT_ATTR_PROVIDER);
|
|
|
60de42 |
const char *rclass = crm_element_value(rsc->xml, XML_AGENT_ATTR_CLASS);
|
|
|
60de42 |
|
|
|
60de42 |
- if (safe_str_eq(rclass, "stonith")) {
|
|
|
60de42 |
+ if (safe_str_eq(rclass, PCMK_RESOURCE_CLASS_STONITH)) {
|
|
|
60de42 |
xmlNode *op = NULL;
|
|
|
60de42 |
|
|
|
60de42 |
needs_quorum = FALSE;
|
|
|
60de42 |
diff --git a/tools/crm_resource_runtime.c b/tools/crm_resource_runtime.c
|
|
|
60de42 |
index 7a64bc9..61aabe9 100644
|
|
|
60de42 |
--- a/tools/crm_resource_runtime.c
|
|
|
60de42 |
+++ b/tools/crm_resource_runtime.c
|
|
|
60de42 |
@@ -1496,7 +1496,7 @@ cli_resource_execute(const char *rsc_id, const char *rsc_action, GHashTable *ove
|
|
|
60de42 |
rprov = crm_element_value(rsc->xml, XML_AGENT_ATTR_PROVIDER);
|
|
|
60de42 |
rtype = crm_element_value(rsc->xml, XML_ATTR_TYPE);
|
|
|
60de42 |
|
|
|
60de42 |
- if(safe_str_eq(rclass, "stonith")){
|
|
|
60de42 |
+ if (safe_str_eq(rclass, PCMK_RESOURCE_CLASS_STONITH)) {
|
|
|
60de42 |
CMD_ERR("Sorry, --%s doesn't support %s resources yet", rsc_action, rclass);
|
|
|
60de42 |
crm_exit(EOPNOTSUPP);
|
|
|
60de42 |
}
|
|
|
60de42 |
diff --git a/tools/fake_transition.c b/tools/fake_transition.c
|
|
|
60de42 |
index c45349f..6448c14 100644
|
|
|
60de42 |
--- a/tools/fake_transition.c
|
|
|
60de42 |
+++ b/tools/fake_transition.c
|
|
|
60de42 |
@@ -298,17 +298,18 @@ inject_resource(xmlNode * cib_node, const char *resource, const char *rclass, co
|
|
|
60de42 |
" Please supply the class and type to continue\n", resource, ID(cib_node));
|
|
|
60de42 |
return NULL;
|
|
|
60de42 |
|
|
|
60de42 |
- } else if (safe_str_neq(rclass, "ocf")
|
|
|
60de42 |
- && safe_str_neq(rclass, "stonith")
|
|
|
60de42 |
- && safe_str_neq(rclass, "heartbeat")
|
|
|
60de42 |
- && safe_str_neq(rclass, "service")
|
|
|
60de42 |
- && safe_str_neq(rclass, "upstart")
|
|
|
60de42 |
- && safe_str_neq(rclass, "systemd")
|
|
|
60de42 |
- && safe_str_neq(rclass, "lsb")) {
|
|
|
60de42 |
+ } else if (safe_str_neq(rclass, PCMK_RESOURCE_CLASS_OCF)
|
|
|
60de42 |
+ && safe_str_neq(rclass, PCMK_RESOURCE_CLASS_STONITH)
|
|
|
60de42 |
+ && safe_str_neq(rclass, PCMK_RESOURCE_CLASS_HB)
|
|
|
60de42 |
+ && safe_str_neq(rclass, PCMK_RESOURCE_CLASS_SERVICE)
|
|
|
60de42 |
+ && safe_str_neq(rclass, PCMK_RESOURCE_CLASS_UPSTART)
|
|
|
60de42 |
+ && safe_str_neq(rclass, PCMK_RESOURCE_CLASS_SYSTEMD)
|
|
|
60de42 |
+ && safe_str_neq(rclass, PCMK_RESOURCE_CLASS_LSB)) {
|
|
|
60de42 |
fprintf(stderr, "Invalid class for %s: %s\n", resource, rclass);
|
|
|
60de42 |
return NULL;
|
|
|
60de42 |
|
|
|
60de42 |
- } else if (safe_str_eq(rclass, "ocf") && rprovider == NULL) {
|
|
|
60de42 |
+ } else if (safe_str_eq(rclass, PCMK_RESOURCE_CLASS_OCF)
|
|
|
60de42 |
+ && rprovider == NULL) {
|
|
|
60de42 |
fprintf(stderr, "Please specify the provider for resource %s\n", resource);
|
|
|
60de42 |
return NULL;
|
|
|
60de42 |
}
|
|
|
60de42 |
--
|
|
|
60de42 |
1.8.3.1
|
|
|
60de42 |
|
|
|
60de42 |
|
|
|
60de42 |
From 1c534b5a773df5b62aeb8a46842d1e2d4d2266ef Mon Sep 17 00:00:00 2001
|
|
|
60de42 |
From: Ken Gaillot <kgaillot@redhat.com>
|
|
|
60de42 |
Date: Wed, 1 Mar 2017 15:04:35 -0600
|
|
|
60de42 |
Subject: [PATCH 10/10] Fix: libservices: ensure recurring actions table is
|
|
|
60de42 |
created before using
|
|
|
60de42 |
|
|
|
60de42 |
---
|
|
|
60de42 |
lib/services/services.c | 20 ++++++++++++++------
|
|
|
60de42 |
1 file changed, 14 insertions(+), 6 deletions(-)
|
|
|
60de42 |
|
|
|
60de42 |
diff --git a/lib/services/services.c b/lib/services/services.c
|
|
|
60de42 |
index 52d3b55..679f8e7 100644
|
|
|
60de42 |
--- a/lib/services/services.c
|
|
|
60de42 |
+++ b/lib/services/services.c
|
|
|
60de42 |
@@ -90,6 +90,15 @@ resources_find_service_class(const char *agent)
|
|
|
60de42 |
return NULL;
|
|
|
60de42 |
}
|
|
|
60de42 |
|
|
|
60de42 |
+static inline void
|
|
|
60de42 |
+init_recurring_actions(void)
|
|
|
60de42 |
+{
|
|
|
60de42 |
+ if (recurring_actions == NULL) {
|
|
|
60de42 |
+ recurring_actions = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
|
|
|
60de42 |
+ NULL);
|
|
|
60de42 |
+ }
|
|
|
60de42 |
+}
|
|
|
60de42 |
+
|
|
|
60de42 |
/*!
|
|
|
60de42 |
* \internal
|
|
|
60de42 |
* \brief Check whether op is in-flight systemd or upstart op
|
|
|
60de42 |
@@ -513,9 +522,11 @@ services_action_cancel(const char *name, const char *action, int interval)
|
|
|
60de42 |
{
|
|
|
60de42 |
gboolean cancelled = FALSE;
|
|
|
60de42 |
char *id = generate_op_key(name, action, interval);
|
|
|
60de42 |
- svc_action_t *op = g_hash_table_lookup(recurring_actions, id);
|
|
|
60de42 |
+ svc_action_t *op = NULL;
|
|
|
60de42 |
|
|
|
60de42 |
/* We can only cancel a recurring action */
|
|
|
60de42 |
+ init_recurring_actions();
|
|
|
60de42 |
+ op = g_hash_table_lookup(recurring_actions, id);
|
|
|
60de42 |
if (op == NULL) {
|
|
|
60de42 |
goto done;
|
|
|
60de42 |
}
|
|
|
60de42 |
@@ -575,6 +586,7 @@ services_action_kick(const char *name, const char *action, int interval /* ms */
|
|
|
60de42 |
svc_action_t * op = NULL;
|
|
|
60de42 |
char *id = generate_op_key(name, action, interval);
|
|
|
60de42 |
|
|
|
60de42 |
+ init_recurring_actions();
|
|
|
60de42 |
op = g_hash_table_lookup(recurring_actions, id);
|
|
|
60de42 |
free(id);
|
|
|
60de42 |
|
|
|
60de42 |
@@ -604,11 +616,6 @@ handle_duplicate_recurring(svc_action_t * op, void (*action_callback) (svc_actio
|
|
|
60de42 |
{
|
|
|
60de42 |
svc_action_t * dup = NULL;
|
|
|
60de42 |
|
|
|
60de42 |
- if (recurring_actions == NULL) {
|
|
|
60de42 |
- recurring_actions = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, NULL);
|
|
|
60de42 |
- return FALSE;
|
|
|
60de42 |
- }
|
|
|
60de42 |
-
|
|
|
60de42 |
/* check for duplicates */
|
|
|
60de42 |
dup = g_hash_table_lookup(recurring_actions, op->id);
|
|
|
60de42 |
|
|
|
60de42 |
@@ -700,6 +707,7 @@ services_action_async(svc_action_t * op, void (*action_callback) (svc_action_t *
|
|
|
60de42 |
}
|
|
|
60de42 |
|
|
|
60de42 |
if (op->interval > 0) {
|
|
|
60de42 |
+ init_recurring_actions();
|
|
|
60de42 |
if (handle_duplicate_recurring(op, action_callback) == TRUE) {
|
|
|
60de42 |
/* entry rescheduled, dup freed */
|
|
|
60de42 |
/* exit early */
|
|
|
60de42 |
--
|
|
|
60de42 |
1.8.3.1
|
|
|
60de42 |
|