This source file includes following definitions.
- pcmk__list_alternatives
- pcmk_list_alternatives
- pcmk__list_agents
- pcmk_list_agents
- pcmk__list_providers
- pcmk_list_providers
- pcmk__list_standards
- pcmk_list_standards
1
2
3
4
5
6
7
8
9
10 #include <crm_internal.h>
11
12 #include <crm/lrmd_internal.h>
13 #include <pacemaker.h>
14 #include <pacemaker-internal.h>
15
16 int
17 pcmk__list_alternatives(pcmk__output_t *out, const char *agent_spec)
18 {
19 int rc = pcmk_rc_ok;
20 lrmd_t *lrmd_conn = NULL;
21 lrmd_list_t *list = NULL;
22
23 pcmk__assert((out != NULL) && (agent_spec != NULL));
24
25 rc = lrmd__new(&lrmd_conn, NULL, NULL, 0);
26 if (rc != pcmk_rc_ok) {
27 goto error;
28 }
29
30 rc = lrmd_conn->cmds->list_ocf_providers(lrmd_conn, agent_spec, &list);
31
32 if (rc > 0) {
33 rc = out->message(out, "alternatives-list", list, agent_spec);
34 } else {
35 rc = pcmk_rc_error;
36 }
37
38 error:
39 if (rc != pcmk_rc_ok) {
40 out->err(out, _("No %s found for %s"), "OCF providers", agent_spec);
41 rc = ENXIO;
42 }
43
44 lrmd_api_delete(lrmd_conn);
45 return rc;
46 }
47
48
49 int
50 pcmk_list_alternatives(xmlNodePtr *xml, const char *agent_spec)
51 {
52 pcmk__output_t *out = NULL;
53 int rc = pcmk_rc_ok;
54
55 rc = pcmk__xml_output_new(&out, xml);
56 if (rc != pcmk_rc_ok) {
57 return rc;
58 }
59
60 lrmd__register_messages(out);
61
62 rc = pcmk__list_alternatives(out, agent_spec);
63 pcmk__xml_output_finish(out, pcmk_rc2exitc(rc), xml);
64 return rc;
65 }
66
67
68
69
70
71
72
73
74
75
76 int
77 pcmk__list_agents(pcmk__output_t *out, char *agent_spec)
78 {
79 int rc = pcmk_rc_ok;
80 char *provider = NULL;
81 lrmd_t *lrmd_conn = NULL;
82 lrmd_list_t *list = NULL;
83
84 pcmk__assert((out != NULL) && (agent_spec != NULL));
85
86 rc = lrmd__new(&lrmd_conn, NULL, NULL, 0);
87 if (rc != pcmk_rc_ok) {
88 goto error;
89 }
90
91 provider = strchr(agent_spec, ':');
92
93 if (provider) {
94 *provider++ = 0;
95 }
96
97 rc = lrmd_conn->cmds->list_agents(lrmd_conn, &list, agent_spec, provider);
98
99 if (rc > 0) {
100 rc = out->message(out, "agents-list", list, agent_spec, provider);
101 } else {
102 rc = pcmk_rc_error;
103 }
104
105 error:
106 if (rc != pcmk_rc_ok) {
107 if (provider == NULL) {
108 out->err(out, _("No agents found for standard '%s'"), agent_spec);
109 } else {
110 out->err(out, _("No agents found for standard '%s' and provider '%s'"),
111 agent_spec, provider);
112 }
113 }
114
115 lrmd_api_delete(lrmd_conn);
116 return rc;
117 }
118
119
120 int
121 pcmk_list_agents(xmlNodePtr *xml, char *agent_spec)
122 {
123 pcmk__output_t *out = NULL;
124 int rc = pcmk_rc_ok;
125
126 rc = pcmk__xml_output_new(&out, xml);
127 if (rc != pcmk_rc_ok) {
128 return rc;
129 }
130
131 lrmd__register_messages(out);
132
133 rc = pcmk__list_agents(out, agent_spec);
134 pcmk__xml_output_finish(out, pcmk_rc2exitc(rc), xml);
135 return rc;
136 }
137
138 int
139 pcmk__list_providers(pcmk__output_t *out, const char *agent_spec)
140 {
141 int rc = pcmk_rc_ok;
142 lrmd_t *lrmd_conn = NULL;
143 lrmd_list_t *list = NULL;
144
145 pcmk__assert(out != NULL);
146
147 rc = lrmd__new(&lrmd_conn, NULL, NULL, 0);
148 if (rc != pcmk_rc_ok) {
149 goto error;
150 }
151
152 rc = lrmd_conn->cmds->list_ocf_providers(lrmd_conn, agent_spec, &list);
153
154 if (rc > 0) {
155 rc = out->message(out, "providers-list", list, agent_spec);
156 } else {
157 rc = pcmk_rc_error;
158 }
159
160 error:
161 if (rc != pcmk_rc_ok) {
162 if (agent_spec == NULL) {
163 out->err(out, _("No %s found"), "OCF providers");
164 } else {
165 out->err(out, _("No %s found for %s"), "OCF providers", agent_spec);
166 }
167
168 rc = ENXIO;
169 }
170
171 lrmd_api_delete(lrmd_conn);
172 return rc;
173 }
174
175
176 int
177 pcmk_list_providers(xmlNodePtr *xml, const char *agent_spec)
178 {
179 pcmk__output_t *out = NULL;
180 int rc = pcmk_rc_ok;
181
182 rc = pcmk__xml_output_new(&out, xml);
183 if (rc != pcmk_rc_ok) {
184 return rc;
185 }
186
187 lrmd__register_messages(out);
188
189 rc = pcmk__list_providers(out, agent_spec);
190 pcmk__xml_output_finish(out, pcmk_rc2exitc(rc), xml);
191 return rc;
192 }
193
194 int
195 pcmk__list_standards(pcmk__output_t *out)
196 {
197 int rc = pcmk_rc_ok;
198 lrmd_t *lrmd_conn = NULL;
199 lrmd_list_t *list = NULL;
200
201 pcmk__assert(out != NULL);
202
203 rc = lrmd__new(&lrmd_conn, NULL, NULL, 0);
204 if (rc != pcmk_rc_ok) {
205 goto error;
206 }
207
208 rc = lrmd_conn->cmds->list_standards(lrmd_conn, &list);
209
210 if (rc > 0) {
211 rc = out->message(out, "standards-list", list);
212 } else {
213 rc = pcmk_rc_error;
214 }
215
216 error:
217 if (rc != pcmk_rc_ok) {
218 out->err(out, _("No %s found"), "standards");
219 rc = ENXIO;
220 }
221
222 lrmd_api_delete(lrmd_conn);
223 return rc;
224 }
225
226
227 int
228 pcmk_list_standards(xmlNodePtr *xml)
229 {
230 pcmk__output_t *out = NULL;
231 int rc = pcmk_rc_ok;
232
233 rc = pcmk__xml_output_new(&out, xml);
234 if (rc != pcmk_rc_ok) {
235 return rc;
236 }
237
238 lrmd__register_messages(out);
239
240 rc = pcmk__list_standards(out);
241 pcmk__xml_output_finish(out, pcmk_rc2exitc(rc), xml);
242 return rc;
243 }