use of com.emc.storageos.db.client.model.BlockConsistencyGroup in project coprhd-controller by CoprHD.
the class BlockServiceUtils method checkCGVolumeCanBeAddedOrRemoved.
/**
* For VMAX, creating/deleting volume in/from CG with existing group relationship is supported for SMI-S provider version 8.0.3 or
* higher
*
* Fox XtremIO creating/deleting volume in/from CG with existing CG is supported.
*
* For VNX, creating/deleting volume in/from CG with existing group relationship is supported if volume is not part of an array
* replication group
*
* For Application support, allow volumes to be added/removed to/from CG for VPLEX when the backend volume is VMAX/VNX/XtremIO
*
* @param cg BlockConsistencyGroup
* @param volume Volume part of the CG
* @dbClient DbClient
* @return true if the operation is supported.
*/
public static boolean checkCGVolumeCanBeAddedOrRemoved(BlockConsistencyGroup cg, Volume volume, DbClient dbClient) {
StorageSystem storage = dbClient.queryObject(StorageSystem.class, volume.getStorageController());
if (storage != null) {
if (storage.deviceIsType(Type.vmax)) {
if (storage.getUsingSmis80()) {
return true;
}
} else if (storage.deviceIsType(Type.vnxblock)) {
BlockConsistencyGroup consistencyGroup = cg;
if (consistencyGroup == null) {
consistencyGroup = dbClient.queryObject(BlockConsistencyGroup.class, volume.getConsistencyGroup());
}
if (consistencyGroup != null && !consistencyGroup.getInactive()) {
return !consistencyGroup.getArrayConsistency();
}
} else if (storage.deviceIsType(Type.xtremio)) {
return true;
} else if (storage.deviceIsType(Type.unity) && volume.checkForRp()) {
return true;
}
if (storage.deviceIsType(Type.vplex)) {
Set<Type> applicationSupported = Sets.newHashSet(Type.vmax, Type.vnxblock, Type.xtremio, Type.unity);
Set<Type> backendSystemTypes = new HashSet<>();
if (volume.getAssociatedVolumes() != null && !volume.getAssociatedVolumes().isEmpty()) {
for (String associatedVolumeId : volume.getAssociatedVolumes()) {
Volume associatedVolume = dbClient.queryObject(Volume.class, URI.create(associatedVolumeId));
if (associatedVolume != null) {
StorageSystem backendSystem = dbClient.queryObject(StorageSystem.class, associatedVolume.getStorageController());
if (backendSystem != null && !Strings.isNullOrEmpty(backendSystem.getSystemType())) {
backendSystemTypes.add(Type.valueOf(backendSystem.getSystemType()));
}
}
}
}
// when the backend volume is VMAX/VNX/XtremIO
if (volume.getApplication(dbClient) != null) {
// Returns true, if any backendSystemTypes are in the supported set for applications
return !Collections.disjoint(applicationSupported, backendSystemTypes);
} else if (!Volume.checkForRP(dbClient, volume.getId())) {
// Returns true, for VPLEX&VMAX scenarios
return backendSystemTypes.contains(Type.vmax);
}
}
}
return false;
}
use of com.emc.storageos.db.client.model.BlockConsistencyGroup in project coprhd-controller by CoprHD.
the class BlockServiceUtils method createFailedTaskOnCG.
/**
* Creates a Task on given CG with Error state
*
* @param opr the opr
* @param cg the consistency group
* @param sc the sc
* @return the failed task for cg
*/
public static TaskResourceRep createFailedTaskOnCG(DbClient dbClient, BlockConsistencyGroup cg, ResourceOperationTypeEnum opr, ServiceCoded sc) {
String taskId = UUID.randomUUID().toString();
Operation op = new Operation();
op.setResourceType(opr);
dbClient.createTaskOpStatus(BlockConsistencyGroup.class, cg.getId(), taskId, op);
cg = dbClient.queryObject(BlockConsistencyGroup.class, cg.getId());
op = cg.getOpStatus().get(taskId);
op.error(sc);
cg.getOpStatus().updateTaskStatus(taskId, op);
dbClient.updateObject(cg);
return TaskMapper.toTask(cg, taskId, op);
}
use of com.emc.storageos.db.client.model.BlockConsistencyGroup in project coprhd-controller by CoprHD.
the class AbstractBlockFullCopyApiImpl method addConsistencyGroupTasks.
/**
* Creates tasks against consistency groups associated with a request and adds them to the given task list.
*
* @param objects
* @param taskList
* @param taskId
* @param operationTypeEnum
* @param <T>
*/
protected <T extends BlockObject> void addConsistencyGroupTasks(List<T> objects, TaskList taskList, String taskId, ResourceOperationTypeEnum operationTypeEnum) {
Set<URI> consistencyGroups = new HashSet<>();
for (T object : objects) {
if (!isNullURI(object.getConsistencyGroup())) {
consistencyGroups.add(object.getConsistencyGroup());
}
}
if (consistencyGroups.isEmpty()) {
return;
}
List<BlockConsistencyGroup> groups = _dbClient.queryObject(BlockConsistencyGroup.class, consistencyGroups);
for (BlockConsistencyGroup group : groups) {
Operation op = _dbClient.createTaskOpStatus(BlockConsistencyGroup.class, group.getId(), taskId, operationTypeEnum);
taskList.getTaskList().add(TaskMapper.toTask(group, taskId, op));
}
}
use of com.emc.storageos.db.client.model.BlockConsistencyGroup in project coprhd-controller by CoprHD.
the class BlockSnapshotSessionManager method getAllSnapshotSessionSources.
private List<BlockObject> getAllSnapshotSessionSources(BlockSnapshotSession snapSession) {
if (snapSession.hasConsistencyGroup() && NullColumnValueGetter.isNotNullValue(snapSession.getReplicationGroupInstance())) {
BlockConsistencyGroup cg = _dbClient.queryObject(BlockConsistencyGroup.class, snapSession.getConsistencyGroup());
List<Volume> cgSources = BlockConsistencyGroupUtils.getAllCGVolumes(cg, _dbClient);
// return only those volumes belonging to session's RG
return ControllerUtils.getAllVolumesForRGInCG(cgSources, snapSession.getReplicationGroupInstance(), snapSession.getStorageController(), _dbClient);
} else {
BlockObject snapSessionSourceObj = BlockSnapshotSessionUtils.querySnapshotSessionSource(snapSession.getParent().getURI(), _uriInfo, true, _dbClient);
return Lists.newArrayList(snapSessionSourceObj);
}
}
use of com.emc.storageos.db.client.model.BlockConsistencyGroup in project coprhd-controller by CoprHD.
the class VolumeIngestionUtil method getBlockObjectConsistencyGroup.
/**
* Creates a BlockConsistencyGroup if it doesn't exist only when we are ingesting the last volume in unmanaged consistencygroup.
*
* In case if the volume is protected by RP or VPLEX, we should not create CG.
*
* @param unManagedVolume - UnManagedVolume object.
* @param blockObj - Ingested BlockObject
* @param context - current unManagedVolume Ingestion context.
* @param dbClient - dbClient instance.
* @return BlockConsistencyGroup
*/
public static BlockConsistencyGroup getBlockObjectConsistencyGroup(UnManagedVolume unManagedVolume, BlockObject blockObj, IngestionRequestContext context, DbClient dbClient) {
UnManagedConsistencyGroup umcg = getUnManagedConsistencyGroup(unManagedVolume, dbClient);
if (umcg != null) {
// Check if the UnManagedConsistencyGroup is present in the volume context which should have the updated info
UnManagedConsistencyGroup umcgInContext = context.findUnManagedConsistencyGroup(umcg.getLabel());
if (umcgInContext != null) {
umcg = umcgInContext;
}
}
// CG ingestion support for such volumes.
if (umcg == null || umcg.getUnManagedVolumesMap() == null) {
_logger.info("There is no unmanaged consistency group associated with unmanaged volume {}, however " + "the volume has the IS_VOLUME_IN_CONSISTENCYGROUP flag set to true. Ignoring CG operation" + " as there is not enough information to put this volume in a CG by itself.", unManagedVolume.getNativeGuid());
return null;
}
List<UnManagedConsistencyGroup> umcgsToUpdate = context.getVolumeContext().getUmCGObjectsToUpdate();
boolean isLastUmvToIngest = isLastUnManagedVolumeToIngest(umcg, unManagedVolume);
boolean isVplexOrRPProtected = isRPOrVplexProtected(unManagedVolume);
if (isVplexOrRPProtected || !isLastUmvToIngest) {
_logger.info("Ignoring the CG creation as the volume is either isVplexRPProtected:{} or isLastUmvToIngest: {} exists to ingest.", isLastUmvToIngest, isVplexOrRPProtected);
_logger.info("Remaining volumes in CG to ingest: {}", umcg.getUnManagedVolumesMap());
// set ReplicationGroupInstance in the block object.
blockObj.setReplicationGroupInstance(umcg.getLabel());
if (blockObj instanceof BlockSnapshot) {
// Check if the unmanaged volume has SNAPSHOT_CONSISTENCY_GROUP_NAME property populated. If yes,
// use that for replicationGroupInstance
String snapsetName = PropertySetterUtil.extractValueFromStringSet(SupportedVolumeInformation.SNAPSHOT_CONSISTENCY_GROUP_NAME.toString(), unManagedVolume.getVolumeInformation());
if (snapsetName != null && !snapsetName.isEmpty()) {
blockObj.setReplicationGroupInstance(snapsetName);
}
}
updateVolumeInUnManagedConsistencyGroup(umcg, unManagedVolume, blockObj);
umcgsToUpdate.add(umcg);
return null;
}
// If the UMV is last volume, mark the UnManagedConsistencyGroup inactive to true.
if (isLastUmvToIngest) {
umcg.setInactive(true);
umcgsToUpdate.add(umcg);
}
if (null == umcg || null == umcg.getLabel()) {
_logger.warn("UnManaged volume {} CG doesn't have label. Hence exiting", unManagedVolume.getNativeGuid());
return null;
}
String cgName = umcg.getLabel();
StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, unManagedVolume.getStorageSystemUri());
_logger.info("UnManagedVolume {} is added to consistency group {}", unManagedVolume.getLabel(), cgName);
URI projectUri = context.getProject().getId();
URI tenantUri = context.getTenant().getId();
URI varrayUri = context.getVarray(unManagedVolume).getId();
VirtualPool vpool = context.getVpool(unManagedVolume);
if (!vpool.getMultivolumeConsistency()) {
_logger.warn("The requested Virtual Pool {} does not have " + "the Multi-Volume Consistency flag set, and this volume " + "is part of a consistency group.", vpool.getLabel());
throw IngestionException.exceptions.unmanagedVolumeVpoolConsistencyGroupMismatch(vpool.getLabel(), unManagedVolume.getLabel());
} else {
List<BlockConsistencyGroup> groups = CustomQueryUtility.queryActiveResourcesByConstraint(dbClient, BlockConsistencyGroup.class, PrefixConstraint.Factory.getFullMatchConstraint(BlockConsistencyGroup.class, "label", cgName));
BlockConsistencyGroup potentialUnclaimedCg = null;
if (!groups.isEmpty()) {
for (BlockConsistencyGroup cg : groups) {
if (validateCGProjectDetails(cg, storageSystem, projectUri, tenantUri, varrayUri, unManagedVolume.getLabel(), cgName, dbClient)) {
return cg;
}
URI storageControllerUri = cg.getStorageController();
URI virtualArrayUri = cg.getVirtualArray();
if (NullColumnValueGetter.isNullURI(storageControllerUri) && NullColumnValueGetter.isNullURI(virtualArrayUri)) {
potentialUnclaimedCg = cg;
}
}
}
// used it yet in creating a volume
if (null != potentialUnclaimedCg) {
potentialUnclaimedCg.addConsistencyGroupTypes(Types.LOCAL.name());
potentialUnclaimedCg.setStorageController(storageSystem.getId());
potentialUnclaimedCg.setVirtualArray(varrayUri);
return potentialUnclaimedCg;
}
_logger.info(String.format("Did not find an existing CG named %s that is associated already with the requested device %s and Virtual Array %s. ViPR will create a new one.", cgName, storageSystem.getNativeGuid(), varrayUri));
// create a new consistency group
BlockConsistencyGroup cg = new BlockConsistencyGroup();
cg.setId(URIUtil.createId(BlockConsistencyGroup.class));
cg.setLabel(cgName);
if (NullColumnValueGetter.isNotNullValue(umcg.getNativeId())) {
cg.setNativeId(umcg.getNativeId());
}
cg.setProject(new NamedURI(projectUri, context.getProject().getLabel()));
cg.setTenant(context.getProject().getTenantOrg());
cg.addConsistencyGroupTypes(Types.LOCAL.name());
cg.addSystemConsistencyGroup(storageSystem.getId().toString(), cgName);
cg.setStorageController(storageSystem.getId());
cg.setVirtualArray(varrayUri);
cg.setArrayConsistency(false);
return cg;
}
}
Aggregations