Search in sources :

Example 61 with BlockObject

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;
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) BlockObject(com.emc.storageos.db.client.model.BlockObject)

Example 62 with BlockObject

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;
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) HashMap(java.util.HashMap) URI(java.net.URI) BlockObject(com.emc.storageos.db.client.model.BlockObject)

Example 63 with BlockObject

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;
}
Also used : VirtualPoolCapabilityValuesWrapper(com.emc.storageos.volumecontroller.impl.utils.VirtualPoolCapabilityValuesWrapper) VirtualArray(com.emc.storageos.db.client.model.VirtualArray) VolumeDescriptor(com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor) BlockOrchestrationController(com.emc.storageos.blockorchestrationcontroller.BlockOrchestrationController) HashMap(java.util.HashMap) TaskList(com.emc.storageos.model.TaskList) ArrayList(java.util.ArrayList) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) URI(java.net.URI) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) Volume(com.emc.storageos.db.client.model.Volume) VolumeRecommendation(com.emc.storageos.api.service.impl.placement.VolumeRecommendation) BlockObject(com.emc.storageos.db.client.model.BlockObject)

Example 64 with BlockObject

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);
    }
}
Also used : ArrayList(java.util.ArrayList) URI(java.net.URI) BlockObject(com.emc.storageos.db.client.model.BlockObject) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 65 with BlockObject

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();
                        }
                    }
                }
            }
        }
    }
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) Volume(com.emc.storageos.db.client.model.Volume) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) URI(java.net.URI) BlockObject(com.emc.storageos.db.client.model.BlockObject) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

BlockObject (com.emc.storageos.db.client.model.BlockObject)341 URI (java.net.URI)222 ArrayList (java.util.ArrayList)152 Volume (com.emc.storageos.db.client.model.Volume)141 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)109 NamedURI (com.emc.storageos.db.client.model.NamedURI)82 HashMap (java.util.HashMap)82 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)69 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)65 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)60 ExportMask (com.emc.storageos.db.client.model.ExportMask)56 HashSet (java.util.HashSet)56 ExportGroup (com.emc.storageos.db.client.model.ExportGroup)48 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)45 CIMObjectPath (javax.cim.CIMObjectPath)44 Initiator (com.emc.storageos.db.client.model.Initiator)43 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)43 List (java.util.List)40 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)38 StringSet (com.emc.storageos.db.client.model.StringSet)36