Search in sources :

Example 21 with BlockConsistencyGroup

use of com.emc.storageos.db.client.model.BlockConsistencyGroup in project coprhd-controller by CoprHD.

the class BlockConsistencyGroupService method resynchronizeConsistencyGroupSnapshot.

/**
 * Resynchronize the specified consistency group snapshot
 *
 * @prereq Activate consistency group snapshot
 *
 * @param consistencyGroupId
 *            - Consistency group URI
 * @param snapshotId
 *            - Consistency group snapshot URI
 *
 * @brief Resynchronize consistency group snapshot
 * @return TaskResourceRep
 */
@POST
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/protection/snapshots/{sid}/resynchronize")
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.OWN, ACL.ALL })
public TaskResourceRep resynchronizeConsistencyGroupSnapshot(@PathParam("id") final URI consistencyGroupId, @PathParam("sid") final URI snapshotId) {
    // Get the consistency group and snapshot and verify the snapshot
    // is actually associated with the consistency group.
    final BlockConsistencyGroup consistencyGroup = (BlockConsistencyGroup) queryResource(consistencyGroupId);
    final BlockSnapshot snapshot = (BlockSnapshot) queryResource(snapshotId);
    verifySnapshotIsForConsistencyGroup(snapshot, consistencyGroup);
    // check for backend CG
    if (BlockConsistencyGroupUtils.getLocalSystemsInCG(consistencyGroup, _dbClient).isEmpty()) {
        _log.error("{} Group Snapshot operations not supported when there is no backend CG", consistencyGroup.getId());
        throw APIException.badRequests.cannotCreateSnapshotOfCG();
    }
    // Get the storage system for the consistency group.
    StorageSystem storage = _permissionsHelper.getObjectById(snapshot.getStorageController(), StorageSystem.class);
    // resync for OpenStack storage system type is not supported
    if (Type.openstack.name().equalsIgnoreCase(storage.getSystemType())) {
        throw APIException.methodNotAllowed.notSupportedWithReason(String.format("Snapshot resynchronization is not possible on third-party storage systems"));
    }
    // resync for IBM XIV storage system type is not supported
    if (Type.ibmxiv.name().equalsIgnoreCase(storage.getSystemType())) {
        throw APIException.methodNotAllowed.notSupportedWithReason("Snapshot resynchronization is not supported on IBM XIV storage systems");
    }
    // resync for VNX storage system type is not supported
    if (Type.vnxblock.name().equalsIgnoreCase(storage.getSystemType())) {
        throw APIException.methodNotAllowed.notSupportedWithReason("Snapshot resynchronization is not supported on VNX storage systems");
    }
    if (storage.checkIfVmax3()) {
        throw APIException.methodNotAllowed.notSupportedWithReason("Snapshot resynchronization is not supported on VMAX3 storage systems");
    }
    // Get the parent volume.
    final Volume snapshotParentVolume = _permissionsHelper.getObjectById(snapshot.getParent(), Volume.class);
    // Get the block implementation
    BlockServiceApi blockServiceApiImpl = getBlockServiceImpl(consistencyGroup);
    // Validate the snapshot restore.
    blockServiceApiImpl.validateResynchronizeSnapshot(snapshot, snapshotParentVolume);
    // Create the restore operation task for the snapshot.
    final String taskId = UUID.randomUUID().toString();
    final Operation op = _dbClient.createTaskOpStatus(BlockSnapshot.class, snapshot.getId(), taskId, ResourceOperationTypeEnum.RESYNCHRONIZE_CONSISTENCY_GROUP_SNAPSHOT);
    // Resync the snapshot.
    blockServiceApiImpl.resynchronizeSnapshot(snapshot, snapshotParentVolume, taskId);
    auditBlockConsistencyGroup(OperationTypeEnum.RESTORE_CONSISTENCY_GROUP_SNAPSHOT, AuditLogManager.AUDITLOG_SUCCESS, AuditLogManager.AUDITOP_BEGIN, snapshotId.toString(), consistencyGroupId.toString(), snapshot.getStorageController().toString());
    return toTask(snapshot, taskId, op);
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) Operation(com.emc.storageos.db.client.model.Operation) MapBlockConsistencyGroup(com.emc.storageos.api.mapper.functions.MapBlockConsistencyGroup) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 22 with BlockConsistencyGroup

use of com.emc.storageos.db.client.model.BlockConsistencyGroup in project coprhd-controller by CoprHD.

the class BlockConsistencyGroupService method validateSessionPartOfConsistencyGroup.

private void validateSessionPartOfConsistencyGroup(URI cgId, URI sessionId) {
    ArgValidator.checkUri(sessionId);
    ArgValidator.checkUri(cgId);
    BlockSnapshotSession session = _dbClient.queryObject(BlockSnapshotSession.class, sessionId);
    BlockConsistencyGroup cg = _dbClient.queryObject(BlockConsistencyGroup.class, cgId);
    if (session == null) {
        throw APIException.notFound.unableToFindEntityInURL(sessionId);
    }
    if (cg == null) {
        throw APIException.notFound.unableToFindEntityInURL(cgId);
    }
    if (!cg.getId().equals(session.getConsistencyGroup())) {
        throw APIException.badRequests.snapshotSessionIsNotForConsistencyGroup(session.getLabel(), cg.getLabel());
    }
}
Also used : BlockSnapshotSession(com.emc.storageos.db.client.model.BlockSnapshotSession) MapBlockConsistencyGroup(com.emc.storageos.api.mapper.functions.MapBlockConsistencyGroup) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup)

Example 23 with BlockConsistencyGroup

use of com.emc.storageos.db.client.model.BlockConsistencyGroup in project coprhd-controller by CoprHD.

the class BlockConsistencyGroupService method failoverProtection.

/**
 * Request to failover the protection link associated with the copy. The target
 * copy is specified by identifying the virtual array in param.copyId.
 *
 * NOTE: This is an asynchronous operation.
 *
 * If volume is srdf protected, then invoking failover internally triggers
 * SRDF SWAP on volume pairs.
 *
 * @prereq none
 *
 * @param id the URI of a BlockConsistencyGroup
 * @param param Copy to failover to
 *
 * @brief Failover the protection link
 * @return TaskList
 *
 * @throws ControllerException
 */
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/protection/continuous-copies/failover")
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.OWN, ACL.ALL })
public TaskList failoverProtection(@PathParam("id") URI id, CopiesParam param) throws ControllerException {
    TaskResourceRep taskResp = null;
    TaskList taskList = new TaskList();
    // Validate the consistency group URI
    ArgValidator.checkFieldUriType(id, BlockConsistencyGroup.class, "id");
    // Validate the list of copies
    ArgValidator.checkFieldNotEmpty(param.getCopies(), "copies");
    // Query Consistency Group
    final BlockConsistencyGroup consistencyGroup = (BlockConsistencyGroup) queryResource(id);
    // system types.
    if (!consistencyGroup.created()) {
        throw APIException.badRequests.consistencyGroupNotCreated();
    }
    List<Copy> copies = param.getCopies();
    if (copies.size() > 1) {
        throw APIException.badRequests.failoverCopiesParamCanOnlyBeOne();
    }
    Copy copy = copies.get(0);
    ArgValidator.checkFieldUriType(copy.getCopyID(), VirtualArray.class, "copyId");
    ArgValidator.checkFieldNotEmpty(copy.getType(), "type");
    if (TechnologyType.RP.name().equalsIgnoreCase(copy.getType())) {
        taskResp = performProtectionAction(id, copy, ProtectionOp.FAILOVER.getRestOp());
        taskList.getTaskList().add(taskResp);
    } else if (TechnologyType.SRDF.name().equalsIgnoreCase(copy.getType())) {
        taskResp = performSRDFProtectionAction(id, copy, ProtectionOp.FAILOVER.getRestOp());
        taskList.getTaskList().add(taskResp);
    } else {
        throw APIException.badRequests.invalidCopyType(copy.getType());
    }
    return taskList;
}
Also used : Copy(com.emc.storageos.model.block.Copy) TaskList(com.emc.storageos.model.TaskList) TaskResourceRep(com.emc.storageos.model.TaskResourceRep) MapBlockConsistencyGroup(com.emc.storageos.api.mapper.functions.MapBlockConsistencyGroup) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 24 with BlockConsistencyGroup

use of com.emc.storageos.db.client.model.BlockConsistencyGroup in project coprhd-controller by CoprHD.

the class BlockService method queryConsistencyGroup.

/**
 * Gets and verifies the consistency group passed in the request.
 *
 * @param consistencyGroupUri
 *            URI of the Consistency Group
 *
 * @return A reference to the BlockConsistencyGroup.
 */
private BlockConsistencyGroup queryConsistencyGroup(final URI consistencyGroupUri) {
    ArgValidator.checkFieldNotNull(consistencyGroupUri, "consistency_group");
    ArgValidator.checkUri(consistencyGroupUri);
    final BlockConsistencyGroup consistencyGroup = _dbClient.queryObject(BlockConsistencyGroup.class, consistencyGroupUri);
    ArgValidator.checkEntity(consistencyGroup, consistencyGroupUri, isIdEmbeddedInURL(consistencyGroupUri));
    return consistencyGroup;
}
Also used : BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup)

Example 25 with BlockConsistencyGroup

use of com.emc.storageos.db.client.model.BlockConsistencyGroup in project coprhd-controller by CoprHD.

the class ExportGroupService method validateDuplicateRPBlockSnapshotsForExport.

/**
 * Validates the list of BlockObjects for RecoverPoint bookmarks that reference
 * the same consistency group and RP site.
 *
 * @param blockObjURIs the list of BlockObject URIs.
 */
private void validateDuplicateRPBlockSnapshotsForExport(List<URI> blockObjURIs) {
    Map<URI, List<String>> cgToRpSiteMap = new HashMap<URI, List<String>>();
    for (URI blockObjectURI : blockObjURIs) {
        if (URIUtil.isType(blockObjectURI, BlockSnapshot.class)) {
            BlockSnapshot snapshot = _dbClient.queryObject(BlockSnapshot.class, blockObjectURI);
            if (TechnologyType.RP.name().equalsIgnoreCase(snapshot.getTechnologyType()) && !NullColumnValueGetter.isNullURI(snapshot.getConsistencyGroup())) {
                // Check to see if there is an RP bookmark that references
                // the same RP copy and consistency group.
                List<String> rpSites = cgToRpSiteMap.get(snapshot.getConsistencyGroup());
                if (rpSites == null) {
                    // Initialize the list of RP sites
                    rpSites = new ArrayList<String>();
                    cgToRpSiteMap.put(snapshot.getConsistencyGroup(), rpSites);
                }
                if (rpSites.contains(snapshot.getEmInternalSiteName())) {
                    // Request is trying to export 2 RP bookmarks for the same target copy and
                    // consistency group.
                    BlockConsistencyGroup cg = _dbClient.queryObject(BlockConsistencyGroup.class, snapshot.getConsistencyGroup());
                    String rpCopyName = RPHelper.getCgCopyName(_dbClient, cg, snapshot.getVirtualArray(), false);
                    throw APIException.badRequests.duplicateRpBookmarkExport(rpCopyName, cg.getLabel());
                } else {
                    rpSites.add(snapshot.getEmInternalSiteName());
                }
            }
        }
    }
}
Also used : HashMap(java.util.HashMap) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) ITLRestRepList(com.emc.storageos.model.block.export.ITLRestRepList) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) List(java.util.List) BulkList(com.emc.storageos.api.service.impl.response.BulkList) SearchedResRepList(com.emc.storageos.api.service.impl.response.SearchedResRepList) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup)

Aggregations

BlockConsistencyGroup (com.emc.storageos.db.client.model.BlockConsistencyGroup)253 Volume (com.emc.storageos.db.client.model.Volume)134 URI (java.net.URI)134 ArrayList (java.util.ArrayList)102 NamedURI (com.emc.storageos.db.client.model.NamedURI)88 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)71 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)71 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)49 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)46 StringSet (com.emc.storageos.db.client.model.StringSet)45 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)43 ControllerException (com.emc.storageos.volumecontroller.ControllerException)43 BlockObject (com.emc.storageos.db.client.model.BlockObject)37 Project (com.emc.storageos.db.client.model.Project)33 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)31 HashMap (java.util.HashMap)31 VirtualArray (com.emc.storageos.db.client.model.VirtualArray)29 List (java.util.List)29 HashSet (java.util.HashSet)28 Produces (javax.ws.rs.Produces)28