This source file includes following definitions.
- pcmk_node_is_online
- pcmk_node_is_pending
- pcmk_node_is_clean
- pcmk_node_is_shutting_down
- pcmk_node_is_in_maintenance
- pcmk_foreach_active_resource
- pcmk__xe_add_node
- pcmk__find_node_in_list
1
2
3
4
5
6
7
8
9
10 #include <crm_internal.h>
11
12 #include <libxml/tree.h>
13 #include <crm/common/nvpair.h>
14
15
16
17
18
19
20
21
22
23 bool
24 pcmk_node_is_online(const pcmk_node_t *node)
25 {
26 return (node != NULL) && node->details->online;
27 }
28
29
30
31
32
33
34
35
36
37
38
39
40
41 bool
42 pcmk_node_is_pending(const pcmk_node_t *node)
43 {
44 return (node != NULL) && node->details->pending;
45 }
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60 bool
61 pcmk_node_is_clean(const pcmk_node_t *node)
62 {
63 return (node != NULL) && !(node->details->unclean);
64 }
65
66
67
68
69
70
71
72
73
74 bool
75 pcmk_node_is_shutting_down(const pcmk_node_t *node)
76 {
77 return (node != NULL) && node->details->shutdown;
78 }
79
80
81
82
83
84
85
86
87
88 bool
89 pcmk_node_is_in_maintenance(const pcmk_node_t *node)
90 {
91 return (node != NULL) && node->details->maintenance;
92 }
93
94
95
96
97
98
99
100
101
102
103
104
105
106 bool
107 pcmk_foreach_active_resource(pcmk_node_t *node,
108 bool (*fn)(pcmk_resource_t *, void *),
109 void *user_data)
110 {
111 bool result = false;
112
113 if ((node != NULL) && (fn != NULL)) {
114 for (GList *item = node->details->running_rsc; item != NULL;
115 item = item->next) {
116
117 result = fn((pcmk_resource_t *) item->data, user_data);
118 if (!result) {
119 break;
120 }
121 }
122 }
123 return result;
124 }
125
126 void
127 pcmk__xe_add_node(xmlNode *xml, const char *node, int nodeid)
128 {
129 CRM_ASSERT(xml != NULL);
130
131 if (node != NULL) {
132 crm_xml_add(xml, PCMK__XA_ATTR_HOST, node);
133 }
134
135 if (nodeid > 0) {
136 crm_xml_add_int(xml, PCMK__XA_ATTR_HOST_ID, nodeid);
137 }
138 }
139
140
141
142
143
144
145
146
147
148
149 pcmk_node_t *
150 pcmk__find_node_in_list(const GList *nodes, const char *node_name)
151 {
152 if (node_name != NULL) {
153 for (const GList *iter = nodes; iter != NULL; iter = iter->next) {
154 pcmk_node_t *node = (pcmk_node_t *) iter->data;
155
156 if (pcmk__str_eq(node->details->uname, node_name,
157 pcmk__str_casei)) {
158 return node;
159 }
160 }
161 }
162 return NULL;
163 }