use of com.emc.storageos.db.client.model.StringSetMap in project coprhd-controller by CoprHD.
the class VNXUnityBlockStorageDevice method doDeleteConsistencyGroup.
@Override
public void doDeleteConsistencyGroup(StorageSystem storage, URI consistencyGroupId, String replicationGroupName, Boolean keepRGName, Boolean markInactive, TaskCompleter taskCompleter) throws DeviceControllerException {
logger.info("Deleting consistency group, array: {}", storage.getSerialNumber());
BlockConsistencyGroup consistencyGroup = dbClient.queryObject(BlockConsistencyGroup.class, consistencyGroupId);
StringSet cgNames = new StringSet();
if (NullColumnValueGetter.isNullValue(replicationGroupName)) {
StringSetMap ssm = consistencyGroup.getSystemConsistencyGroups();
if (ssm != null) {
cgNames = ssm.get(storage.getId().toString());
if (cgNames == null || cgNames.isEmpty()) {
logger.info("There is no array consistency group to be deleted.");
// Clean up the system consistency group references
BlockConsistencyGroupUtils.cleanUpCGAndUpdate(consistencyGroup, storage.getId(), null, markInactive, dbClient);
taskCompleter.ready(dbClient);
return;
}
}
} else {
cgNames.add(replicationGroupName);
}
VNXeApiClient apiClient = getVnxUnityClient(storage);
try {
for (String cgName : cgNames) {
logger.info("Deleting the consistency group {}", cgName);
String id = apiClient.getConsistencyGroupIdByName(cgName);
if (id != null && !id.isEmpty()) {
apiClient.deleteConsistencyGroup(id, false, false);
}
if (!keepRGName) {
// Clean up the system consistency group references
BlockConsistencyGroupUtils.cleanUpCGAndUpdate(consistencyGroup, storage.getId(), cgName, markInactive, dbClient);
if (consistencyGroup.getInactive()) {
logger.info("CG is deleted");
}
}
}
taskCompleter.ready(dbClient);
} catch (Exception e) {
logger.info("Failed to delete consistency group: " + e);
// Set task to error
ServiceError error = DeviceControllerErrors.vnxe.jobFailed("doDeleteConsistencyGroup", e.getMessage());
taskCompleter.error(dbClient, error);
}
}
use of com.emc.storageos.db.client.model.StringSetMap in project coprhd-controller by CoprHD.
the class VNXUnityUnManagedObjectDiscoverer method discoverUnManagedVolumes.
public void discoverUnManagedVolumes(AccessProfile accessProfile, DbClient dbClient, CoordinatorClient coordinator, PartitionManager partitionManager) throws Exception {
log.info("Started discovery of UnManagedVolumes for system {}", accessProfile.getSystemId());
VNXeApiClient apiClient = getVnxUnityClient(accessProfile);
unManagedVolumesInsert = new ArrayList<UnManagedVolume>();
unManagedVolumesUpdate = new ArrayList<UnManagedVolume>();
unManagedCGToUpdateMap = new HashMap<String, UnManagedConsistencyGroup>();
StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, accessProfile.getSystemId());
List<VNXeLun> luns = apiClient.getAllLuns();
if (luns != null && !luns.isEmpty()) {
Map<String, StoragePool> pools = getStoragePoolMap(storageSystem, dbClient);
Map<String, List<UnManagedVolume>> hostVolumesMap = new HashMap<String, List<UnManagedVolume>>();
for (VNXeLun lun : luns) {
UnManagedVolume unManagedVolume = null;
String managedVolumeNativeGuid = NativeGUIDGenerator.generateNativeGuidForVolumeOrBlockSnapShot(storageSystem.getNativeGuid(), lun.getId());
if (null != DiscoveryUtils.checkStorageVolumeExistsInDB(dbClient, managedVolumeNativeGuid)) {
log.info("Skipping volume {} as it is already managed by ViPR", managedVolumeNativeGuid);
}
StoragePool storagePool = getStoragePoolOfUnManagedObject(lun.getPool().getId(), storageSystem, pools);
if (null == storagePool) {
log.error("Skipping unmanaged volume discovery as the volume {} storage pool doesn't exist in ViPR", lun.getId());
continue;
}
String unManagedVolumeNatvieGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingVolume(storageSystem.getNativeGuid(), lun.getId());
unManagedVolume = DiscoveryUtils.checkUnManagedVolumeExistsInDB(dbClient, unManagedVolumeNatvieGuid);
unManagedVolume = createUnManagedVolume(unManagedVolume, unManagedVolumeNatvieGuid, lun, storageSystem, storagePool, dbClient, hostVolumesMap);
unManagedVolumesReturnedFromProvider.add(unManagedVolume.getId());
Boolean isVolumeInCG = lun.getType() == VNXeApiClient.GENERIC_STORAGE_LUN_TYPE ? true : false;
String cgId = null;
if (isVolumeInCG) {
cgId = lun.getStorageResource().getId();
addObjectToUnManagedConsistencyGroup(apiClient, unManagedVolume, cgId, storageSystem, 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(), "");
}
// Discover snaps
Integer snapCount = lun.getSnapCount();
boolean hasSnap = false;
if (snapCount > 0) {
List<Snap> snaps = apiClient.getSnapshotsForLun(lun.getId());
if (snaps != null && !snaps.isEmpty()) {
StringSet parentMatchedVPools = unManagedVolume.getSupportedVpoolUris();
StringSet discoveredSnaps = discoverVolumeSnaps(storageSystem, snaps, unManagedVolumeNatvieGuid, parentMatchedVPools, apiClient, dbClient, hostVolumesMap, lun, isVolumeInCG, cgId);
if (discoveredSnaps != null && !discoveredSnaps.isEmpty()) {
hasSnap = true;
unManagedVolume.getVolumeCharacterstics().put(SupportedVolumeCharacterstics.HAS_REPLICAS.toString(), Boolean.TRUE.toString());
StringSetMap unManagedVolumeInformation = unManagedVolume.getVolumeInformation();
if (unManagedVolumeInformation.containsKey(SupportedVolumeInformation.SNAPSHOTS.toString())) {
// 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 (!hasSnap) {
// no snap
unManagedVolume.getVolumeCharacterstics().put(SupportedVolumeCharacterstics.HAS_REPLICAS.toString(), Boolean.FALSE.toString());
StringSetMap unManagedVolumeInformation = unManagedVolume.getVolumeInformation();
if (unManagedVolumeInformation != null && unManagedVolumeInformation.containsKey(SupportedVolumeInformation.SNAPSHOTS.toString())) {
// replace with empty string set doesn't work, hence added explicit code to remove all
unManagedVolumeInformation.get(SupportedVolumeInformation.SNAPSHOTS.toString()).clear();
}
}
}
if (!unManagedCGToUpdateMap.isEmpty()) {
unManagedCGToUpdate = new ArrayList<UnManagedConsistencyGroup>(unManagedCGToUpdateMap.values());
partitionManager.updateAndReIndexInBatches(unManagedCGToUpdate, unManagedCGToUpdate.size(), dbClient, UNMANAGED_CONSISTENCY_GROUP);
unManagedCGToUpdate.clear();
}
if (!unManagedVolumesInsert.isEmpty()) {
partitionManager.insertInBatches(unManagedVolumesInsert, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_VOLUME);
}
if (!unManagedVolumesUpdate.isEmpty()) {
partitionManager.updateAndReIndexInBatches(unManagedVolumesUpdate, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_VOLUME);
}
// Process those active unmanaged volume objects available in database but not in newly discovered items, to
// mark them inactive.
DiscoveryUtils.markInActiveUnManagedVolumes(storageSystem, unManagedVolumesReturnedFromProvider, 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(), hostVolumesMap, apiClient, dbClient, partitionManager);
} else {
log.info("There are no luns found on the system: {}", storageSystem.getId());
}
}
use of com.emc.storageos.db.client.model.StringSetMap in project coprhd-controller by CoprHD.
the class QualityOfServiceMigrationTest method prepareData.
@Override
protected void prepareData() throws Exception {
StringSet stringSet = new StringSet();
stringSet.add(V_POOL_PROTOCOL);
StringSetMap arrayInfo = new StringSetMap();
arrayInfo.put("system_type", V_POOL_SYSTEM_TYPE);
arrayInfo.put("raid_level", V_POOL_RAID_LEVEL);
vPoolId = URIUtil.createId(VirtualPool.class);
// Create Virtual Pool with given parameters
VirtualPool virtualPool = new VirtualPool();
virtualPool.setId(vPoolId);
virtualPool.setLabel(V_POOL_LABEL);
virtualPool.setSupportedProvisioningType(V_POOL_PROVISIONING_TYPE);
virtualPool.setProtocols(stringSet);
virtualPool.setDriveType(V_POOL_DRIVE_TYPE);
virtualPool.setMultivolumeConsistency(V_POOL_MULTI_VOLUME_CONSISTENCY);
virtualPool.setExpandable(V_POOL_EXPENDABLE);
virtualPool.setNumPaths(V_POOL_MAX_SAN_PATHS);
virtualPool.setMinPaths(V_POOL_MIN_SAN_PATHS);
virtualPool.setMaxNativeContinuousCopies(V_POOL_MAX_BLOCK_MIRRORS);
virtualPool.setPathsPerInitiator(V_POOL_PATHS_PER_INITIATOR);
virtualPool.setMaxNativeSnapshots(V_POOL_MAX_SNAPSHOTS);
virtualPool.setArrayInfo(arrayInfo);
// Persist Virtual Pool to DB
_dbClient.createObject(virtualPool);
}
use of com.emc.storageos.db.client.model.StringSetMap in project coprhd-controller by CoprHD.
the class ExternalDeviceExportOperations method prepareCapabilitiesForAddInitiators.
private void prepareCapabilitiesForAddInitiators(ExportPathParams pathParams, StringSetMap existingZoningMap, URI varrayURI, List<com.emc.storageos.db.client.model.Initiator> initiators, StorageCapabilities capabilities) {
int driverMaxPath;
StringSetMap zoningMap = new StringSetMap();
// Calculate existing paths (without new initiators).
int existingPaths = 0;
List<URI> initiatorUris = URIUtil.toUris(initiators);
for (Map.Entry<String, AbstractChangeTrackingSet<String>> entry : existingZoningMap.entrySet()) {
if (!initiatorUris.contains(URIUtil.uri(entry.getKey()))) {
zoningMap.put(entry.getKey(), entry.getValue());
}
}
Map<com.emc.storageos.db.client.model.Initiator, List<com.emc.storageos.db.client.model.StoragePort>> assignments = blockScheduler.generateInitiatorsToStoragePortsMap(zoningMap, varrayURI);
existingPaths = assignments.values().size();
log.info("Existing path number in the export mask is {}", existingPaths);
// Otherwise we allocate the difference between max paths and existing paths
if (existingPaths + pathParams.getPathsPerInitiator() > pathParams.getMaxPaths()) {
// we always need at least path-per-initiator ports
driverMaxPath = pathParams.getPathsPerInitiator();
} else {
driverMaxPath = pathParams.getMaxPaths() - existingPaths;
}
// We assume that masking view meets min path before new initiators are added. We pass ppi as a minPath
// to driver, so we can zone at least one new initiator.
ExportPathsServiceOption numPath = new ExportPathsServiceOption(pathParams.getPathsPerInitiator(), driverMaxPath);
List<ExportPathsServiceOption> exportPathParams = new ArrayList<>();
exportPathParams.add(numPath);
CommonStorageCapabilities commonCapabilities = new CommonStorageCapabilities();
commonCapabilities.setExportPathParams(exportPathParams);
capabilities.setCommonCapabilitis(commonCapabilities);
}
use of com.emc.storageos.db.client.model.StringSetMap in project coprhd-controller by CoprHD.
the class ExternalDeviceUnManagedVolumeDiscoverer method processUnManagedClones.
/**
* Process clones of unManaged volume.
* Check if unManaged clone should be created and create unManaged volume instance for a clone in such a case.
* Add unManaged clone to parent volume CG if needed and update the clone with parent volume CG information.
* Gets export information for clones and stores it in the provided map.
*
* @param driverVolume driver volume for clone parent volume. [IN]
* @param unManagedParentVolume unManaged parent volume [IN/OUT]
* @param storageSystem storage system [IN]
* @param storagePool storage pool [IN]
* @param unManagedVolumesToCreate list of unmanaged volumes to create [OUT]
* @param unManagedVolumesToUpdate list of unmanaged volumes to update [OUT]
* @param allCurrentUnManagedCgURIs set of unManaged CG uris found in the current discovery [OUT]
* @param unManagedCGToUpdateMap map of unManaged CG GUID to unManaged CG instance [IN/OUT]
* @param unManagedVolumeNativeIdToUriMap map of unmanaged volumes nativeId to their uri [OUT]
* @param hostToUnManagedVolumeExportInfoMap map with export data for unmanaged volumes (including snaps and clones)
* @param driver storage driver [IN]
* @param dbClient reference to db client [IN]
* @return set of URIs for unmanaged clones
* @throws Exception
*/
private Set<URI> processUnManagedClones(StorageVolume driverVolume, UnManagedVolume unManagedParentVolume, com.emc.storageos.db.client.model.StorageSystem storageSystem, com.emc.storageos.db.client.model.StoragePool storagePool, List<UnManagedVolume> unManagedVolumesToCreate, List<UnManagedVolume> unManagedVolumesToUpdate, Set<URI> allCurrentUnManagedCgURIs, Map<String, UnManagedConsistencyGroup> unManagedCGToUpdateMap, Map<String, URI> unManagedVolumeNativeIdToUriMap, Map<String, List<HostExportInfo>> hostToUnManagedVolumeExportInfoMap, BlockStorageDriver driver, DbClient dbClient) throws Exception {
log.info("Processing clones for volume {} ", unManagedParentVolume.getNativeGuid());
Set<URI> cloneUris = new HashSet<>();
List<VolumeClone> driverClones = driver.getVolumeClones(driverVolume);
if (driverClones == null || driverClones.isEmpty()) {
log.info("There are no clones for volume {} ", unManagedParentVolume.getNativeGuid());
} else {
log.info("Clones for unManaged volume {}:" + Joiner.on("\t").join(driverClones), unManagedParentVolume.getNativeGuid());
StringSet unManagedClones = new StringSet();
for (VolumeClone driverClone : driverClones) {
String managedCloneNativeGuid = NativeGUIDGenerator.generateNativeGuidForVolumeOrBlockSnapShot(storageSystem.getNativeGuid(), driverClone.getNativeId());
Volume systemClone = DiscoveryUtils.checkStorageVolumeExistsInDB(dbClient, managedCloneNativeGuid);
if (null != systemClone) {
log.info("Skipping clone {} as it is already managed by the system.", managedCloneNativeGuid);
continue;
}
String unManagedCloneNatvieGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingVolume(storageSystem.getNativeGuid(), driverClone.getNativeId());
UnManagedVolume unManagedClone = createUnManagedClone(driverClone, unManagedParentVolume, storageSystem, storagePool, unManagedVolumesToCreate, unManagedVolumesToUpdate, dbClient);
cloneUris.add(unManagedClone.getId());
unManagedClones.add(unManagedCloneNatvieGuid);
// Check if this clone is for a volume in consistency group on device.
String isParentVolumeInCG = unManagedParentVolume.getVolumeCharacterstics().get(UnManagedVolume.SupportedVolumeCharacterstics.IS_VOLUME_ADDED_TO_CONSISTENCYGROUP.toString());
if (isParentVolumeInCG.equals(Boolean.TRUE.toString())) {
log.info("Clone {} is for volume in CG. ", managedCloneNativeGuid);
// add clone to parent volume unManaged consistency group, update clone with parent volume CG information.
addObjectToUnManagedConsistencyGroup(storageSystem, driverVolume.getConsistencyGroup(), unManagedClone, allCurrentUnManagedCgURIs, unManagedCGToUpdateMap, driver, dbClient);
}
// get export data for the clone
unManagedVolumeNativeIdToUriMap.put(driverClone.getNativeId(), unManagedClone.getId());
getCloneExportInfo(driver, driverClone, hostToUnManagedVolumeExportInfoMap);
}
if (!unManagedClones.isEmpty()) {
// set the HAS_REPLICAS property
unManagedParentVolume.getVolumeCharacterstics().put(UnManagedVolume.SupportedVolumeCharacterstics.HAS_REPLICAS.toString(), TRUE);
StringSetMap unManagedVolumeInformation = unManagedParentVolume.getVolumeInformation();
log.info("New unManaged clones for unManaged volume {}:" + Joiner.on("\t").join(unManagedClones), unManagedParentVolume.getNativeGuid());
if (unManagedVolumeInformation.containsKey(UnManagedVolume.SupportedVolumeInformation.FULL_COPIES.toString())) {
log.info("Old unManaged clones for unManaged volume {}:" + Joiner.on("\t").join(unManagedVolumeInformation.get(UnManagedVolume.SupportedVolumeInformation.FULL_COPIES.toString())), unManagedParentVolume.getNativeGuid());
// replace with new StringSet
unManagedVolumeInformation.get(UnManagedVolume.SupportedVolumeInformation.FULL_COPIES.toString()).replace(unManagedClones);
log.info("Replaced clones :" + Joiner.on("\t").join(unManagedVolumeInformation.get(UnManagedVolume.SupportedVolumeInformation.FULL_COPIES.toString())));
} else {
unManagedVolumeInformation.put(UnManagedVolume.SupportedVolumeInformation.FULL_COPIES.toString(), unManagedClones);
}
} else {
log.info("All clones for volume {} are already managed.", unManagedParentVolume.getNativeGuid());
}
}
return cloneUris;
}
Aggregations