use of com.emc.storageos.storagedriver.model.StorageSystem 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.storagedriver.model.StorageSystem in project coprhd-controller by CoprHD.
the class ExternalDeviceUnManagedVolumeDiscoverer method discoverUnManagedBlockObjects.
/**
* Discovers unmanaged block objects: volumes, snaps, clones, their CG information and their exports.
* @param driver storage driver reference [IN]
* @param storageSystem storage system [IN]
* @param dbClient reference to db client [IN]
* @param partitionManager partition manager [IN]
*/
public void discoverUnManagedBlockObjects(BlockStorageDriver driver, com.emc.storageos.db.client.model.StorageSystem storageSystem, DbClient dbClient, PartitionManager partitionManager) {
Set<URI> allCurrentUnManagedVolumeUris = new HashSet<>();
Set<URI> allCurrentUnManagedCgURIs = new HashSet<>();
MutableInt lastPage = new MutableInt(0);
MutableInt nextPage = new MutableInt(0);
List<UnManagedVolume> unManagedVolumesToCreate = new ArrayList<>();
List<UnManagedVolume> unManagedVolumesToUpdate = new ArrayList<>();
List<UnManagedConsistencyGroup> unManagedCGToUpdate;
Map<String, UnManagedConsistencyGroup> unManagedCGToUpdateMap = new HashMap<>();
// We support only single export mask concept for host-array combination for external devices.
// If we find that storage system has volumes which are exported to the same host through
// different initiators or different array ports (we cannot create single UnManaged export
// mask for the host and the array in this case), we won't discover exports to this
// host on the array; we discover only volumes.
// The result of this limitation is that it could happen that for some volumes we are able to
// discover all their host exports;
// for some volumes we will be able to discover their exports to subset of hosts;
// for some volumes we may not be able to discover their exports to hosts.
// This limits management scope for pre-existing exports initially, but this does not
// not present a management issue for exports going forward, since driver implementation should handle export requests based
// on provided initiators and volumes in the requests and the current state of device.
// set of hosts for which we cannot build single export mask
Set<String> invalidExportHosts = new HashSet<>();
// for exported array volumes
// get inter-process lock for exclusive discovery of unmanaged objects for a given system
// lock is backed by curator's InterProcessMutex.
InterProcessLock lock = null;
String lockName = UNMANAGED_DISCOVERY_LOCK + storageSystem.getSystemType() + "-" + storageSystem.getNativeId();
try {
lock = coordinator.getLock(lockName);
boolean lockAcquired = lock.acquire(UNMANAGED_DISCOVERY_LOCK_TIMEOUT, TimeUnit.SECONDS);
if (lockAcquired) {
log.info("Acquired lock {} for storage system {} .", lockName, storageSystem.getNativeId());
} else {
log.info("Failed to acquire lock {} for storage system {} .", lockName, storageSystem.getNativeId());
return;
}
} catch (Exception ex) {
// check that lock was not acquired. if lock was acquired for this thread, proceed.
if (lock == null || !lock.isAcquiredInThisProcess()) {
log.error("Error processing unmanaged discovery for storage system: {}. Failed to get lock {} for this operation.", storageSystem.getNativeId(), lockName, ex);
return;
}
}
log.info("Started discovery of UnManagedVolumes for system {}", storageSystem.getId());
try {
// We need to deactivate all old unManaged export masks for this array. Each export discovery starts a new.
// Otherwise, we cannot distinguish between stale host masks and host mask discovered for volumes on the previous pages.
DiscoveryUtils.markInActiveUnManagedExportMask(storageSystem.getId(), new HashSet<URI>(), dbClient, partitionManager);
// prepare storage system
StorageSystem driverStorageSystem = ExternalDeviceCommunicationInterface.initStorageSystem(storageSystem);
do {
Map<String, List<HostExportInfo>> hostToVolumeExportInfoMap = new HashMap<>();
List<StorageVolume> driverVolumes = new ArrayList<>();
Map<String, URI> unManagedVolumeNativeIdToUriMap = new HashMap<>();
Map<String, URI> managedVolumeNativeIdToUriMap = new HashMap<>();
log.info("Processing page {} ", nextPage);
driver.getStorageVolumes(driverStorageSystem, driverVolumes, nextPage);
log.info("Volume count on this page {} ", driverVolumes.size());
for (StorageVolume driverVolume : driverVolumes) {
UnManagedVolume unManagedVolume = null;
try {
com.emc.storageos.db.client.model.StoragePool storagePool = getStoragePoolOfUnManagedVolume(storageSystem, driverVolume, dbClient);
if (null == storagePool) {
log.error("Skipping unManaged volume discovery as the volume {} storage pool doesn't exist in controller", driverVolume.getNativeId());
continue;
}
String managedVolumeNativeGuid = NativeGUIDGenerator.generateNativeGuidForVolumeOrBlockSnapShot(storageSystem.getNativeGuid(), driverVolume.getNativeId());
Volume systemVolume = DiscoveryUtils.checkStorageVolumeExistsInDB(dbClient, managedVolumeNativeGuid);
if (null != systemVolume) {
log.info("Skipping volume {} as it is already managed by the system. Id: {}", managedVolumeNativeGuid, systemVolume.getId());
// get export data for managed volume to process later --- we need to collect export data for
// managed volume
managedVolumeNativeIdToUriMap.put(driverVolume.getNativeId(), systemVolume.getId());
getVolumeExportInfo(driver, driverVolume, hostToVolumeExportInfoMap);
getExportInfoForManagedVolumeReplicas(managedVolumeNativeIdToUriMap, hostToVolumeExportInfoMap, dbClient, storageSystem, systemVolume, driverVolume, driver);
continue;
}
unManagedVolume = createUnManagedVolume(driverVolume, storageSystem, storagePool, unManagedVolumesToCreate, unManagedVolumesToUpdate, dbClient);
unManagedVolumeNativeIdToUriMap.put(driverVolume.getNativeId(), unManagedVolume.getId());
// if the volume is associated with a CG, set up the unManaged CG
if (driverVolume.getConsistencyGroup() != null && !driverVolume.getConsistencyGroup().isEmpty()) {
addObjectToUnManagedConsistencyGroup(storageSystem, driverVolume.getConsistencyGroup(), unManagedVolume, allCurrentUnManagedCgURIs, unManagedCGToUpdateMap, driver, dbClient);
} else {
// Make sure the unManagedVolume object does not contain CG information from previous discovery
unManagedVolume.getVolumeCharacterstics().put(UnManagedVolume.SupportedVolumeCharacterstics.IS_VOLUME_ADDED_TO_CONSISTENCYGROUP.toString(), Boolean.FALSE.toString());
// remove uri of the unManaged CG in the unManaged volume object
unManagedVolume.getVolumeInformation().remove(UnManagedVolume.SupportedVolumeInformation.UNMANAGED_CONSISTENCY_GROUP_URI.toString());
}
allCurrentUnManagedVolumeUris.add(unManagedVolume.getId());
getVolumeExportInfo(driver, driverVolume, hostToVolumeExportInfoMap);
Set<URI> unManagedSnaphotUris = processUnManagedSnapshots(driverVolume, unManagedVolume, storageSystem, storagePool, unManagedVolumesToCreate, unManagedVolumesToUpdate, allCurrentUnManagedCgURIs, unManagedCGToUpdateMap, unManagedVolumeNativeIdToUriMap, hostToVolumeExportInfoMap, driver, dbClient);
allCurrentUnManagedVolumeUris.addAll(unManagedSnaphotUris);
Set<URI> unManagedCloneUris = processUnManagedClones(driverVolume, unManagedVolume, storageSystem, storagePool, unManagedVolumesToCreate, unManagedVolumesToUpdate, allCurrentUnManagedCgURIs, unManagedCGToUpdateMap, unManagedVolumeNativeIdToUriMap, hostToVolumeExportInfoMap, driver, dbClient);
allCurrentUnManagedVolumeUris.addAll(unManagedCloneUris);
} catch (Exception ex) {
log.error("Error processing {} volume {}", storageSystem.getNativeId(), driverVolume.getNativeId(), ex);
}
}
if (!unManagedVolumesToCreate.isEmpty()) {
log.info("Unmanaged volumes to create: {}", unManagedVolumesToCreate);
partitionManager.insertInBatches(unManagedVolumesToCreate, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_VOLUME);
unManagedVolumesToCreate.clear();
}
if (!unManagedVolumesToUpdate.isEmpty()) {
log.info("Unmanaged volumes to update: {}", unManagedVolumesToUpdate);
partitionManager.updateAndReIndexInBatches(unManagedVolumesToUpdate, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_VOLUME);
unManagedVolumesToUpdate.clear();
}
// Process export data for volumes
processExportData(driver, storageSystem, unManagedVolumeNativeIdToUriMap, managedVolumeNativeIdToUriMap, hostToVolumeExportInfoMap, invalidExportHosts, dbClient, partitionManager);
} while (!nextPage.equals(lastPage));
if (!unManagedCGToUpdateMap.isEmpty()) {
unManagedCGToUpdate = new ArrayList<>(unManagedCGToUpdateMap.values());
partitionManager.updateAndReIndexInBatches(unManagedCGToUpdate, unManagedCGToUpdate.size(), dbClient, UNMANAGED_CONSISTENCY_GROUP);
unManagedCGToUpdate.clear();
}
log.info("Processed {} unmanged objects.", allCurrentUnManagedVolumeUris.size());
// Process those active unManaged volume objects available in database but not in newly discovered items, to mark them inactive.
DiscoveryUtils.markInActiveUnManagedVolumes(storageSystem, allCurrentUnManagedVolumeUris, dbClient, partitionManager);
// Process those active unManaged consistency group objects available in database but not in newly discovered items, to mark them
// inactive.
DiscoveryUtils.performUnManagedConsistencyGroupsBookKeeping(storageSystem, allCurrentUnManagedCgURIs, dbClient, partitionManager);
} catch (Exception ex) {
log.error("Error processing unmanaged discovery for storage system: {}. Error on page: {}.", storageSystem.getNativeId(), nextPage.toString(), ex);
} finally {
// release lock
try {
lock.release();
log.info("Released lock for storage system {}", storageSystem.getNativeId());
} catch (Exception e) {
log.error("Failed to release Lock {} : {}", lockName, e.getMessage());
}
}
}
use of com.emc.storageos.storagedriver.model.StorageSystem in project coprhd-controller by CoprHD.
the class DellSCDiscovery method discoverStorageProvider.
/**
* Perform discovery for a storage provider.
*
* @param storageProvider The provider.
* @param storageSystems The storage systems collection to populate.
* @return The driver task.
*/
public DriverTask discoverStorageProvider(StorageProvider storageProvider, List<StorageSystem> storageSystems) {
DellSCDriverTask task = new DellSCDriverTask("discover");
try {
LOG.info("Getting information for storage provider [{}:{}] as user {}", storageProvider.getProviderHost(), storageProvider.getPortNumber(), storageProvider.getUsername());
StorageCenterAPI api = connectionManager.getConnection(storageProvider.getProviderHost(), storageProvider.getPortNumber(), storageProvider.getUsername(), storageProvider.getPassword(), true);
LOG.info("Connected to DSM {} as user {}", storageProvider.getProviderHost(), storageProvider.getUsername());
// Populate the provider information
storageProvider.setAccessStatus(AccessStatus.READ_WRITE);
storageProvider.setManufacturer("Dell");
storageProvider.setProviderVersion(driverVersion);
storageProvider.setIsSupportedVersion(true);
// Get some info about the DSM for debugging purposes
EmDataCollector em = api.getDSMInfo();
if (em != null) {
LOG.info("Connected to {} DSM version {}, Java version {}", em.type, em.version, em.javaVersion);
storageProvider.setProviderVersion(em.version);
}
// Populate the basic SC information
StorageCenter[] scs = api.getStorageCenterInfo();
for (StorageCenter sc : scs) {
StorageSystem storageSystem = util.getStorageSystemFromStorageCenter(api, sc, null);
storageSystem.setSystemType(driverName);
storageSystems.add(storageSystem);
}
task.setStatus(DriverTask.TaskStatus.READY);
} catch (Exception e) {
String msg = String.format("Exception encountered getting storage provider information: %s", e);
LOG.error(msg);
task.setFailed(msg);
}
return task;
}
use of com.emc.storageos.storagedriver.model.StorageSystem in project coprhd-controller by CoprHD.
the class DellSCUtil method getStorageSystemFromStorageCenter.
/**
* Populate a StorageSystem object with Storage Center info.
*
* @param api The SC API connection.
* @param sc The Storage Center.
* @param storageSystemOrNull The StorageSystem to populate or null.
* @return The StorageSystem.
*/
public StorageSystem getStorageSystemFromStorageCenter(StorageCenterAPI api, StorageCenter sc, StorageSystem storageSystemOrNull) {
StorageSystem storageSystem = storageSystemOrNull;
if (storageSystem == null) {
storageSystem = new StorageSystem();
}
storageSystem.setSerialNumber(sc.scSerialNumber);
storageSystem.setAccessStatus(AccessStatus.READ_WRITE);
storageSystem.setModel(sc.modelSeries);
storageSystem.setProvisioningType(SupportedProvisioningType.THIN);
storageSystem.setNativeId(sc.scSerialNumber);
// Parse out version information
String[] version = sc.version.split("\\.");
storageSystem.setMajorVersion(version[0]);
storageSystem.setMinorVersion(version[1]);
storageSystem.setFirmwareVersion(sc.version);
storageSystem.setIsSupportedVersion(true);
storageSystem.setDeviceLabel(sc.scName);
storageSystem.setDisplayName(sc.name);
// Make sure it's reported that we support CGs
Set<SupportedReplication> supportedReplications = new HashSet<>();
supportedReplications.add(SupportedReplication.elementReplica);
supportedReplications.add(SupportedReplication.groupReplica);
storageSystem.setSupportedReplications(supportedReplications);
// Check the supported protocols for this array
List<String> protocols = getSupportedProtocols(api, sc.scSerialNumber);
storageSystem.setProtocols(protocols);
return storageSystem;
}
use of com.emc.storageos.storagedriver.model.StorageSystem in project coprhd-controller by CoprHD.
the class ExternalDeviceCommunicationInterface method initStorageSystem.
public static StorageSystem initStorageSystem(com.emc.storageos.db.client.model.StorageSystem storageSystem) {
StorageSystem driverStorageSystem = new StorageSystem();
driverStorageSystem.setNativeId(storageSystem.getNativeId());
driverStorageSystem.setIpAddress(storageSystem.getIpAddress());
driverStorageSystem.setSystemName(storageSystem.getLabel());
return driverStorageSystem;
}
Aggregations