/* * Helper function to retrieve just goal instance names */ wbem::framework::instance_names_t* wbem::mem_config::MemoryConfigurationFactory::getGoalInstanceNames( const bool onlyUnappliedGoals) throw (wbem::framework::Exception) { LogEnterExit logging(__FUNCTION__, __FILE__, __LINE__); framework::instance_names_t *pNames = new framework::instance_names_t(); try { std::string hostName = wbem::server::getHostName(); // get dimm uids std::vector<std::string> uids = wbem::physical_asset::NVDIMMFactory::getManageableDeviceUids(); for (unsigned int i = 0; i < uids.size(); i++) { framework::attributes_t keys; struct config_goal goal; NVM_UID uid; uid_copy(uids[i].c_str(), uid); int rc; if ((rc = nvm_get_config_goal(uid, &goal)) == NVM_SUCCESS) { if (goal.status != CONFIG_GOAL_STATUS_SUCCESS) { std::string instanceIdStr(uids[i]); instanceIdStr += GOAL_CONFIG; keys[INSTANCEID_KEY] = framework::Attribute(instanceIdStr, true); framework::ObjectPath configPath(hostName, NVM_NAMESPACE, MEMORYCONFIGURATION_CREATIONCLASSNAME, keys); pNames->push_back(configPath); } if ((!onlyUnappliedGoals) && (goal.status == CONFIG_GOAL_STATUS_SUCCESS)) { std::string instanceIdStr(uids[i]); instanceIdStr += CURRENT_CONFIG; keys[INSTANCEID_KEY] = framework::Attribute(instanceIdStr, true); framework::ObjectPath configPath(hostName, NVM_NAMESPACE, MEMORYCONFIGURATION_CREATIONCLASSNAME, keys); pNames->push_back(configPath); } } else if (rc != NVM_ERR_NOTFOUND) { throw exception::NvmExceptionLibError(rc); } } } catch (framework::Exception &) // clean up and re-throw { delete pNames; throw; } return pNames; }
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); } }
int LibWrapper::getConfigGoal(const NVM_UID deviceUid, struct config_goal *pGoal) const { LogEnterExit(__FUNCTION__, __FILE__, __LINE__); return nvm_get_config_goal(deviceUid, pGoal); }
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"); } } }