pacemaker  2.1.9-49aab99839
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 <pacemaker-internal.h>
16 #include <pacemaker.h>
17 
18 #include "libpacemaker_private.h"
19 
40 int
42  pcmk_scheduler_t **scheduler, xmlNode **xml)
43 {
44  int rc = pcmk_rc_ok;
45 
46  rc = pcmk__xml_output_new(out, xml);
47  if (rc != pcmk_rc_ok) {
48  return rc;
49  }
50 
51  if (cib != NULL) {
52  *cib = cib_new();
53  if (*cib == NULL) {
54  return pcmk_rc_cib_corrupt;
55  }
56 
57  rc = (*cib)->cmds->signon(*cib, crm_system_name, cib_command);
58  rc = pcmk_legacy2rc(rc);
59 
60  if (rc != pcmk_rc_ok) {
62  return rc;
63  }
64  }
65 
66  if (scheduler != NULL) {
67  rc = pcmk__init_scheduler(*out, NULL, NULL, scheduler);
68  if (rc != pcmk_rc_ok && cib != NULL) {
70  return rc;
71  }
72 
74  }
75 
77  return rc;
78 }
Control output from tools.
cib_t * cib_new(void)
Create a new CIB connection object.
Definition: cib_client.c:598
High Level API.
char * crm_system_name
Definition: utils.c:48
Scheduler API.
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:2680
int pcmk_legacy2rc(int legacy_rc)
Definition: results.c:561
int cib__clean_up_connection(cib_t **cib)
Definition: cib_utils.c:1051
Function and executable result codes.
int pcmk__setup_output_cib_sched(pcmk__output_t **out, cib_t **cib, pcmk_scheduler_t **scheduler, xmlNode **xml)
Definition: pcmk_setup.c:41
pcmk_scheduler_t * scheduler
This structure contains everything that makes up a single output formatter.