Example #1
0
static void wd_resource_object_created(hdb_handle_t parent_object_handle,
	hdb_handle_t object_handle,
	const void *name_pt, size_t name_len,
	void *priv_data_pt)
{
	wd_resource_create (object_handle);
}
Example #2
0
static void wd_resource_created_cb(
	int32_t event,
	const char *key_name,
	struct icmap_notify_value new_val,
	struct icmap_notify_value old_val,
	void *user_data)
{
	char res_name[ICMAP_KEYNAME_MAXLEN];
	char res_type[ICMAP_KEYNAME_MAXLEN];
	char tmp_key[ICMAP_KEYNAME_MAXLEN];
	int res;

	if (event != ICMAP_TRACK_ADD) {
		return ;
	}

	res = sscanf(key_name, "resources.%[^.].%[^.].%[^.]", res_type, res_name, tmp_key);
	if (res != 3) {
		return ;
	}

	if (strcmp(tmp_key, "state") != 0) {
		return ;
	}

	snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "resources.%s.%s.", res_type, res_name);
	wd_resource_create (tmp_key, res_name);
}
Example #3
0
static void wd_scan_resources (void)
{
	hdb_handle_t obj_finder;
	hdb_handle_t obj_finder2;
	hdb_handle_t resource_type;
	hdb_handle_t resource;
	int res_count = 0;

	ENTER();

	api->object_find_create (
		OBJECT_PARENT_HANDLE,
		"resources", strlen ("resources"),
		&obj_finder);

	api->object_find_next (obj_finder, &resources_obj);
	api->object_find_destroy (obj_finder);

	/* this will be the system or process level
	 */
	api->object_find_create (
		resources_obj,
		NULL, 0,
		&obj_finder);
	while (api->object_find_next (obj_finder,
			&resource_type) == 0) {

		api->object_find_create (
			resource_type,
			NULL, 0,
			&obj_finder2);

		while (api->object_find_next (obj_finder2,
				&resource) == 0) {

			if (wd_resource_create (resource) == 0) {
				res_count++;
			}
		}
		api->object_find_destroy (obj_finder2);

		api->object_track_start (resource_type, OBJECT_TRACK_DEPTH_ONE,
			NULL, wd_resource_object_created, NULL,
			NULL, NULL);
	}
	api->object_find_destroy (obj_finder);
	if (res_count == 0) {
		log_printf (LOGSYS_LEVEL_INFO, "no resources configured.");
	}
}
Example #4
0
static void wd_scan_resources (void)
{
	int res_count = 0;
	icmap_track_t icmap_track = NULL;
	icmap_iter_t iter;
	const char *key_name;
	int res;
	char res_name[ICMAP_KEYNAME_MAXLEN];
	char res_type[ICMAP_KEYNAME_MAXLEN];
	char tmp_key[ICMAP_KEYNAME_MAXLEN];

	ENTER();

	iter = icmap_iter_init("resources.");
	while ((key_name = icmap_iter_next(iter, NULL, NULL)) != NULL) {
		res = sscanf(key_name, "resources.%[^.].%[^.].%[^.]", res_type, res_name, tmp_key);
		if (res != 3) {
			continue ;
		}

		if (strcmp(tmp_key, "state") != 0) {
			continue ;
		}

		snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "resources.%s.%s.", res_type, res_name);
		if (wd_resource_create (tmp_key, res_name) == 0) {
			res_count++;
		}
	}
	icmap_iter_finalize(iter);

	icmap_track_add("resources.process.", ICMAP_TRACK_ADD | ICMAP_TRACK_PREFIX,
			wd_resource_created_cb, NULL, &icmap_track);
	icmap_track_add("resources.system.", ICMAP_TRACK_ADD | ICMAP_TRACK_PREFIX,
			wd_resource_created_cb, NULL, &icmap_track);

	if (res_count == 0) {
		log_printf (LOGSYS_LEVEL_INFO, "no resources configured.");
	}
}