Пример #1
0
int main(int argc, char **argv)
{
	reg_sigterm_handler(sigterm_handler);
	rmm_log_init();
	enable_core_dump();

	init_ipmi_subscribe();

	ipmi_init();

	register_ipmb_resp();

	register_rmcp_resp();

	IPMI_LOG_INFO("IPMI-Daemon is Running ...\n");

	fd_events_main_loop();
	return 0;
}
Пример #2
0
int main(int argc, char **argv)
{
	int fd;
	int port;
	pthread_t	tid_ipmi_cb;
	pthread_t	tid_asset_module_set_attr;
	gami_reg_t reg_info = {{0}};
	char value[WRAP_DB_MAX_VALUE_LEN] = {0};
	int64 error_code;
	memdb_integer root_service_nid = 0;
	memdb_integer rmc_nid = 0;
	struct node_info *pnode = NULL;
	int32 node_num = 0;

	reg_sigterm_handler(sigterm_handler);

	if (rmm_modules_init(MODULEINIT_LOG | MODULEINIT_COREDUMP | MODULEINIT_REDFISHD,
				ASSETMGR_JSONRPC_PORT,
				JSONRPCINIT_MEMDB | JSONRPCINIT_JIPMI) == -1) {
		exit(-1);
	}

	rmm_log(INFO, "Assetd daemon is Running ...\n");

	create_listen_socket(&fd);

	libdb_is_ready(DB_RMM, LOCK_ID_NULL, -1);
	error_code = libdb_attr_get_string(DB_RMM, MC_NODE_ROOT, RACK_FW_VER_STR, value, WRAP_DB_MAX_VALUE_LEN, LOCK_ID_NULL);
	if (error_code == 0) {
		/*TODO: compare the fw version to decide if need to do db-migration. */
	}

	init_rack_attr();

	pnode = libdb_list_node_by_type(DB_RMM, MC_TYPE_V1, MC_TYPE_V1, &node_num, NULL, LOCK_ID_NULL);
	if ((pnode == NULL) || (node_num == 0)) {
		root_service_nid = libdb_create_node(DB_RMM, MC_NODE_ROOT, MC_TYPE_V1, SNAPSHOT_NEED, LOCK_ID_NULL);
		if (root_service_nid == 0) {
			rmm_log(ERROR, "Failed to create root service node!\n");
			return -1;
		}
		init_root_service_attr(&root_service_nid, PERSISTENT_ALL);

		rmc_nid = libdb_create_node(DB_RMM, root_service_nid, MC_TYPE_RMC, SNAPSHOT_NEED, LOCK_ID_NULL);
		if (rmc_nid == 0) {
			rmm_log(ERROR, "Failed to create root service node!\n");
			return -1;
		}
		init_rmc_attr(&rmc_nid, PERSISTENT_ALL);
	} else {
		root_service_nid = pnode[0].node_id;
		init_root_service_attr(&root_service_nid, PERSISTENT_N);

		pnode = libdb_list_subnode_by_type(DB_RMM, root_service_nid, MC_TYPE_RMC, &node_num, NULL, LOCK_ID_NULL);
		if (pnode != NULL)
			rmc_nid = pnode[0].node_id;
		init_rmc_attr(&rmc_nid, PERSISTENT_N);
	}

	if (pthread_create(&tid_ipmi_cb, NULL, ipmi_cb_thread, NULL) != 0) {
		rmm_log(ERROR, "Failed to create ipmi callback thread!\n");
		return -1;
	}

	if (pthread_create(&tid_asset_module_set_attr, NULL, asset_module_set_gami_attr_thread, NULL) != 0) {
		rmm_log(ERROR, "Failed to create asset module notify thread!\n");
		return -1;
	}

	main_loop(fd);
	return 0;
}