Search in sources :

Example 41 with ServiceError

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

the class FileOrchestrationDeviceController method assignFileReplicationPolicyToProjects.

@Override
public void assignFileReplicationPolicyToProjects(List<FileStorageSystemAssociation> associations, URI vpoolURI, List<URI> projectURIs, URI filePolicyToAssign, String taskId) {
    FilePolicy filePolicy = s_dbClient.queryObject(FilePolicy.class, filePolicyToAssign);
    FilePolicyAssignWorkflowCompleter completer = new FilePolicyAssignWorkflowCompleter(filePolicyToAssign, projectURIs, vpoolURI, taskId);
    try {
        String waitFor = null;
        String stepId = null;
        String stepDes = null;
        Workflow workflow = _workflowService.getNewWorkflow(this, ASSIGN_FILE_POLICY_WF_NAME, false, taskId, completer);
        completer.setWorkFlowId(workflow.getWorkflowURI());
        String usePhysicalNASForProvisioning = customConfigHandler.getComputedCustomConfigValue(CustomConfigConstants.USE_PHYSICAL_NAS_FOR_PROVISIONING, "isilon", null);
        Boolean usePhysicalNAS = Boolean.valueOf(usePhysicalNASForProvisioning);
        // Verify the associations have many to one storage system relation.
        // If so, inform the user to configure cluster name in provisioning path!!
        verifyClusterNameInPathForManyToOneRecommendations(associations, filePolicy);
        s_logger.info("Generating steps for assigning file policy {} to project.", filePolicyToAssign);
        for (FileStorageSystemAssociation association : associations) {
            StorageSystem sourceStoragesystem = s_dbClient.queryObject(StorageSystem.class, association.getSourceSystem());
            URI projectURI = association.getAppliedAtResource();
            URI vPoolURI = association.getProjectvPool();
            List<TargetAssociation> targetAssociations = association.getTargets();
            if (targetAssociations != null && !targetAssociations.isEmpty()) {
                for (Iterator<TargetAssociation> iterator = targetAssociations.iterator(); iterator.hasNext(); ) {
                    TargetAssociation targetAssociation = iterator.next();
                    URI targetVNASURI = targetAssociation.getvNASURI();
                    URI targetStorage = targetAssociation.getStorageSystemURI();
                    URI targetVArray = targetAssociation.getvArrayURI();
                    if (targetVNASURI != null && association.getSourceVNAS() != null) {
                        stepId = workflow.createStepId();
                        stepDes = String.format("Assigning file policy: %s, to project: %s on storage system: %s", filePolicy.getId(), projectURI, association.getSourceSystem());
                        // Let the all workflow steps be executed
                        // workflow completer should handle the unsuccessful steps
                        Object[] args = new Object[] { association.getSourceSystem(), targetStorage, association.getSourceVNAS(), targetVArray, targetVNASURI, filePolicyToAssign, vPoolURI, projectURI };
                        _fileDeviceController.createMethod(workflow, waitFor, ASSIGN_FILE_REPLICATION_POLICY_TO_PROJECTS_METHOD, stepId, stepDes, association.getSourceSystem(), args);
                    } else {
                        if (sourceStoragesystem.getSystemType().equals(Type.isilon.toString())) {
                            if (usePhysicalNAS) {
                                stepId = workflow.createStepId();
                                stepDes = String.format("Assigning file policy: %s, to project: %s on storage system: %s", filePolicy.getId(), projectURI, association.getSourceSystem());
                                // Let the all workflow steps be executed
                                // workflow completer should handle the unsuccessful steps
                                Object[] args = new Object[] { association.getSourceSystem(), targetStorage, association.getSourceVNAS(), targetVArray, null, filePolicyToAssign, vPoolURI, projectURI };
                                _fileDeviceController.createMethod(workflow, waitFor, ASSIGN_FILE_REPLICATION_POLICY_TO_PROJECTS_METHOD, stepId, stepDes, association.getSourceSystem(), args);
                            }
                        }
                    }
                }
            }
        }
        String successMessage = String.format("Assigning file policy : %s, to project(s) successful.", filePolicy.getId());
        workflow.executePlan(completer, successMessage);
    } catch (Exception ex) {
        // If no other resources are assigned to replication policy
        // Remove the replication topology from the policy
        FileOrchestrationUtils.removeTopologyInfo(filePolicy, s_dbClient);
        s_logger.error(String.format("Assigning file policy : %s to project(s) failed", filePolicy.getId()), ex);
        ServiceError serviceError = DeviceControllerException.errors.assignFilePolicyFailed(filePolicyToAssign.toString(), filePolicy.getApplyAt(), ex);
        completer.error(s_dbClient, _locker, serviceError);
    }
}
Also used : FilePolicyAssignWorkflowCompleter(com.emc.storageos.volumecontroller.impl.file.FilePolicyAssignWorkflowCompleter) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) FilePolicy(com.emc.storageos.db.client.model.FilePolicy) TargetAssociation(com.emc.storageos.fileorchestrationcontroller.FileStorageSystemAssociation.TargetAssociation) Workflow(com.emc.storageos.workflow.Workflow) URI(java.net.URI) WorkflowException(com.emc.storageos.workflow.WorkflowException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) FileObject(com.emc.storageos.db.client.model.FileObject) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 42 with ServiceError

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

the class FileOrchestrationDeviceController method createNFSExport.

@Override
public void createNFSExport(URI storage, URI uri, List<FileShareExport> exports, String opId) throws ControllerException {
    FileObject fileObj = null;
    String stepDescription = null;
    String successMessage = null;
    String opName = null;
    TaskCompleter completer = null;
    if (URIUtil.isType(uri, FileShare.class)) {
        completer = new FileWorkflowCompleter(uri, opId);
        fileObj = s_dbClient.queryObject(FileShare.class, uri);
        stepDescription = String.format("Creating NFS export for file system : %s", uri);
        successMessage = String.format("Creating NFS export for file system : %s finished succesfully.", uri);
        opName = ResourceOperationTypeEnum.EXPORT_FILE_SYSTEM.getName();
    } else {
        completer = new FileSnapshotWorkflowCompleter(uri, opId);
        fileObj = s_dbClient.queryObject(Snapshot.class, uri);
        stepDescription = String.format("Creating NFS export for file system snapshot : %s", uri);
        successMessage = String.format("Creating NFS export for file system snapshot : %s finished succesfully.", uri);
        opName = ResourceOperationTypeEnum.EXPORT_FILE_SNAPSHOT.getName();
    }
    try {
        Workflow workflow = _workflowService.getNewWorkflow(this, CREATE_FILESYSTEM_NFS_EXPORT_WF_NAME, false, opId, completer);
        String exportStep = workflow.createStepId();
        Object[] args = new Object[] { storage, uri, exports };
        _fileDeviceController.createMethod(workflow, null, CREATE_FILESYSTEM_EXPORT_METHOD, exportStep, stepDescription, storage, args);
        workflow.executePlan(completer, successMessage);
    } catch (Exception ex) {
        s_logger.error(String.format("Creating NFS export for file system/snapshot : %s failed", uri), ex);
        ServiceError serviceError = DeviceControllerException.errors.exportFileShareFailed(fileObj.toString(), opName, ex);
        completer.error(s_dbClient, _locker, serviceError);
    }
}
Also used : Snapshot(com.emc.storageos.db.client.model.Snapshot) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) FileWorkflowCompleter(com.emc.storageos.volumecontroller.impl.file.FileWorkflowCompleter) FileSnapshotWorkflowCompleter(com.emc.storageos.volumecontroller.impl.file.FileSnapshotWorkflowCompleter) Workflow(com.emc.storageos.workflow.Workflow) FileObject(com.emc.storageos.db.client.model.FileObject) FileObject(com.emc.storageos.db.client.model.FileObject) VNXeFSSnapshotTaskCompleter(com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeFSSnapshotTaskCompleter) MirrorFileFailoverTaskCompleter(com.emc.storageos.volumecontroller.impl.file.MirrorFileFailoverTaskCompleter) MirrorFileFailbackTaskCompleter(com.emc.storageos.volumecontroller.impl.file.MirrorFileFailbackTaskCompleter) TaskCompleter(com.emc.storageos.volumecontroller.TaskCompleter) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) WorkflowException(com.emc.storageos.workflow.WorkflowException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ControllerException(com.emc.storageos.volumecontroller.ControllerException)

Example 43 with ServiceError

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

the class FileOrchestrationDeviceController method restoreFS.

@Override
public void restoreFS(URI storage, URI fs, URI snapshot, String opId) throws ControllerException {
    // Using VNXeFSSnapshotTaskCompleter as it will serve the purpose..
    VNXeFSSnapshotTaskCompleter completer = new VNXeFSSnapshotTaskCompleter(Snapshot.class, snapshot, opId);
    Workflow workflow = null;
    try {
        workflow = this._workflowService.getNewWorkflow(this, RESTORE_FILESYSTEM_SNAPSHOT_WF_NAME, false, opId, completer);
        String restoreFSStep = workflow.createStepId();
        String stepDescription = String.format("Restoring file System : %s from snapshot: %s", fs, snapshot);
        Object[] args = new Object[] { storage, fs, snapshot };
        _fileDeviceController.createMethod(workflow, null, RESTORE_FILESYSTEM_SNAPSHOT_METHOD, restoreFSStep, stepDescription, storage, args);
        String successMessage = String.format("Restoring file system : %s from snapshot: %s finished successfully.", fs, snapshot);
        workflow.executePlan(completer, successMessage);
    } catch (Exception ex) {
        s_logger.error(String.format("Restoring file system : %s from snapshot: %s failed.", fs, snapshot), ex);
        String opName = ResourceOperationTypeEnum.RESTORE_FILE_SNAPSHOT.getName();
        ServiceError serviceError = DeviceControllerException.errors.restoreFSFromSnapshotFailed(fs.toString(), opName, ex);
        completer.error(s_dbClient, this._locker, serviceError);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) VNXeFSSnapshotTaskCompleter(com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeFSSnapshotTaskCompleter) Workflow(com.emc.storageos.workflow.Workflow) FileObject(com.emc.storageos.db.client.model.FileObject) WorkflowException(com.emc.storageos.workflow.WorkflowException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ControllerException(com.emc.storageos.volumecontroller.ControllerException)

Example 44 with ServiceError

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

the class FileOrchestrationDeviceController method deleteShareACLs.

@Override
public void deleteShareACLs(URI storage, URI uri, String shareName, String taskId) throws ControllerException {
    String stepDescription = null;
    String successMessage = null;
    String opName = null;
    TaskCompleter completer = null;
    if (URIUtil.isType(uri, FileShare.class)) {
        completer = new FileWorkflowCompleter(uri, taskId);
        stepDescription = String.format("Deleting file system : %s share : %s  ACLs", uri, shareName);
        successMessage = String.format("Deleting file system : %s share : %s ACLs finished successfully", uri, shareName);
        opName = ResourceOperationTypeEnum.DELETE_FILE_SYSTEM_SHARE_ACL.getName();
    } else {
        completer = new FileSnapshotWorkflowCompleter(uri, taskId);
        stepDescription = String.format("Deleting file system snapshot : %s share: %s ACLs", uri, shareName);
        successMessage = String.format("Deleting file system snapshot : %s share: %s ACLs: finished successfully", uri, shareName);
        opName = ResourceOperationTypeEnum.DELETE_FILE_SNAPSHOT_SHARE_ACL.getName();
    }
    try {
        Workflow workflow = this._workflowService.getNewWorkflow(this, DELETE_FILESYSTEM_SHARE_ACLS_WF_NAME, false, taskId, completer);
        String shareACLDeleteStep = workflow.createStepId();
        Object[] args = new Object[] { storage, uri, shareName };
        _fileDeviceController.createMethod(workflow, null, DELETE_FILESYSTEM_SHARE_ACLS_METHOD, shareACLDeleteStep, stepDescription, storage, args);
        workflow.executePlan(completer, successMessage);
    } catch (Exception ex) {
        s_logger.error(String.format("Deleting file system snapshot : %s share: %s ACLs failed.", uri, shareName), ex);
        ServiceError serviceError = DeviceControllerException.errors.deleteShareACLFailed(uri.toString(), opName, ex);
        completer.error(s_dbClient, this._locker, serviceError);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) FileWorkflowCompleter(com.emc.storageos.volumecontroller.impl.file.FileWorkflowCompleter) FileSnapshotWorkflowCompleter(com.emc.storageos.volumecontroller.impl.file.FileSnapshotWorkflowCompleter) Workflow(com.emc.storageos.workflow.Workflow) FileObject(com.emc.storageos.db.client.model.FileObject) VNXeFSSnapshotTaskCompleter(com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeFSSnapshotTaskCompleter) MirrorFileFailoverTaskCompleter(com.emc.storageos.volumecontroller.impl.file.MirrorFileFailoverTaskCompleter) MirrorFileFailbackTaskCompleter(com.emc.storageos.volumecontroller.impl.file.MirrorFileFailbackTaskCompleter) TaskCompleter(com.emc.storageos.volumecontroller.TaskCompleter) WorkflowException(com.emc.storageos.workflow.WorkflowException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ControllerException(com.emc.storageos.volumecontroller.ControllerException)

Example 45 with ServiceError

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

the class FileOrchestrationDeviceController method expandFileSystem.

/*
     * (non-Javadoc)
     * 
     * @see com.emc.storageos.fileorchestrationcontroller.FileOrchestrationController#expandFileSystem(java.net.URI,
     * long, java.lang.String)
     */
/**
 * expand one or more filesystem
 *
 * @param fileDescriptors
 * @param taskId
 * @throws ControllerException
 */
@Override
public void expandFileSystem(List<FileDescriptor> fileDescriptors, String taskId) throws ControllerException {
    // the wait for key returned by previous call
    String waitFor = null;
    List<URI> fileShareUris = FileDescriptor.getFileSystemURIs(fileDescriptors);
    FileWorkflowCompleter completer = new FileWorkflowCompleter(fileShareUris, taskId);
    Workflow workflow = null;
    try {
        // Generate the Workflow.
        workflow = _workflowService.getNewWorkflow(this, EXPAND_FILESYSTEMS_WF_NAME, false, taskId);
        // Next, call the FileDeviceController to add its delete methods.
        waitFor = _fileDeviceController.addStepsForExpandFileSystems(workflow, waitFor, fileDescriptors, taskId);
        // Finish up and execute the plan.
        // The Workflow will handle the TaskCompleter
        String successMessage = "Expand FileShares successful for: " + fileShareUris.toString();
        Object[] callbackArgs = new Object[] { fileShareUris };
        workflow.executePlan(completer, successMessage, new WorkflowCallback(), callbackArgs, null, null);
    } catch (Exception ex) {
        s_logger.error("Could not Expand FileShares: " + fileShareUris, ex);
        releaseWorkflowLocks(workflow);
        String opName = ResourceOperationTypeEnum.EXPORT_FILE_SYSTEM.getName();
        ServiceError serviceError = DeviceControllerException.errors.expandFileShareFailed(fileShareUris.toString(), opName, ex);
        completer.error(s_dbClient, _locker, serviceError);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) FileWorkflowCompleter(com.emc.storageos.volumecontroller.impl.file.FileWorkflowCompleter) Workflow(com.emc.storageos.workflow.Workflow) FileObject(com.emc.storageos.db.client.model.FileObject) URI(java.net.URI) WorkflowException(com.emc.storageos.workflow.WorkflowException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ControllerException(com.emc.storageos.volumecontroller.ControllerException)

Aggregations

ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)707 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)625 ControllerException (com.emc.storageos.volumecontroller.ControllerException)345 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)289 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)270 WorkflowException (com.emc.storageos.workflow.WorkflowException)258 URI (java.net.URI)250 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)246 ArrayList (java.util.ArrayList)238 Volume (com.emc.storageos.db.client.model.Volume)206 Workflow (com.emc.storageos.workflow.Workflow)127 WBEMException (javax.wbem.WBEMException)124 CIMObjectPath (javax.cim.CIMObjectPath)118 TaskCompleter (com.emc.storageos.volumecontroller.TaskCompleter)113 ExportMask (com.emc.storageos.db.client.model.ExportMask)107 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)105 QueueJob (com.emc.storageos.volumecontroller.impl.job.QueueJob)104 URISyntaxException (java.net.URISyntaxException)94 HashMap (java.util.HashMap)86 NamedURI (com.emc.storageos.db.client.model.NamedURI)82