pacemaker  3.0.0-d8340737c4
Scalable High-Availability cluster resource manager
pcmk_setup.c
Go to the documentation of this file.
1 /*
2  * Copyright 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 #include <crm_internal.h>
11 #include <crm/cib/internal.h>
12 #include <crm/common/output.h>
13 #include <crm/common/results.h>
14 #include <crm/common/scheduler.h>
15 #include <crm/fencing/internal.h>
16 #include <pacemaker-internal.h>
17 #include <pacemaker.h>
18 
19 #include "libpacemaker_private.h"
20 
41 int
43  pcmk_scheduler_t **scheduler, xmlNode **xml)
44 {
45  int rc = pcmk_rc_ok;
46 
47  rc = pcmk__xml_output_new(out, xml);
48  if (rc != pcmk_rc_ok) {
49  return rc;
50  }
51 
52  if (cib != NULL) {
53  *cib = cib_new();
54  if (*cib == NULL) {
55  return pcmk_rc_cib_corrupt;
56  }
57 
58  rc = (*cib)->cmds->signon(*cib, crm_system_name, cib_command);
59  rc = pcmk_legacy2rc(rc);
60 
61  if (rc != pcmk_rc_ok) {
63  return rc;
64  }
65  }
66 
67  if (scheduler != NULL) {
68  rc = pcmk__init_scheduler(*out, NULL, NULL, scheduler);
69  if (rc != pcmk_rc_ok && cib != NULL) {
71  return rc;
72  }
73 
75  }
76 
78  return rc;
79 }
80 
96 int
98 {
99  int rc = pcmk_rc_ok;
100 
101  rc = pcmk__xml_output_new(out, xml);
102  if (rc != pcmk_rc_ok) {
103  return rc;
104  }
105 
106  *st = stonith_api_new();
107  if (*st == NULL) {
108  return ENOMEM;
109  }
110 
111  rc = (*st)->cmds->connect(*st, crm_system_name, NULL);
112  if (rc < 0) {
113  rc = pcmk_legacy2rc(rc);
115  return rc;
116  }
117 
120  return rc;
121 }
Control output from tools.
void stonith__register_messages(pcmk__output_t *out)
Definition: st_output.c:604
cib_t * cib_new(void)
Create a new CIB connection object.
Definition: cib_client.c:562
High Level API.
char * crm_system_name
Definition: utils.c:44
stonith_t * stonith_api_new(void)
Definition: st_client.c:1858
Scheduler API.
stonith_t * st
Definition: pcmk_fence.c:30
void pcmk__unpack_constraints(pcmk_scheduler_t *scheduler)
int pcmk__xml_output_new(pcmk__output_t **out, xmlNodePtr *xml)
Definition: output.c:244
G_GNUC_INTERNAL int pcmk__init_scheduler(pcmk__output_t *out, xmlNodePtr input, const crm_time_t *date, pcmk_scheduler_t **scheduler)
void pcmk__register_lib_messages(pcmk__output_t *out)
Definition: pcmk_output.c:2709
int pcmk_legacy2rc(int legacy_rc)
Definition: results.c:667
int cib__clean_up_connection(cib_t **cib)
Definition: cib_utils.c:920
Function and executable result codes.
int pcmk__setup_output_fencing(pcmk__output_t **out, stonith_t **st, xmlNode **xml)
Definition: pcmk_setup.c:97
int pcmk__setup_output_cib_sched(pcmk__output_t **out, cib_t **cib, pcmk_scheduler_t **scheduler, xmlNode **xml)
Definition: pcmk_setup.c:42
void stonith_api_delete(stonith_t *st)
Definition: st_client.c:1725
pcmk_scheduler_t * scheduler
This structure contains everything that makes up a single output formatter.