use of com.emc.storageos.db.exceptions.DatabaseException in project coprhd-controller by CoprHD.
the class DataCollectionJobUtil method getSMISProvidersWithUpdatedSystems.
/**
* Update all the SMISProviders with their actively managed storage systems information.
*
* @param providersToUpdate : dataStructure holds the provider => list of managed systems.
*/
private List<StorageProvider> getSMISProvidersWithUpdatedSystems(Map<URI, List<String>> providersToUpdate) {
List<StorageProvider> providerList = new ArrayList<StorageProvider>();
if (!providersToUpdate.isEmpty()) {
Iterator<URI> providerIdKeyItr = providersToUpdate.keySet().iterator();
while (providerIdKeyItr.hasNext()) {
URI providerIdKey = null;
try {
providerIdKey = providerIdKeyItr.next();
List<String> storageSystemList = providersToUpdate.get(providerIdKey);
StorageProvider provider = _dbClient.queryObject(StorageProvider.class, providerIdKey);
if (null != provider.getStorageSystems()) {
provider.getStorageSystems().clear();
provider.getStorageSystems().addAll(storageSystemList);
} else {
StringSet storageSystems = new StringSet();
storageSystems.addAll(storageSystemList);
provider.setStorageSystems(storageSystems);
}
providerList.add(provider);
} catch (DatabaseException ioEx) {
_logger.error("IOException occurred while updating storageSystems for provider {}", providerIdKey);
}
}
}
return providerList;
}
use of com.emc.storageos.db.exceptions.DatabaseException in project coprhd-controller by CoprHD.
the class DataCollectionJobUtil method performBookKeeping.
/**
* 1. Iterate through the scanner result cache.
* 2. For each serialId, find a storageSystem.
* 3. If it is null, then create a new StorageSystem and update the details.
* 4. If it is not null, then update active providers & registered status.
*
* @param scannedSystemsNativeGuidsMap
* : scanner result cache.
*/
public void performBookKeeping(Map<String, StorageSystemViewObject> scannedSystemsNativeGuidsMap, List<URI> providerList) {
StorageSystem storageSystem = null;
List<StorageSystem> systemsToPersist = new ArrayList<StorageSystem>();
List<StorageSystem> systemsToCreate = new ArrayList<StorageSystem>();
Set<String> scannedSystemNativeGuidKeySet;
synchronized (scannedSystemsNativeGuidsMap) {
scannedSystemNativeGuidKeySet = new HashSet(scannedSystemsNativeGuidsMap.keySet());
}
Set<URI> scannedProviderList = new HashSet<URI>(providerList);
Map<URI, List<String>> providersToUpdate = new HashMap<URI, List<String>>();
for (String scannedSystemNativeGuid : scannedSystemNativeGuidKeySet) {
try {
_logger.info("Found during scan : scannedSystemNativeGuid {}", scannedSystemNativeGuid);
List<StorageSystem> systems = CustomQueryUtility.getActiveStorageSystemByNativeGuid(_dbClient, scannedSystemNativeGuid);
if (DecommissionedResource.checkDecommissioned(_dbClient, scannedSystemNativeGuid, StorageSystem.class)) {
scannedSystemsNativeGuidsMap.remove(scannedSystemNativeGuid);
_logger.info("Storage system {} was decommissioned and cannot be added to Vipr", scannedSystemNativeGuid);
continue;
}
if (null == systems || systems.isEmpty()) {
storageSystem = createStorageSystem(scannedSystemsNativeGuidsMap.get(scannedSystemNativeGuid), scannedSystemNativeGuid, providersToUpdate);
if (storageSystem != null) {
systemsToCreate.add(storageSystem);
_logger.info("Added new storage system to be created to the create list with Native Guid: {}", storageSystem.getNativeGuid());
}
}
} catch (Exception e) {
_logger.error(e.getMessage(), e);
_logger.error("Exception while creating new system: {} due to {}", storageSystem != null ? storageSystem.getId() : "N/A", e.getCause());
}
}
try {
_dbClient.createObject(systemsToCreate);
} catch (DatabaseException ex) {
_logger.error("Exception occurred while persisting new StorageSystems due to ", ex);
}
// If a provider is not managing an array and it is moved to some other array,
// then this will update the active provider in the storage system.
updateActiveProviderDetailsInDbSystem(scannedSystemsNativeGuidsMap, systemsToPersist, scannedProviderList, providersToUpdate);
// Persist all storage systems & providers
persistAllSystemsAndProviders(systemsToPersist, getSMISProvidersWithUpdatedSystems(providersToUpdate));
}
use of com.emc.storageos.db.exceptions.DatabaseException in project coprhd-controller by CoprHD.
the class RPCommunicationInterface method discover.
@Override
public void discover(AccessProfile accessProfile) throws BaseCollectionException {
URI storageSystemId = null;
ProtectionSystem protectionSystem = null;
boolean discoverySuccess = true;
StringBuffer errMsgBuilder = new StringBuffer();
String detailedStatusMessage = "Unknown Status";
boolean isNewlyCreated = false;
try {
_log.info("Access Profile Details : IpAddress : {}, PortNumber : {}", accessProfile.getIpAddress(), accessProfile.getPortNumber());
storageSystemId = accessProfile.getSystemId();
protectionSystem = _dbClient.queryObject(ProtectionSystem.class, storageSystemId);
if (protectionSystem.getDiscoveryStatus().equals(DiscoveredDataObject.DataCollectionJobStatus.CREATED.toString())) {
isNewlyCreated = true;
}
if (StorageSystem.Discovery_Namespaces.UNMANAGED_CGS.toString().equalsIgnoreCase(accessProfile.getnamespace())) {
try {
unManagedCGDiscoverer.discoverUnManagedObjects(accessProfile, _dbClient, _partitionManager);
} catch (RecoverPointException rpe) {
discoverySuccess = false;
String msg = "Discover RecoverPoint Unmanaged CGs failed. Protection system: " + storageSystemId;
buildErrMsg(errMsgBuilder, rpe, msg);
}
} else {
try {
discoverCluster(protectionSystem);
} catch (RecoverPointException rpe) {
discoverySuccess = false;
String msg = "Discover RecoverPoint cluster failed. Protection system: " + storageSystemId;
buildErrMsg(errMsgBuilder, rpe, msg);
}
// get RP array mappings
try {
if (discoverySuccess) {
discoverRPSiteArrays(protectionSystem);
_dbClient.persistObject(protectionSystem);
}
} catch (Exception rpe) {
discoverySuccess = false;
String msg = "Discover RecoverPoint site/cluster failed. Protection system: " + storageSystemId;
buildErrMsg(errMsgBuilder, rpe, msg);
}
try {
if (discoverySuccess) {
discoverConnectivity(protectionSystem);
}
} catch (Exception rpe) {
discoverySuccess = false;
String msg = "Discover RecoverPoint connectivity failed. Protection system: " + storageSystemId;
buildErrMsg(errMsgBuilder, rpe, msg);
}
// Perform maintenance on the RP bookmarks; some may no longer be valid
try {
if (discoverySuccess) {
RPHelper.cleanupSnapshots(_dbClient, protectionSystem);
}
} catch (Exception rpe) {
discoverySuccess = false;
String msg = "Snapshot maintenance failed. Protection system: " + storageSystemId;
buildErrMsg(errMsgBuilder, rpe, msg);
}
// Rematch storage pools for RP virtual pools
try {
if (discoverySuccess && isNewlyCreated) {
matchVPools(protectionSystem.getId());
}
} catch (Exception rpe) {
discoverySuccess = false;
String msg = "Virtual Pool matching failed. Protection system: " + storageSystemId;
buildErrMsg(errMsgBuilder, rpe, msg);
}
// Discover the Connected-via-RP-itself Storage Systems
try {
if (discoverySuccess) {
discoverVisibleStorageSystems(protectionSystem);
}
} catch (Exception rpe) {
discoverySuccess = false;
String msg = "RP-visible storage system discovery failed. Protection system: " + storageSystemId;
buildErrMsg(errMsgBuilder, rpe, msg);
}
// Discover the Connected-via-NetworkStorage Systems
try {
if (discoverySuccess) {
discoverAssociatedStorageSystems(protectionSystem);
}
} catch (Exception rpe) {
discoverySuccess = false;
String msg = "Storage system discovery failed. Protection system: " + storageSystemId;
buildErrMsg(errMsgBuilder, rpe, msg);
}
// Discover the protection sets
try {
if (discoverySuccess) {
discoverProtectionSets(protectionSystem);
}
} catch (Exception rpe) {
discoverySuccess = false;
String msg = "Discovery of protection sets failed. Protection system: " + storageSystemId;
buildErrMsg(errMsgBuilder, rpe, msg);
}
// Discover the protection system cluster connectivity topology information
try {
if (discoverySuccess) {
discoverTopology(protectionSystem);
}
} catch (Exception rpe) {
discoverySuccess = false;
String msg = "Discovery of topology failed. Protection system: " + storageSystemId;
buildErrMsg(errMsgBuilder, rpe, msg);
}
}
if (!discoverySuccess) {
throw DeviceControllerExceptions.recoverpoint.discoveryFailure(errMsgBuilder.toString());
} else {
detailedStatusMessage = String.format("Discovery completed successfully for Protection System: %s", storageSystemId.toString());
}
} catch (Exception e) {
detailedStatusMessage = String.format("Discovery failed for Protection System %s because %s", storageSystemId.toString(), e.getLocalizedMessage());
_log.error(detailedStatusMessage, e);
throw DeviceControllerExceptions.recoverpoint.discoveryFailure(detailedStatusMessage);
} finally {
releaseResources();
if (null != protectionSystem) {
try {
// set detailed message
protectionSystem.setLastDiscoveryStatusMessage(detailedStatusMessage);
_dbClient.persistObject(protectionSystem);
} catch (DatabaseException ex) {
_log.error("Error while persisting object to DB", ex);
}
}
}
}
use of com.emc.storageos.db.exceptions.DatabaseException in project coprhd-controller by CoprHD.
the class SMICommunicationInterface method scan.
/**
* {@inheritDoc}
*/
@Override
public void scan(AccessProfile accessProfile) throws BaseCollectionException {
URI providerURI = null;
StorageProvider providerObj = null;
String detailedStatusMessage = "Unknown Status";
try {
_logger.info("Access Profile Details :" + accessProfile.toString());
providerURI = accessProfile.getSystemId();
providerObj = _dbClient.queryObject(StorageProvider.class, providerURI);
_keyMap = new ConcurrentHashMap<String, Object>();
_wbemClient = getCIMClient(accessProfile);
_logger.info("CIMClient initialized successfully");
_keyMap.put(Constants.PROPS, accessProfile.getProps());
if (accessProfile.getCache() == null) {
accessProfile.setCache(new HashMap<String, StorageSystemViewObject>());
}
_keyMap.put(Constants._computerSystem, new ArrayList<CIMObjectPath>());
_keyMap.put(Constants.REGISTEREDPROFILE, CimObjectPathCreator.createInstance(Constants.PROFILECLASS, "interop"));
_keyMap.put(Constants._cimClient, _wbemClient);
_keyMap.put(Constants.dbClient, _dbClient);
_keyMap.put(Constants.COORDINATOR_CLIENT, _coordinator);
if (_networkDeviceController != null) {
_keyMap.put(Constants.networkDeviceController, _networkDeviceController);
}
_keyMap.put(Constants._InteropNamespace, accessProfile.getInteropNamespace());
_keyMap.put(Constants.ACCESSPROFILE, accessProfile);
_keyMap.put(Constants.SYSTEMCACHE, accessProfile.getCache());
executor.setKeyMap(_keyMap);
executor.execute((Namespace) namespaces.getNsList().get(SCAN));
// scan succeeds
detailedStatusMessage = String.format("Scan job completed successfully for " + "SMISProvider: %s", providerURI.toString());
} catch (Exception e) {
detailedStatusMessage = String.format("Scan job failed for SMISProvider: %s because %s", providerURI.toString(), e.getMessage());
throw new SMIPluginException(detailedStatusMessage);
} finally {
if (providerObj != null) {
try {
// set detailed message
providerObj.setLastScanStatusMessage(detailedStatusMessage);
_dbClient.persistObject(providerObj);
} catch (DatabaseException ex) {
_logger.error("Error while persisting object to DB", ex);
}
}
releaseResources();
}
}
use of com.emc.storageos.db.exceptions.DatabaseException in project coprhd-controller by CoprHD.
the class VPlexCommunicationInterface method discoverAll.
/**
* Implementation for discovering everything in a VPLEX storage system.
*
* @param accessProfile providing context for this discovery session
*
* @throws BaseCollectionException
*/
private void discoverAll(AccessProfile accessProfile) throws BaseCollectionException {
boolean discoverySuccess = true;
StringBuffer errMsgBuilder = new StringBuffer();
URI storageSystemURI = null;
StorageSystem vplexStorageSystem = null;
String detailedStatusMessage = "Unknown Status";
VPlexApiClient client = null;
try {
s_logger.info("Access Profile Details : IpAddress : {}, PortNumber : {}", accessProfile.getIpAddress(), accessProfile.getPortNumber());
storageSystemURI = accessProfile.getSystemId();
// Get the VPlex storage system from the database.
vplexStorageSystem = _dbClient.queryObject(StorageSystem.class, storageSystemURI);
s_logger.info("Discover VPlex storage system {} at IP:{}, PORT:{}", new Object[] { storageSystemURI.toString(), accessProfile.getIpAddress(), accessProfile.getPortNumber() });
// Get the Http client for getting information about the VPlex
// storage system.
client = getVPlexAPIClient(accessProfile);
s_logger.debug("Got handle to VPlex API client");
// clear cached discovery data in the VPlexApiClient
client.clearCaches();
client.primeCaches();
// The version for the storage system is the version of its active provider
// and since we are discovering it, the provider was compatible, so the
// VPLEX must also be compatible.
StorageProvider activeProvider = _dbClient.queryObject(StorageProvider.class, vplexStorageSystem.getActiveProviderURI());
String serialNumber = getSystemSerialNumber(client, activeProvider, null);
if (!vplexStorageSystem.getSerialNumber().equals(serialNumber)) {
s_logger.error(String.format("The VPLEX serial number unexpectedly changed from %s to %s.", vplexStorageSystem.getSerialNumber(), serialNumber));
throw VPlexApiException.exceptions.vplexSerialNumberChanged(vplexStorageSystem.getSerialNumber(), serialNumber);
}
vplexStorageSystem.setFirmwareVersion(activeProvider.getVersionString());
vplexStorageSystem.setCompatibilityStatus(CompatibilityStatus.COMPATIBLE.toString());
// Discover the cluster identification (serial number / cluster id ) mapping
try {
s_logger.info("Discovering cluster identification.");
discoverClusterIdentification(vplexStorageSystem, client);
_completer.statusPending(_dbClient, "Completed cluster identification discovery");
} catch (VPlexCollectionException vce) {
discoverySuccess = false;
String errMsg = String.format("Failed cluster identification discovery for VPlex %s", storageSystemURI.toString());
s_logger.error(errMsg, vce);
if (errMsgBuilder.length() != 0) {
errMsgBuilder.append(", ");
}
errMsgBuilder.append(errMsg);
}
List<StoragePort> allPorts = new ArrayList<StoragePort>();
// Discover the VPlex port information.
try {
// When we discover storage ports on the VPlex, we create
// initiators, if they don't exist, for backend ports.
// The backend storage ports serve as initiators for the
// connected backend storage.
s_logger.info("Discovering frontend and backend ports.");
discoverPorts(client, vplexStorageSystem, allPorts, null);
_dbClient.updateObject(vplexStorageSystem);
_completer.statusPending(_dbClient, "Completed port discovery");
} catch (VPlexCollectionException vce) {
discoverySuccess = false;
String errMsg = String.format("Failed port discovery for VPlex %s", storageSystemURI.toString());
s_logger.error(errMsg, vce);
if (errMsgBuilder.length() != 0) {
errMsgBuilder.append(", ");
}
errMsgBuilder.append(errMsg);
}
// update host initiators with registered initiator names from VPLEX
try {
updateHostInitiators(client, vplexStorageSystem.getSerialNumber());
} catch (VPlexCollectionException vce) {
discoverySuccess = false;
String errMsg = String.format("Failed host initiator update for VPlex %s", storageSystemURI.toString());
s_logger.error(errMsg, vce);
if (errMsgBuilder.length() != 0) {
errMsgBuilder.append(", ");
}
errMsgBuilder.append(errMsg);
}
try {
s_logger.info("Discovering connectivity.");
discoverConnectivity(vplexStorageSystem);
_dbClient.updateObject(vplexStorageSystem);
_completer.statusPending(_dbClient, "Completed connectivity verification");
} catch (VPlexCollectionException vce) {
discoverySuccess = false;
String errMsg = String.format("Failed connectivity discovery for VPlex %s", storageSystemURI.toString());
s_logger.error(errMsg, vce);
if (errMsgBuilder.length() != 0) {
errMsgBuilder.append(", ");
}
errMsgBuilder.append(errMsg);
}
if (discoverySuccess) {
vplexStorageSystem.setReachableStatus(true);
_dbClient.updateObject(vplexStorageSystem);
} else {
// If part of the discovery process failed, throw an exception.
vplexStorageSystem.setReachableStatus(false);
_dbClient.updateObject(vplexStorageSystem);
throw new Exception(errMsgBuilder.toString());
}
StoragePortAssociationHelper.runUpdatePortAssociationsProcess(allPorts, null, _dbClient, _coordinator, null);
// discovery succeeds
detailedStatusMessage = String.format("Discovery completed successfully for Storage System: %s", storageSystemURI.toString());
} catch (Exception e) {
if (null != client) {
// clear cached discovery data in the VPlexApiClient
client.clearCaches();
}
VPlexCollectionException vce = VPlexCollectionException.exceptions.failedDiscovery(storageSystemURI.toString(), e.getLocalizedMessage());
detailedStatusMessage = vce.getLocalizedMessage();
s_logger.error(detailedStatusMessage, e);
throw vce;
} finally {
if (vplexStorageSystem != null) {
try {
// set detailed message
vplexStorageSystem.setLastDiscoveryStatusMessage(detailedStatusMessage);
_dbClient.updateObject(vplexStorageSystem);
} catch (DatabaseException ex) {
s_logger.error("Error persisting last discovery status for storage system {}", vplexStorageSystem.getId(), ex);
}
}
}
}
Aggregations