use of com.emc.storageos.db.client.model.StringSetMap in project coprhd-controller by CoprHD.
the class VNXUnityUnManagedObjectDiscoverer method createUnManagedVolumeForSnap.
/**
* Creates a new UnManagedVolume with the given arguments for a snap.
*
* @param unManagedVolumeNativeGuid
* @param lun
* @param system
* @param pool
* @param dbClient
* @param hostVolumeMap
* hosts and exported volumes map
* @param snap
* detail of the snap
* @return
*/
private UnManagedVolume createUnManagedVolumeForSnap(UnManagedVolume unManagedVolume, String unManagedVolumeNativeGuid, VNXeLun lun, StorageSystem system, DbClient dbClient, Map<String, List<UnManagedVolume>> hostVolumeMap, Snap snap) {
boolean created = false;
if (null == unManagedVolume) {
unManagedVolume = new UnManagedVolume();
unManagedVolume.setId(URIUtil.createId(UnManagedVolume.class));
unManagedVolume.setNativeGuid(unManagedVolumeNativeGuid);
unManagedVolume.setStorageSystemUri(system.getId());
created = true;
}
unManagedVolume.setLabel(snap.getName());
StringSetMap unManagedVolumeInformation = new StringSetMap();
Map<String, String> unManagedVolumeCharacteristics = new HashMap<String, String>();
Boolean isSnapExported = false;
if (lun.getHostAccess() != null && !lun.getHostAccess().isEmpty()) {
// clear the previous unmanaged export masks, initiators if any. The latest export masks will be updated
// later.
unManagedVolume.getUnmanagedExportMasks().clear();
unManagedVolume.getInitiatorNetworkIds().clear();
unManagedVolume.getInitiatorUris().clear();
for (BlockHostAccess access : lun.getHostAccess()) {
int accessMask = access.getAccessMask();
if (accessMask == BlockHostAccess.HostLUNAccessEnum.BOTH.getValue() || accessMask == BlockHostAccess.HostLUNAccessEnum.SNAPSHOT.getValue()) {
isSnapExported = true;
String hostId = access.getHost().getId();
List<UnManagedVolume> exportedSnaps = hostVolumeMap.get(hostId);
if (exportedSnaps == null) {
exportedSnaps = new ArrayList<UnManagedVolume>();
hostVolumeMap.put(hostId, exportedSnaps);
}
exportedSnaps.add(unManagedVolume);
}
}
}
unManagedVolumeCharacteristics.put(SupportedVolumeCharacterstics.IS_VOLUME_EXPORTED.toString(), isSnapExported.toString());
StringSet deviceLabel = new StringSet();
deviceLabel.add(snap.getName());
unManagedVolumeInformation.put(SupportedVolumeInformation.DEVICE_LABEL.toString(), deviceLabel);
String snapWWN = snap.getAttachedWWN();
if (snapWWN != null && !snapWWN.isEmpty()) {
String volumeWWN = snapWWN.replaceAll(":", "");
unManagedVolume.setWwn(volumeWWN);
}
StringSet systemTypes = new StringSet();
systemTypes.add(system.getSystemType());
StringSet provCapacity = new StringSet();
provCapacity.add(String.valueOf(snap.getSize()));
unManagedVolumeInformation.put(SupportedVolumeInformation.PROVISIONED_CAPACITY.toString(), provCapacity);
StringSet allocatedCapacity = new StringSet();
allocatedCapacity.add(String.valueOf(snap.getSize()));
unManagedVolumeInformation.put(SupportedVolumeInformation.ALLOCATED_CAPACITY.toString(), allocatedCapacity);
unManagedVolumeInformation.put(SupportedVolumeInformation.SYSTEM_TYPE.toString(), systemTypes);
StringSet nativeId = new StringSet();
nativeId.add(snap.getId());
unManagedVolumeInformation.put(SupportedVolumeInformation.NATIVE_ID.toString(), nativeId);
unManagedVolumeCharacteristics.put(SupportedVolumeCharacterstics.IS_INGESTABLE.toString(), Boolean.TRUE.toString());
unManagedVolumeCharacteristics.put(SupportedVolumeCharacterstics.IS_THINLY_PROVISIONED.toString(), lun.getIsThinEnabled().toString());
unManagedVolume.setVolumeInformation(unManagedVolumeInformation);
if (unManagedVolume.getVolumeCharacterstics() == null) {
unManagedVolume.setVolumeCharacterstics(new StringMap());
}
unManagedVolume.getVolumeCharacterstics().replace(unManagedVolumeCharacteristics);
if (created) {
unManagedVolumesInsert.add(unManagedVolume);
} else {
unManagedVolumesUpdate.add(unManagedVolume);
}
return unManagedVolume;
}
use of com.emc.storageos.db.client.model.StringSetMap in project coprhd-controller by CoprHD.
the class VNXUnityUnManagedObjectDiscoverer method createUnManagedVolume.
/**
* Creates a new UnManagedVolume with the given arguments.
*
* @param unManagedVolumeNativeGuid
* @param lun
* @param system
* @param pool
* @param dbClient
* @param hostVolumeMap
* hosts and exported volumes map
* @return
*/
private UnManagedVolume createUnManagedVolume(UnManagedVolume unManagedVolume, String unManagedVolumeNativeGuid, VNXeLun lun, StorageSystem system, StoragePool pool, DbClient dbClient, Map<String, List<UnManagedVolume>> hostVolumeMap) {
boolean created = false;
if (null == unManagedVolume) {
unManagedVolume = new UnManagedVolume();
unManagedVolume.setId(URIUtil.createId(UnManagedVolume.class));
unManagedVolume.setNativeGuid(unManagedVolumeNativeGuid);
unManagedVolume.setStorageSystemUri(system.getId());
unManagedVolume.setStoragePoolUri(pool.getId());
created = true;
}
unManagedVolume.setLabel(lun.getName());
StringSetMap unManagedVolumeInformation = new StringSetMap();
Map<String, String> unManagedVolumeCharacteristics = new HashMap<String, String>();
Boolean isVolumeExported = false;
if (lun.getHostAccess() != null && !lun.getHostAccess().isEmpty()) {
// clear the previous unmanaged export masks, initiators if any. The latest export masks will be updated
// later.
unManagedVolume.getUnmanagedExportMasks().clear();
unManagedVolume.getInitiatorNetworkIds().clear();
unManagedVolume.getInitiatorUris().clear();
for (BlockHostAccess access : lun.getHostAccess()) {
int accessMask = access.getAccessMask();
if (accessMask == BlockHostAccess.HostLUNAccessEnum.BOTH.getValue() || accessMask == BlockHostAccess.HostLUNAccessEnum.PRODUCTION.getValue()) {
isVolumeExported = true;
String hostId = access.getHost().getId();
List<UnManagedVolume> exportedVolumes = hostVolumeMap.get(hostId);
if (exportedVolumes == null) {
exportedVolumes = new ArrayList<UnManagedVolume>();
hostVolumeMap.put(hostId, exportedVolumes);
}
exportedVolumes.add(unManagedVolume);
}
}
}
unManagedVolumeCharacteristics.put(SupportedVolumeCharacterstics.IS_VOLUME_EXPORTED.toString(), isVolumeExported.toString());
unManagedVolumeCharacteristics.put(SupportedVolumeCharacterstics.IS_NONRP_EXPORTED.toString(), Boolean.FALSE.toString());
unManagedVolumeCharacteristics.put(SupportedVolumeCharacterstics.IS_RECOVERPOINT_ENABLED.toString(), Boolean.FALSE.toString());
StringSet deviceLabel = new StringSet();
deviceLabel.add(lun.getName());
unManagedVolumeInformation.put(SupportedVolumeInformation.DEVICE_LABEL.toString(), deviceLabel);
String volumeWWN = lun.getWwn().replaceAll(":", "");
unManagedVolume.setWwn(volumeWWN);
StringSet systemTypes = new StringSet();
systemTypes.add(system.getSystemType());
StringSet provCapacity = new StringSet();
provCapacity.add(String.valueOf(lun.getSizeTotal()));
unManagedVolumeInformation.put(SupportedVolumeInformation.PROVISIONED_CAPACITY.toString(), provCapacity);
StringSet allocatedCapacity = new StringSet();
allocatedCapacity.add(String.valueOf(lun.getSizeAllocated()));
unManagedVolumeInformation.put(SupportedVolumeInformation.ALLOCATED_CAPACITY.toString(), allocatedCapacity);
unManagedVolumeInformation.put(SupportedVolumeInformation.SYSTEM_TYPE.toString(), systemTypes);
StringSet nativeId = new StringSet();
nativeId.add(lun.getId());
unManagedVolumeInformation.put(SupportedVolumeInformation.NATIVE_ID.toString(), nativeId);
unManagedVolumeCharacteristics.put(SupportedVolumeCharacterstics.IS_INGESTABLE.toString(), Boolean.TRUE.toString());
unManagedVolumeCharacteristics.put(SupportedVolumeCharacterstics.IS_THINLY_PROVISIONED.toString(), lun.getIsThinEnabled().toString());
if (null != pool) {
unManagedVolume.setStoragePoolUri(pool.getId());
StringSet pools = new StringSet();
pools.add(pool.getId().toString());
unManagedVolumeInformation.put(SupportedVolumeInformation.STORAGE_POOL.toString(), pools);
StringSet driveTypes = pool.getSupportedDriveTypes();
if (null != driveTypes) {
unManagedVolumeInformation.put(SupportedVolumeInformation.DISK_TECHNOLOGY.toString(), driveTypes);
}
StringSet matchedVPools = DiscoveryUtils.getMatchedVirtualPoolsForPool(dbClient, pool.getId(), unManagedVolumeCharacteristics.get(SupportedVolumeCharacterstics.IS_THINLY_PROVISIONED.toString()), unManagedVolume);
log.debug("Matched Pools : {}", Joiner.on("\t").join(matchedVPools));
if (null == matchedVPools || matchedVPools.isEmpty()) {
// clear all existing supported vpools.
unManagedVolume.getSupportedVpoolUris().clear();
} else {
// replace with new StringSet
unManagedVolume.getSupportedVpoolUris().replace(matchedVPools);
log.info("Replaced Pools : {}", Joiner.on("\t").join(unManagedVolume.getSupportedVpoolUris()));
}
}
unManagedVolume.setVolumeInformation(unManagedVolumeInformation);
if (unManagedVolume.getVolumeCharacterstics() == null) {
unManagedVolume.setVolumeCharacterstics(new StringMap());
}
unManagedVolume.getVolumeCharacterstics().replace(unManagedVolumeCharacteristics);
// clear the mask to HLU map. Fresh data gets persisted during UnManagedExportMask discovery
if (unManagedVolume.getVolumeInformation().get(SupportedVolumeInformation.HLU_TO_EXPORT_MASK_NAME_MAP.name()) != null) {
unManagedVolume.getVolumeInformation().get(SupportedVolumeInformation.HLU_TO_EXPORT_MASK_NAME_MAP.name()).clear();
}
if (created) {
unManagedVolumesInsert.add(unManagedVolume);
} else {
unManagedVolumesUpdate.add(unManagedVolume);
}
return unManagedVolume;
}
use of com.emc.storageos.db.client.model.StringSetMap in project coprhd-controller by CoprHD.
the class XtremIOUnManagedVolumeDiscoverer method createUnManagedVolume.
/**
* Creates a new UnManagedVolume with the given arguments.
*
* @param unManagedVolumeNativeGuid
* @param volume
* @param system
* @param pool
* @param dbClient
* @return
*/
private UnManagedVolume createUnManagedVolume(UnManagedVolume unManagedVolume, String unManagedVolumeNativeGuid, XtremIOVolume volume, Map<String, List<UnManagedVolume>> igVolumesMap, StorageSystem system, StoragePool pool, DbClient dbClient) {
boolean created = false;
StringSetMap unManagedVolumeInformation = null;
Map<String, String> unManagedVolumeCharacteristics = null;
if (null == unManagedVolume) {
unManagedVolume = new UnManagedVolume();
unManagedVolume.setId(URIUtil.createId(UnManagedVolume.class));
unManagedVolume.setNativeGuid(unManagedVolumeNativeGuid);
unManagedVolume.setStorageSystemUri(system.getId());
if (pool != null) {
unManagedVolume.setStoragePoolUri(pool.getId());
}
created = true;
unManagedVolumeInformation = new StringSetMap();
unManagedVolumeCharacteristics = new HashMap<String, String>();
} else {
unManagedVolumeInformation = unManagedVolume.getVolumeInformation();
unManagedVolumeCharacteristics = unManagedVolume.getVolumeCharacterstics();
}
unManagedVolume.setLabel(volume.getVolInfo().get(1));
Boolean isVolumeExported = false;
if (!volume.getLunMaps().isEmpty()) {
// clear the previous unmanaged export masks, initiators if any. The latest export masks will be updated later.
unManagedVolume.getUnmanagedExportMasks().clear();
unManagedVolume.getInitiatorNetworkIds().clear();
unManagedVolume.getInitiatorUris().clear();
isVolumeExported = true;
for (List<Object> lunMapEntries : volume.getLunMaps()) {
@SuppressWarnings("unchecked") List<Object> // This can't be null
igDetails = (List<Object>) lunMapEntries.get(0);
if (null == igDetails.get(1) || null == lunMapEntries.get(2)) {
log.warn("IG Name is null in returned lun map response for volume {}", volume.toString());
continue;
}
String igNameToProcess = (String) igDetails.get(1);
List<UnManagedVolume> igVolumes = igVolumesMap.get(igNameToProcess);
if (igVolumes == null) {
igVolumes = new ArrayList<UnManagedVolume>();
igVolumesMap.put(igNameToProcess, igVolumes);
}
igVolumes.add(unManagedVolume);
}
}
unManagedVolumeCharacteristics.put(SupportedVolumeCharacterstics.IS_VOLUME_EXPORTED.toString(), isVolumeExported.toString());
// Set these default to false. The individual storage discovery will change them if needed.
unManagedVolumeCharacteristics.put(SupportedVolumeCharacterstics.IS_NONRP_EXPORTED.toString(), FALSE);
unManagedVolumeCharacteristics.put(SupportedVolumeCharacterstics.IS_RECOVERPOINT_ENABLED.toString(), FALSE);
StringSet deviceLabel = new StringSet();
deviceLabel.add(volume.getVolInfo().get(1));
unManagedVolumeInformation.put(SupportedVolumeInformation.DEVICE_LABEL.toString(), deviceLabel);
String volumeWWN = volume.getWwn().isEmpty() ? volume.getVolInfo().get(0) : volume.getWwn();
unManagedVolume.setWwn(volumeWWN);
StringSet systemTypes = new StringSet();
systemTypes.add(system.getSystemType());
StringSet accessState = new StringSet();
accessState.add(Volume.VolumeAccessState.READWRITE.getState());
unManagedVolumeInformation.put(SupportedVolumeInformation.ACCESS.toString(), accessState);
StringSet provCapacity = new StringSet();
provCapacity.add(String.valueOf(Long.parseLong(volume.getAllocatedCapacity()) * 1024));
unManagedVolumeInformation.put(SupportedVolumeInformation.PROVISIONED_CAPACITY.toString(), provCapacity);
StringSet allocatedCapacity = new StringSet();
allocatedCapacity.add(String.valueOf(Long.parseLong(volume.getAllocatedCapacity()) * 1024));
unManagedVolumeInformation.put(SupportedVolumeInformation.ALLOCATED_CAPACITY.toString(), allocatedCapacity);
unManagedVolumeInformation.put(SupportedVolumeInformation.SYSTEM_TYPE.toString(), systemTypes);
StringSet nativeId = new StringSet();
nativeId.add(volume.getVolInfo().get(0));
unManagedVolumeInformation.put(SupportedVolumeInformation.NATIVE_ID.toString(), nativeId);
unManagedVolumeCharacteristics.put(SupportedVolumeCharacterstics.IS_INGESTABLE.toString(), TRUE);
unManagedVolumeCharacteristics.put(SupportedVolumeCharacterstics.IS_THINLY_PROVISIONED.toString(), TRUE);
// Set up default MAXIMUM_IO_BANDWIDTH and MAXIMUM_IOPS
StringSet bwValues = new StringSet();
bwValues.add("0");
if (unManagedVolumeInformation.get(SupportedVolumeInformation.EMC_MAXIMUM_IO_BANDWIDTH.toString()) == null) {
unManagedVolumeInformation.put(SupportedVolumeInformation.EMC_MAXIMUM_IO_BANDWIDTH.toString(), bwValues);
} else {
unManagedVolumeInformation.get(SupportedVolumeInformation.EMC_MAXIMUM_IO_BANDWIDTH.toString()).replace(bwValues);
}
StringSet iopsVal = new StringSet();
iopsVal.add("0");
if (unManagedVolumeInformation.get(SupportedVolumeInformation.EMC_MAXIMUM_IOPS.toString()) == null) {
unManagedVolumeInformation.put(SupportedVolumeInformation.EMC_MAXIMUM_IOPS.toString(), iopsVal);
} else {
unManagedVolumeInformation.get(SupportedVolumeInformation.EMC_MAXIMUM_IOPS.toString()).replace(iopsVal);
}
if (null != pool) {
unManagedVolume.setStoragePoolUri(pool.getId());
StringSet pools = new StringSet();
pools.add(pool.getId().toString());
unManagedVolumeInformation.put(SupportedVolumeInformation.STORAGE_POOL.toString(), pools);
StringSet driveTypes = pool.getSupportedDriveTypes();
if (null != driveTypes) {
unManagedVolumeInformation.put(SupportedVolumeInformation.DISK_TECHNOLOGY.toString(), driveTypes);
}
StringSet matchedVPools = DiscoveryUtils.getMatchedVirtualPoolsForPool(dbClient, pool.getId(), unManagedVolumeCharacteristics.get(SupportedVolumeCharacterstics.IS_THINLY_PROVISIONED.toString()), unManagedVolume);
log.debug("Matched Pools : {}", Joiner.on("\t").join(matchedVPools));
if (null == matchedVPools || matchedVPools.isEmpty()) {
// clear all existing supported vpools.
unManagedVolume.getSupportedVpoolUris().clear();
} else {
// replace with new StringSet
unManagedVolume.getSupportedVpoolUris().replace(matchedVPools);
log.info("Replaced Pools : {}", Joiner.on("\t").join(unManagedVolume.getSupportedVpoolUris()));
}
}
unManagedVolume.setVolumeInformation(unManagedVolumeInformation);
if (unManagedVolume.getVolumeCharacterstics() == null) {
unManagedVolume.setVolumeCharacterstics(new StringMap());
}
unManagedVolume.getVolumeCharacterstics().replace(unManagedVolumeCharacteristics);
if (created) {
unManagedVolumesToCreate.add(unManagedVolume);
} else {
unManagedVolumesToUpdate.add(unManagedVolume);
}
return unManagedVolume;
}
use of com.emc.storageos.db.client.model.StringSetMap in project coprhd-controller by CoprHD.
the class XtremIOUnManagedVolumeDiscoverer method discoverUnManagedObjects.
public void discoverUnManagedObjects(AccessProfile accessProfile, DbClient dbClient, PartitionManager partitionManager) throws Exception {
log.info("Started discovery of UnManagedVolumes for system {}", accessProfile.getSystemId());
StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, accessProfile.getSystemId());
XtremIOClient xtremIOClient = XtremIOProvUtils.getXtremIOClient(dbClient, storageSystem, xtremioRestClientFactory);
unManagedVolumesToCreate = new ArrayList<UnManagedVolume>();
unManagedVolumesToUpdate = new ArrayList<UnManagedVolume>();
unManagedCGToUpdateMap = new HashMap<String, UnManagedConsistencyGroup>();
// get the storage pool associated with the xtremio system
StoragePool storagePool = XtremIOProvUtils.getXtremIOStoragePool(storageSystem.getId(), dbClient);
if (storagePool == null) {
log.error("Skipping unmanaged volume discovery as the volume storage pool doesn't exist in ViPR");
return;
}
Map<String, List<UnManagedVolume>> igUnmanagedVolumesMap = new HashMap<String, List<UnManagedVolume>>();
Map<String, StringSet> igKnownVolumesMap = new HashMap<String, StringSet>();
Map<String, Map<String, Integer>> volumeIGHLUMap = new HashMap<String, Map<String, Integer>>();
String xioClusterName = xtremIOClient.getClusterDetails(storageSystem.getSerialNumber()).getName();
// get the xtremio volume links and process them in batches
List<XtremIOObjectInfo> volLinks = xtremIOClient.getXtremIOVolumeLinks(xioClusterName);
// Get the volume details
List<List<XtremIOObjectInfo>> volume_partitions = Lists.partition(volLinks, Constants.DEFAULT_PARTITION_SIZE);
// Set containing cgs that cannot be ingested, for now that
// means they contain volumes which belong to more than one cg
unSupportedCG = new HashSet<String>();
for (List<XtremIOObjectInfo> partition : volume_partitions) {
List<XtremIOVolume> volumes = xtremIOClient.getXtremIOVolumesForLinks(partition, xioClusterName);
for (XtremIOVolume volume : volumes) {
try {
// volumes later
if (volume.getAncestoVolInfo() != null && !volume.getAncestoVolInfo().isEmpty()) {
log.debug("Skipping volume {} as it is a snap", volume.getVolInfo().get(0));
continue;
}
// check if cgs are null before trying to access, older versions of
// the XtremIO REST client do not return cgs as part of volume response
// flag indicating the volume is part of a cg
boolean hasCGs = false;
if (volume.getConsistencyGroups() != null && !volume.getConsistencyGroups().isEmpty()) {
hasCGs = true;
if (volume.getConsistencyGroups().size() > 1) {
// volumes that belong to multiple CGs are not supported in ViPR
log.warn("Skipping volume {} as it belongs to multiple CGs and this is not supported", volume.getVolInfo().get(0));
// add all the CGs that this volume belongs to to the list that are unsupported for ingestion
for (List<Object> cg : volume.getConsistencyGroups()) {
Object cgNameToProcess = cg.get(1);
unSupportedCG.add(cgNameToProcess.toString());
log.warn("Skipping CG {} as it contains volumes belonging to multiple CGs and this is not supported", cgNameToProcess.toString());
}
continue;
}
}
UnManagedVolume unManagedVolume = null;
boolean isExported = !volume.getLunMaps().isEmpty();
boolean hasSnaps = !volume.getSnaps().isEmpty();
String managedVolumeNativeGuid = NativeGUIDGenerator.generateNativeGuidForVolumeOrBlockSnapShot(storageSystem.getNativeGuid(), volume.getVolInfo().get(0));
Volume viprVolume = DiscoveryUtils.checkStorageVolumeExistsInDB(dbClient, managedVolumeNativeGuid);
if (null != viprVolume) {
log.info("Skipping volume {} as it is already managed by ViPR", managedVolumeNativeGuid);
// export masks.
if (isExported) {
populateKnownVolsMap(volume, viprVolume, igKnownVolumesMap);
}
// retrieve snap info to be processed later
if (hasSnaps) {
StringSet vpoolUriSet = new StringSet();
vpoolUriSet.add(viprVolume.getVirtualPool().toString());
discoverVolumeSnaps(storageSystem, volume.getSnaps(), viprVolume.getNativeGuid(), vpoolUriSet, xtremIOClient, xioClusterName, dbClient, igUnmanagedVolumesMap, igKnownVolumesMap);
}
continue;
}
String unManagedVolumeNatvieGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingVolume(storageSystem.getNativeGuid(), volume.getVolInfo().get(0));
// retrieve snap info to be processed later
unManagedVolume = DiscoveryUtils.checkUnManagedVolumeExistsInDB(dbClient, unManagedVolumeNatvieGuid);
unManagedVolume = createUnManagedVolume(unManagedVolume, unManagedVolumeNatvieGuid, volume, igUnmanagedVolumesMap, storageSystem, storagePool, dbClient);
// if the volume is associated with a CG, set up the unmanaged CG
if (hasCGs) {
for (List<Object> cg : volume.getConsistencyGroups()) {
// retrieve what should be the first and only consistency group from the list
// volumes belonging to multiple cgs are not supported and were excluded above
Object cgNameToProcess = cg.get(1);
addObjectToUnManagedConsistencyGroup(xtremIOClient, unManagedVolume, cgNameToProcess.toString(), storageSystem, xioClusterName, dbClient);
}
} else {
// Make sure the unManagedVolume object does not contain CG information from previous discovery
unManagedVolume.getVolumeCharacterstics().put(SupportedVolumeCharacterstics.IS_VOLUME_ADDED_TO_CONSISTENCYGROUP.toString(), Boolean.FALSE.toString());
// set the uri of the unmanaged CG in the unmanaged volume object to empty
unManagedVolume.getVolumeInformation().put(SupportedVolumeInformation.UNMANAGED_CONSISTENCY_GROUP_URI.toString(), "");
}
if (isExported) {
Map<String, Integer> igHLUMap = new HashMap<String, Integer>();
for (List<Object> lunMapEntries : volume.getLunMaps()) {
Double hlu = (Double) lunMapEntries.get(2);
log.info("Found HLU {}", hlu);
List<Object> igDetails = (List<Object>) lunMapEntries.get(0);
// key value IG-HLU
igHLUMap.put(igDetails.get(1).toString(), Integer.valueOf(hlu.intValue()));
}
if (!igHLUMap.isEmpty()) {
volumeIGHLUMap.put(unManagedVolumeNatvieGuid, igHLUMap);
}
}
boolean hasReplicas = false;
if (hasSnaps) {
StringSet parentMatchedVPools = unManagedVolume.getSupportedVpoolUris();
StringSet discoveredSnaps = discoverVolumeSnaps(storageSystem, volume.getSnaps(), unManagedVolumeNatvieGuid, parentMatchedVPools, xtremIOClient, xioClusterName, dbClient, igUnmanagedVolumesMap, igKnownVolumesMap);
if (!discoveredSnaps.isEmpty()) {
hasReplicas = true;
// set the HAS_REPLICAS property
unManagedVolume.getVolumeCharacterstics().put(SupportedVolumeCharacterstics.HAS_REPLICAS.toString(), TRUE);
StringSetMap unManagedVolumeInformation = unManagedVolume.getVolumeInformation();
if (unManagedVolumeInformation.containsKey(SupportedVolumeInformation.SNAPSHOTS.toString())) {
log.debug("Snaps :" + Joiner.on("\t").join(discoveredSnaps));
if (null != discoveredSnaps && discoveredSnaps.isEmpty()) {
// replace with empty string set doesn't work, hence added explicit code to remove all
unManagedVolumeInformation.get(SupportedVolumeInformation.SNAPSHOTS.toString()).clear();
} else {
// replace with new StringSet
unManagedVolumeInformation.get(SupportedVolumeInformation.SNAPSHOTS.toString()).replace(discoveredSnaps);
log.info("Replaced snaps :" + Joiner.on("\t").join(unManagedVolumeInformation.get(SupportedVolumeInformation.SNAPSHOTS.toString())));
}
} else {
unManagedVolumeInformation.put(SupportedVolumeInformation.SNAPSHOTS.toString(), discoveredSnaps);
}
}
}
if (!hasReplicas) {
unManagedVolume.getVolumeCharacterstics().put(SupportedVolumeCharacterstics.HAS_REPLICAS.toString(), FALSE);
StringSet snapshots = unManagedVolume.getVolumeInformation().get(SupportedVolumeInformation.SNAPSHOTS.toString());
if (snapshots != null && !snapshots.isEmpty()) {
unManagedVolume.getVolumeInformation().get(SupportedVolumeInformation.SNAPSHOTS.toString()).clear();
}
}
allCurrentUnManagedVolumeUris.add(unManagedVolume.getId());
} catch (Exception ex) {
log.error("Error processing XIO volume {}", volume, ex);
}
}
}
if (!unManagedCGToUpdateMap.isEmpty()) {
unManagedCGToUpdate = new ArrayList<UnManagedConsistencyGroup>(unManagedCGToUpdateMap.values());
partitionManager.updateAndReIndexInBatches(unManagedCGToUpdate, unManagedCGToUpdate.size(), dbClient, UNMANAGED_CONSISTENCY_GROUP);
unManagedCGToUpdate.clear();
}
if (!unManagedVolumesToCreate.isEmpty()) {
partitionManager.insertInBatches(unManagedVolumesToCreate, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_VOLUME);
unManagedVolumesToCreate.clear();
}
if (!unManagedVolumesToUpdate.isEmpty()) {
partitionManager.updateAndReIndexInBatches(unManagedVolumesToUpdate, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_VOLUME);
unManagedVolumesToUpdate.clear();
}
// 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);
// Next discover the unmanaged export masks
discoverUnmanagedExportMasks(storageSystem.getId(), igUnmanagedVolumesMap, igKnownVolumesMap, xtremIOClient, xioClusterName, dbClient, partitionManager, volumeIGHLUMap);
}
use of com.emc.storageos.db.client.model.StringSetMap in project coprhd-controller by CoprHD.
the class ImplicitUnManagedObjectsMatcher method matchVirtualPoolsWithUnManagedVolumes.
public static void matchVirtualPoolsWithUnManagedVolumes(VirtualPool virtualPool, Set<URI> srdfEnabledTargetVPools, Set<URI> rpEnabledTargetVPools, DbClient dbClient, boolean recalcVplexVolumes) {
List<UnManagedVolume> modifiedUnManagedVolumes = new ArrayList<UnManagedVolume>();
Map<String, StringSet> poolMapping = new HashMap<String, StringSet>();
StringSet invalidPools = null;
// Otherwise use matched pools
if (virtualPool.getUseMatchedPools() && null != virtualPool.getMatchedStoragePools()) {
poolMapping.put(MATCHED, virtualPool.getMatchedStoragePools());
} else if (null != virtualPool.getAssignedStoragePools()) {
poolMapping.put(MATCHED, virtualPool.getAssignedStoragePools());
if (null != virtualPool.getMatchedStoragePools()) {
// Find out the storage pools which are in matched pools but not in assigned pools.
// These pools should not be in the supported vpool list
invalidPools = (StringSet) virtualPool.getMatchedStoragePools().clone();
invalidPools.removeAll(virtualPool.getAssignedStoragePools());
}
}
if (null != virtualPool.getInvalidMatchedPools()) {
if (invalidPools == null) {
invalidPools = virtualPool.getInvalidMatchedPools();
} else {
invalidPools.addAll(virtualPool.getInvalidMatchedPools());
}
}
if (invalidPools != null) {
poolMapping.put(INVALID, invalidPools);
}
// matched pools within the same logic.T
for (Entry<String, StringSet> entry : poolMapping.entrySet()) {
String key = entry.getKey();
// loop through matchedPools and later on invalid pools
for (String pool : entry.getValue()) {
StorageSystem system = null;
@SuppressWarnings("deprecation") List<URI> unManagedVolumeUris = dbClient.queryByConstraint(ContainmentConstraint.Factory.getPoolUnManagedVolumeConstraint(URI.create(pool)));
Iterator<UnManagedVolume> unManagedVolumes = dbClient.queryIterativeObjects(UnManagedVolume.class, unManagedVolumeUris);
while (unManagedVolumes.hasNext()) {
UnManagedVolume unManagedVolume = unManagedVolumes.next();
StringSetMap unManagedVolumeInfo = unManagedVolume.getVolumeInformation();
if (null == unManagedVolumeInfo) {
continue;
}
if (system == null) {
system = dbClient.queryObject(StorageSystem.class, unManagedVolume.getStorageSystemUri());
}
String unManagedVolumeProvisioningType = UnManagedVolume.SupportedProvisioningType.getProvisioningType(unManagedVolume.getVolumeCharacterstics().get(SupportedVolumeCharacterstics.IS_THINLY_PROVISIONED.toString()));
// remove the vpool from supported Vpool List if present
if (INVALID.equalsIgnoreCase(key) || !unManagedVolumeProvisioningType.equalsIgnoreCase(virtualPool.getSupportedProvisioningType())) {
if (removeVPoolFromUnManagedVolumeObjectVPools(virtualPool, unManagedVolume)) {
modifiedUnManagedVolumes.add(unManagedVolume);
}
} else if (addVPoolToUnManagedObjectSupportedVPools(virtualPool, unManagedVolumeInfo, unManagedVolume, system, srdfEnabledTargetVPools, rpEnabledTargetVPools)) {
modifiedUnManagedVolumes.add(unManagedVolume);
}
if (modifiedUnManagedVolumes.size() > VOLUME_BATCH_SIZE) {
insertInBatches(modifiedUnManagedVolumes, dbClient, "UnManagedVolumes");
modifiedUnManagedVolumes.clear();
}
}
}
}
if (recalcVplexVolumes) {
// VPLEX unmanaged volumes need to be matched by different rules.
matchVirtualPoolWithUnManagedVolumeVPLEX(modifiedUnManagedVolumes, virtualPool, dbClient);
}
insertInBatches(modifiedUnManagedVolumes, dbClient, "UnManagedVolumes");
}
Aggregations