Search in sources :

Example 71 with InternalException

use of com.emc.storageos.svcs.errorhandling.resources.InternalException in project coprhd-controller by CoprHD.

the class MaskingWorkflowEntryPoints method doExportGroupRemoveVolumes.

public void doExportGroupRemoveVolumes(URI storageURI, URI exportGroupURI, URI exportMaskURI, List<URI> volumeURIs, List<URI> initiatorURIs, TaskCompleter taskCompleter, String token) throws ControllerException {
    String call = String.format("doExportGroupRemoveVolumes(%s, %s, %s, [%s], [%s], %s)", storageURI.toString(), exportGroupURI.toString(), exportMaskURI.toString(), volumeURIs != null ? Joiner.on(',').join(volumeURIs) : "No Volumes", initiatorURIs != null ? Joiner.on(',').join(initiatorURIs) : "No Initiators", taskCompleter.getOpId());
    try {
        WorkflowStepCompleter.stepExecuting(token);
        ExportMask exportMask = _dbClient.queryObject(ExportMask.class, exportMaskURI);
        StorageSystem storage = _dbClient.queryObject(StorageSystem.class, storageURI);
        List<Initiator> initiators = new ArrayList<>();
        if (initiatorURIs != null && !initiatorURIs.isEmpty()) {
            initiators = _dbClient.queryObject(Initiator.class, initiatorURIs);
        }
        // Test mechanism to invoke a failure. No-op on production systems.
        InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_017);
        getDevice(storage).doExportRemoveVolumes(storage, exportMask, volumeURIs, initiators, taskCompleter);
        _log.info(String.format("%s end", call));
    } catch (final InternalException e) {
        _log.info(call + " Encountered an exception", e);
        taskCompleter.error(_dbClient, e);
    } catch (final Exception e) {
        _log.info(call + " Encountered an exception", e);
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
        taskCompleter.error(_dbClient, serviceError);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) Initiator(com.emc.storageos.db.client.model.Initiator) ExportMask(com.emc.storageos.db.client.model.ExportMask) ArrayList(java.util.ArrayList) WorkflowException(com.emc.storageos.workflow.WorkflowException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException)

Example 72 with InternalException

use of com.emc.storageos.svcs.errorhandling.resources.InternalException in project coprhd-controller by CoprHD.

the class MaskingWorkflowEntryPoints method doExportMaskAddPaths.

public void doExportMaskAddPaths(URI storageURI, URI exportGroupURI, URI exportMaskURI, Map<URI, List<URI>> newPaths, TaskCompleter taskCompleter, String token) throws ControllerException {
    String call = String.format("doExporMaskAddPaths(%s, %s, %s, %s, %s)", storageURI.toString(), exportGroupURI.toString(), exportMaskURI.toString(), newPaths != null ? Joiner.on(',').withKeyValueSeparator("=").join(newPaths) : "No path", taskCompleter.getOpId());
    try {
        _log.info(call + " starts");
        WorkflowStepCompleter.stepExecuting(token);
        StorageSystem storage = _dbClient.queryObject(StorageSystem.class, storageURI);
        getDevice(storage).doExportAddPaths(storage, exportMaskURI, newPaths, taskCompleter);
        _log.info(String.format("%s end", call));
    } catch (final InternalException e) {
        _log.info(call + " Encountered an exception", e);
        taskCompleter.error(_dbClient, e);
    } catch (final Exception e) {
        _log.info(call + " Encountered an exception", e);
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
        taskCompleter.error(_dbClient, serviceError);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) WorkflowException(com.emc.storageos.workflow.WorkflowException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException)

Example 73 with InternalException

use of com.emc.storageos.svcs.errorhandling.resources.InternalException in project coprhd-controller by CoprHD.

the class MaskingWorkflowEntryPoints method doExportGroupAddVolumes.

public void doExportGroupAddVolumes(URI storageURI, URI exportGroupURI, URI exportMaskURI, Map<URI, Integer> volumeMap, List<URI> initiatorURIs, TaskCompleter taskCompleter, String token) throws ControllerException {
    String call = String.format("doExportGroupAddVolumes(%s, %s, %s, [%s], [%s], %s)", storageURI.toString(), exportGroupURI.toString(), exportMaskURI.toString(), volumeMap != null ? Joiner.on(',').join(volumeMap.entrySet()) : "No Volumes", initiatorURIs != null ? Joiner.on(',').join(initiatorURIs) : "No Initiators", taskCompleter.getOpId());
    try {
        WorkflowStepCompleter.stepExecuting(token);
        ExportMask exportMask = _dbClient.queryObject(ExportMask.class, exportMaskURI);
        StorageSystem storage = _dbClient.queryObject(StorageSystem.class, storageURI);
        List<Initiator> initiators = new ArrayList<>();
        if (initiatorURIs != null && !initiatorURIs.isEmpty()) {
            initiators = _dbClient.queryObject(Initiator.class, initiatorURIs);
        }
        // Test mechanism to invoke a failure. No-op on production systems.
        InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_001);
        getDevice(storage).doExportAddVolumes(storage, exportMask, initiators, volumeMap, taskCompleter);
        _log.info(String.format("%s end", call));
    } catch (final InternalException e) {
        _log.info(call + " Encountered an exception", e);
        taskCompleter.error(_dbClient, e);
    } catch (final Exception e) {
        _log.info(call + " Encountered an exception", e);
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
        taskCompleter.error(_dbClient, serviceError);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) Initiator(com.emc.storageos.db.client.model.Initiator) ExportMask(com.emc.storageos.db.client.model.ExportMask) ArrayList(java.util.ArrayList) WorkflowException(com.emc.storageos.workflow.WorkflowException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException)

Example 74 with InternalException

use of com.emc.storageos.svcs.errorhandling.resources.InternalException in project coprhd-controller by CoprHD.

the class MaskingWorkflowEntryPoints method doExportChangePortGroupAddPaths.

/**
 * Calls to underlying storage device to do the add paths operation for change port group
 *
 * @param storageURI
 *            - Storage system URI
 * @param exportGroupURI
 *            - Export group URI
 * @param newMaskURI
 *            - New export mask URI
 * @param oldMaskURI
 *            - Old export mask URI
 * @param portGroupURI
 *            - The new port group URI
 * @param taskCompleter
 *            - Task completer
 * @param token
 *            - Task token
 */
public void doExportChangePortGroupAddPaths(URI storageURI, URI exportGroupURI, URI newMaskURI, URI oldMaskURI, URI portGroupURI, TaskCompleter taskCompleter, String token) {
    try {
        WorkflowStepCompleter.stepExecuting(token);
        StorageSystem storage = _dbClient.queryObject(StorageSystem.class, storageURI);
        getDevice(storage).doExportChangePortGroupAddPaths(storage, newMaskURI, oldMaskURI, portGroupURI, taskCompleter);
    } catch (final InternalException e) {
        _log.info("doExportChangePortGroup Encountered an exception", e);
        taskCompleter.error(_dbClient, e);
    } catch (final Exception e) {
        _log.info("doExportChangePortGroup Encountered an exception", e);
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
        taskCompleter.error(_dbClient, serviceError);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) WorkflowException(com.emc.storageos.workflow.WorkflowException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException)

Example 75 with InternalException

use of com.emc.storageos.svcs.errorhandling.resources.InternalException in project coprhd-controller by CoprHD.

the class FileService method unAssignFilePolicy.

/**
 * Unassign existing file system to file policy.
 *
 * @param id
 *            the URN of a ViPR fileSystem
 * @param filePolicyUri
 *            the URN of a Policy
 * @brief Update file system with Policy detail
 * @return Task resource representation
 * @throws InternalException
 */
@PUT
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/unassign-file-policy/{filePolicyUri}")
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.OWN, ACL.ALL })
public TaskResourceRep unAssignFilePolicy(@PathParam("id") URI id, @PathParam("filePolicyUri") URI filePolicyUri) throws InternalException {
    // log input received.
    _log.info("Unassign Policy on File System : request received for {}  with {}", id, filePolicyUri);
    String task = UUID.randomUUID().toString();
    // Validate the FS id.
    ArgValidator.checkFieldUriType(id, FileShare.class, "id");
    FileShare fs = queryResource(id);
    ArgValidator.checkEntity(fs, id, isIdEmbeddedInURL(id));
    ArgValidator.checkFieldUriType(filePolicyUri, FilePolicy.class, "filePolicyUri");
    ArgValidator.checkUri(filePolicyUri);
    FilePolicy fp = _permissionsHelper.getObjectById(filePolicyUri, FilePolicy.class);
    ArgValidator.checkEntityNotNull(fp, filePolicyUri, isIdEmbeddedInURL(filePolicyUri));
    // verify the schedule policy is associated with file system or not.
    if (!fs.getFilePolicies().isEmpty() && !fs.getFilePolicies().contains(filePolicyUri.toString())) {
        throw APIException.badRequests.cannotFindAssociatedPolicy(filePolicyUri);
    }
    StorageSystem device = _dbClient.queryObject(StorageSystem.class, fs.getStorageDevice());
    FileOrchestrationController controller = getController(FileOrchestrationController.class, FileOrchestrationController.FILE_ORCHESTRATION_DEVICE);
    Operation op = _dbClient.createTaskOpStatus(FilePolicy.class, fp.getId(), task, ResourceOperationTypeEnum.UNASSIGN_FILE_POLICY);
    op.setDescription("Filesystem unassign policy");
    // As the action done by tenant admin
    // Set current tenant as task's tenant!!!
    Task taskObj = op.getTask(fp.getId());
    FilePolicyServiceUtils.updateTaskTenant(_dbClient, fp, "unassign", taskObj, fs.getTenant().getURI());
    try {
        Set<URI> unassignFrom = new HashSet<URI>();
        unassignFrom.add(id);
        _log.info("No Errors found proceeding further {}, {}, {}", new Object[] { _dbClient, fs, fp });
        controller.unassignFilePolicy(filePolicyUri, unassignFrom, task);
        auditOp(OperationTypeEnum.UNASSIGN_FILE_POLICY, true, "BEGIN", fp.getId().toString(), fp.getFilePolicyName());
    } catch (BadRequestException e) {
        op = _dbClient.error(FilePolicy.class, fp.getId(), task, e);
        _log.error("Error Unassigning File policy {}, {}", e.getMessage(), e);
        throw e;
    } catch (Exception e) {
        _log.error("Error Unassigning Filesystem policy {}, {}", e.getMessage(), e);
        throw APIException.badRequests.unableToProcessRequest(e.getMessage());
    }
    return toTask(fp, task, op);
}
Also used : TaskMapper.toTask(com.emc.storageos.api.mapper.TaskMapper.toTask) Task(com.emc.storageos.db.client.model.Task) FilePolicy(com.emc.storageos.db.client.model.FilePolicy) FileOrchestrationController(com.emc.storageos.fileorchestrationcontroller.FileOrchestrationController) BadRequestException(com.emc.storageos.svcs.errorhandling.resources.BadRequestException) Operation(com.emc.storageos.db.client.model.Operation) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) MapFileShare(com.emc.storageos.api.mapper.functions.MapFileShare) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) URISyntaxException(java.net.URISyntaxException) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) BadRequestException(com.emc.storageos.svcs.errorhandling.resources.BadRequestException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) HashSet(java.util.HashSet) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) PUT(javax.ws.rs.PUT) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Aggregations

InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)209 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)112 URI (java.net.URI)106 ControllerException (com.emc.storageos.volumecontroller.ControllerException)100 Volume (com.emc.storageos.db.client.model.Volume)91 ArrayList (java.util.ArrayList)86 WorkflowException (com.emc.storageos.workflow.WorkflowException)84 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)83 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)77 NamedURI (com.emc.storageos.db.client.model.NamedURI)63 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)60 URISyntaxException (java.net.URISyntaxException)58 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)55 Operation (com.emc.storageos.db.client.model.Operation)51 InternalServerErrorException (com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException)45 Workflow (com.emc.storageos.workflow.Workflow)41 TaskResourceRep (com.emc.storageos.model.TaskResourceRep)40 Path (javax.ws.rs.Path)39 Produces (javax.ws.rs.Produces)39 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)37