use of com.emc.storageos.db.client.model.BlockObject in project coprhd-controller by CoprHD.
the class BlockFullCopyUtils method queryFullCopyResource.
/**
* Returns the volume or block snapshot instance for the passed URI.
*
* @param fcResourceURI The URI for the Volume or BlockSnapshot instance.
* @param uriInfo A reference to the URI information.
* @param isSource true if the passed URI is for the full copy source, false otherwise.
* @param dbClient A reference to a database client.
*
* @return A reference to the block object.
*/
public static BlockObject queryFullCopyResource(URI fcResourceURI, UriInfo uriInfo, boolean isSource, DbClient dbClient) {
ArgValidator.checkUri(fcResourceURI);
if (isSource) {
if ((!URIUtil.isType(fcResourceURI, Volume.class)) && (!URIUtil.isType(fcResourceURI, BlockSnapshot.class))) {
throw APIException.badRequests.invalidFullCopySource(fcResourceURI.toString());
}
} else if (!URIUtil.isType(fcResourceURI, Volume.class)) {
throw APIException.badRequests.protectionVolumeNotFullCopy(fcResourceURI);
}
BlockObject blockObj = BlockObject.fetch(dbClient, fcResourceURI);
ArgValidator.checkEntity(blockObj, fcResourceURI, BlockServiceUtils.isIdEmbeddedInURL(fcResourceURI, uriInfo), true);
return blockObj;
}
use of com.emc.storageos.db.client.model.BlockObject in project coprhd-controller by CoprHD.
the class BlockFullCopyUtils method verifySourceAndFullCopy.
/**
* Verifies the passed source and full copy URIs for a requested full
* copy operation.
*
* @param sourceURI The URI of the source volume or snapshot.
* @param fullCopyURI The URI of a full copy of the source.
* @param uriInfo A reference to the URI information.
* @param dbClient A reference to a database client.
*
* @return The map containing references to the source and full copy.
*/
public static Map<URI, BlockObject> verifySourceAndFullCopy(URI sourceURI, URI fullCopyURI, UriInfo uriInfo, DbClient dbClient) {
// Verify passed URIs.
BlockObject fcSourceObj = queryFullCopyResource(sourceURI, uriInfo, true, dbClient);
Volume fullCopyVolume = (Volume) queryFullCopyResource(fullCopyURI, uriInfo, false, dbClient);
// Verify the full copy volume is actually a full copy.
verifyVolumeIsFullCopy(fullCopyVolume);
// Verify the copy is for the source.
verifyCopyIsForSource(fullCopyVolume, sourceURI);
// Add the volumes to the volume map.
Map<URI, BlockObject> resourceMap = new HashMap<URI, BlockObject>();
resourceMap.put(sourceURI, fcSourceObj);
resourceMap.put(fullCopyURI, fullCopyVolume);
return resourceMap;
}
use of com.emc.storageos.db.client.model.BlockObject in project coprhd-controller by CoprHD.
the class DefaultBlockFullCopyApiImpl method create.
/**
* {@inheritDoc}
*/
@Override
public TaskList create(List<BlockObject> fcSourceObjList, VirtualArray varray, String name, boolean createInactive, int count, String taskId) {
// Get the placement recommendations for the full copies and
// prepare the ViPR volumes to represent the full copies.
// TBD We are getting recommendations one at a time instead
// of for all full copies at the same time as was done
// previously. However, now we are allowing for creating
// full copies for multiple volume form a CG. These volumes
// could have different vpools and sizes. Therefore, I don't
// see how we can get them at the same time for all volumes
// as the capabilities could be different. I guess the
// possible result is that if the volumes are the same, they
// could be placed in the same storage pool and if the pool
// is approaching capacity, there may not actually be enough
// space in the recommended pool.
int sourceCounter = 0;
List<Volume> volumesList = new ArrayList<Volume>();
BlockObject aFCSource = null;
Map<URI, VirtualArray> vArrayCache = new HashMap<URI, VirtualArray>();
List<BlockObject> sortedSourceObjectList = sortFullCopySourceList(fcSourceObjList);
try {
for (BlockObject fcSourceObj : sortedSourceObjectList) {
// Make sure when there are multiple source objects,
// each full copy has a unique name.
aFCSource = fcSourceObj;
// volumes in VolumeGroup can be from different vArrays
varray = getVarrayFromCache(vArrayCache, fcSourceObj.getVirtualArray());
String copyName = null;
boolean inApplication = false;
if (aFCSource instanceof Volume && ((Volume) aFCSource).getApplication(_dbClient) != null) {
inApplication = true;
}
if (NullColumnValueGetter.isNotNullValue(fcSourceObj.getReplicationGroupInstance()) && inApplication) {
copyName = name + "-" + fcSourceObj.getReplicationGroupInstance() + (sortedSourceObjectList.size() > 1 ? "-" + ++sourceCounter : "");
} else {
copyName = name + (sortedSourceObjectList.size() > 1 ? "-" + ++sourceCounter : "");
}
VirtualPool vpool = BlockFullCopyUtils.queryFullCopySourceVPool(fcSourceObj, _dbClient);
VirtualPoolCapabilityValuesWrapper capabilities = getCapabilitiesForFullCopyCreate(fcSourceObj, vpool, count);
List<VolumeRecommendation> placementRecommendations = getPlacementRecommendations(fcSourceObj, capabilities, varray, vpool.getId());
volumesList.addAll(prepareClonesForEachRecommendation(copyName, name, fcSourceObj, capabilities, createInactive, placementRecommendations));
}
} catch (Exception ex) {
handlePlacementFailure(volumesList);
throw ex;
}
// get volume descriptors
List<VolumeDescriptor> volumeDescriptors = prepareVolumeDescriptorsForFullCopy(volumesList, createInactive);
// get all tasks
TaskList tasks = getTasksForCreateFullCopy(aFCSource, volumesList, taskId);
try {
BlockOrchestrationController controller = getController(BlockOrchestrationController.class, BlockOrchestrationController.BLOCK_ORCHESTRATION_DEVICE);
controller.createFullCopy(volumeDescriptors, taskId);
} catch (InternalException ie) {
handleFailedRequest(taskId, tasks, volumesList, ie, true);
}
return tasks;
}
use of com.emc.storageos.db.client.model.BlockObject in project coprhd-controller by CoprHD.
the class RPBlockFullCopyApiImpl method validateFullCopyCreateRequest.
/**
* {@inheritDoc}
*/
@Override
public void validateFullCopyCreateRequest(List<BlockObject> fcSourceObjList, int count) {
BlockFullCopyApi fullCopyApiImpl = null;
List<BlockObject> vplexList = new ArrayList<BlockObject>();
List<BlockObject> blockList = new ArrayList<BlockObject>();
if (fcSourceObjList != null && !fcSourceObjList.isEmpty()) {
// Sort the volume list for vplex and non-vplex volumes
for (BlockObject src : fcSourceObjList) {
URI storageUri = src.getStorageController();
StorageSystem storage = _dbClient.queryObject(StorageSystem.class, storageUri);
if (storage.getSystemType().equalsIgnoreCase(DiscoveredDataObject.Type.vplex.toString())) {
vplexList.add(src);
} else {
blockList.add(src);
}
}
} else {
throw APIException.methodNotAllowed.notSupportedForRP();
}
if (!vplexList.isEmpty()) {
fullCopyApiImpl = _fullCopyMgr.getVplexFullCopyImpl();
fullCopyApiImpl.validateFullCopyCreateRequest(vplexList, count);
}
if (!blockList.isEmpty()) {
BlockObject block = blockList.get(0);
StorageSystem system = _dbClient.queryObject(StorageSystem.class, block.getStorageController());
fullCopyApiImpl = _fullCopyMgr.getPlatformSpecificFullCopyImplForSystem(system);
fullCopyApiImpl.validateFullCopyCreateRequest(blockList, count);
}
}
use of com.emc.storageos.db.client.model.BlockObject in project coprhd-controller by CoprHD.
the class VPlexBlockFullCopyApiImpl method validateFullCopyCreateRequest.
/**
* {@inheritDoc}
*/
@Override
public void validateFullCopyCreateRequest(List<BlockObject> fcSourceObjList, int count) {
if (!fcSourceObjList.isEmpty()) {
BlockObject fcsourceObj = fcSourceObjList.get(0);
URI fcSourceObjURI = fcsourceObj.getId();
if (URIUtil.isType(fcSourceObjURI, BlockSnapshot.class) && !BlockServiceUtils.isSnapshotFullCopySupported(fcSourceObjURI, _dbClient)) {
// Snapshot full copy is supported only for OpenStack, VNXBlock, VMAX and IBMXIV
throw APIException.badRequests.cantCreateFullCopyForVPlexSnapshot();
}
// Group clone for IBM XIV storage system type is not supported
if (null != fcsourceObj.getConsistencyGroup() && VPlexUtil.isIBMXIVBackend(fcsourceObj, _dbClient)) {
throw APIException.methodNotAllowed.notSupportedWithReason("Consistency Group Full Copy is not supported on backend IBM XIV storage systems");
}
// Call super first.
super.validateFullCopyCreateRequest(fcSourceObjList, count);
// all the volumes in vplex cg should be having association with back end cg/Volume Group.
if (VPlexUtil.isBackendVolumesNotHavingBackendCG(fcSourceObjList, _dbClient)) {
throw APIException.badRequests.fullcopyNotAllowedWhenBackendVolumeDoestHavingCG();
}
for (BlockObject fcSourceObj : fcSourceObjList) {
if (fcSourceObj instanceof Volume) {
Volume fcSourceVolume = (Volume) fcSourceObj;
// we don't support creation of a full copy.
if (VPlexUtil.isVolumeBuiltOnBlockSnapshot(_dbClient, fcSourceVolume)) {
throw APIException.badRequests.fullCopyNotAllowedVolumeIsExposedSnapshot(fcSourceVolume.getId().toString());
}
StorageSystem system = _dbClient.queryObject(StorageSystem.class, fcSourceObj.getStorageController());
if (DiscoveredDataObject.Type.vplex.name().equals(system.getSystemType())) {
// If the volume is a VPLEX volume, then we need to be sure that
// storage pool of the source backend volume of the VPLEX volume,
// which is volume used to create the native full copy, supports
// full copy.
Volume srcBackendVolume = VPlexUtil.getVPLEXBackendVolume(fcSourceVolume, true, _dbClient, true);
StoragePool storagePool = _dbClient.queryObject(StoragePool.class, srcBackendVolume.getPool());
verifyFullCopySupportedForStoragePool(storagePool);
// volume will fail. As such, we prevent it.
if ((BlockFullCopyUtils.isVolumeFullCopy(fcSourceVolume, _dbClient)) && (!BlockFullCopyUtils.isFullCopyDetached(fcSourceVolume, _dbClient))) {
URI backendSystemURI = srcBackendVolume.getStorageController();
StorageSystem backendSystem = _dbClient.queryObject(StorageSystem.class, backendSystemURI);
if (DiscoveredDataObject.Type.vnxblock.name().equals(backendSystem.getSystemType())) {
throw APIException.badRequests.cantCreateFullCopyOfVPlexFullCopyUsingVNX();
}
}
}
}
}
}
}
Aggregations