コード例 #1
0
/*
 * for each device uid, call the library to update it's firmware with the path provided
 */
void wbem::software::NVDIMMSoftwareInstallationServiceFactory::installFromPath(
		const std::string& deviceUid,
		const std::string& path, bool activate, bool force) const
throw (framework::Exception)
{
	LogEnterExit logging(__FUNCTION__, __FILE__, __LINE__);
	COMMON_LOG_DEBUG_F("URI: %s", path.c_str());

	if(path.empty())
	{
		throw framework::ExceptionBadParameter("path");
	}
	if (!core::device::isUidValid(deviceUid))
	{
		throw framework::ExceptionBadParameter("deviceUid");
	}

	int rc;
	NVM_UID uid;
	uid_copy(deviceUid.c_str(), uid);
	// library will check if device is manageable and can update the FW ... if not it will return an error
	if (NVM_SUCCESS !=
			(rc = m_UpdateDeviceFw(uid, path.c_str(), path.length(), activate, force)))
	{
		throw exception::NvmExceptionLibError(rc);
	}
}
コード例 #2
0
ファイル: nvm_management.c プロジェクト: 01org/ixpdimm_sw
/*
 * Open the library
 */
int nvm_open_lib()
{
	int rc = NVM_SUCCESS;

	// initialize the connection to the database
	if (!open_default_lib_store())
	{
		rc = NVM_ERR_UNKNOWN;
	}
	else
	{
		char sim_path[CONFIG_VALUE_LEN];
		// attempt to open a default simulator
		if (get_config_value(SQL_KEY_DEFAULT_SIMULATOR, sim_path) == COMMON_SUCCESS)
		{
			// don't care about failures. sim_adapter will log any
			// errors to the config database. other adapters will just
			// return not supported
			COMMON_LOG_DEBUG_F("Opening default simulator %s", sim_path);
			nvm_add_simulator(sim_path, s_strnlen(sim_path, CONFIG_VALUE_LEN));
		}

		// initialize the event monitor lock
		// event monitoring is per process so no need to be cross-process safe
		// thus no name on the mutex
		if (!mutex_init((OS_MUTEX*)&g_eventmonitor_lock, NULL))
		{
			rc = NVM_ERR_UNKNOWN;
		}

		// initialize the context lock
		// context is per proces so no need to be cross-process safe
		// thus no name on the mutex
		if (!mutex_init((OS_MUTEX*)&g_context_lock, NULL))
		{
			rc = NVM_ERR_UNKNOWN;
		}
	}
	return rc;
}
コード例 #3
0
wbem::framework::Instance *wbem::indication::InstIndicationFactory::createIndication(
		struct event *pEvent)
throw(framework::Exception)
{
	LogEnterExit logging(__FUNCTION__, __FILE__, __LINE__);
	framework::Instance *pResult = NULL;

	if (pEvent == NULL)
	{
		COMMON_LOG_ERROR("pEvent was NULL");
	}
	else
	{
		COMMON_LOG_DEBUG_F("Event Type: %d, Event Code: %d", (int)pEvent->type, (int)pEvent->code);
		try
		{
			if (isNamespaceEvent(pEvent))
			{
				pResult = createNamespaceIndication(pEvent);
			}
			else if (isDeviceEvent(pEvent))
			{
				pResult = createDeviceIndication(pEvent);
			}
			else if (isSensorEvent(pEvent))
			{
				pResult = createSensorIndication(pEvent);
			}
		}
		catch (core::NoMemoryException)
		{
			throw framework::ExceptionNoMemory(__FILE__, __FUNCTION__, "Could not allocate memory");
		}
	}

	return pResult;
}
コード例 #4
0
/*
 * Retrieve a specific instance given an object path
 */
wbem::framework::Instance* wbem::memory::MemoryControllerFactory::getInstance(
	framework::ObjectPath &path, framework::attribute_names_t &attributes)
	throw (framework::Exception)
{
	LogEnterExit logging(__FUNCTION__, __FILE__, __LINE__);

	// create the instance, initialize with attributes from the path
	framework::Instance *pInstance = new framework::Instance(path);
	try
	{
		checkAttributes(attributes);

		path.checkKey(CREATIONCLASSNAME_KEY, MEMORYCONTROLLER_CREATIONCLASSNAME);
		path.checkKey(SYSTEMCREATIONCLASSNAME_KEY, server::BASESERVER_CREATIONCLASSNAME);
		path.checkKey(SYSTEMNAME_KEY, server::getHostName());

		// extract the memory controller id from the object path
		framework::Attribute devIdAttr = path.getKeyValue(DEVICEID_KEY);
		COMMON_LOG_DEBUG_F("DeviceID: %s", devIdAttr.asStr().c_str());

		int rc = nvm_get_device_count();
		if (rc < NVM_SUCCESS)
		{
			throw exception::NvmExceptionLibError(rc);
		}
		else if (rc == 0)
		{
			throw framework::Exception(
					"Could not find any NVDIMMs connected to Memory Controller");
		}

		// get the device_discovery information for all of the dimms
		struct device_discovery dimms[rc];
		if ((rc = nvm_get_devices(dimms, rc)) < NVM_SUCCESS)
		{
			throw exception::NvmExceptionLibError(rc);
		}
		else if (rc == 0)
		{
			throw framework::Exception(
					"Could not find any NVDIMMs connected to Memory Controller");
		}

		// initialize indicator
		int instance_found = 0;
		// find the set of unique memory controller ids used across all DIMMs
		for (int i = 0; i < rc; i++)
		{
			// compare the current DIMM's mem controller to the one that we are searching for
			instance_found = (devIdAttr.stringValue().compare(
					generateUniqueMemoryControllerID(&(dimms[i]))) == 0);
			if (instance_found)
			{
				// if found, update pInstance
				MemoryControllerFactory::addNonKeyAttributesToInstance(
						pInstance, &attributes, &(dimms[i]));

				// break the loop since we found what we were looking for
				break;
			}
		}

		// handle failures
		if (!instance_found)
		{
			COMMON_LOG_ERROR_F("Device ID Not Found: %s", devIdAttr.stringValue().c_str());
			throw framework::ExceptionBadParameter(DEVICEID_KEY.c_str());
		}
	}
	catch (framework::Exception) // clean up and re-throw
	{
		delete pInstance;
		throw;
	}

	return pInstance;
}
コード例 #5
0
ファイル: EventMonitor.cpp プロジェクト: jubalh/IXPDIMMSW
void monitor::EventMonitor::checkConfigGoalStatus(const std::string &uidStr, const deviceInfo &device) const
{
	// check platform config errors
	struct event_filter filter;
	memset(&filter, 0, sizeof (filter));
	filter.filter_mask = NVM_FILTER_ON_UID | NVM_FILTER_ON_TYPE;
	memmove(filter.uid, device.discovery.uid, NVM_MAX_UID_LEN);
	filter.type = EVENT_TYPE_CONFIG;

	struct config_goal goal;
	memset(&goal, 0, sizeof (goal));
	int rc = nvm_get_config_goal(device.discovery.uid, &goal);
	if (rc == NVM_SUCCESS)
	{
		enum config_goal_status configGoalStatus = goal.status;
		// ensure this is a new event
		if (!device.stored ||
		    configGoalStatus != device.storedState.config_goal_status)
		{
			// configuration processed successfully
			if (configGoalStatus == CONFIG_GOAL_STATUS_SUCCESS)
			{
				store_event_by_parts(EVENT_TYPE_CONFIG,
				                     EVENT_SEVERITY_INFO,
				                     EVENT_CODE_CONFIG_GOAL_APPLIED,
				                     device.discovery.uid,
				                     false,
				                     uidStr.c_str(),
				                     NULL,
				                     NULL,
				                     DIAGNOSTIC_RESULT_UNKNOWN);

				// acknowledge any old config events for this dimm
				acknowledge_events(&filter);
			}
			else if (configGoalStatus == CONFIG_GOAL_STATUS_ERR_BADREQUEST)
			{
				store_event_by_parts(EVENT_TYPE_CONFIG,
				                     EVENT_SEVERITY_WARN,
				                     EVENT_CODE_CONFIG_GOAL_FAILED_CONFIG_ERROR,
				                     device.discovery.uid,
				                     true,
				                     uidStr.c_str(),
				                     NULL,
				                     NULL,
				                     DIAGNOSTIC_RESULT_UNKNOWN);
			}
			else if (configGoalStatus == CONFIG_GOAL_STATUS_ERR_FW)
			{
				store_event_by_parts(EVENT_TYPE_CONFIG,
				                     EVENT_SEVERITY_WARN,
				                     EVENT_CODE_CONFIG_GOAL_FAILED_FW_ERROR,
				                     device.discovery.uid,
				                     true,
				                     uidStr.c_str(),
				                     NULL,
				                     NULL,
				                     DIAGNOSTIC_RESULT_UNKNOWN);
			}
			else if (configGoalStatus == CONFIG_GOAL_STATUS_ERR_INSUFFICIENTRESOURCES)
			{
				store_event_by_parts(EVENT_TYPE_CONFIG,
				                     EVENT_SEVERITY_WARN,
				                     EVENT_CODE_CONFIG_GOAL_FAILED_INSUFFICIENT_RESOURCES,
				                     device.discovery.uid,
				                     true,
				                     uidStr.c_str(),
				                     NULL,
				                     NULL,
				                     DIAGNOSTIC_RESULT_UNKNOWN);
			}
			else if (configGoalStatus == CONFIG_GOAL_STATUS_ERR_UNKNOWN)
			{
				store_event_by_parts(EVENT_TYPE_CONFIG,
				                     EVENT_SEVERITY_WARN,
				                     EVENT_CODE_CONFIG_GOAL_FAILED_UNKNOWN,
				                     device.discovery.uid,
				                     true,
				                     uidStr.c_str(),
				                     NULL,
				                     NULL,
				                     DIAGNOSTIC_RESULT_UNKNOWN);
			}
			else if (configGoalStatus == CONFIG_GOAL_STATUS_UNKNOWN)
			{
				store_event_by_parts(EVENT_TYPE_CONFIG,
				                     EVENT_SEVERITY_CRITICAL,
				                     EVENT_CODE_CONFIG_DATA_INVALID,
				                     device.discovery.uid,
				                     true,
				                     uidStr.c_str(),
				                     NULL,
				                     NULL,
				                     DIAGNOSTIC_RESULT_UNKNOWN);
			}
		} // end new config status
	}
	else if (rc == NVM_ERR_BADDEVICECONFIG)
	{
		store_event_by_parts(EVENT_TYPE_CONFIG,
		                     EVENT_SEVERITY_CRITICAL,
		                     EVENT_CODE_CONFIG_DATA_INVALID,
		                     device.discovery.uid,
		                     true,
		                     uidStr.c_str(),
		                     NULL,
		                     NULL,
		                     DIAGNOSTIC_RESULT_UNKNOWN);
	}
	else if (rc == NVM_ERR_NOTFOUND)
	{
		COMMON_LOG_DEBUG_F("No config goal found for DIMM %s", uidStr.c_str());
	}
	else
	{
		COMMON_LOG_ERROR_F("Error fetching config goal for DIMM %s, rc=%d", uidStr.c_str(), rc);
	}
}
コード例 #6
0
ファイル: EventMonitor.cpp プロジェクト: jubalh/IXPDIMMSW
void monitor::EventMonitor::saveCurrentTopologyState(const DeviceMap &devices)
{
	LogEnterExit logging(__FUNCTION__, __FILE__, __LINE__);

	bool saved = true;

	PersistentStore *pStore = get_lib_store();
	if (pStore)
	{
		// Only keep the latest topology
		if (db_delete_all_topology_states(pStore) != DB_SUCCESS)
		{
			COMMON_LOG_ERROR("couldn't delete old topology_state");
			saved = false;
		}
		else
		{
			// Preserve topology state in config DB
			for (DeviceMap::const_iterator iter = devices.begin();
					iter != devices.end(); iter++)
			{
				const std::string &uidStr = iter->first;
				const struct deviceInfo &device = iter->second;

				// only store current devices
				if (device.discovered)
				{
					struct db_topology_state topoState;
					memset(&topoState, 0, sizeof(topoState));
					s_strcpy(topoState.uid, uidStr.c_str(), NVM_MAX_UID_LEN);
					topoState.device_handle = device.discovery.device_handle.handle;
					topoState.manufacturer = MANUFACTURER_TO_UINT(device.discovery.manufacturer);
					topoState.serial_num = SERIAL_NUMBER_TO_UINT(device.discovery.serial_number);
					memmove(topoState.model_num, device.discovery.model_number, NVM_MODEL_LEN);

					topoState.current_config_status = device.status.config_status;
					topoState.config_goal_status = CONFIG_GOAL_STATUS_UNKNOWN;

					struct config_goal goal;
					memset(&goal, 0, sizeof (goal));
					int rc = nvm_get_config_goal(device.discovery.uid, &goal);
					if (rc == NVM_SUCCESS)
					{
						topoState.config_goal_status = goal.status;
					}
					else if (rc == NVM_ERR_NOTFOUND)
					{
						COMMON_LOG_DEBUG_F("No goal for DIMM %s", uidStr.c_str());
					}
					else
					{
						COMMON_LOG_ERROR_F("Error fetching config goalfor DIMM %s: %d",
						                   uidStr.c_str(),
						                   rc);
					}

					if (db_add_topology_state(pStore, &topoState) != DB_SUCCESS)
					{
						COMMON_LOG_ERROR_F("couldn't add topology_state for DIMM %s",
								topoState.uid);
						saved = false;
						break;
					}
				}
			}
		}

		// everything succeeded
		if (saved)
		{
			add_config_value(SQL_KEY_TOPOLOGY_STATE_VALID, "1");
		}
	}
}