MCPcopy Create free account
hub / github.com/ClusterLabs/pacemaker / setup_input

Function setup_input

tools/crm_simulate.c:1035–1100  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1033}
1034
1035static void
1036setup_input(const char *input, const char *output)
1037{
1038 int rc = pcmk_ok;
1039 cib_t *cib_conn = NULL;
1040 xmlNode *cib_object = NULL;
1041 char *local_output = NULL;
1042
1043 if (input == NULL) {
1044 /* Use live CIB */
1045 cib_conn = cib_new();
1046 rc = cib_conn->cmds->signon(cib_conn, crm_system_name, cib_command);
1047
1048 if (rc == pcmk_ok) {
1049 cib_object = get_cib_copy(cib_conn);
1050 }
1051
1052 cib_conn->cmds->signoff(cib_conn);
1053 cib_delete(cib_conn);
1054 cib_conn = NULL;
1055
1056 if (cib_object == NULL) {
1057 fprintf(stderr, "Live CIB query failed: empty result\n");
1058 crm_exit(3);
1059 }
1060
1061 } else if (safe_str_eq(input, "-")) {
1062 cib_object = filename2xml(NULL);
1063
1064 } else {
1065 cib_object = filename2xml(input);
1066 }
1067
1068 if (get_object_root(XML_CIB_TAG_STATUS, cib_object) == NULL) {
1069 create_xml_node(cib_object, XML_CIB_TAG_STATUS);
1070 }
1071
1072 if (cli_config_update(&cib_object, NULL, FALSE) == FALSE) {
1073 free_xml(cib_object);
1074 crm_exit(-ENOKEY);
1075 }
1076
1077 if (validate_xml(cib_object, NULL, FALSE) != TRUE) {
1078 free_xml(cib_object);
1079 crm_exit(-pcmk_err_dtd_validation);
1080 }
1081
1082 if (output == NULL) {
1083 char *pid = crm_itoa(getpid());
1084
1085 local_output = get_shadow_file(pid);
1086 output = local_output;
1087 free(pid);
1088 }
1089
1090 rc = write_xml_file(cib_object, output, FALSE);
1091 free_xml(cib_object);
1092 cib_object = NULL;

Callers 1

mainFunction · 0.85

Calls 15

cib_newFunction · 0.85
get_cib_copyFunction · 0.85
cib_deleteFunction · 0.85
crm_exitFunction · 0.85
filename2xmlFunction · 0.85
get_object_rootFunction · 0.85
create_xml_nodeFunction · 0.85
cli_config_updateFunction · 0.85
free_xmlFunction · 0.85
validate_xmlFunction · 0.85
crm_itoaFunction · 0.85
get_shadow_fileFunction · 0.85

Tested by

no test coverage detected