use of com.emc.storageos.db.client.model.StorageProvider 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.client.model.StorageProvider in project coprhd-controller by CoprHD.
the class VNXUnityCommunicationInterface method scan.
/**
* Implementation for scan for Vnx Unity storage systems.
*
* @param accessProfile
*
* @throws BaseCollectionException
*/
@Override
public void scan(AccessProfile accessProfile) throws BaseCollectionException {
_logger.info("Starting scan of Unity StorageProvider. IP={}", accessProfile.getIpAddress());
StorageProvider.ConnectionStatus cxnStatus = StorageProvider.ConnectionStatus.CONNECTED;
StorageProvider provider = _dbClient.queryObject(StorageProvider.class, accessProfile.getSystemId());
_locker.acquireLock(accessProfile.getIpAddress(), LOCK_WAIT_SECONDS);
try {
VNXeApiClient apiClient = getVnxUnityClient(accessProfile);
if (apiClient != null) {
Map<String, StorageSystemViewObject> storageSystemsCache = accessProfile.getCache();
BasicSystemInfo unitySystem = apiClient.getBasicSystemInfo();
String unityType = StorageSystem.Type.unity.name();
String version = unitySystem.getApiVersion();
String compatibility = StorageSystem.CompatibilityStatus.COMPATIBLE.name();
provider.setCompatibilityStatus(compatibility);
provider.setVersionString(version);
VNXeStorageSystem system = apiClient.getStorageSystem();
_logger.info("Found Unity: {} ", system.getSerialNumber());
String id = system.getSerialNumber();
String nativeGuid = generateNativeGuid(unityType, id);
StorageSystemViewObject viewObject = storageSystemsCache.get(nativeGuid);
if (viewObject == null) {
viewObject = new StorageSystemViewObject();
}
viewObject.setDeviceType(unityType);
viewObject.addprovider(accessProfile.getSystemId().toString());
viewObject.setProperty(StorageSystemViewObject.MODEL, unitySystem.getModel());
viewObject.setProperty(StorageSystemViewObject.SERIAL_NUMBER, id);
storageSystemsCache.put(nativeGuid, viewObject);
}
} catch (Exception e) {
cxnStatus = StorageProvider.ConnectionStatus.NOTCONNECTED;
_logger.error(String.format("Exception was encountered when attempting to scan Unity Instance %s", accessProfile.getIpAddress()), e);
throw VNXeException.exceptions.scanFailed(accessProfile.getIpAddress(), e);
} finally {
provider.setConnectionStatus(cxnStatus.name());
_dbClient.updateObject(provider);
_logger.info("Completed scan of Unity StorageProvider. IP={}", accessProfile.getIpAddress());
_locker.releaseLock(accessProfile.getIpAddress());
}
}
use of com.emc.storageos.db.client.model.StorageProvider in project coprhd-controller by CoprHD.
the class BlockControllerImpl method scanStorageProviders.
/**
* {@inheritDoc}
*/
@Override
public void scanStorageProviders(AsyncTask[] tasks) throws ControllerException {
try {
Map<String, DataCollectionScanJob> scanJobByInterfaceType = new HashMap<String, DataCollectionScanJob>();
for (AsyncTask task : tasks) {
ScanTaskCompleter completer = new ScanTaskCompleter(task);
StorageProvider provider = _dbClient.queryObject(StorageProvider.class, completer.getId());
if (provider != null && !provider.getInactive()) {
if (scanJobByInterfaceType.get(provider.getInterfaceType()) == null) {
scanJobByInterfaceType.put(provider.getInterfaceType(), new DataCollectionScanJob());
}
scanJobByInterfaceType.get(provider.getInterfaceType()).addCompleter(completer);
}
}
for (DataCollectionScanJob job : scanJobByInterfaceType.values()) {
_util.scheduleScanningJobs(job);
}
} catch (Exception e) {
throw ClientControllerException.fatals.unableToScanSMISProviders(tasks, "BlockController", e);
}
}
use of com.emc.storageos.db.client.model.StorageProvider 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);
}
}
}
}
use of com.emc.storageos.db.client.model.StorageProvider in project coprhd-controller by CoprHD.
the class VPlexCommunicationInterface method scan.
/**
* Implementation for scan for VPlex storage systems.
*
* @param accessProfile
*
* @throws BaseCollectionException
*/
@Override
public void scan(AccessProfile accessProfile) throws BaseCollectionException {
URI mgmntServerURI = accessProfile.getSystemId();
StorageProvider mgmntServer = null;
String scanStatusMessage = "Unknown Status";
VPlexApiClient client = null;
try {
// Get the storage provider representing a VPLEX management server.
mgmntServer = _dbClient.queryObject(StorageProvider.class, mgmntServerURI);
// Get the Http client for getting information about the VPLEX
// cluster(s) managed by the VPLEX management server.
client = getVPlexAPIClient(accessProfile);
s_logger.debug("Got handle to VPlex API client");
// Verify the connectivity to the VPLEX management server.
verifyConnectivity(client, mgmntServer);
// Verify the VPLEX system firmware version is supported.
verifyMinimumSupportedFirmwareVersion(client, mgmntServer);
// Determine the VPLEX system managed by this management server.
Map<String, StorageSystemViewObject> scanCache = accessProfile.getCache();
s_logger.info("Storage System scanCache before scanning:" + scanCache);
scanManagedSystems(client, mgmntServer, scanCache);
s_logger.info("Storage System scanCache after scanning:" + scanCache);
scanStatusMessage = String.format("Scan job completed successfully for " + "VPLEX management server: %s", mgmntServerURI.toString());
} catch (Exception e) {
if (null != client) {
// clear cached discovery data in the VPlexApiClient
client.clearCaches();
}
VPlexCollectionException vce = VPlexCollectionException.exceptions.failedScan(mgmntServer.getIPAddress(), e.getLocalizedMessage());
scanStatusMessage = vce.getLocalizedMessage();
throw vce;
} finally {
if (mgmntServer != null) {
try {
mgmntServer.setLastScanStatusMessage(scanStatusMessage);
_dbClient.updateObject(mgmntServer);
} catch (Exception e) {
s_logger.error("Error persisting scan status message for management server {}", mgmntServerURI.toString(), e);
}
}
}
}
Aggregations