This source file includes following definitions.
- systemd_new_method
- systemd_send
- systemd_send_recv
- systemd_call_simple_method
- systemd_init
- systemd_get_property
- systemd_cleanup
- systemd_unit_extension
- systemd_service_name
- systemd_daemon_reload_complete
- systemd_daemon_reload
- systemd_mask_error
- systemd_loadunit_result
- systemd_loadunit_cb
- systemd_unit_by_name
- sort_str
- systemd_unit_listall
- systemd_unit_exists
- systemd_unit_metadata
- systemd_exec_result
- systemd_async_dispatch
- create_world_readable
- create_override_dir
- get_override_filename
- systemd_create_override
- systemd_remove_override
- systemd_unit_check
- systemd_unit_exec_with_unit
- systemd_timeout_callback
- systemd_unit_exec
1
2
3
4
5
6
7
8
9
10 #include <crm_internal.h>
11 #include <crm/crm.h>
12 #include <crm/services.h>
13 #include <crm/common/mainloop.h>
14
15 #include <sys/stat.h>
16 #include <gio/gio.h>
17 #include <services_private.h>
18 #include <systemd.h>
19 #include <dbus/dbus.h>
20 #include <pcmk-dbus.h>
21
22 gboolean systemd_unit_exec_with_unit(svc_action_t * op, const char *unit);
23
24 #define BUS_NAME "org.freedesktop.systemd1"
25 #define BUS_NAME_MANAGER BUS_NAME ".Manager"
26 #define BUS_NAME_UNIT BUS_NAME ".Unit"
27 #define BUS_PATH "/org/freedesktop/systemd1"
28
29 static inline DBusMessage *
30 systemd_new_method(const char *method)
31 {
32 crm_trace("Calling: %s on " BUS_NAME_MANAGER, method);
33 return dbus_message_new_method_call(BUS_NAME, BUS_PATH, BUS_NAME_MANAGER,
34 method);
35 }
36
37
38
39
40
41 static DBusConnection* systemd_proxy = NULL;
42
43 static inline DBusPendingCall *
44 systemd_send(DBusMessage *msg,
45 void(*done)(DBusPendingCall *pending, void *user_data),
46 void *user_data, int timeout)
47 {
48 return pcmk_dbus_send(msg, systemd_proxy, done, user_data, timeout);
49 }
50
51 static inline DBusMessage *
52 systemd_send_recv(DBusMessage *msg, DBusError *error, int timeout)
53 {
54 return pcmk_dbus_send_recv(msg, systemd_proxy, error, timeout);
55 }
56
57
58
59
60
61
62
63
64
65
66
67
68 static DBusMessage *
69 systemd_call_simple_method(const char *method)
70 {
71 DBusMessage *msg = systemd_new_method(method);
72 DBusMessage *reply = NULL;
73 DBusError error;
74
75
76 CRM_CHECK(systemd_proxy, return NULL);
77
78 if (msg == NULL) {
79 crm_err("Could not create message to send %s to systemd", method);
80 return NULL;
81 }
82
83 dbus_error_init(&error);
84 reply = systemd_send_recv(msg, &error, DBUS_TIMEOUT_USE_DEFAULT);
85 dbus_message_unref(msg);
86
87 if (dbus_error_is_set(&error)) {
88 crm_err("Could not send %s to systemd: %s (%s)",
89 method, error.message, error.name);
90 dbus_error_free(&error);
91 return NULL;
92
93 } else if (reply == NULL) {
94 crm_err("Could not send %s to systemd: no reply received", method);
95 return NULL;
96 }
97
98 return reply;
99 }
100
101 static gboolean
102 systemd_init(void)
103 {
104 static int need_init = 1;
105
106
107 if (systemd_proxy
108 && dbus_connection_get_is_connected(systemd_proxy) == FALSE) {
109 crm_warn("Connection to System DBus is closed. Reconnecting...");
110 pcmk_dbus_disconnect(systemd_proxy);
111 systemd_proxy = NULL;
112 need_init = 1;
113 }
114
115 if (need_init) {
116 need_init = 0;
117 systemd_proxy = pcmk_dbus_connect();
118 }
119 if (systemd_proxy == NULL) {
120 return FALSE;
121 }
122 return TRUE;
123 }
124
125 static inline char *
126 systemd_get_property(const char *unit, const char *name,
127 void (*callback)(const char *name, const char *value, void *userdata),
128 void *userdata, DBusPendingCall **pending, int timeout)
129 {
130 return systemd_proxy?
131 pcmk_dbus_get_property(systemd_proxy, BUS_NAME, unit, BUS_NAME_UNIT,
132 name, callback, userdata, pending, timeout)
133 : NULL;
134 }
135
136 void
137 systemd_cleanup(void)
138 {
139 if (systemd_proxy) {
140 pcmk_dbus_disconnect(systemd_proxy);
141 systemd_proxy = NULL;
142 }
143 }
144
145
146
147
148
149
150
151
152
153
154
155
156
157 static const char *
158 systemd_unit_extension(const char *name)
159 {
160 if (name) {
161 const char *dot = strrchr(name, '.');
162
163 if (dot && (!strcmp(dot, ".service")
164 || !strcmp(dot, ".socket")
165 || !strcmp(dot, ".mount")
166 || !strcmp(dot, ".timer")
167 || !strcmp(dot, ".path"))) {
168 return dot;
169 }
170 }
171 return NULL;
172 }
173
174 static char *
175 systemd_service_name(const char *name)
176 {
177 if (name == NULL) {
178 return NULL;
179 }
180
181 if (systemd_unit_extension(name)) {
182 return strdup(name);
183 }
184
185 return crm_strdup_printf("%s.service", name);
186 }
187
188 static void
189 systemd_daemon_reload_complete(DBusPendingCall *pending, void *user_data)
190 {
191 DBusError error;
192 DBusMessage *reply = NULL;
193 unsigned int reload_count = GPOINTER_TO_UINT(user_data);
194
195 dbus_error_init(&error);
196 if(pending) {
197 reply = dbus_pending_call_steal_reply(pending);
198 }
199
200 if (pcmk_dbus_find_error(pending, reply, &error)) {
201 crm_err("Could not issue systemd reload %d: %s", reload_count, error.message);
202 dbus_error_free(&error);
203
204 } else {
205 crm_trace("Reload %d complete", reload_count);
206 }
207
208 if(pending) {
209 dbus_pending_call_unref(pending);
210 }
211 if(reply) {
212 dbus_message_unref(reply);
213 }
214 }
215
216 static bool
217 systemd_daemon_reload(int timeout)
218 {
219 static unsigned int reload_count = 0;
220 DBusMessage *msg = systemd_new_method("Reload");
221
222 reload_count++;
223 CRM_ASSERT(msg != NULL);
224 systemd_send(msg, systemd_daemon_reload_complete,
225 GUINT_TO_POINTER(reload_count), timeout);
226 dbus_message_unref(msg);
227
228 return TRUE;
229 }
230
231 static bool
232 systemd_mask_error(svc_action_t *op, const char *error)
233 {
234 crm_trace("Could not issue %s for %s: %s", op->action, op->rsc, error);
235 if(strstr(error, "org.freedesktop.systemd1.InvalidName")
236 || strstr(error, "org.freedesktop.systemd1.LoadFailed")
237 || strstr(error, "org.freedesktop.systemd1.NoSuchUnit")) {
238
239 if (pcmk__str_eq(op->action, "stop", pcmk__str_casei)) {
240 crm_trace("Masking %s failure for %s: unknown services are stopped", op->action, op->rsc);
241 op->rc = PCMK_OCF_OK;
242 return TRUE;
243
244 } else {
245 crm_trace("Mapping %s failure for %s: unknown services are not installed", op->action, op->rsc);
246 op->rc = PCMK_OCF_NOT_INSTALLED;
247 op->status = PCMK_LRM_OP_NOT_INSTALLED;
248 return FALSE;
249 }
250 }
251
252 return FALSE;
253 }
254
255 static const char *
256 systemd_loadunit_result(DBusMessage *reply, svc_action_t * op)
257 {
258 const char *path = NULL;
259 DBusError error;
260
261 if (pcmk_dbus_find_error((void*)&path, reply, &error)) {
262 if(op && !systemd_mask_error(op, error.name)) {
263 crm_err("Could not load systemd unit %s for %s: %s",
264 op->agent, op->id, error.message);
265 }
266 dbus_error_free(&error);
267
268 } else if (!pcmk_dbus_type_check(reply, NULL, DBUS_TYPE_OBJECT_PATH,
269 __func__, __LINE__)) {
270 crm_err("Could not load systemd unit %s for %s: "
271 "systemd reply has unexpected type", op->agent, op->id);
272
273 } else {
274 dbus_message_get_args (reply, NULL,
275 DBUS_TYPE_OBJECT_PATH, &path,
276 DBUS_TYPE_INVALID);
277 }
278
279 if(op) {
280 if (path) {
281 systemd_unit_exec_with_unit(op, path);
282
283 } else if (op->synchronous == FALSE) {
284 operation_finalize(op);
285 }
286 }
287
288 return path;
289 }
290
291
292 static void
293 systemd_loadunit_cb(DBusPendingCall *pending, void *user_data)
294 {
295 DBusMessage *reply = NULL;
296 svc_action_t * op = user_data;
297
298 if(pending) {
299 reply = dbus_pending_call_steal_reply(pending);
300 }
301
302 crm_trace("Got result: %p for %p / %p for %s", reply, pending, op->opaque->pending, op->id);
303
304 CRM_LOG_ASSERT(pending == op->opaque->pending);
305 services_set_op_pending(op, NULL);
306
307 systemd_loadunit_result(reply, user_data);
308
309 if(reply) {
310 dbus_message_unref(reply);
311 }
312 }
313
314 static char *
315 systemd_unit_by_name(const gchar * arg_name, svc_action_t *op)
316 {
317 DBusMessage *msg;
318 DBusMessage *reply = NULL;
319 DBusPendingCall* pending = NULL;
320 char *name = NULL;
321
322
323
324
325
326
327
328
329
330 if (systemd_init() == FALSE) {
331 return FALSE;
332 }
333
334 msg = systemd_new_method("LoadUnit");
335 CRM_ASSERT(msg != NULL);
336
337 name = systemd_service_name(arg_name);
338 CRM_LOG_ASSERT(dbus_message_append_args(msg, DBUS_TYPE_STRING, &name, DBUS_TYPE_INVALID));
339 free(name);
340
341 if(op == NULL || op->synchronous) {
342 const char *unit = NULL;
343 char *munit = NULL;
344
345 reply = systemd_send_recv(msg, NULL,
346 (op? op->timeout : DBUS_TIMEOUT_USE_DEFAULT));
347 dbus_message_unref(msg);
348
349 unit = systemd_loadunit_result(reply, op);
350 if(unit) {
351 munit = strdup(unit);
352 }
353 if(reply) {
354 dbus_message_unref(reply);
355 }
356 return munit;
357 }
358
359 pending = systemd_send(msg, systemd_loadunit_cb, op, op->timeout);
360 if(pending) {
361 services_set_op_pending(op, pending);
362 }
363
364 dbus_message_unref(msg);
365 return NULL;
366 }
367
368
369
370
371
372
373
374
375
376
377
378
379
380 static gint
381 sort_str(gconstpointer a, gconstpointer b)
382 {
383 if (!a && !b) {
384 return 0;
385 } else if (!a) {
386 return -1;
387 } else if (!b) {
388 return 1;
389 }
390 return strcasecmp(a, b);
391 }
392
393 GList *
394 systemd_unit_listall(void)
395 {
396 int nfiles = 0;
397 GList *units = NULL;
398 DBusMessageIter args;
399 DBusMessageIter unit;
400 DBusMessageIter elem;
401 DBusMessage *reply = NULL;
402
403 if (systemd_init() == FALSE) {
404 return NULL;
405 }
406
407
408
409
410
411
412
413 reply = systemd_call_simple_method("ListUnitFiles");
414 if (reply == NULL) {
415 return NULL;
416 }
417 if (!dbus_message_iter_init(reply, &args)) {
418 crm_err("Could not list systemd unit files: systemd reply has no arguments");
419 dbus_message_unref(reply);
420 return NULL;
421 }
422 if (!pcmk_dbus_type_check(reply, &args, DBUS_TYPE_ARRAY,
423 __func__, __LINE__)) {
424 crm_err("Could not list systemd unit files: systemd reply has invalid arguments");
425 dbus_message_unref(reply);
426 return NULL;
427 }
428
429 dbus_message_iter_recurse(&args, &unit);
430 for (; dbus_message_iter_get_arg_type(&unit) != DBUS_TYPE_INVALID;
431 dbus_message_iter_next(&unit)) {
432
433 DBusBasicValue value;
434 const char *match = NULL;
435 char *unit_name = NULL;
436 char *basename = NULL;
437
438 if(!pcmk_dbus_type_check(reply, &unit, DBUS_TYPE_STRUCT, __func__, __LINE__)) {
439 crm_warn("Skipping systemd reply argument with unexpected type");
440 continue;
441 }
442
443 dbus_message_iter_recurse(&unit, &elem);
444 if(!pcmk_dbus_type_check(reply, &elem, DBUS_TYPE_STRING, __func__, __LINE__)) {
445 crm_warn("Skipping systemd reply argument with no string");
446 continue;
447 }
448
449 dbus_message_iter_get_basic(&elem, &value);
450 if (value.str == NULL) {
451 crm_debug("ListUnitFiles reply did not provide a string");
452 continue;
453 }
454 crm_trace("DBus ListUnitFiles listed: %s", value.str);
455
456 match = systemd_unit_extension(value.str);
457 if (match == NULL) {
458
459 crm_debug("ListUnitFiles entry '%s' is not supported as resource",
460 value.str);
461 continue;
462 }
463
464
465 basename = strrchr(value.str, '/');
466 if (basename) {
467 basename = basename + 1;
468 } else {
469 basename = value.str;
470 }
471
472 if (!strcmp(match, ".service")) {
473
474 unit_name = strndup(basename, match - basename);
475 } else {
476 unit_name = strdup(basename);
477 }
478
479 nfiles++;
480 units = g_list_prepend(units, unit_name);
481 }
482
483 dbus_message_unref(reply);
484
485 crm_trace("Found %d manageable systemd unit files", nfiles);
486 units = g_list_sort(units, sort_str);
487 return units;
488 }
489
490 gboolean
491 systemd_unit_exists(const char *name)
492 {
493 char *unit = NULL;
494
495
496
497
498 unit = systemd_unit_by_name(name, NULL);
499 if(unit) {
500 free(unit);
501 return TRUE;
502 }
503 return FALSE;
504 }
505
506 static char *
507 systemd_unit_metadata(const char *name, int timeout)
508 {
509 char *meta = NULL;
510 char *desc = NULL;
511 char *path = systemd_unit_by_name(name, NULL);
512
513 if (path) {
514
515 desc = systemd_get_property(path, "Description", NULL, NULL, NULL,
516 timeout);
517 } else {
518 desc = crm_strdup_printf("Systemd unit file for %s", name);
519 }
520
521 meta = crm_strdup_printf("<?xml version=\"1.0\"?>\n"
522 "<!DOCTYPE resource-agent SYSTEM \"ra-api-1.dtd\">\n"
523 "<resource-agent name=\"%s\" version=\"" PCMK_DEFAULT_AGENT_VERSION "\">\n"
524 " <version>1.0</version>\n"
525 " <longdesc lang=\"en\">\n"
526 " %s\n"
527 " </longdesc>\n"
528 " <shortdesc lang=\"en\">systemd unit file for %s</shortdesc>\n"
529 " <parameters>\n"
530 " </parameters>\n"
531 " <actions>\n"
532 " <action name=\"start\" timeout=\"100\" />\n"
533 " <action name=\"stop\" timeout=\"100\" />\n"
534 " <action name=\"status\" timeout=\"100\" />\n"
535 " <action name=\"monitor\" timeout=\"100\" interval=\"60\"/>\n"
536 " <action name=\"meta-data\" timeout=\"5\" />\n"
537 " </actions>\n"
538 " <special tag=\"systemd\">\n"
539 " </special>\n" "</resource-agent>\n", name, desc, name);
540 free(desc);
541 free(path);
542 return meta;
543 }
544
545 static void
546 systemd_exec_result(DBusMessage *reply, svc_action_t *op)
547 {
548 DBusError error;
549
550 if (pcmk_dbus_find_error((void*)&error, reply, &error)) {
551
552
553 if (!systemd_mask_error(op, error.name)) {
554 crm_err("Could not issue %s for %s: %s", op->action, op->rsc, error.message);
555 }
556 dbus_error_free(&error);
557
558 } else {
559 if(!pcmk_dbus_type_check(reply, NULL, DBUS_TYPE_OBJECT_PATH, __func__, __LINE__)) {
560 crm_warn("Call to %s passed but return type was unexpected", op->action);
561 op->rc = PCMK_OCF_OK;
562
563 } else {
564 const char *path = NULL;
565
566 dbus_message_get_args (reply, NULL,
567 DBUS_TYPE_OBJECT_PATH, &path,
568 DBUS_TYPE_INVALID);
569 crm_info("Call to %s passed: %s", op->action, path);
570 op->rc = PCMK_OCF_OK;
571 }
572 }
573
574 operation_finalize(op);
575 }
576
577 static void
578 systemd_async_dispatch(DBusPendingCall *pending, void *user_data)
579 {
580 DBusMessage *reply = NULL;
581 svc_action_t *op = user_data;
582
583 if(pending) {
584 reply = dbus_pending_call_steal_reply(pending);
585 }
586
587 crm_trace("Got result: %p for %p for %s, %s", reply, pending, op->rsc, op->action);
588
589 CRM_LOG_ASSERT(pending == op->opaque->pending);
590 services_set_op_pending(op, NULL);
591 systemd_exec_result(reply, op);
592
593 if(reply) {
594 dbus_message_unref(reply);
595 }
596 }
597
598 #define SYSTEMD_OVERRIDE_ROOT "/run/systemd/system/"
599
600
601
602
603
604
605
606
607
608
609 #define SYSTEMD_OVERRIDE_TEMPLATE \
610 "[Unit]\n" \
611 "Description=Cluster Controlled %s\n" \
612 "Before=pacemaker.service pacemaker_remote.service\n" \
613 "\n" \
614 "[Service]\n" \
615 "Restart=no\n"
616
617
618 static FILE *
619 create_world_readable(const char *filename)
620 {
621 mode_t orig_umask = umask(S_IWGRP | S_IWOTH);
622 FILE *fp = fopen(filename, "w");
623
624 umask(orig_umask);
625 return fp;
626 }
627
628 static void
629 create_override_dir(const char *agent)
630 {
631 char *override_dir = crm_strdup_printf(SYSTEMD_OVERRIDE_ROOT
632 "/%s.service.d", agent);
633
634 crm_build_path(override_dir, 0755);
635 free(override_dir);
636 }
637
638 static char *
639 get_override_filename(const char *agent)
640 {
641 return crm_strdup_printf(SYSTEMD_OVERRIDE_ROOT
642 "/%s.service.d/50-pacemaker.conf", agent);
643 }
644
645 static void
646 systemd_create_override(const char *agent, int timeout)
647 {
648 FILE *file_strm = NULL;
649 char *override_file = get_override_filename(agent);
650
651 create_override_dir(agent);
652
653
654
655
656 file_strm = create_world_readable(override_file);
657 if (file_strm == NULL) {
658 crm_err("Cannot open systemd override file %s for writing",
659 override_file);
660 } else {
661 char *override = crm_strdup_printf(SYSTEMD_OVERRIDE_TEMPLATE, agent);
662
663 int rc = fprintf(file_strm, "%s\n", override);
664
665 free(override);
666 if (rc < 0) {
667 crm_perror(LOG_WARNING, "Cannot write to systemd override file %s",
668 override_file);
669 }
670 fflush(file_strm);
671 fclose(file_strm);
672 systemd_daemon_reload(timeout);
673 }
674
675 free(override_file);
676 }
677
678 static void
679 systemd_remove_override(const char *agent, int timeout)
680 {
681 char *override_file = get_override_filename(agent);
682 int rc = unlink(override_file);
683
684 if (rc < 0) {
685
686 crm_perror(LOG_DEBUG, "Cannot remove systemd override file %s",
687 override_file);
688 } else {
689 systemd_daemon_reload(timeout);
690 }
691 free(override_file);
692 }
693
694 static void
695 systemd_unit_check(const char *name, const char *state, void *userdata)
696 {
697 svc_action_t * op = userdata;
698
699 crm_trace("Resource %s has %s='%s'", op->rsc, name, state);
700
701 if(state == NULL) {
702 op->rc = PCMK_OCF_NOT_RUNNING;
703
704 } else if (g_strcmp0(state, "active") == 0) {
705 op->rc = PCMK_OCF_OK;
706 } else if (g_strcmp0(state, "reloading") == 0) {
707 op->rc = PCMK_OCF_OK;
708 } else if (g_strcmp0(state, "activating") == 0) {
709 op->rc = PCMK_OCF_PENDING;
710 } else if (g_strcmp0(state, "deactivating") == 0) {
711 op->rc = PCMK_OCF_PENDING;
712 } else {
713 op->rc = PCMK_OCF_NOT_RUNNING;
714 }
715
716 if (op->synchronous == FALSE) {
717 services_set_op_pending(op, NULL);
718 operation_finalize(op);
719 }
720 }
721
722 gboolean
723 systemd_unit_exec_with_unit(svc_action_t * op, const char *unit)
724 {
725 const char *method = op->action;
726 DBusMessage *msg = NULL;
727 DBusMessage *reply = NULL;
728
729 CRM_ASSERT(unit);
730
731 if (pcmk__str_eq(op->action, "monitor", pcmk__str_casei) || pcmk__str_eq(method, "status", pcmk__str_casei)) {
732 DBusPendingCall *pending = NULL;
733 char *state;
734
735 state = systemd_get_property(unit, "ActiveState",
736 (op->synchronous? NULL : systemd_unit_check),
737 op, (op->synchronous? NULL : &pending),
738 op->timeout);
739 if (op->synchronous) {
740 systemd_unit_check("ActiveState", state, op);
741 free(state);
742 return op->rc == PCMK_OCF_OK;
743 } else if (pending) {
744 services_set_op_pending(op, pending);
745 return TRUE;
746
747 } else {
748 return operation_finalize(op);
749 }
750
751 } else if (g_strcmp0(method, "start") == 0) {
752 method = "StartUnit";
753 systemd_create_override(op->agent, op->timeout);
754
755 } else if (g_strcmp0(method, "stop") == 0) {
756 method = "StopUnit";
757 systemd_remove_override(op->agent, op->timeout);
758
759 } else if (g_strcmp0(method, "restart") == 0) {
760 method = "RestartUnit";
761
762 } else {
763 op->rc = PCMK_OCF_UNIMPLEMENT_FEATURE;
764 goto cleanup;
765 }
766
767 crm_debug("Calling %s for %s: %s", method, op->rsc, unit);
768
769 msg = systemd_new_method(method);
770 CRM_ASSERT(msg != NULL);
771
772
773 {
774 const char *replace_s = "replace";
775 char *name = systemd_service_name(op->agent);
776
777 CRM_LOG_ASSERT(dbus_message_append_args(msg, DBUS_TYPE_STRING, &name, DBUS_TYPE_INVALID));
778 CRM_LOG_ASSERT(dbus_message_append_args(msg, DBUS_TYPE_STRING, &replace_s, DBUS_TYPE_INVALID));
779
780 free(name);
781 }
782
783 if (op->synchronous == FALSE) {
784 DBusPendingCall *pending = systemd_send(msg, systemd_async_dispatch,
785 op, op->timeout);
786
787 dbus_message_unref(msg);
788 if(pending) {
789 services_set_op_pending(op, pending);
790 return TRUE;
791
792 } else {
793 return operation_finalize(op);
794 }
795
796 } else {
797 reply = systemd_send_recv(msg, NULL, op->timeout);
798 dbus_message_unref(msg);
799 systemd_exec_result(reply, op);
800
801 if(reply) {
802 dbus_message_unref(reply);
803 }
804 return FALSE;
805 }
806
807 cleanup:
808 if (op->synchronous == FALSE) {
809 return operation_finalize(op);
810 }
811
812 return op->rc == PCMK_OCF_OK;
813 }
814
815 static gboolean
816 systemd_timeout_callback(gpointer p)
817 {
818 svc_action_t * op = p;
819
820 op->opaque->timerid = 0;
821 crm_warn("%s operation on systemd unit %s named '%s' timed out", op->action, op->agent, op->rsc);
822 operation_finalize(op);
823
824 return FALSE;
825 }
826
827
828
829 gboolean
830 systemd_unit_exec(svc_action_t * op)
831 {
832 char *unit = NULL;
833
834 CRM_ASSERT(op);
835 CRM_ASSERT(systemd_init());
836 op->rc = PCMK_OCF_UNKNOWN_ERROR;
837 crm_debug("Performing %ssynchronous %s op on systemd unit %s named '%s'",
838 op->synchronous ? "" : "a", op->action, op->agent, op->rsc);
839
840 if (pcmk__str_eq(op->action, "meta-data", pcmk__str_casei)) {
841
842 op->stdout_data = systemd_unit_metadata(op->agent, op->timeout);
843 op->rc = PCMK_OCF_OK;
844
845 if (op->synchronous == FALSE) {
846 return operation_finalize(op);
847 }
848 return TRUE;
849 }
850
851 unit = systemd_unit_by_name(op->agent, op);
852 free(unit);
853
854 if (op->synchronous == FALSE) {
855 if (op->opaque->pending) {
856 op->opaque->timerid = g_timeout_add(op->timeout + 5000, systemd_timeout_callback, op);
857 services_add_inflight_op(op);
858 return TRUE;
859
860 } else {
861 return operation_finalize(op);
862 }
863 }
864
865 return op->rc == PCMK_OCF_OK;
866 }