use of com.emc.storageos.plugins.StorageSystemViewObject in project coprhd-controller by CoprHD.
the class ScaleIOCommunicationInterface method scan.
@Override
public void scan(AccessProfile accessProfile) throws BaseCollectionException {
log.info("Starting scan of ScaleIO StorageProvider. IP={}", accessProfile.getIpAddress());
StorageProvider.ConnectionStatus cxnStatus = StorageProvider.ConnectionStatus.CONNECTED;
StorageProvider provider = _dbClient.queryObject(StorageProvider.class, accessProfile.getSystemId());
if (provider.getInterfaceType().equalsIgnoreCase(DiscoveredDataObject.Type.scaleio.name())) {
provider.setConnectionStatus(StorageProvider.ConnectionStatus.NOTCONNECTED.name());
ScaleIOException ex = ScaleIOException.exceptions.scaleioCliNotSupported();
provider.setLastScanStatusMessage(ex.getLocalizedMessage());
_dbClient.persistObject(provider);
throw ScaleIOException.exceptions.scaleioCliNotSupported();
}
_locker.acquireLock(accessProfile.getIpAddress(), LOCK_WAIT_SECONDS);
try {
ScaleIORestClient scaleIOHandle = scaleIOHandleFactory.using(_dbClient).getClientHandle(provider);
if (scaleIOHandle != null) {
Map<String, StorageSystemViewObject> storageSystemsCache = accessProfile.getCache();
ScaleIOSystem sioSystem = scaleIOHandle.getSystem();
String[] ipList = null;
if (sioSystem.getVersion().substring(0, 1).compareTo("2") >= 0) {
Slaves[] slaves = sioSystem.getMdmCluster().getSlaves();
if ((slaves.length > 0))
ipList = new String[slaves.length];
for (int iterInd = 0; iterInd < slaves.length; iterInd++) {
ipList[iterInd] = slaves[iterInd].getIps()[0];
}
} else {
ipList = sioSystem.getSecondaryMdmActorIpList();
}
if (ipList != null && ipList.length > 0) {
StringSet secondaryIps = new StringSet();
secondaryIps.add(ipList[0]);
provider.setSecondaryIps(secondaryIps);
}
String scaleIOType = StorageSystem.Type.scaleio.name();
String installationId = sioSystem.getInstallId();
String version = sioSystem.getVersion().replaceAll("_", ".");
String minimumSupported = VersionChecker.getMinimumSupportedVersion(StorageSystem.Type.scaleio);
String compatibility = (VersionChecker.verifyVersionDetails(minimumSupported, version) < 0) ? StorageSystem.CompatibilityStatus.INCOMPATIBLE.name() : StorageSystem.CompatibilityStatus.COMPATIBLE.name();
provider.setCompatibilityStatus(compatibility);
provider.setVersionString(version);
List<ScaleIOProtectionDomain> protectionDomains = scaleIOHandle.getProtectionDomains();
for (ScaleIOProtectionDomain protectionDomain : protectionDomains) {
log.info("For ScaleIO instance {}, found ProtectionDomain {}", installationId, protectionDomain.getName());
String id = String.format("%s+%s", installationId, protectionDomain.getName());
String nativeGuid = generateNativeGuid(scaleIOType, id);
StorageSystemViewObject viewObject = storageSystemsCache.get(nativeGuid);
if (viewObject == null) {
viewObject = new StorageSystemViewObject();
}
viewObject.setDeviceType(scaleIOType);
viewObject.addprovider(accessProfile.getSystemId().toString());
viewObject.setProperty(StorageSystemViewObject.MODEL, "ScaleIO ECS");
viewObject.setProperty(StorageSystemViewObject.SERIAL_NUMBER, id);
storageSystemsCache.put(nativeGuid, viewObject);
}
}
} catch (Exception e) {
cxnStatus = StorageProvider.ConnectionStatus.NOTCONNECTED;
log.error(String.format("Exception was encountered when attempting to scan ScaleIO Instance %s", accessProfile.getIpAddress()), e);
throw ScaleIOException.exceptions.scanFailed(e);
} finally {
provider.setConnectionStatus(cxnStatus.name());
_dbClient.persistObject(provider);
log.info("Completed scan of ScaleIO StorageProvider. IP={}", accessProfile.getIpAddress());
_locker.releaseLock(accessProfile.getIpAddress());
}
}
use of com.emc.storageos.plugins.StorageSystemViewObject in project coprhd-controller by CoprHD.
the class CephCommunicationInterface method scan.
@Override
public void scan(AccessProfile accessProfile) throws BaseCollectionException {
_log.info("Starting scan of Ceph StorageProvider. IP={}", accessProfile.getIpAddress());
StorageProvider provider = _dbClient.queryObject(StorageProvider.class, accessProfile.getSystemId());
StorageProvider.ConnectionStatus status = StorageProvider.ConnectionStatus.NOTCONNECTED;
Map<String, StorageSystemViewObject> storageSystemsCache = accessProfile.getCache();
String cephType = StorageSystem.Type.ceph.name();
try (CephClient cephClient = CephUtils.connectToCeph(_cephClientFactory, provider)) {
ClusterInfo clusterInfo = cephClient.getClusterInfo();
String systemNativeGUID = NativeGUIDGenerator.generateNativeGuid(cephType, clusterInfo.getFsid());
StorageSystemViewObject viewObject = storageSystemsCache.get(systemNativeGUID);
if (viewObject == null) {
viewObject = new StorageSystemViewObject();
}
viewObject.setDeviceType(cephType);
viewObject.addprovider(accessProfile.getSystemId().toString());
viewObject.setProperty(StorageSystemViewObject.SERIAL_NUMBER, clusterInfo.getFsid());
viewObject.setProperty(StorageSystemViewObject.STORAGE_NAME, systemNativeGUID);
viewObject.setProperty(StorageSystemViewObject.MODEL, "Ceph Storage Cluster");
// TODO It is possible to figure out more Ceph cluster details (version, alternative IPs, etc),
// but neither Java client, nor pure librados provide this info. Since Ceph (with clien libraries)
// is an open source project it is possible to extend its functionality, and then use it here
storageSystemsCache.put(systemNativeGUID, viewObject);
status = StorageProvider.ConnectionStatus.CONNECTED;
} catch (Exception e) {
_log.error(String.format("Exception was encountered when attempting to scan Ceph Instance %s", accessProfile.getIpAddress()), e);
throw CephException.exceptions.operationException(e);
} finally {
provider.setConnectionStatus(status.name());
_dbClient.updateObject(provider);
}
}
use of com.emc.storageos.plugins.StorageSystemViewObject in project coprhd-controller by CoprHD.
the class CinderCommunicationInterface method fillStorageSystemCache.
private void fillStorageSystemCache(AccessProfile accessProfile, ArrayList<Section> sections) {
Map<String, StorageSystemViewObject> storageSystemsCache = accessProfile.getCache();
// Analyze each section, and update the cache if a new backend is found
for (Section section : sections) {
if (section.volume_driver.isEmpty()) {
continue;
}
String systemType = StorageSystem.Type.openstack.name();
String model = "";
String driverName = section.volume_driver;
String label = section.volume_backend_name;
if (label.isEmpty()) {
// use section title instead
label = section.title;
}
// If it is the default section and label doesn't have Default tag, then add Default tag in label
if (section.title.equalsIgnoreCase(CinderConstants.DEFAULT) && !label.toUpperCase().contains(CinderConstants.DEFAULT)) {
label = String.format("%s_%s", CinderConstants.DEFAULT, label);
}
String vendor = "";
String[] driver_splits = section.volume_driver.split("\\.");
if (driver_splits.length > 3) {
vendor = driver_splits[3];
if (driver_splits.length > 4) {
model = driver_splits[4];
}
if (driver_splits.length > 5) {
driverName = driver_splits[5];
}
}
// truncate the driver name if it is lengthy, since label length cannot be >64.
if (driverName.contains(".")) {
driverName = driverName.substring(driverName.lastIndexOf("."));
}
StorageSystemViewObject systemVO = null;
label = String.format("%s_%s", label, driverName);
String serialNumber = generateSerialNumber(label + accessProfile.getIpAddress());
String nativeGuid = String.format("%s+%s", label, serialNumber);
if (storageSystemsCache.containsKey(nativeGuid)) {
systemVO = storageSystemsCache.get(nativeGuid);
_logger.info("Updating existing Storage System: label = {}, model = {},", label, model);
_logger.info(" type = {}, serial Number generated = {}", systemType, serialNumber);
} else {
systemVO = new StorageSystemViewObject();
_logger.info("Adding new Storage System: label = {}, model = {},", label, model);
_logger.info(" type = {}, serial Number generated = {}", systemType, serialNumber);
}
systemVO.setDeviceType(systemType);
systemVO.addprovider(accessProfile.getSystemId().toString());
systemVO.setProperty(StorageSystemViewObject.MODEL, model);
systemVO.setProperty(StorageSystemViewObject.SERIAL_NUMBER, serialNumber);
systemVO.setProperty(StorageSystemViewObject.STORAGE_NAME, nativeGuid);
storageSystemsCache.put(nativeGuid, systemVO);
}
_logger.info("Found {} system(s) during scanning for ip {}", storageSystemsCache.size(), accessProfile.getIpAddress());
}
use of com.emc.storageos.plugins.StorageSystemViewObject in project coprhd-controller by CoprHD.
the class ExternalDeviceCommunicationInterface method scan.
@Override
public void scan(AccessProfile accessProfile) throws BaseCollectionException {
// Initialize driver instance for storage provider,
// call driver to scan the provider to get list of managed storage systems,
// update the system with this information.
_log.info("Scanning started for provider: {}", accessProfile.getSystemId());
com.emc.storageos.db.client.model.StorageProvider.ConnectionStatus cxnStatus = com.emc.storageos.db.client.model.StorageProvider.ConnectionStatus.CONNECTED;
// Get discovery driver class based on storage device type
String deviceType = accessProfile.getSystemType();
AbstractStorageDriver driver = getDriver(deviceType);
if (driver == null) {
String errorMsg = String.format("No driver entry defined for device type: %s . ", deviceType);
_log.info(errorMsg);
throw new ExternalDeviceCollectionException(false, ServiceCode.DISCOVERY_ERROR, null, errorMsg, null, null);
}
com.emc.storageos.db.client.model.StorageProvider storageProvider = null;
try {
storageProvider = _dbClient.queryObject(com.emc.storageos.db.client.model.StorageProvider.class, accessProfile.getSystemId());
String username = storageProvider.getUserName();
String password = storageProvider.getPassword();
String hostName = storageProvider.getIPAddress();
Integer portNumber = storageProvider.getPortNumber();
String providerType = storageProvider.getInterfaceType();
Boolean useSsl = storageProvider.getUseSSL();
String msg = String.format("Storage provider info: type: %s, host: %s, port: %s, user: %s, useSsl: %s", providerType, hostName, portNumber, username, useSsl);
_log.info(msg);
StorageProvider driverProvider = new StorageProvider();
// initialize driver provider
driverProvider.setProviderHost(hostName);
driverProvider.setPortNumber(portNumber);
driverProvider.setUsername(username);
driverProvider.setPassword(password);
driverProvider.setUseSSL(useSsl);
// call the driver
List<StorageSystem> systems = new ArrayList<>();
DriverTask task = driver.discoverStorageProvider(driverProvider, systems);
// todo: need to implement support for async case.
if (task.getStatus() == DriverTask.TaskStatus.READY) {
// process results, populate cache
_log.info("Scan: found {} systems for provider {}", systems.size(), accessProfile.getSystemId());
// update provider with scan info
storageProvider.setVersionString(driverProvider.getProviderVersion());
if (driverProvider.isSupportedVersion()) {
storageProvider.setCompatibilityStatus(DiscoveredDataObject.CompatibilityStatus.COMPATIBLE.name());
} else {
storageProvider.setCompatibilityStatus(DiscoveredDataObject.CompatibilityStatus.INCOMPATIBLE.name());
String errorMsg = String.format("Storage provider %s has version %s which is not supported by driver", storageProvider.getIPAddress(), storageProvider.getVersionString());
throw new ExternalDeviceCollectionException(false, ServiceCode.DISCOVERY_ERROR, null, errorMsg, null, null);
}
// process storage system cache
Map<String, StorageSystemViewObject> storageSystemsCache = accessProfile.getCache();
for (StorageSystem driverStorageSystem : systems) {
String systemType = driverStorageSystem.getSystemType();
String nativeGuid = NativeGUIDGenerator.generateNativeGuid(systemType, driverStorageSystem.getNativeId());
StorageSystemViewObject storageSystemView = storageSystemsCache.get(nativeGuid);
if (storageSystemView == null) {
storageSystemView = new StorageSystemViewObject();
}
storageSystemView.setDeviceType(systemType);
storageSystemView.addprovider(accessProfile.getSystemId().toString());
storageSystemView.setProperty(StorageSystemViewObject.SERIAL_NUMBER, driverStorageSystem.getSerialNumber());
storageSystemView.setProperty(StorageSystemViewObject.VERSION, driverStorageSystem.getFirmwareVersion());
storageSystemView.setProperty(StorageSystemViewObject.STORAGE_NAME, driverStorageSystem.getNativeId());
storageSystemsCache.put(nativeGuid, storageSystemView);
_log.info(String.format("Info for storage system %s (provider ip %s): type: %s, nativeGuid: %s", driverStorageSystem.getSerialNumber(), accessProfile.getIpAddress(), systemType, nativeGuid));
}
} else {
// task status is not ready
String errorMsg = String.format("Failed to scan provider %s of type %s. \n" + " Driver task message: %s", accessProfile.getSystemId(), accessProfile.getSystemType(), task.getMessage());
throw new ExternalDeviceCollectionException(false, ServiceCode.DISCOVERY_ERROR, null, errorMsg, null, null);
}
} catch (Exception ex) {
_log.error("Error scanning provider: {} of type: {} .", accessProfile.getIpAddress(), accessProfile.getSystemType(), ex);
cxnStatus = com.emc.storageos.db.client.model.StorageProvider.ConnectionStatus.NOTCONNECTED;
throw ex;
} finally {
if (storageProvider != null) {
storageProvider.setConnectionStatus(cxnStatus.name());
_dbClient.updateObject(storageProvider);
}
_log.info("Completed scan of {} provider: ", accessProfile.getSystemType(), accessProfile.getIpAddress());
}
}
use of com.emc.storageos.plugins.StorageSystemViewObject in project coprhd-controller by CoprHD.
the class HDSCommunicationInterface method processScanResponse.
/**
* Process the XMLAPI response and persist storageSystem.
*
* @param result
*/
private void processScanResponse(List<StorageArray> arrayList, AccessProfile accessProfile) {
_logger.info("{} systems found", arrayList.size());
Map<String, StorageSystemViewObject> storageSystemsCache = accessProfile.getCache();
for (StorageArray array : arrayList) {
String systemType = StorageSystem.Type.hds.name();
String model = array.getDisplayArrayType();
String objectID = array.getObjectID();
String serialNumber = objectID.split(COMMA_SEPERATOR)[2];
String arrayFamily = array.getArrayFamily();
// @TODO Add a model based check for HDS arrays if required.
StorageSystemViewObject systemVO = null;
String nativeGuid = NativeGUIDGenerator.generateNativeGuid(systemType, objectID);
if (storageSystemsCache.containsKey(nativeGuid)) {
systemVO = storageSystemsCache.get(nativeGuid);
} else {
systemVO = new StorageSystemViewObject();
}
systemVO.setDeviceType(systemType);
systemVO.addprovider(accessProfile.getSystemId().toString());
systemVO.setProperty(StorageSystemViewObject.MODEL, model);
systemVO.setProperty(StorageSystemViewObject.SERIAL_NUMBER, serialNumber);
systemVO.setProperty(StorageSystemViewObject.STORAGE_NAME, nativeGuid);
storageSystemsCache.put(nativeGuid, systemVO);
}
_logger.info("Found {} systems during scanning for ip {}", storageSystemsCache.size(), accessProfile.getIpAddress());
}
Aggregations