예제 #1
0
static int list_pools(vici_conn_t *conn)
{
	vici_req_t *req;
	vici_res_t *res;
	bool raw = FALSE;
	char *arg;
	int ret = 0;

	while (TRUE)
	{
		switch (command_getopt(&arg))
		{
			case 'h':
				return command_usage(NULL);
			case 'r':
				raw = TRUE;
				continue;
			case EOF:
				break;
			default:
				return command_usage("invalid --list-pools option");
		}
		break;
	}

	req = vici_begin("get-pools");
	res = vici_submit(req, conn);
	if (!res)
	{
		fprintf(stderr, "get-pools request failed: %s\n", strerror(errno));
		return errno;
	}
	if (raw)
	{
		vici_dump(res, "get-pools reply", stdout);
	}
	else
	{
		ret = vici_parse_cb(res, list_pool, NULL, NULL, NULL);
	}
	vici_free_res(res);
	return ret;
}
예제 #2
0
/**
 * Create a list of currently loaded pools
 */
static linked_list_t* list_pools(vici_conn_t *conn,
								 command_format_options_t format)
{
	linked_list_t *list;
	vici_res_t *res;

	list = linked_list_create();

	res = vici_submit(vici_begin("get-pools"), conn);
	if (res)
	{
		if (format & COMMAND_FORMAT_RAW)
		{
			vici_dump(res, "get-pools reply", format & COMMAND_FORMAT_PRETTY,
					  stdout);
		}
		vici_parse_cb(res, list_pool, NULL, NULL, list);
		vici_free_res(res);
	}
	return list;
}