Пример #1
0
/*
 * remove_remote -- (internal) remove remote pool
 */
static int
remove_remote(const char *target, const char *pool_set)
{
#ifdef USE_RPMEM
	struct rpmem_target_info *info = rpmem_target_parse(target);
	if (!info)
		goto err_parse;

	struct rpmem_ssh *ssh = rpmem_ssh_exec(info, "--remove",
			pool_set, "--force", NULL);
	if (!ssh) {
		goto err_ssh_exec;
	}

	if (rpmem_ssh_monitor(ssh, 0))
		goto err_ssh_monitor;

	int ret = rpmem_ssh_close(ssh);
	rpmem_target_free(info);

	return ret;
err_ssh_monitor:
	rpmem_ssh_close(ssh);
err_ssh_exec:
	rpmem_target_free(info);
err_parse:
	return -1;
#else
	FATAL("remote replication not supported");
	return -1;
#endif
}
Пример #2
0
/*
 * rpmem_obc_close_conn -- (internal) close connection
 */
static void
rpmem_obc_close_conn(struct rpmem_obc *rpc)
{
	rpmem_ssh_close(rpc->ssh);

	(void) util_fetch_and_and64(&rpc->ssh, 0);
}
Пример #3
0
/*
 * rpmem_obc_close_conn -- (internal) close connection
 */
static void
rpmem_obc_close_conn(struct rpmem_obc *rpc)
{
	rpmem_ssh_close(rpc->ssh);

	rpc->ssh = NULL;
}
Пример #4
0
/*
 * rpmem_ssh_open -- open ssh connection with specified node and wait for status
 */
struct rpmem_ssh *
rpmem_ssh_open(const struct rpmem_target_info *info)
{
	struct rpmem_ssh *ssh = rpmem_ssh_exec(info, NULL);
	if (!ssh)
		return NULL;

	/*
	 * Read initial status from invoked command.
	 * This is for synchronization purposes and to make it possible
	 * to inform client that command's initialization failed.
	 */
	int32_t status;
	int ret = rpmem_ssh_recv(ssh, &status, sizeof(status));
	if (ret) {
		if (ret == 1 || errno == ECONNRESET)
			ERR("%s", rpmem_ssh_strerror(ssh, errno));
		else
			ERR("!%s", info->node);
		goto err_recv_status;
	}

	if (status) {
		ERR("%s: unexpected status received -- '%d'",
				info->node, status);
		errno = status;
		goto err_status;
	}

	RPMEM_LOG(INFO, "received status: %u", status);

	return ssh;
err_recv_status:
err_status:
	rpmem_ssh_close(ssh);
	return NULL;
}
Пример #5
0
/*
 * clnt_close -- close client
 */
void
clnt_close(struct rpmem_ssh *ssh)
{
	rpmem_ssh_close(ssh);
}
Пример #6
0
Файл: rm.c Проект: mslusarz/nvml
/*
 * remove_remote -- (internal) remove remote pool
 */
static int
remove_remote(const char *target, const char *pool_set)
{
#ifdef USE_RPMEM
	char cask = 'y';
	switch (ask_mode) {
	case ASK_ALWAYS:
		cask = '?';
		break;
	case ASK_NEVER:
	case ASK_SOMETIMES:
		cask = 'y';
		break;
	}

	if (ask_Yn(cask, "remove remote pool '%s' on '%s'?",
		pool_set, target) != 'y')
		return 0;

	struct rpmem_target_info *info = rpmem_target_parse(target);
	if (!info)
		goto err_parse;

	struct rpmem_ssh *ssh;

	if (force) {
		ssh = rpmem_ssh_exec(info, "--remove",
				pool_set, "--force", NULL);
	} else {
		ssh = rpmem_ssh_exec(info, "--remove",
				pool_set, NULL);
	}

	if (!ssh)
		goto err_ssh_exec;

	int ret = 0;

	if (rpmem_ssh_monitor(ssh, 0))
		ret = 1;

	if (rpmem_ssh_close(ssh))
		ret = 1;

	if (ret)
		goto err_ssh_exec;

	rpmem_target_free(info);

	outv(1, "removed '%s' on '%s'\n",
			pool_set, target);

	return ret;
err_ssh_exec:
	rpmem_target_free(info);
err_parse:
	if (!force)
		outv_err("cannot remove '%s' on '%s'", pool_set, target);
	return 1;
#else
	outv_err("remote replication not supported");
	return 1;
#endif
}