Search in sources :

Example 1 with RPController

use of com.emc.storageos.protectioncontroller.RPController in project coprhd-controller by CoprHD.

the class RPBlockServiceApiImpl method updateVolumesInVolumeGroup.

/**
 * {@inheritDoc}
 */
@Override
public void updateVolumesInVolumeGroup(VolumeGroupVolumeList addVolumes, List<Volume> removeVolumes, URI applicationId, String taskId) {
    VolumeGroup volumeGroup = _dbClient.queryObject(VolumeGroup.class, applicationId);
    ApplicationAddVolumeList addVolumeList = null;
    List<URI> removeVolumesURI = null;
    RPController controller = null;
    URI protSystemUri = null;
    Volume firstVolume = null;
    if (addVolumes != null && addVolumes.getVolumes() != null && !addVolumes.getVolumes().isEmpty()) {
        addVolumeList = addVolumesToApplication(addVolumes, volumeGroup);
        List<URI> vols = addVolumeList.getVolumes();
        if (vols != null && !vols.isEmpty()) {
            firstVolume = _dbClient.queryObject(Volume.class, vols.get(0));
        }
    }
    if (removeVolumes != null && !removeVolumes.isEmpty()) {
        removeVolumesURI = getValidVolumesToRemoveFromCG(removeVolumes);
        if (firstVolume == null) {
            firstVolume = removeVolumes.get(0);
        }
    }
    if ((addVolumeList != null && !addVolumeList.getVolumes().isEmpty()) || (removeVolumesURI != null && !removeVolumesURI.isEmpty())) {
        protSystemUri = firstVolume.getProtectionController();
        ProtectionSystem system = _dbClient.queryObject(ProtectionSystem.class, protSystemUri);
        controller = getController(RPController.class, system.getSystemType());
        controller.updateApplication(protSystemUri, addVolumeList, removeVolumesURI, volumeGroup.getId(), taskId);
    } else {
        // No need to call to controller. update the application task
        Operation op = volumeGroup.getOpStatus().get(taskId);
        op.ready();
        volumeGroup.getOpStatus().updateTaskStatus(taskId, op);
        _dbClient.updateObject(volumeGroup);
    }
}
Also used : ApplicationAddVolumeList(com.emc.storageos.volumecontroller.ApplicationAddVolumeList) RPController(com.emc.storageos.protectioncontroller.RPController) Volume(com.emc.storageos.db.client.model.Volume) VolumeGroup(com.emc.storageos.db.client.model.VolumeGroup) Operation(com.emc.storageos.db.client.model.Operation) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) ProtectionSystem(com.emc.storageos.db.client.model.ProtectionSystem)

Example 2 with RPController

use of com.emc.storageos.protectioncontroller.RPController in project coprhd-controller by CoprHD.

the class RPBlockServiceApiImpl method updateReplicationMode.

/**
 * Update the replication mode for the CG in RecoverPoint.
 *
 * @param volumes the selected volumes who's common CG is being updated.
 * @param newVpool the new virtual pool with the replication mode change specified.
 * @param taskId the task id
 * @throws InternalException
 */
private void updateReplicationMode(List<Volume> volumes, VirtualPool newVpool, String taskId) throws InternalException {
    if (volumes == null || volumes.isEmpty()) {
        throw APIException.badRequests.vpoolChangeNotAllowedInvalidVolumeList();
    }
    // Validate all volumes to ensure they have a valid protection system and
    // consistency group associated to them.
    List<URI> volumeURIs = new ArrayList<URI>();
    Volume firstVol = volumes.get(0);
    // Verify that all volumes belong to the same consistency group.
    URI cgURI = firstVol.getConsistencyGroup();
    for (Volume volume : volumes) {
        // Collect a list of volume URIs to be used for the controller call.
        volumeURIs.add(volume.getId());
        if (NullColumnValueGetter.isNullURI(volume.getProtectionController()) || NullColumnValueGetter.isNullURI(volume.getConsistencyGroup())) {
            // Either the protection system or CG is invalid so we must fail.
            throw APIException.badRequests.vpoolChangeInvalidProtectionSystemOrCg(volume.getId().toString());
        }
        if (!cgURI.equals(volume.getConsistencyGroup())) {
            // Not all volumes belong to the same consistency group.
            throw APIException.badRequests.vpoolChangeNotAllowedCGsMustBeTheSame();
        }
    }
    RPController controller = getController(RPController.class, "rp");
    controller.updateConsistencyGroupPolicy(firstVol.getProtectionController(), firstVol.getConsistencyGroup(), volumeURIs, newVpool.getId(), taskId);
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) RPController(com.emc.storageos.protectioncontroller.RPController) ArrayList(java.util.ArrayList) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI)

Example 3 with RPController

use of com.emc.storageos.protectioncontroller.RPController in project coprhd-controller by CoprHD.

the class RPBlockServiceApiImpl method deleteSnapshot.

/**
 * {@inheritDoc}
 */
@Override
public void deleteSnapshot(BlockSnapshot requestedSnapshot, List<BlockSnapshot> allSnapshots, String taskId, String deleteType) {
    // If the volume is under protection
    if ((TechnologyType.RP.name().equals(requestedSnapshot.getTechnologyType())) && (!VolumeDeleteTypeEnum.VIPR_ONLY.name().equals(deleteType))) {
        Volume volume = _dbClient.queryObject(Volume.class, requestedSnapshot.getParent());
        RPController rpController = getController(RPController.class, ProtectionSystem._RP);
        rpController.deleteSnapshot(volume.getProtectionController(), requestedSnapshot.getId(), taskId);
    } else {
        super.deleteSnapshot(requestedSnapshot, allSnapshots, taskId, deleteType);
    }
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) RPController(com.emc.storageos.protectioncontroller.RPController)

Example 4 with RPController

use of com.emc.storageos.protectioncontroller.RPController in project coprhd-controller by CoprHD.

the class BlockConsistencyGroupService method performProtectionAction.

/**
 * Since all of the protection operations are very similar, this method does all of the work.
 * We keep the actual REST methods separate mostly for the purpose of documentation generators.
 *
 * @param consistencyGroupId the URI of the BlockConsistencyGroup to perform the protection action against.
 * @param targetVarrayId the target virtual array.
 * @param pointInTime any point in time, specified in UTC.
 *            Allowed values: "yyyy-MM-dd_HH:mm:ss" formatted date or datetime in milliseconds.
 * @param op operation to perform (pause, stop, failover, etc)
 * @return task resource rep
 * @throws InternalException
 */
private TaskResourceRep performProtectionAction(URI consistencyGroupId, Copy copy, String op) throws InternalException {
    ArgValidator.checkFieldUriType(consistencyGroupId, BlockConsistencyGroup.class, "id");
    ArgValidator.checkFieldUriType(copy.getCopyID(), VirtualArray.class, "copyId");
    // Get the BlockConsistencyGroup and target VirtualArray associated with the request.
    final BlockConsistencyGroup consistencyGroup = (BlockConsistencyGroup) queryResource(consistencyGroupId);
    final VirtualArray targetVirtualArray = _permissionsHelper.getObjectById(copy.getCopyID(), VirtualArray.class);
    ArgValidator.checkEntity(consistencyGroup, consistencyGroupId, true);
    ArgValidator.checkEntity(targetVirtualArray, copy.getCopyID(), true);
    // The consistency group needs to be associated with RecoverPoint in order to perform the operation.
    if (!consistencyGroup.checkForType(Types.RP)) {
        // Attempt to do protection link management on unprotected CG
        throw APIException.badRequests.consistencyGroupMustBeRPProtected(consistencyGroupId);
    }
    if (op.equalsIgnoreCase(ProtectionOp.SWAP.getRestOp()) && !NullColumnValueGetter.isNullURI(consistencyGroupId)) {
        ExportUtils.validateConsistencyGroupBookmarksExported(_dbClient, consistencyGroupId);
    }
    // Catch any attempts to use an invalid access mode
    if (op.equalsIgnoreCase(ProtectionOp.CHANGE_ACCESS_MODE.getRestOp()) && !Copy.ImageAccessMode.DIRECT_ACCESS.name().equalsIgnoreCase(copy.getAccessMode())) {
        throw APIException.badRequests.unsupportedAccessMode(copy.getAccessMode());
    }
    // Verify that the supplied target Virtual Array is being referenced by at least one target volume in the CG.
    List<Volume> targetVolumes = getTargetVolumes(consistencyGroup, copy.getCopyID());
    if (targetVolumes == null || targetVolumes.isEmpty()) {
        // The supplied target varray is not referenced by any target volumes in the CG.
        throw APIException.badRequests.targetVirtualArrayDoesNotMatch(consistencyGroupId, copy.getCopyID());
    }
    // Get the first target volume
    Volume targetVolume = targetVolumes.get(0);
    String task = UUID.randomUUID().toString();
    Operation status = new Operation();
    status.setResourceType(ProtectionOp.getResourceOperationTypeEnum(op));
    _dbClient.createTaskOpStatus(BlockConsistencyGroup.class, consistencyGroupId, task, status);
    ProtectionSystem system = _dbClient.queryObject(ProtectionSystem.class, targetVolume.getProtectionController());
    String deviceType = system.getSystemType();
    if (!deviceType.equals(DiscoveredDataObject.Type.rp.name())) {
        throw APIException.badRequests.protectionForRpClusters();
    }
    RPController controller = getController(RPController.class, system.getSystemType());
    controller.performProtectionOperation(system.getId(), consistencyGroupId, targetVolume.getId(), copy.getPointInTime(), copy.getAccessMode(), op, task);
    /*
         * auditOp(OperationTypeEnum.PERFORM_PROTECTION_ACTION, true, AuditLogManager.AUDITOP_BEGIN,
         * op, copyID.toString(), id.toString(), system.getId().toString());
         */
    return toTask(consistencyGroup, task, status);
}
Also used : VirtualArray(com.emc.storageos.db.client.model.VirtualArray) Volume(com.emc.storageos.db.client.model.Volume) RPController(com.emc.storageos.protectioncontroller.RPController) Operation(com.emc.storageos.db.client.model.Operation) ProtectionSystem(com.emc.storageos.db.client.model.ProtectionSystem) MapBlockConsistencyGroup(com.emc.storageos.api.mapper.functions.MapBlockConsistencyGroup) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup)

Example 5 with RPController

use of com.emc.storageos.protectioncontroller.RPController in project coprhd-controller by CoprHD.

the class BlockService method performProtectionAction.

/**
 * Since all of the protection operations are very similar, this method does all of the work.
 * We keep the actual REST methods separate mostly for the purpose of documentation generators.
 *
 * @param id
 *            the URN of a ViPR source volume
 * @param copyID
 *            id of the target volume
 * @param pointInTime
 *            any point in time used for failover, specified in UTC.
 *            Allowed values: "yyyy-MM-dd_HH:mm:ss" formatted date or datetime in milliseconds. Can be
 *            null.
 * @param op
 *            operation to perform (pause, stop, failover, etc)
 * @return task resource rep
 * @throws InternalException
 */
private TaskResourceRep performProtectionAction(URI id, Copy copy, String op) throws InternalException {
    ArgValidator.checkFieldUriType(copy.getCopyID(), Volume.class, "copyID");
    // Get the volume associated with the URI
    Volume volume = queryVolumeResource(id);
    Volume copyVolume = queryVolumeResource(copy.getCopyID());
    ArgValidator.checkEntity(volume, id, true);
    ArgValidator.checkEntity(copyVolume, copy.getCopyID(), true);
    if (op.equalsIgnoreCase(ProtectionOp.SWAP.getRestOp()) && !NullColumnValueGetter.isNullURI(volume.getConsistencyGroup())) {
        ExportUtils.validateConsistencyGroupBookmarksExported(_dbClient, volume.getConsistencyGroup());
    }
    // cancel operations)
    if ((op.equalsIgnoreCase(ProtectionOp.CHANGE_ACCESS_MODE.getRestOp()) || op.equalsIgnoreCase(ProtectionOp.FAILOVER.getRestOp()) || op.equalsIgnoreCase(ProtectionOp.FAILOVER_CANCEL.getRestOp())) && !NullColumnValueGetter.isNullURI(volume.getConsistencyGroup()) && !volume.getConsistencyGroup().equals(copyVolume.getConsistencyGroup())) {
        throw APIException.badRequests.invalidConsistencyGroupsForProtectionOperation();
    }
    // Catch any attempts to use an invalid access mode
    if (op.equalsIgnoreCase(ProtectionOp.CHANGE_ACCESS_MODE.getRestOp()) && !Copy.ImageAccessMode.DIRECT_ACCESS.name().equalsIgnoreCase(copy.getAccessMode())) {
        throw APIException.badRequests.unsupportedAccessMode(copy.getAccessMode());
    }
    if (isNullURI(volume.getProtectionController())) {
        throw new ServiceCodeException(ServiceCode.IO_ERROR, "Attempt to do protection link management on unprotected volume: {0}", new Object[] { volume.getWWN() });
    }
    // Make sure that we don't have some pending
    // operation against the volume
    checkForPendingTasks(Arrays.asList(volume.getTenant().getURI()), Arrays.asList(volume));
    String task = UUID.randomUUID().toString();
    Operation status = new Operation();
    status.setResourceType(ProtectionOp.getResourceOperationTypeEnum(op));
    _dbClient.createTaskOpStatus(Volume.class, volume.getId(), task, status);
    _log.info(String.format("Protection %s --- VolumeId id: %s on Protection Appliance: %s", task, id, volume.getProtectionController()));
    ProtectionSystem system = _dbClient.queryObject(ProtectionSystem.class, volume.getProtectionController());
    String deviceType = system.getSystemType();
    if (!deviceType.equals(DiscoveredDataObject.Type.rp.name())) {
        throw APIException.badRequests.protectionForRpClusters();
    }
    RPController controller = getController(RPController.class, system.getSystemType());
    controller.performProtectionOperation(system.getId(), id, copy.getCopyID(), copy.getPointInTime(), copy.getAccessMode(), op, task);
    /*
         * auditOp(OperationTypeEnum.PERFORM_PROTECTION_ACTION, true, AuditLogManager.AUDITOP_BEGIN,
         * op, copyID.toString(), id.toString(), system.getId().toString());
         */
    return toTask(volume, task, status);
}
Also used : MapVolume(com.emc.storageos.api.mapper.functions.MapVolume) Volume(com.emc.storageos.db.client.model.Volume) RPController(com.emc.storageos.protectioncontroller.RPController) ServiceCodeException(com.emc.storageos.svcs.errorhandling.resources.ServiceCodeException) Operation(com.emc.storageos.db.client.model.Operation) ProtectionSystem(com.emc.storageos.db.client.model.ProtectionSystem)

Aggregations

Volume (com.emc.storageos.db.client.model.Volume)7 RPController (com.emc.storageos.protectioncontroller.RPController)7 NamedURI (com.emc.storageos.db.client.model.NamedURI)4 Operation (com.emc.storageos.db.client.model.Operation)4 ProtectionSystem (com.emc.storageos.db.client.model.ProtectionSystem)4 URI (java.net.URI)4 VolumeGroup (com.emc.storageos.db.client.model.VolumeGroup)2 ArrayList (java.util.ArrayList)2 MapBlockConsistencyGroup (com.emc.storageos.api.mapper.functions.MapBlockConsistencyGroup)1 MapVolume (com.emc.storageos.api.mapper.functions.MapVolume)1 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)1 BlockConsistencyGroup (com.emc.storageos.db.client.model.BlockConsistencyGroup)1 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)1 OpStatusMap (com.emc.storageos.db.client.model.OpStatusMap)1 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)1 VirtualArray (com.emc.storageos.db.client.model.VirtualArray)1 ServiceCodeException (com.emc.storageos.svcs.errorhandling.resources.ServiceCodeException)1 ApplicationAddVolumeList (com.emc.storageos.volumecontroller.ApplicationAddVolumeList)1