NVM_UINT16 Device::getManufacturerId() { LogEnterExit logging(__FUNCTION__, __FILE__, __LINE__); return MANUFACTURER_TO_UINT(getDiscovery().manufacturer); }
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"); } } }