1 /*
2 * Copyright 2004-2024 the Pacemaker project contributors
3 *
4 * The version control history for this file may have further details.
5 *
6 * This source code is licensed under the GNU Lesser General Public License
7 * version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY.
8 */
9
10 #ifndef PCMK__CRM_COMMON_RESOURCES__H
11 #define PCMK__CRM_COMMON_RESOURCES__H
12
13 #include <stdbool.h> // bool
14 #include <sys/types.h> // time_t
15 #include <libxml/tree.h> // xmlNode
16 #include <glib.h> // gboolean, guint, GList, GHashTable
17
18 #include <crm/common/roles.h> // enum rsc_role_e
19 #include <crm/common/scheduler_types.h> // pcmk_resource_t, etc.
20
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24
25 /*!
26 * \file
27 * \brief Scheduler API for resources
28 * \ingroup core
29 */
30
31 //! Search options for resources (exact resource ID always matches)
32 enum pe_find {
33 //! Also match clone instance ID from resource history
34 pcmk_rsc_match_history = (1 << 0),
35
36 //! Also match anonymous clone instances by base name
37 pcmk_rsc_match_anon_basename = (1 << 1),
38
39 //! Match only clones and their instances, by either clone or instance ID
40 pcmk_rsc_match_clone_only = (1 << 2),
41
42 //! If matching by node, compare current node instead of assigned node
43 pcmk_rsc_match_current_node = (1 << 3),
44
45 //! Match clone instances (even unique) by base name as well as exact ID
46 pcmk_rsc_match_basename = (1 << 5),
47 };
48
49 //! \internal Do not use
50 typedef struct pcmk__resource_private pcmk__resource_private_t;
51
52 // Implementation of pcmk_resource_t
53 // @COMPAT Make this internal when we can break API backward compatibility
54 //!@{
55 //! \deprecated Do not use (public access will be removed in a future release)
56 struct pcmk__resource {
57 /* @COMPAT Once all members are moved to pcmk__resource_private_t,
58 * We can make that the pcmk_resource_t implementation and drop this
59 * struct altogether, leaving pcmk_resource_t as an opaque public type.
60 */
61 pcmk__resource_private_t *priv;
62
63 // NOTE: sbd (as of at least 1.5.2) uses this
64 //! \deprecated Call pcmk_resource_id() instead
65 char *id; // Resource ID in configuration
66
67 // NOTE: sbd (as of at least 1.5.2) uses this
68 //! \deprecated Call pcmk_resource_is_managed() instead
69 unsigned long long flags; // Group of enum pcmk__rsc_flags
70 };
71 //!@}
72
73 const char *pcmk_resource_id(const pcmk_resource_t *rsc);
74 bool pcmk_resource_is_managed(const pcmk_resource_t *rsc);
75
76 #ifdef __cplusplus
77 }
78 #endif
79
80 #endif // PCMK__CRM_COMMON_RESOURCES__H