~ubuntu-branches/ubuntu/utopic/pacemaker/utopic-proposed

« back to all changes in this revision

Viewing changes to tools/crm_verify.c

  • Committer: Package Import Robot
  • Author(s): Andres Rodriguez
  • Date: 2013-07-16 16:40:24 UTC
  • mfrom: (1.1.11) (2.2.3 experimental)
  • Revision ID: package-import@ubuntu.com-20130716164024-lvwrf4xivk1wdr3c
Tags: 1.1.9+git20130321-1ubuntu1
* Resync from debian expiremental.
* debian/control:
  - Use lower version for Build-Depends on libcorosync-dev
    and libqb-dev.
  - Build-Depends on libcfg-dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
void usage(const char *cmd, int exit_status);
42
42
extern gboolean stage0(pe_working_set_t * data_set);
43
43
extern void cleanup_alloc_calculations(pe_working_set_t * data_set);
44
 
extern xmlNode *do_calculations(pe_working_set_t * data_set, xmlNode * xml_input, ha_time_t * now);
 
44
extern xmlNode *do_calculations(pe_working_set_t * data_set, xmlNode * xml_input, crm_time_t * now);
45
45
 
46
46
/* *INDENT-OFF* */
47
47
static struct crm_option long_options[] = {
81
81
 
82
82
    pe_working_set_t data_set;
83
83
    cib_t *cib_conn = NULL;
84
 
    int rc = cib_ok;
 
84
    int rc = pcmk_ok;
85
85
 
 
86
    bool verbose = FALSE;
86
87
    gboolean xml_stdin = FALSE;
87
88
    const char *xml_tag = NULL;
88
89
    const char *xml_file = NULL;
89
90
    const char *xml_string = NULL;
90
91
 
91
 
    g_log_set_handler(NULL,
92
 
                      G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL
93
 
                      | G_LOG_LEVEL_WARNING | G_LOG_LEVEL_MESSAGE
94
 
                      | G_LOG_LEVEL_INFO | G_LOG_LEVEL_DEBUG
95
 
                      | G_LOG_FLAG_RECURSION | G_LOG_FLAG_FATAL, cl_glib_msg_handler, NULL);
96
 
 
97
 
    /* and for good measure... - this enum is a bit field (!) */
98
 
    g_log_set_always_fatal((GLogLevelFlags) 0); /*value out of range */
99
 
 
100
 
    crm_log_init_quiet(NULL, LOG_ERR, FALSE, TRUE, argc, argv);
 
92
    crm_log_cli_init("crm_verify");
101
93
    crm_set_options(NULL, "[modifiers] data_source", long_options,
102
94
                    "Check a (complete) confiuration for syntax and common conceptual errors."
103
95
                    "\n\nChecks the well-formedness of an XML configuration, its conformance to the configured DTD/schema and for the presence of common misconfigurations."
123
115
 
124
116
            case 'X':
125
117
                crm_trace("Option %c => %s", flag, optarg);
126
 
                xml_string = crm_strdup(optarg);
 
118
                xml_string = strdup(optarg);
127
119
                break;
128
120
            case 'x':
129
121
                crm_trace("Option %c => %s", flag, optarg);
130
 
                xml_file = crm_strdup(optarg);
 
122
                xml_file = strdup(optarg);
131
123
                break;
132
124
            case 'p':
133
125
                xml_stdin = TRUE;
134
126
                break;
135
127
            case 'S':
136
 
                cib_save = crm_strdup(optarg);
 
128
                cib_save = strdup(optarg);
137
129
                break;
138
130
            case 'V':
139
 
                crm_bump_log_level();
 
131
                verbose = TRUE;
 
132
                crm_bump_log_level(argc, argv);
140
133
                break;
141
134
            case 'L':
142
135
                USE_LIVE_CIB = TRUE;
143
136
                break;
144
137
            case '$':
145
138
            case '?':
146
 
                crm_help(flag, LSB_EXIT_OK);
 
139
                crm_help(flag, EX_OK);
147
140
                break;
148
141
            default:
149
142
                fprintf(stderr, "Option -%c is not yet supported\n", flag);
166
159
 
167
160
    if (argerr) {
168
161
        crm_err("%d errors in option parsing", argerr);
169
 
        crm_help(flag, LSB_EXIT_GENERIC);
 
162
        crm_help(flag, EX_USAGE);
170
163
    }
171
164
 
172
165
    crm_info("=#=#=#=#= Getting XML =#=#=#=#=");
177
170
    }
178
171
 
179
172
    if (USE_LIVE_CIB) {
180
 
        if (rc == cib_ok) {
 
173
        if (rc == pcmk_ok) {
181
174
            int options = cib_scope_local | cib_sync_call;
182
175
 
183
176
            crm_info("Reading XML from: live cluster");
184
177
            rc = cib_conn->cmds->query(cib_conn, NULL, &cib_object, options);
185
178
        }
186
179
 
187
 
        if (rc != cib_ok) {
188
 
            fprintf(stderr, "Live CIB query failed: %s\n", cib_error2string(rc));
 
180
        if (rc != pcmk_ok) {
 
181
            fprintf(stderr, "Live CIB query failed: %s\n", pcmk_strerror(rc));
189
182
            return 3;
190
183
        }
191
184
        if (cib_object == NULL) {
257
250
        cleanup_alloc_calculations(&data_set);
258
251
 
259
252
    } else {
260
 
        data_set.now = new_ha_date(TRUE);
 
253
        data_set.now = crm_time_new(NULL);
261
254
        data_set.input = cib_object;
262
255
        stage0(&data_set);
263
256
        cleanup_alloc_calculations(&data_set);
265
258
 
266
259
    if (crm_config_error) {
267
260
        fprintf(stderr, "Errors found during check: config not valid\n");
268
 
        if (get_crm_log_level() < LOG_WARNING) {
 
261
        if (verbose == FALSE) {
269
262
            fprintf(stderr, "  -V may provide more details\n");
270
263
        }
271
264
        rc = 2;
272
265
 
273
266
    } else if (crm_config_warning) {
274
267
        fprintf(stderr, "Warnings found during check: config may not be valid\n");
275
 
        if (get_crm_log_level() < LOG_WARNING) {
 
268
        if (verbose == FALSE) {
276
269
            fprintf(stderr, "  Use -V for more details\n");
277
270
        }
278
271
        rc = 1;