Exemplo n.º 1
0
static int pcmk_load_ticket(struct ticket_config *tk)
{
	char cmd[COMMAND_MAX];
	int rv = 0, pipe_rv;
	FILE *p;

	/* This here gets run during startup; testing that here means that
	 * normal operation won't be interrupted with that test. */
	test_atomicity();

	snprintf(cmd, COMMAND_MAX,
			"crm_ticket -t '%s' -q",
			tk->name);

	p = popen(cmd, "r");
	if (p == NULL) {
		pipe_rv = errno;
		log_error("popen error %d (%s) for \"%s\"",
				pipe_rv, strerror(pipe_rv), cmd);
		return pipe_rv || -EINVAL;
	}

	rv = parse_ticket_state(tk, p);

	if (!tk->leader) {
		/* Hmm, no site found for the ticket we have in the
		 * CIB!?
		 * Assume that the ticket belonged to us if it was
		 * granted here!
		 */
		log_warn("%s: no site matches; site got reconfigured?",
			tk->name);
		if (tk->is_granted) {
			log_warn("%s: granted here, assume it belonged to us",
				tk->name);
			set_leader(tk, local);
		}
	}

	pipe_rv = pclose(p);
	if (!pipe_rv) {
		log_debug("command \"%s\"", cmd);
	} else if (WEXITSTATUS(pipe_rv) == 6) {
		log_info("command \"%s\", ticket not found", cmd);
	} else {
		log_error("command \"%s\" %s", cmd, interpret_rv(pipe_rv));
	}
	return rv | pipe_rv;
}
Exemplo n.º 2
0
static int pcmk_load_ticket(struct ticket_config *tk)
{
	int rv;
	int64_t v;


	/* This here gets run during startup; testing that here means that
	 * normal operation won't be interrupted with that test. */
	test_atomicity();


	rv = crm_ticket_get(tk, "expires", &v);
	if (!rv) {
		secs2tv(unwall_ts(v), &tk->term_expires);
	}

	rv = crm_ticket_get(tk, "term", &v);
	if (!rv) {
		tk->current_term = v;
	}

	rv = crm_ticket_get(tk, "granted", &v);
	if (!rv) {
		tk->is_granted = v;
	}

	rv = crm_ticket_get(tk, "owner", &v);
	if (!rv) {
		/* No check, node could have been deconfigured. */
		if (!find_site_by_id(v, &tk->leader)) {
			/* Hmm, no site found for the ticket we have in the
			 * CIB!?
			 * Assume that the ticket belonged to us if it was
			 * granted here!
			 */
			log_warn("%s: no site matches; site got reconfigured?",
				tk->name);
			if (tk->is_granted) {
				log_warn("%s: granted here, assume it belonged to us",
					tk->name);
				tk->leader = local;
			}
		}
	}

	return rv;
}
Exemplo n.º 3
0
static int pcmk_revoke_ticket(struct ticket_config *tk)
{
	char cmd[COMMAND_MAX];
	int rv;


	test_atomicity();
	if (atomicity == YES)
		return pcmk_write_ticket_atomic(tk, -1);


	rv = pcmk_store_ticket_nonatomic(tk);
	if (rv)
		return rv;

	snprintf(cmd, COMMAND_MAX, "crm_ticket -t %s -r --force",
			tk->name);
	log_debug("command: '%s' was executed", cmd);
	rv = system(cmd);
	if (rv != 0)
		log_error("error: \"%s\" failed, %s", cmd, interpret_rv(rv));
	return rv;
}