Search in sources :

Example 46 with ServiceCoded

use of com.emc.storageos.svcs.errorhandling.model.ServiceCoded in project coprhd-controller by CoprHD.

the class VPlexDeviceController method validateVPlexVolume.

/**
 * Validates that the backend volumes of the passed VPLEX volumes in the
 * ViPR database are the actual backend volumes used by the VPLEX volume
 * on the VPLEX system.
 *
 * @param vplexSystemURI
 *            The URI of the VPLEX storage system.
 * @param vplexVolumeURI
 *            The URI of the VPLEX volume to validate.
 * @param stepId
 *            The workflow step id.
 */
public void validateVPlexVolume(URI vplexSystemURI, URI vplexVolumeURI, String stepId) {
    Volume vplexVolume = null;
    try {
        // Skip this if validation disabled
        ValidatorConfig validatorConfig = new ValidatorConfig();
        validatorConfig.setCoordinator(coordinator);
        if (!validatorConfig.isValidationEnabled()) {
            WorkflowStepCompleter.stepSucceeded(stepId, "Validations not enabled");
            return;
        }
        // Update step state to executing.
        WorkflowStepCompleter.stepExecuting(stepId);
        // Get the VPLEX API client for the VPLEX system.
        VPlexApiClient client = getVPlexAPIClient(_vplexApiFactory, vplexSystemURI, _dbClient);
        // Get the VPLEX volume
        vplexVolume = getDataObject(Volume.class, vplexVolumeURI, _dbClient);
        // Get a VolumeInfo for each backend volume and any mirrors, mapped by VPLEX cluster name.
        Set<String> volumeIds = new HashSet<>();
        Map<String, List<VolumeInfo>> volumeInfoMap = new HashMap<>();
        StringSet associatedVolumeIds = vplexVolume.getAssociatedVolumes();
        if ((associatedVolumeIds == null) || (associatedVolumeIds.isEmpty())) {
            // Ingested volume w/o backend volume ingestion. We can't verify the backend volumes.
            _log.info("VPLEX volume {}:{} has no backend volumes to validate", vplexVolumeURI, vplexVolume.getLabel());
            WorkflowStepCompleter.stepSucceded(stepId);
            return;
        } else {
            volumeIds.addAll(associatedVolumeIds);
        }
        // Now mirrors.
        StringSet mirrorIds = vplexVolume.getMirrors();
        if ((mirrorIds != null) && (mirrorIds.isEmpty() == false)) {
            for (String mirrorId : mirrorIds) {
                VplexMirror mirror = getDataObject(VplexMirror.class, URI.create(mirrorId), _dbClient);
                StringSet associatedVolumeIdsForMirror = mirror.getAssociatedVolumes();
                if ((associatedVolumeIdsForMirror == null) || (associatedVolumeIdsForMirror.isEmpty())) {
                    _log.info("VPLEX mirror {}:{} has no associated volumes", mirrorId, mirror.getLabel());
                    throw DeviceControllerExceptions.vplex.vplexMirrorDoesNotHaveAssociatedVolumes(vplexVolume.getLabel(), mirror.getLabel());
                } else {
                    volumeIds.addAll(associatedVolumeIdsForMirror);
                }
            }
        }
        // Get the WWNs for these volumes mapped by VPLEX cluster name.
        for (String volumesId : volumeIds) {
            URI volumeURI = URI.create(volumesId);
            Volume volume = getDataObject(Volume.class, volumeURI, _dbClient);
            String clusterName = VPlexUtil.getVplexClusterName(volume.getVirtualArray(), vplexSystemURI, client, _dbClient);
            StorageSystem storageSystem = getDataObject(StorageSystem.class, volume.getStorageController(), _dbClient);
            List<String> itls = VPlexControllerUtils.getVolumeITLs(volume);
            VolumeInfo volumeInfo = new VolumeInfo(storageSystem.getNativeGuid(), storageSystem.getSystemType(), volume.getWWN().toUpperCase().replaceAll(":", ""), volume.getNativeId(), volume.getThinlyProvisioned().booleanValue(), itls);
            _log.info(String.format("Validating backend volume %s on cluster %s", volumeURI, clusterName));
            if (volumeInfoMap.containsKey(clusterName)) {
                List<VolumeInfo> clusterVolumeInfos = volumeInfoMap.get(clusterName);
                clusterVolumeInfos.add(volumeInfo);
            } else {
                List<VolumeInfo> clusterVolumeInfos = new ArrayList<>();
                clusterVolumeInfos.add(volumeInfo);
                volumeInfoMap.put(clusterName, clusterVolumeInfos);
            }
        }
        // Validate the ViPR backend volume WWNs match those on the VPLEX.
        client.validateBackendVolumesForVPlexVolume(vplexVolume.getDeviceLabel(), vplexVolume.getNativeId(), volumeInfoMap);
        WorkflowStepCompleter.stepSucceded(stepId);
    } catch (InternalException ie) {
        _log.info("Exception attempting to validate the backend volumes for VPLEX volume {}", vplexVolumeURI);
        WorkflowStepCompleter.stepFailed(stepId, ie);
    } catch (Exception e) {
        _log.info("Exception attempting to validate the backend volumes for VPLEX volume {}", vplexVolumeURI);
        ServiceCoded sc = DeviceControllerExceptions.vplex.failureValidatingVplexVolume(vplexVolumeURI.toString(), (vplexVolume != null ? vplexVolume.getLabel() : ""), e.getMessage());
        WorkflowStepCompleter.stepFailed(stepId, sc);
    }
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) VolumeInfo(com.emc.storageos.vplex.api.clientdata.VolumeInfo) VPlexVirtualVolumeInfo(com.emc.storageos.vplex.api.VPlexVirtualVolumeInfo) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) InternalServerErrorException(com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException) VPlexApiException(com.emc.storageos.vplex.api.VPlexApiException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) IOException(java.io.IOException) URISyntaxException(java.net.URISyntaxException) WorkflowException(com.emc.storageos.workflow.WorkflowException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ValidatorConfig(com.emc.storageos.volumecontroller.impl.validators.ValidatorConfig) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) Volume(com.emc.storageos.db.client.model.Volume) ServiceCoded(com.emc.storageos.svcs.errorhandling.model.ServiceCoded) VPlexApiClient(com.emc.storageos.vplex.api.VPlexApiClient) StringSet(com.emc.storageos.db.client.model.StringSet) ApplicationAddVolumeList(com.emc.storageos.volumecontroller.ApplicationAddVolumeList) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) List(java.util.List) VplexMirror(com.emc.storageos.db.client.model.VplexMirror) HashSet(java.util.HashSet) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 47 with ServiceCoded

use of com.emc.storageos.svcs.errorhandling.model.ServiceCoded in project coprhd-controller by CoprHD.

the class VPlexDeviceController method detachFullCopy.

/**
 * {@inheritDoc}
 */
@Override
public void detachFullCopy(URI vplexURI, List<URI> fullCopyURIs, String opId) throws InternalException {
    TaskCompleter completer = null;
    try {
        completer = new VolumeDetachCloneCompleter(fullCopyURIs, opId);
        // Generate the Workflow.
        Workflow workflow = _workflowService.getNewWorkflow(this, DETACH_FULL_COPY_WF_NAME, false, opId);
        _log.info("Created detach full copy workflow with operation id {}", opId);
        // add CG to taskCompleter
        Volume firstFullCopy = getDataObject(Volume.class, fullCopyURIs.get(0), _dbClient);
        BlockObject firstSource = BlockObject.fetch(_dbClient, firstFullCopy.getAssociatedSourceVolume());
        if (!NullColumnValueGetter.isNullURI(firstSource.getConsistencyGroup())) {
            completer.addConsistencyGroupId(firstSource.getConsistencyGroup());
        }
        // Get the native full copy volumes.
        URI nativeSystemURI = null;
        Map<URI, Volume> nativeFullCopyMap = new HashMap<URI, Volume>();
        for (URI fullCopyURI : fullCopyURIs) {
            Volume fullCopyVolume = getDataObject(Volume.class, fullCopyURI, _dbClient);
            Volume nativeFullCopyVolume = VPlexUtil.getVPLEXBackendVolume(fullCopyVolume, true, _dbClient);
            nativeFullCopyMap.put(nativeFullCopyVolume.getId(), nativeFullCopyVolume);
            if (nativeSystemURI == null) {
                nativeSystemURI = nativeFullCopyVolume.getStorageController();
            }
        }
        // Get the native system.
        StorageSystem nativeSystem = getDataObject(StorageSystem.class, nativeSystemURI, _dbClient);
        // We'll need a list of the native full copy URIs.
        List<URI> nativeFullCopyURIs = new ArrayList<URI>(nativeFullCopyMap.keySet());
        // Create a workflow step to detach the native
        // full copies.
        createWorkflowStepForDetachNativeFullCopy(workflow, nativeSystem, nativeFullCopyURIs, null, null);
        // Execute the workflow.
        _log.info("Executing workflow plan");
        String successMsg = String.format("Detach full copy volumes %s completed successfully", fullCopyURIs);
        FullCopyOperationCompleteCallback wfCompleteCB = new FullCopyOperationCompleteCallback();
        workflow.executePlan(completer, successMsg, wfCompleteCB, new Object[] { fullCopyURIs }, null, null);
        _log.info("Workflow plan executing");
    } catch (Exception e) {
        String failMsg = String.format("detach full copy volumes %s failed", fullCopyURIs);
        _log.error(failMsg, e);
        ServiceCoded sc = VPlexApiException.exceptions.detachFullCopyFailed(fullCopyURIs.toString(), e);
        failStep(completer, opId, sc);
    }
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Workflow(com.emc.storageos.workflow.Workflow) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) InternalServerErrorException(com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException) VPlexApiException(com.emc.storageos.vplex.api.VPlexApiException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) IOException(java.io.IOException) URISyntaxException(java.net.URISyntaxException) WorkflowException(com.emc.storageos.workflow.WorkflowException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) Volume(com.emc.storageos.db.client.model.Volume) ServiceCoded(com.emc.storageos.svcs.errorhandling.model.ServiceCoded) VolumeDetachCloneCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeDetachCloneCompleter) ExportTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportTaskCompleter) MigrationTaskCompleter(com.emc.storageos.vplexcontroller.completers.MigrationTaskCompleter) CloneTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.CloneTaskCompleter) MigrationOperationTaskCompleter(com.emc.storageos.vplexcontroller.completers.MigrationOperationTaskCompleter) CacheStatusTaskCompleter(com.emc.storageos.vplexcontroller.completers.CacheStatusTaskCompleter) VplexMirrorTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.VplexMirrorTaskCompleter) VolumeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeTaskCompleter) VolumeGroupUpdateTaskCompleter(com.emc.storageos.vplexcontroller.completers.VolumeGroupUpdateTaskCompleter) TaskCompleter(com.emc.storageos.volumecontroller.TaskCompleter) WorkflowTaskCompleter(com.emc.storageos.workflow.WorkflowTaskCompleter) BlockObject(com.emc.storageos.db.client.model.BlockObject) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 48 with ServiceCoded

use of com.emc.storageos.svcs.errorhandling.model.ServiceCoded in project coprhd-controller by CoprHD.

the class CephStorageDevice method doExpandVolume.

@Override
public void doExpandVolume(StorageSystem storage, StoragePool pool, Volume volume, Long size, TaskCompleter taskCompleter) throws DeviceControllerException {
    try (CephClient cephClient = getClient(storage)) {
        cephClient.resizeImage(pool.getPoolName(), volume.getNativeId(), size);
        volume.setProvisionedCapacity(size);
        volume.setAllocatedCapacity(size);
        volume.setCapacity(size);
        _dbClient.updateObject(volume);
        taskCompleter.ready(_dbClient);
    } catch (Exception e) {
        _log.error("Error while expanding volumes", e);
        ServiceCoded code = DeviceControllerErrors.ceph.operationFailed("expandVolume", e.getMessage());
        taskCompleter.error(_dbClient, code);
    }
}
Also used : ServiceCoded(com.emc.storageos.svcs.errorhandling.model.ServiceCoded) CephClient(com.emc.storageos.ceph.CephClient) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Example 49 with ServiceCoded

use of com.emc.storageos.svcs.errorhandling.model.ServiceCoded in project coprhd-controller by CoprHD.

the class CephStorageDevice method unmapVolumes.

/**
 * Unmap volumes from hosts on the hosts themselves.
 *
 * @param storage
 *            [in] - StorageSystem object
 * @param volumeURIs
 *            [in] - Collection of Volume URIs
 * @param initiators
 *            [in] - Collection of Initiator objects
 * @param completer
 *            [in] - TaskCompleter
 */
private void unmapVolumes(StorageSystem storage, List<URI> volumeURIs, Collection<Initiator> initiators, TaskCompleter completer) {
    _log.info("unmapVolumes: volumeURIs: {}", volumeURIs);
    _log.info("unmapVolumes: initiators: {}", initiators);
    try {
        for (URI uri : volumeURIs) {
            BlockObject object = BlockObject.fetch(_dbClient, uri);
            if (object == null) {
                _log.warn("Attempted to unmap BlockObject {}, which is empty", uri);
                continue;
            }
            if (object.getInactive()) {
                _log.warn("Attempted to unmap BlockObject {}, which is inactive", uri);
                continue;
            }
            RBDMappingOptions rbdOptions = new RBDMappingOptions(object);
            for (Initiator initiator : initiators) {
                Host host = _dbClient.queryObject(Host.class, initiator.getHost());
                String port = initiator.getInitiatorPort();
                if (initiator.getProtocol().equalsIgnoreCase(HostInterface.Protocol.RBD.name())) {
                    LinuxSystemCLI linuxClient = getLinuxClient(host);
                    linuxClient.unmapRBD(rbdOptions.poolName, rbdOptions.volumeName, rbdOptions.snapshotName);
                } else {
                    String msgPattern = "Unexpected initiator protocol %s for port %s and uri %s";
                    String msg = String.format(msgPattern, initiator.getProtocol(), port, uri);
                    ServiceCoded code = DeviceControllerErrors.ceph.operationFailed("unmapVolumes", msg);
                    completer.error(_dbClient, code);
                    return;
                }
            }
        }
        completer.ready(_dbClient);
    } catch (Exception e) {
        _log.error("Encountered an exception", e);
        ServiceCoded code = DeviceControllerErrors.ceph.operationFailed("unmapVolumes", e.getMessage());
        completer.error(_dbClient, code);
    }
}
Also used : LinuxSystemCLI(com.iwave.ext.linux.LinuxSystemCLI) Initiator(com.emc.storageos.db.client.model.Initiator) ServiceCoded(com.emc.storageos.svcs.errorhandling.model.ServiceCoded) Host(com.emc.storageos.db.client.model.Host) URI(java.net.URI) BlockObject(com.emc.storageos.db.client.model.BlockObject) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Example 50 with ServiceCoded

use of com.emc.storageos.svcs.errorhandling.model.ServiceCoded in project coprhd-controller by CoprHD.

the class CephStorageDevice method completeTaskAsUnsupported.

/**
 * Method calls the completer with error message indicating that the caller's method is unsupported
 *
 * @param completer
 *            [in] - TaskCompleter
 */
private void completeTaskAsUnsupported(TaskCompleter completer) {
    StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
    String methodName = stackTrace[2].getMethodName();
    ServiceCoded code = DeviceControllerErrors.ceph.operationIsUnsupported(methodName);
    completer.error(_dbClient, code);
}
Also used : ServiceCoded(com.emc.storageos.svcs.errorhandling.model.ServiceCoded)

Aggregations

ServiceCoded (com.emc.storageos.svcs.errorhandling.model.ServiceCoded)94 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)48 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)44 URI (java.net.URI)41 Volume (com.emc.storageos.db.client.model.Volume)31 ControllerException (com.emc.storageos.volumecontroller.ControllerException)27 NamedURI (com.emc.storageos.db.client.model.NamedURI)26 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)22 WorkflowException (com.emc.storageos.workflow.WorkflowException)22 ArrayList (java.util.ArrayList)22 BlockObject (com.emc.storageos.db.client.model.BlockObject)18 Operation (com.emc.storageos.db.client.model.Operation)17 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)17 InternalServerErrorException (com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException)16 TaskCompleter (com.emc.storageos.volumecontroller.TaskCompleter)15 ComputeSystemControllerException (com.emc.storageos.computesystemcontroller.exceptions.ComputeSystemControllerException)14 HashMap (java.util.HashMap)14 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)13 URISyntaxException (java.net.URISyntaxException)13 Host (com.emc.storageos.db.client.model.Host)12