use of com.emc.storageos.db.client.model.StoragePool in project coprhd-controller by CoprHD.
the class VNXeCommunicationInterface method discoverStoragePools.
/**
* Returns the list of storage pools for the specified VNXe storage system.
*
* @param system
* storage system information.
* @param client
* VNXe service client
* @param supportedProtocols
* calculated supportedProtocols for the array
* @return Map of New and Existing known storage pools.
* @throws VNXeException
*/
private Map<String, List<StoragePool>> discoverStoragePools(StorageSystem system, VNXeApiClient client, StringSet supportedProtocols, List<StoragePool> poolsToMatchWithVpool) throws VNXeException {
Map<String, List<StoragePool>> storagePools = new HashMap<String, List<StoragePool>>();
List<StoragePool> newPools = new ArrayList<StoragePool>();
List<StoragePool> existingPools = new ArrayList<StoragePool>();
_logger.info("Start storage pool discovery for storage system {}", system.getId());
try {
List<VNXePool> pools = client.getPools();
for (VNXePool vnxePool : pools) {
StoragePool pool = null;
URIQueryResultList results = new URIQueryResultList();
String poolNativeGuid = NativeGUIDGenerator.generateNativeGuid(system, vnxePool.getId(), NativeGUIDGenerator.POOL);
_dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStoragePoolByNativeGuidConstraint(poolNativeGuid), results);
boolean isModified = false;
if (results.iterator().hasNext()) {
StoragePool tmpPool = _dbClient.queryObject(StoragePool.class, results.iterator().next());
if (tmpPool.getStorageDevice().equals(system.getId())) {
pool = tmpPool;
_logger.info("Found StoragePool {} at {}", pool.getPoolName(), poolNativeGuid);
}
}
if (pool == null) {
pool = new StoragePool();
pool.setId(URIUtil.createId(StoragePool.class));
pool.setLabel(poolNativeGuid);
pool.setNativeGuid(poolNativeGuid);
pool.setOperationalStatus(vnxePool.getStatus());
pool.setPoolServiceType(PoolServiceType.block_file.toString());
pool.setStorageDevice(system.getId());
pool.setProtocols(supportedProtocols);
pool.setNativeId(vnxePool.getId());
pool.setPoolName(vnxePool.getName());
pool.setCompatibilityStatus(DiscoveredDataObject.CompatibilityStatus.COMPATIBLE.name());
StringSet raidLevels = new StringSet();
RaidTypeEnum raid = vnxePool.getRaidTypeEnum();
if (raid != null) {
raidLevels.add(vnxePool.getRaidTypeEnum().name());
pool.setSupportedRaidLevels(raidLevels);
}
// Supported resource type indicates what type of file
// systems are supported.
pool.setSupportedResourceTypes(StoragePool.SupportedResourceTypes.THIN_AND_THICK.toString());
pool.setPoolClassName(StoragePool.PoolClassNames.VNXe_Pool.name());
pool.setPoolServiceType(StoragePool.PoolServiceType.block_file.name());
pool.setAutoTieringEnabled(getPoolAutoTieringEnabled(vnxePool, system));
pool.setRegistrationStatus(RegistrationStatus.REGISTERED.toString());
_logger.info("Creating new storage pool using NativeGuid : {}", poolNativeGuid);
newPools.add(pool);
} else {
// update pool attributes
_logger.info("updating the pool: {}", poolNativeGuid);
pool.setOperationalStatus(vnxePool.getStatus());
if (ImplicitPoolMatcher.checkPoolPropertiesChanged(pool.getProtocols(), supportedProtocols)) {
isModified = true;
}
pool.setProtocols(supportedProtocols);
StringSet raidLevels = new StringSet();
RaidTypeEnum raid = vnxePool.getRaidTypeEnum();
if (raid != null) {
raidLevels.add(vnxePool.getRaidTypeEnum().name());
pool.setSupportedRaidLevels(raidLevels);
}
pool.setAutoTieringEnabled(getPoolAutoTieringEnabled(vnxePool, system));
existingPools.add(pool);
}
List<PoolTier> poolTiers = vnxePool.getTiers();
StringSet diskTypes = new StringSet();
for (PoolTier poolTier : poolTiers) {
List<RaidGroup> raidGroups = poolTier.getRaidGroups();
for (RaidGroup raidGroup : raidGroups) {
VNXeBase diskGroup = raidGroup.getDiskGroup();
if (diskGroup != null) {
DiskGroup diskgroupObj = client.getDiskGroup(diskGroup.getId());
diskTypes.add(diskgroupObj.getDiskTechnologyEnum().name());
}
}
}
pool.setSupportedDriveTypes(diskTypes);
double size = vnxePool.getSizeTotal();
if (size > 0) {
// convert to kb
pool.setTotalCapacity(VNXeUtils.convertDoubleSizeToViPRLong(size));
}
long free = VNXeUtils.convertDoubleSizeToViPRLong(vnxePool.getSizeFree());
if (free > 0) {
pool.setFreeCapacity(free);
pool.setMaximumThinVolumeSize(free);
pool.setMaximumThickVolumeSize(free);
}
long subscribed = VNXeUtils.convertDoubleSizeToViPRLong(vnxePool.getSizeSubscribed());
pool.setSubscribedCapacity(subscribed);
if (isModified || ImplicitPoolMatcher.checkPoolPropertiesChanged(pool.getCompatibilityStatus(), DiscoveredDataObject.CompatibilityStatus.COMPATIBLE.name()) || ImplicitPoolMatcher.checkPoolPropertiesChanged(pool.getDiscoveryStatus(), DiscoveryStatus.VISIBLE.name())) {
poolsToMatchWithVpool.add(pool);
}
pool.setDiscoveryStatus(DiscoveryStatus.VISIBLE.name());
pool.setCompatibilityStatus(DiscoveredDataObject.CompatibilityStatus.COMPATIBLE.name());
}
} catch (VNXeException e) {
_logger.error("Discovery of storage pools failed for storage system {} for {}", system.getId(), e.getMessage());
throw e;
}
for (StoragePool newPool : newPools) {
_logger.info("New Storage Pool : " + newPool);
_logger.info("New Storage Pool : {} : {}", newPool.getNativeGuid(), newPool.getId());
}
for (StoragePool pool : existingPools) {
_logger.info("Old Storage Pool : " + pool);
_logger.info("Old Storage Pool : {} : {}", pool.getNativeGuid(), pool.getId());
}
// return storagePools;
storagePools.put(NEW, newPools);
storagePools.put(EXISTING, existingPools);
_logger.info("Number of pools found {} : ", storagePools.size());
_logger.info("Storage pool discovery for storage system {} complete", system.getId());
return storagePools;
}
use of com.emc.storageos.db.client.model.StoragePool in project coprhd-controller by CoprHD.
the class VolumeSizeProcessor method processResult.
@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
DbClient _dbClient;
AccessProfile profile = (AccessProfile) keyMap.get(Constants.ACCESSPROFILE);
try {
String minVolSize = null;
String maxVolSize = null;
_dbClient = (DbClient) keyMap.get(Constants.dbClient);
StorageSystem device = getStorageSystem(_dbClient, profile.getSystemId());
if (resultObj instanceof CIMArgument<?>[]) {
CIMArgument<?>[] outputArguments = (CIMArgument<?>[]) resultObj;
for (CIMArgument<?> outArg : outputArguments) {
if (null == outArg) {
continue;
}
if (outArg.getName().equalsIgnoreCase(MINIMUM_VOLUME_SIZE)) {
minVolSize = outArg.getValue().toString();
} else if (outArg.getName().equalsIgnoreCase(MAXIMUM_VOLUME_SIZE)) {
maxVolSize = outArg.getValue().toString();
}
}
// we are setting at compile time, hence value will be there always.
CIMObjectPath poolObjectPath = getObjectPathfromCIMArgument();
String instanceID = poolObjectPath.getKey(Constants.INSTANCEID).getValue().toString();
StoragePool pool = checkStoragePoolExistsInDB(getNativeIDFromInstance(instanceID), _dbClient, device);
if (null != pool) {
Long maxVolumeSize = ControllerUtils.convertBytesToKBytes(maxVolSize);
Long minVolumeSize = ControllerUtils.convertBytesToKBytes(minVolSize);
if (Type.ibmxiv.name().equals((device.getSystemType()))) {
String supportedResourceType = pool.getSupportedResourceTypes();
if (SupportedResourceTypes.THIN_ONLY.name().equals(supportedResourceType)) {
pool.setMaximumThinVolumeSize(maxVolumeSize);
pool.setMinimumThinVolumeSize(minVolumeSize);
} else if (SupportedResourceTypes.THICK_ONLY.name().equals(supportedResourceType)) {
pool.setMaximumThickVolumeSize(maxVolumeSize);
pool.setMinimumThickVolumeSize(minVolumeSize);
}
} else {
// TODO - could this be changed to use the same logic as for IBM pool?
// if the result is obtained from calling on Thick, use thick volume size else thin
String elementType = determineCallType();
if (elementType.equalsIgnoreCase(FIVE)) {
pool.setMaximumThinVolumeSize(maxVolumeSize);
pool.setMinimumThinVolumeSize(minVolumeSize);
} else if (elementType.equalsIgnoreCase(THREE)) {
pool.setMaximumThickVolumeSize(maxVolumeSize);
pool.setMinimumThickVolumeSize(minVolumeSize);
}
}
_logger.info(String.format("Maximum limits for volume capacity in storage pool: %s %n max thin volume capacity: %s, max thick volume capacity: %s ", pool.getId(), pool.getMaximumThinVolumeSize(), pool.getMaximumThickVolumeSize()));
_dbClient.persistObject(pool);
}
}
} catch (Exception e) {
_logger.error("Failed while processing Result : ", e);
}
}
use of com.emc.storageos.db.client.model.StoragePool in project coprhd-controller by CoprHD.
the class StoragePoolProcessor method processResult.
@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
try {
@SuppressWarnings("unchecked") final Iterator<CIMObjectPath> it = (Iterator<CIMObjectPath>) resultObj;
_dbClient = (DbClient) keyMap.get(Constants.dbClient);
while (it.hasNext()) {
CIMObjectPath poolPath = it.next();
String poolNativeGuid = NativeGUIDGenerator.generateNativeGuidForPool(poolPath);
StoragePool pool = checkStoragePoolExistsInDB(poolNativeGuid, _dbClient);
if (pool != null && validPool(poolPath)) {
addPath(keyMap, operation.getResult(), poolPath);
// add VMAX2 Thin pools to get BoundVolumes later
if (poolPath.toString().contains(StoragePool.PoolClassNames.Symm_VirtualProvisioningPool.toString())) {
addPath(keyMap, Constants.VMAX2_THIN_POOLS, poolPath);
}
String poolClass = poolPath.getObjectName();
if (poolClass.startsWith(SYMM_CLASS_PREFIX) && !poolClass.equals(StoragePool.PoolClassNames.Symm_SRPStoragePool.name())) {
addPath(keyMap, Constants.VMAX2POOLS, poolPath);
}
}
}
} catch (Exception e) {
_logger.error("Processing Storage Pool failed", e);
}
}
use of com.emc.storageos.db.client.model.StoragePool in project coprhd-controller by CoprHD.
the class StorageVolumeBoundPoolProcessor method processResult.
@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
CloseableIterator<CIMInstance> allocatedFromStoragePoolInstances = null;
EnumerateResponse<CIMInstance> allocatedFromStoragePoolInstanceChunks = null;
@SuppressWarnings("unchecked") Map<String, Set<String>> vmax2ThinPoolToBoundVolumesMap = (Map<String, Set<String>>) keyMap.get(Constants.VMAX2_THIN_POOL_TO_BOUND_VOLUMES);
_dbClient = (DbClient) keyMap.get(Constants.dbClient);
WBEMClient client = SMICommunicationInterface.getCIMClient(keyMap);
CIMObjectPath storagePoolPath = null;
try {
storagePoolPath = getObjectPathfromCIMArgument(_args);
_logger.debug("VMAX2 Thin Pool: {}", storagePoolPath.toString());
String poolNativeGuid = NativeGUIDGenerator.generateNativeGuidForPool(storagePoolPath);
StoragePool pool = checkStoragePoolExistsInDB(poolNativeGuid, _dbClient);
if (pool == null) {
_logger.error("Skipping unmanaged volume discovery as the storage pool with path {} doesn't exist in ViPR", storagePoolPath.toString());
return;
}
Set<String> boundVolumes = new HashSet<String>();
allocatedFromStoragePoolInstanceChunks = (EnumerateResponse<CIMInstance>) resultObj;
allocatedFromStoragePoolInstances = allocatedFromStoragePoolInstanceChunks.getResponses();
processVolumes(allocatedFromStoragePoolInstances, boundVolumes);
while (!allocatedFromStoragePoolInstanceChunks.isEnd()) {
_logger.info("Processing Next Volume Chunk of size {}", BATCH_SIZE);
allocatedFromStoragePoolInstanceChunks = client.getInstancesWithPath(storagePoolPath, allocatedFromStoragePoolInstanceChunks.getContext(), new UnsignedInteger32(BATCH_SIZE));
processVolumes(allocatedFromStoragePoolInstanceChunks.getResponses(), boundVolumes);
}
vmax2ThinPoolToBoundVolumesMap.put(storagePoolPath.toString(), boundVolumes);
_logger.debug("Bound volumes list {}", Joiner.on("\t").join(boundVolumes));
} catch (Exception e) {
_logger.error("Processing Bound Storage Volume Information failed :", e);
} finally {
if (null != allocatedFromStoragePoolInstances) {
allocatedFromStoragePoolInstances.close();
}
if (null != allocatedFromStoragePoolInstanceChunks) {
try {
client.closeEnumeration(storagePoolPath, allocatedFromStoragePoolInstanceChunks.getContext());
} catch (Exception e) {
_logger.debug("Exception occurred while closing enumeration", e);
}
}
}
}
use of com.emc.storageos.db.client.model.StoragePool in project coprhd-controller by CoprHD.
the class StorageVolumeInfoProcessor method processResult.
@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
CloseableIterator<CIMInstance> volumeInstances = null;
EnumerateResponse<CIMInstance> volumeInstanceChunks = null;
CIMObjectPath storagePoolPath = null;
WBEMClient client = null;
try {
_dbClient = (DbClient) keyMap.get(Constants.dbClient);
client = SMICommunicationInterface.getCIMClient(keyMap);
_profile = (AccessProfile) keyMap.get(Constants.ACCESSPROFILE);
Map<String, VolHostIOObject> exportedVolumes = (Map<String, VolHostIOObject>) keyMap.get(Constants.EXPORTED_VOLUMES);
Set<String> existingVolumesInCG = (Set<String>) keyMap.get(Constants.VOLUMES_PART_OF_CG);
@SuppressWarnings("unchecked") Map<String, RemoteMirrorObject> volumeToRAGroupMap = (Map<String, RemoteMirrorObject>) keyMap.get(Constants.UN_VOLUME_RAGROUP_MAP);
@SuppressWarnings("unchecked") Map<String, LocalReplicaObject> volumeToLocalReplicaMap = (Map<String, LocalReplicaObject>) keyMap.get(Constants.UN_VOLUME_LOCAL_REPLICA_MAP);
@SuppressWarnings("unchecked") Map<String, Map<String, String>> volumeToSyncAspectMap = (Map<String, Map<String, String>>) keyMap.get(Constants.SNAPSHOT_NAMES_SYNCHRONIZATION_ASPECT_MAP);
@SuppressWarnings("unchecked") Map<String, Set<String>> duplicateSyncAspectElementNameMap = (Map<String, Set<String>>) keyMap.get(Constants.DUPLICATE_SYNC_ASPECT_ELEMENT_NAME_MAP);
@SuppressWarnings("unchecked") Map<String, Set<String>> vmax2ThinPoolToBoundVolumesMap = (Map<String, Set<String>>) keyMap.get(Constants.VMAX2_THIN_POOL_TO_BOUND_VOLUMES);
Set<String> boundVolumes = null;
storagePoolPath = getObjectPathfromCIMArgument(_args);
String poolNativeGuid = NativeGUIDGenerator.generateNativeGuidForPool(storagePoolPath);
StoragePool pool = checkStoragePoolExistsInDB(poolNativeGuid, _dbClient);
if (pool == null) {
_logger.error("Skipping unmanaged volume discovery as the storage pool with path {} doesn't exist in ViPR", storagePoolPath.toString());
return;
}
StorageSystem system = _dbClient.queryObject(StorageSystem.class, _profile.getSystemId());
_unManagedVolumesInsert = new ArrayList<UnManagedVolume>();
_unManagedVolumesUpdate = new ArrayList<UnManagedVolume>();
_unManagedExportMasksUpdate = new ArrayList<UnManagedExportMask>();
// get bound volumes list for VMAX2 Thin pools
boundVolumes = vmax2ThinPoolToBoundVolumesMap.get(storagePoolPath.toString());
Set<String> poolSupportedSLONames = (Set<String>) keyMap.get(poolNativeGuid);
_logger.debug("Pool Supporting SLO Names:{}", poolSupportedSLONames);
_metaVolumeViewPaths = (List<CIMObjectPath>) keyMap.get(Constants.META_VOLUMES_VIEWS);
if (_metaVolumeViewPaths == null) {
_metaVolumeViewPaths = new ArrayList<CIMObjectPath>();
keyMap.put(Constants.META_VOLUMES_VIEWS, _metaVolumeViewPaths);
}
// create empty place holder list for meta volume paths (cannot
// define this in xml)
_metaVolumePaths = (List<CIMObjectPath>) keyMap.get(Constants.META_VOLUMES);
if (_metaVolumePaths == null) {
_metaVolumePaths = new ArrayList<CIMObjectPath>();
keyMap.put(Constants.META_VOLUMES, _metaVolumePaths);
}
_volumeToSpaceConsumedMap = (Map<String, String>) keyMap.get(Constants.VOLUME_SPACE_CONSUMED_MAP);
// get VolumeInfo Object and inject Fast Policy Name.
volumeInstanceChunks = (EnumerateResponse<CIMInstance>) resultObj;
volumeInstances = volumeInstanceChunks.getResponses();
Set<URI> srdfEnabledTargetVPools = SRDFUtils.fetchSRDFTargetVirtualPools(_dbClient);
processVolumes(volumeInstances, keyMap, operation, pool, system, exportedVolumes, existingVolumesInCG, volumeToRAGroupMap, volumeToLocalReplicaMap, volumeToSyncAspectMap, poolSupportedSLONames, boundVolumes, srdfEnabledTargetVPools, duplicateSyncAspectElementNameMap);
while (!volumeInstanceChunks.isEnd()) {
_logger.info("Processing Next Volume Chunk of size {}", BATCH_SIZE);
volumeInstanceChunks = client.getInstancesWithPath(storagePoolPath, volumeInstanceChunks.getContext(), new UnsignedInteger32(BATCH_SIZE));
processVolumes(volumeInstanceChunks.getResponses(), keyMap, operation, pool, system, exportedVolumes, existingVolumesInCG, volumeToRAGroupMap, volumeToLocalReplicaMap, volumeToSyncAspectMap, poolSupportedSLONames, boundVolumes, srdfEnabledTargetVPools, duplicateSyncAspectElementNameMap);
}
if (null != _unManagedVolumesUpdate && !_unManagedVolumesUpdate.isEmpty()) {
_partitionManager.updateAndReIndexInBatches(_unManagedVolumesUpdate, getPartitionSize(keyMap), _dbClient, UNMANAGED_VOLUME);
}
if (null != _unManagedVolumesInsert && !_unManagedVolumesInsert.isEmpty()) {
_partitionManager.insertInBatches(_unManagedVolumesInsert, getPartitionSize(keyMap), _dbClient, UNMANAGED_VOLUME);
}
if (null != _unManagedExportMasksUpdate && !_unManagedExportMasksUpdate.isEmpty()) {
_partitionManager.updateAndReIndexInBatches(_unManagedExportMasksUpdate, getPartitionSize(keyMap), _dbClient, UNMANAGED_EXPORT_MASK);
}
performStorageUnManagedVolumeBookKeeping(pool.getId());
} catch (Exception e) {
_logger.error("Processing Storage Volume Information failed :", e);
} finally {
_unManagedVolumesInsert = null;
_unManagedVolumesUpdate = null;
if (null != volumeInstances) {
volumeInstances.close();
}
if (null != volumeInstanceChunks) {
try {
client.closeEnumeration(storagePoolPath, volumeInstanceChunks.getContext());
} catch (Exception e) {
_logger.debug("Exception occurred while closing enumeration", e);
}
}
}
}
Aggregations