예제 #1
0
파일: rainx.c 프로젝트: amogrid/redcurrant
gboolean
stg_pol_rainx_get_param(namespace_info_t *ni, const gchar *stgpol,
		const gchar *param, gint64 *p_val)
{
	const char *val_str = NULL;
	struct storage_policy_s *sp = storage_policy_init(ni, stgpol);
	const struct data_security_s *datasec = storage_policy_get_data_security(sp);
	gboolean ret;

	if (!datasec) {
		GRID_INFO("Cannot find datasecurity values for policy [%s]", stgpol);
		ret = FALSE;
	} else {
		if (NULL == (val_str = data_security_get_param(datasec, param))) {
			GRID_INFO("Cannot get parameter '%s' from data security [%s]",
					param, data_security_get_name(datasec));
			ret = FALSE;
		} else {
			*p_val = g_ascii_strtoll(val_str, NULL, 10);
			ret = TRUE;
		}
	}
	storage_policy_clean(sp);
	return ret;
}
예제 #2
0
static dav_error *
_load_request_info(const dav_resource *resource, char **full_path, struct storage_policy_s **sp)
{
	dav_error *e = NULL;
	const request_rec *r = resource->info->request;

	/* configure full path */
	e = __build_chunk_full_path(resource, full_path);
	if (NULL != e)
		return e;

	DAV_DEBUG_REQ(r, 0, "Chunk path build from request: %s", *full_path);
	
	/* init loaded storage policy */
	const char *pol_name = apr_table_get(r->headers_in, "storage-policy");
	if (!pol_name) {
		return server_create_and_stat_error(request_get_server_config(r), r->pool,
				HTTP_BAD_REQUEST, 0, "No storage-policy specified");
	}
	DAV_DEBUG_REQ(r, 0, "Policy found in request: %s", pol_name);

	dav_rawx_server_conf *conf = resource_get_server_config(resource);

	*sp = storage_policy_init(conf->rawx_conf->ni, pol_name);
	apr_pool_cleanup_register(r->pool, *sp, apr_storage_policy_clean, apr_pool_cleanup_null);

	return NULL;
}
예제 #3
0
gboolean
update_rawx_conf(apr_pool_t* p, rawx_conf_t **rawx_conf, const gchar* ns_name)
{
	rawx_conf_t* new_conf = NULL;
        namespace_info_t* ns_info;
        GError *local_error = NULL;

        ns_info = get_namespace_info(ns_name, &local_error);
        if (!ns_info)
                return FALSE;

	new_conf = apr_palloc(p, sizeof(rawx_conf_t));
	char * stgpol = NULL;
	stgpol = namespace_storage_policy(ns_info, ns_info->name);
	if(NULL != stgpol) {
		new_conf->sp = storage_policy_init(ns_info, stgpol);
	}

	new_conf->ni = ns_info;
	new_conf->acl = _get_acl(p, ns_info);
        new_conf->last_update = time(0);

	*rawx_conf = new_conf;
	return TRUE;
}
예제 #4
0
static const char *
dav_rainx_cmd_gridconfig_namespace(cmd_parms *cmd, void *config, const char *arg1)
{
	dav_rainx_server_conf *conf;
	(void) config;

	DAV_XDEBUG_POOL(cmd->pool, 0, "%s()", __FUNCTION__);

	conf = ap_get_module_config(cmd->server->module_config, &dav_rainx_module);
	memset(conf->ns_name, 0x00, sizeof(conf->ns_name));
	apr_cpystrn(conf->ns_name, arg1, sizeof(conf->ns_name));


	DAV_DEBUG_POOL(cmd->pool, 0, "NS=[%s]", conf->ns_name);

	/* Prepare COMPRESSION / ACL CONF when we get ns name */
	namespace_info_t* ns_info;
	GError *local_error = NULL;
	ns_info = get_namespace_info(conf->ns_name, &local_error);
	if (!ns_info) {
		DAV_DEBUG_POOL(cmd->temp_pool, 0, "Failed to get namespace info from ns [%s]", conf->ns_name);
		return apr_pstrcat(cmd->temp_pool, "Failed to get namespace info from ns: ",
				conf->ns_name, " ", local_error->message, NULL);
	}

	if (!conf->rainx_conf_lock) {
		apr_thread_mutex_create(&(conf->rainx_conf_lock),
				APR_THREAD_MUTEX_DEFAULT, conf->pool);
	}

	apr_thread_mutex_lock(conf->rainx_conf_lock);
	conf->rainx_conf = apr_palloc(cmd->pool, sizeof(rawx_conf_t));

	char * stgpol = NULL;
	stgpol = namespace_storage_policy(ns_info, ns_info->name);
	if(NULL != stgpol) {
		conf->rainx_conf->sp = storage_policy_init(ns_info, stgpol);
	} else {
		conf->rainx_conf->sp = NULL;
	}

	conf->rainx_conf->ni = ns_info;

	conf->rainx_conf->acl = _get_acl(cmd->pool, ns_info);
	conf->rainx_conf->last_update = time(0);
	apr_thread_mutex_unlock(conf->rainx_conf_lock);

	if(local_error)
		g_clear_error(&local_error);
	return NULL;
}
예제 #5
0
파일: rainx.c 프로젝트: amogrid/redcurrant
gboolean
stg_pol_is_rainx(namespace_info_t *ni, const gchar *stgpol)
{
	struct storage_policy_s *sp = storage_policy_init(ni, stgpol);
	const struct data_security_s *datasec = storage_policy_get_data_security(sp);
	gboolean ret;
	if (!datasec) {
		GRID_ERROR("Cannot find datasecurity values for policy [%s]", stgpol);
		ret = FALSE;
	} else {
		ret = data_security_get_type(datasec) == RAIN;
	}
	storage_policy_clean(sp);
	return ret;
}
예제 #6
0
static GError*
_check_policy(struct meta2_backend_s *m2, const gchar *polname)
{
	GError *err = NULL;
	struct storage_policy_s *policy = NULL;

	if (!*polname)
		return NEWERROR(CODE_BAD_REQUEST, "Invalid policy: %s", "empty");

	g_mutex_lock (&m2->nsinfo_lock);
	policy = storage_policy_init(m2->nsinfo, polname);
	g_mutex_unlock (&m2->nsinfo_lock);

	if (!policy)
		err = NEWERROR(CODE_POLICY_NOT_SUPPORTED, "Invalid policy: %s", "not found");
	else
		storage_policy_clean(policy);
	return err;
}
예제 #7
0
static struct storage_policy_s *
_init_storage_policy(const char *ns, const char *polname)
{
	namespace_info_t *ni = NULL;
	GError *e = NULL;
	struct storage_policy_s *sp =NULL;

	ni = get_namespace_info(ns, &e);
	if(NULL != e) {
		GRID_ERROR("Failed to get namespace info : %s", e->message);
		g_clear_error(&e);
		return NULL;
	}

	sp = storage_policy_init(ni, polname);

	namespace_info_clear(ni);
	g_free(ni);
	return sp;
}