Search in sources :

Example 56 with VPlexApiException

use of com.emc.storageos.vplex.api.VPlexApiException in project coprhd-controller by CoprHD.

the class VPlexConsistencyGroupManager method createVplexCG.

/**
 * Create a Vplex CG within a step. This routine does not complete the step unless there is an error (and it returns false).
 * @param vplexSystem -- StorageSystem of the VPLEX
 * @param cg -- BlockConsistencyGroup object
 * @param protoVolume -- A prototypical Vplex volume
 * @param stepId -- String stepId, completed only if error
 * @return true if no error, false if error
 */
private boolean createVplexCG(StorageSystem vplexSystem, BlockConsistencyGroup cg, Volume protoVolume, String stepId) {
    try {
        VPlexApiClient client = getVPlexAPIClient(vplexApiFactory, vplexSystem, dbClient);
        log.info("Got VPLEX API client.");
        // Check to see if it was created since we defined the workflow.
        if (cg.created(vplexSystem.getId())) {
            StringSet cgNames = cg.getSystemConsistencyGroups().get(vplexSystem.getId().toString());
            log.info("Consistency group(s) already created: " + cgNames.toString());
            return true;
        }
        // We need to know on what cluster to create the consistency group.
        // The cluster would be determined by the virtual array specified in
        // a volume creation request, which is the virtual array of the
        // passed virtual volumes. Get the virtual array for one of the
        // vplex volumes.
        // Lets determine the VPlex consistency group that need to be created for this volume.
        ClusterConsistencyGroupWrapper clusterConsistencyGroup = getClusterConsistencyGroup(protoVolume, cg);
        String cgName = clusterConsistencyGroup.getCgName();
        String clusterName = clusterConsistencyGroup.getClusterName();
        boolean isDistributed = clusterConsistencyGroup.isDistributed();
        URI vaURI = protoVolume.getVirtualArray();
        log.info("Got virtual array for VPLEX volume.");
        // Now we can create the consistency group.
        client.createConsistencyGroup(cgName, clusterName, isDistributed);
        log.info("Created VPLEX consistency group.");
        // Now update the CG in the DB.
        cg.setVirtualArray(vaURI);
        cg.addSystemConsistencyGroup(vplexSystem.getId().toString(), BlockConsistencyGroupUtils.buildClusterCgName(clusterName, cgName));
        cg.addConsistencyGroupTypes(Types.VPLEX.name());
        dbClient.updateObject(cg);
        log.info("Updated consistency group in DB.");
    } catch (VPlexApiException vex) {
        log.error("Exception creating consistency group: " + vex.getMessage(), vex);
        WorkflowStepCompleter.stepFailed(stepId, vex);
        return false;
    } catch (Exception ex) {
        log.error("Exception creating consistency group: " + ex.getMessage(), ex);
        String opName = ResourceOperationTypeEnum.CREATE_CONSISTENCY_GROUP.getName();
        ServiceError serviceError = VPlexApiException.errors.createConsistencyGroupFailed(opName, ex);
        WorkflowStepCompleter.stepFailed(stepId, serviceError);
        return false;
    }
    return true;
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) ClusterConsistencyGroupWrapper(com.emc.storageos.volumecontroller.impl.utils.ClusterConsistencyGroupWrapper) VPlexApiException(com.emc.storageos.vplex.api.VPlexApiException) VPlexApiClient(com.emc.storageos.vplex.api.VPlexApiClient) StringSet(com.emc.storageos.db.client.model.StringSet) URI(java.net.URI) WorkflowException(com.emc.storageos.workflow.WorkflowException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) VPlexApiException(com.emc.storageos.vplex.api.VPlexApiException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) InternalServerErrorException(com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException)

Example 57 with VPlexApiException

use of com.emc.storageos.vplex.api.VPlexApiException in project coprhd-controller by CoprHD.

the class VPlexConsistencyGroupManager method setCGProperties.

/**
 * Called by the workflow to set the properties for an existing VPLEX
 * consistency group with no volumes.
 *
 * @param vplexURI The URI of the VPLEX storage system.
 * @param cgURI The URI of the Bourne consistency group.
 * @param vplexVolumeURIs The URIs of the VPLEX volumes to be added to the
 *            consistency group.
 * @param stepId The workflow step id.
 *
 * @throws WorkflowException When an error occurs updating the workflow step
 *             state.
 */
public void setCGProperties(URI vplexURI, URI cgURI, List<URI> vplexVolumeURIs, String stepId) throws WorkflowException {
    try {
        // Update workflow step.
        WorkflowStepCompleter.stepExecuting(stepId);
        log.info("Updated step state for consistency group properties to execute.");
        // Lock the CG for the step duration.
        List<String> lockKeys = new ArrayList<String>();
        lockKeys.add(ControllerLockingUtil.getConsistencyGroupStorageKey(dbClient, cgURI, vplexURI));
        workflowService.acquireWorkflowStepLocks(stepId, lockKeys, LockTimeoutValue.get(LockType.RP_VPLEX_CG));
        // Get the API client.
        StorageSystem vplexSystem = getDataObject(StorageSystem.class, vplexURI, dbClient);
        VPlexApiClient client = getVPlexAPIClient(vplexApiFactory, vplexSystem, dbClient);
        log.info("Got VPLEX API client.");
        // Get the consistency group
        BlockConsistencyGroup cg = getDataObject(BlockConsistencyGroup.class, cgURI, dbClient);
        // We need to know on what cluster to find the consistency group.
        // The cluster would be determined by the virtual array specified in
        // a volume creation request, which is the virtual array of the
        // passed virtual volumes. Get the virtual array for one of the
        // vplex volumes.
        Volume firstVPlexVolume = getDataObject(Volume.class, vplexVolumeURIs.get(0), dbClient);
        ClusterConsistencyGroupWrapper clusterConsistencyGroup = getClusterConsistencyGroup(firstVPlexVolume, cg);
        String cgName = clusterConsistencyGroup.getCgName();
        String clusterName = clusterConsistencyGroup.getClusterName();
        boolean isDistributed = clusterConsistencyGroup.isDistributed();
        // Now we can update the consistency group properties.
        client.updateConsistencyGroupProperties(cgName, clusterName, isDistributed);
        log.info("Updated VPLEX consistency group properties.");
        // Update workflow step state to success.
        WorkflowStepCompleter.stepSucceded(stepId);
        log.info("Updated workflow step for consistency group properties to success.");
    } catch (VPlexApiException vae) {
        log.error("Exception updating consistency group properties: " + vae.getMessage(), vae);
        WorkflowStepCompleter.stepFailed(stepId, vae);
    } catch (Exception ex) {
        log.error("Exception updating consistency group properties: " + ex.getMessage(), ex);
        ServiceError serviceError = VPlexApiException.errors.jobFailed(ex);
        WorkflowStepCompleter.stepFailed(stepId, serviceError);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) ClusterConsistencyGroupWrapper(com.emc.storageos.volumecontroller.impl.utils.ClusterConsistencyGroupWrapper) Volume(com.emc.storageos.db.client.model.Volume) VPlexApiException(com.emc.storageos.vplex.api.VPlexApiException) VPlexApiClient(com.emc.storageos.vplex.api.VPlexApiClient) ArrayList(java.util.ArrayList) WorkflowException(com.emc.storageos.workflow.WorkflowException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) VPlexApiException(com.emc.storageos.vplex.api.VPlexApiException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) InternalServerErrorException(com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup)

Example 58 with VPlexApiException

use of com.emc.storageos.vplex.api.VPlexApiException in project coprhd-controller by CoprHD.

the class VPlexConsistencyGroupManager method rollbackCreateCG.

/**
 * Method call when we need to rollback the deletion of a consistency group.
 *
 * @param vplexSystemURI The URI of the VPlex system.
 * @param cgURI The consistency group URI
 * @param deleteStepId The step that deleted the CG.
 * @param stepId The step id.
 */
public void rollbackCreateCG(URI vplexSystemURI, URI cgURI, String createStepId, String stepId) {
    try {
        // Update step state to executing.
        WorkflowStepCompleter.stepExecuting(stepId);
        log.info("Updated workflow step to executing");
        // Get the rollback data.
        Object rbDataObj = workflowService.loadStepData(createStepId);
        if (rbDataObj == null) {
            // Update step state to done.
            log.info("CG was not created, nothing to do.");
            cleanUpVplexCG(vplexSystemURI, cgURI, null, false);
            WorkflowStepCompleter.stepSucceded(stepId);
            return;
        }
        StorageSystem vplexSystem = getDataObject(StorageSystem.class, vplexSystemURI, dbClient);
        // Get the CG.
        BlockConsistencyGroup cg = getDataObject(BlockConsistencyGroup.class, cgURI, dbClient);
        // Get the VPlex API client.
        VPlexApiClient client = getVPlexAPIClient(vplexApiFactory, vplexSystem, dbClient);
        log.info("Got VPlex API client for VPlex system {}", vplexSystemURI);
        // at this point.
        if (BlockConsistencyGroupUtils.referencesVPlexCGs(cg, dbClient)) {
            for (StorageSystem storageSystem : BlockConsistencyGroupUtils.getVPlexStorageSystems(cg, dbClient)) {
                URI vplexSystemUri = storageSystem.getId();
                // Iterate over the VPlex consistency groups that need to be
                // deleted.
                Map<String, String> vplexCgsToDelete = new HashMap<String, String>();
                for (String clusterCgName : cg.getSystemConsistencyGroups().get(vplexSystemUri.toString())) {
                    String cgName = BlockConsistencyGroupUtils.fetchCgName(clusterCgName);
                    String clusterName = BlockConsistencyGroupUtils.fetchClusterName(clusterCgName);
                    if (!vplexCgsToDelete.containsKey(cgName)) {
                        vplexCgsToDelete.put(cgName, clusterName);
                    }
                }
                for (Map.Entry<String, String> vplexCg : vplexCgsToDelete.entrySet()) {
                    String cgName = vplexCg.getKey();
                    // Make a call to the VPlex API client to delete the consistency group.
                    client.deleteConsistencyGroup(cgName);
                    log.info(String.format("Deleted consistency group %s", cgName));
                    cleanUpVplexCG(vplexSystemURI, cgURI, cgName, false);
                }
            }
        }
        // Update step state to done.
        WorkflowStepCompleter.stepSucceded(stepId);
    } catch (VPlexApiException vae) {
        log.error("Exception rolling back VPLEX consistency group creation: " + vae.getMessage(), vae);
        WorkflowStepCompleter.stepFailed(stepId, vae);
    } catch (Exception ex) {
        log.error("Exception rolling back VPLEX consistency group creation: " + ex.getMessage(), ex);
        String opName = ResourceOperationTypeEnum.DELETE_CONSISTENCY_GROUP.getName();
        ServiceError serviceError = VPlexApiException.errors.deleteCGFailed(opName, ex);
        WorkflowStepCompleter.stepFailed(stepId, serviceError);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) HashMap(java.util.HashMap) URI(java.net.URI) WorkflowException(com.emc.storageos.workflow.WorkflowException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) VPlexApiException(com.emc.storageos.vplex.api.VPlexApiException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) InternalServerErrorException(com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup) VPlexApiException(com.emc.storageos.vplex.api.VPlexApiException) VPlexApiClient(com.emc.storageos.vplex.api.VPlexApiClient) VPlexControllerUtils.getDataObject(com.emc.storageos.vplexcontroller.VPlexControllerUtils.getDataObject) HashMap(java.util.HashMap) Map(java.util.Map) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 59 with VPlexApiException

use of com.emc.storageos.vplex.api.VPlexApiException in project coprhd-controller by CoprHD.

the class VPlexConsistencyGroupManager method addVolumesToCG.

/**
 * The method called by the workflow to add VPLEX volumes to a VPLEX
 * consistency group.
 *
 * @param vplexURI The URI of the VPLEX storage system.
 * @param cgURI The URI of the consistency group.
 * @param vplexVolumeURIs The URIs of the volumes to be added to the
 *            consistency group.
 * @param stepId The workflow step id.
 *
 * @throws WorkflowException When an error occurs updating the workflow step
 *             state.
 */
public void addVolumesToCG(URI vplexURI, URI cgURI, List<URI> vplexVolumeURIs, String stepId) throws WorkflowException {
    try {
        // Update workflow step.
        WorkflowStepCompleter.stepExecuting(stepId);
        log.info("Updated workflow step state to execute for add volumes to consistency group.");
        // Get the API client.
        StorageSystem vplexSystem = getDataObject(StorageSystem.class, vplexURI, dbClient);
        VPlexApiClient client = getVPlexAPIClient(vplexApiFactory, vplexSystem, dbClient);
        log.info("Got VPLEX API client.");
        Volume firstVPlexVolume = getDataObject(Volume.class, vplexVolumeURIs.get(0), dbClient);
        String cgName = getVplexCgName(firstVPlexVolume, cgURI);
        // Get the names of the volumes to be added.
        List<Volume> vplexVolumes = new ArrayList<Volume>();
        List<String> vplexVolumeNames = new ArrayList<String>();
        for (URI vplexVolumeURI : vplexVolumeURIs) {
            Volume vplexVolume = getDataObject(Volume.class, vplexVolumeURI, dbClient);
            vplexVolumes.add(vplexVolume);
            vplexVolumeNames.add(vplexVolume.getDeviceLabel());
            log.info("VPLEX volume:" + vplexVolume.getDeviceLabel());
        }
        log.info("Got VPLEX volume names.");
        long startTime = System.currentTimeMillis();
        // Add the volumes to the CG.
        client.addVolumesToConsistencyGroup(cgName, vplexVolumeNames);
        long elapsed = System.currentTimeMillis() - startTime;
        log.info(String.format("TIMER: Adding %s virtual volume(s) %s to the consistency group %s took %f seconds", vplexVolumeNames.size(), vplexVolumeNames, cgName, (double) elapsed / (double) 1000));
        // adding volumes to a CG after volume creation.
        for (Volume vplexVolume : vplexVolumes) {
            vplexVolume.setConsistencyGroup(cgURI);
            dbClient.updateObject(vplexVolume);
        }
        // Update workflow step state to success.
        WorkflowStepCompleter.stepSucceded(stepId);
        log.info("Updated workflow step state to success for add volumes to consistency group.");
    } catch (VPlexApiException vae) {
        log.error("Exception adding volumes to consistency group: " + vae.getMessage(), vae);
        WorkflowStepCompleter.stepFailed(stepId, vae);
    } catch (Exception ex) {
        log.error("Exception adding volumes to consistency group: " + ex.getMessage(), ex);
        ServiceError svcError = VPlexApiException.errors.jobFailed(ex);
        WorkflowStepCompleter.stepFailed(stepId, svcError);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) Volume(com.emc.storageos.db.client.model.Volume) VPlexApiException(com.emc.storageos.vplex.api.VPlexApiException) VPlexApiClient(com.emc.storageos.vplex.api.VPlexApiClient) ArrayList(java.util.ArrayList) URI(java.net.URI) WorkflowException(com.emc.storageos.workflow.WorkflowException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) VPlexApiException(com.emc.storageos.vplex.api.VPlexApiException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) InternalServerErrorException(com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

VPlexApiException (com.emc.storageos.vplex.api.VPlexApiException)59 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)53 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)43 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)43 ControllerException (com.emc.storageos.volumecontroller.ControllerException)43 WorkflowException (com.emc.storageos.workflow.WorkflowException)43 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)41 InternalServerErrorException (com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException)41 VPlexApiClient (com.emc.storageos.vplex.api.VPlexApiClient)40 URI (java.net.URI)39 ArrayList (java.util.ArrayList)39 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)34 IOException (java.io.IOException)34 URISyntaxException (java.net.URISyntaxException)34 ExportMask (com.emc.storageos.db.client.model.ExportMask)26 Volume (com.emc.storageos.db.client.model.Volume)25 NamedURI (com.emc.storageos.db.client.model.NamedURI)21 Initiator (com.emc.storageos.db.client.model.Initiator)20 BlockStorageDevice (com.emc.storageos.volumecontroller.BlockStorageDevice)14 VPlexVirtualVolumeInfo (com.emc.storageos.vplex.api.VPlexVirtualVolumeInfo)12