1
2
3
4
5
6
7
8
9
10 #include <crm_internal.h>
11
12 #include <stdint.h>
13 #include <stdbool.h>
14
15 #include <crm/crm.h>
16
17 #include <crm/msg_xml.h>
18 #include <crm/services.h>
19 #include <crm/common/xml.h>
20 #include <crm/common/mainloop.h>
21 #include <crm/common/output_internal.h>
22 #include <crm/common/scheduler_internal.h>
23
24 #include <crm/cib.h>
25 #include <crm/common/attrd_internal.h>
26 #include <crm/pengine/rules.h>
27 #include <crm/pengine/status.h>
28 #include <crm/pengine/internal.h>
29 #include <pacemaker-internal.h>
30
31 #define ATTR_SET_ELEMENT "attr_set_element"
32
33 typedef struct node_info_s {
34 const char *node_name;
35 bool promoted;
36 } node_info_t;
37
38 enum resource_check_flags {
39 rsc_remain_stopped = (1 << 0),
40 rsc_unpromotable = (1 << 1),
41 rsc_unmanaged = (1 << 2),
42 rsc_locked = (1 << 3),
43 rsc_node_health = (1 << 4),
44 };
45
46 typedef struct resource_checks_s {
47 pcmk_resource_t *rsc;
48 uint32_t flags;
49 const char *lock_node;
50 } resource_checks_t;
51
52 resource_checks_t *cli_check_resource(pcmk_resource_t *rsc, char *role_s,
53 char *managed);
54
55
56 int cli_resource_prefer(pcmk__output_t *out, const char *rsc_id, const char *host,
57 const char *move_lifetime, cib_t * cib_conn, int cib_options,
58 gboolean promoted_role_only, const char *promoted_role);
59 int cli_resource_ban(pcmk__output_t *out, const char *rsc_id, const char *host,
60 const char *move_lifetime, cib_t *cib_conn, int cib_options,
61 gboolean promoted_role_only, const char *promoted_role);
62 int cli_resource_clear(const char *rsc_id, const char *host, GList *allnodes,
63 cib_t * cib_conn, int cib_options, bool clear_ban_constraints, gboolean force);
64 int cli_resource_clear_all_expired(xmlNode *root, cib_t *cib_conn, int cib_options,
65 const char *rsc, const char *node, gboolean promoted_role_only);
66
67
68 void cli_resource_print_cts(pcmk_resource_t *rsc, pcmk__output_t *out);
69 void cli_resource_print_cts_constraints(pcmk_scheduler_t *scheduler);
70
71 int cli_resource_print(pcmk_resource_t *rsc, pcmk_scheduler_t *scheduler,
72 bool expanded);
73 int cli_resource_print_operations(const char *rsc_id, const char *host_uname,
74 bool active, pcmk_scheduler_t *scheduler);
75
76
77 int cli_resource_check(pcmk__output_t *out, pcmk_resource_t *rsc,
78 pcmk_node_t *node);
79 int cli_resource_fail(pcmk_ipc_api_t *controld_api, const char *host_uname,
80 const char *rsc_id, pcmk_scheduler_t *scheduler);
81 GList *cli_resource_search(pcmk_resource_t *rsc, const char *requested_name,
82 pcmk_scheduler_t *scheduler);
83 int cli_resource_delete(pcmk_ipc_api_t *controld_api, const char *host_uname,
84 const pcmk_resource_t *rsc, const char *operation,
85 const char *interval_spec, bool just_failures,
86 pcmk_scheduler_t *scheduler, gboolean force);
87 int cli_cleanup_all(pcmk_ipc_api_t *controld_api, const char *node_name,
88 const char *operation, const char *interval_spec,
89 pcmk_scheduler_t *scheduler);
90 int cli_resource_restart(pcmk__output_t *out, pcmk_resource_t *rsc,
91 const pcmk_node_t *node, const char *move_lifetime,
92 int timeout_ms, cib_t *cib, int cib_options,
93 gboolean promoted_role_only, gboolean force);
94 int cli_resource_move(const pcmk_resource_t *rsc, const char *rsc_id,
95 const char *host_name, const char *move_lifetime,
96 cib_t *cib, int cib_options, pcmk_scheduler_t *scheduler,
97 gboolean promoted_role_only, gboolean force);
98 crm_exit_t cli_resource_execute_from_params(pcmk__output_t *out, const char *rsc_name,
99 const char *rsc_class, const char *rsc_prov,
100 const char *rsc_type, const char *rsc_action,
101 GHashTable *params, GHashTable *override_hash,
102 int timeout_ms, int resource_verbose,
103 gboolean force, int check_level);
104 crm_exit_t cli_resource_execute(pcmk_resource_t *rsc,
105 const char *requested_name,
106 const char *rsc_action, GHashTable *override_hash,
107 int timeout_ms, cib_t *cib,
108 pcmk_scheduler_t *scheduler,
109 int resource_verbose, gboolean force, int check_level);
110
111 int cli_resource_update_attribute(pcmk_resource_t *rsc,
112 const char *requested_name,
113 const char *attr_set, const char *attr_set_type,
114 const char *attr_id, const char *attr_name,
115 const char *attr_value, gboolean recursive,
116 cib_t *cib, int cib_options, gboolean force);
117 int cli_resource_delete_attribute(pcmk_resource_t *rsc,
118 const char *requested_name,
119 const char *attr_set, const char *attr_set_type,
120 const char *attr_id, const char *attr_name,
121 cib_t *cib, int cib_options, gboolean force);
122
123 int update_scheduler_input(pcmk_scheduler_t *scheduler, xmlNode **xml);
124 int wait_till_stable(pcmk__output_t *out, int timeout_ms, cib_t * cib);
125
126 bool resource_is_running_on(pcmk_resource_t *rsc, const char *host);
127
128 void crm_resource_register_messages(pcmk__output_t *out);