Search in sources :

Example 1 with FilePolicyAssignWorkflowCompleter

use of com.emc.storageos.volumecontroller.impl.file.FilePolicyAssignWorkflowCompleter in project coprhd-controller by CoprHD.

the class FileOrchestrationDeviceController method assignFileReplicationPolicyToVirtualPools.

@Override
public void assignFileReplicationPolicyToVirtualPools(List<FileStorageSystemAssociation> associations, List<URI> vpoolURIs, URI filePolicyToAssign, String taskId) {
    FilePolicy filePolicy = s_dbClient.queryObject(FilePolicy.class, filePolicyToAssign);
    FilePolicyAssignWorkflowCompleter completer = new FilePolicyAssignWorkflowCompleter(filePolicyToAssign, vpoolURIs, null, 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 replication policy to vpool: {}.", filePolicyToAssign);
        for (FileStorageSystemAssociation association : associations) {
            StorageSystem sourceStoragesystem = s_dbClient.queryObject(StorageSystem.class, association.getSourceSystem());
            URI vpoolURI = association.getAppliedAtResource();
            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 vpool: %s on storage system: %s with source vnas %s and target vnas %s", filePolicy.getId(), vpoolURI, association.getSourceSystem(), association.getSourceVNAS(), targetVNASURI);
                        Object[] args = new Object[] { association.getSourceSystem(), targetStorage, association.getSourceVNAS(), targetVArray, targetVNASURI, filePolicyToAssign, vpoolURI };
                        _fileDeviceController.createMethod(workflow, waitFor, ASSIGN_FILE_REPLICATION_POLICY_TO_VIRTUAL_POOLS_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 vpool: %s on storage system: %s", filePolicy.getId(), vpoolURI, 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 };
                                _fileDeviceController.createMethod(workflow, waitFor, ASSIGN_FILE_REPLICATION_POLICY_TO_VIRTUAL_POOLS_METHOD, stepId, stepDes, association.getSourceSystem(), args);
                            }
                        }
                    }
                }
            }
        }
        String successMessage = String.format("Assigning file policy : %s, to vpool(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 vpool(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 2 with FilePolicyAssignWorkflowCompleter

use of com.emc.storageos.volumecontroller.impl.file.FilePolicyAssignWorkflowCompleter 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 3 with FilePolicyAssignWorkflowCompleter

use of com.emc.storageos.volumecontroller.impl.file.FilePolicyAssignWorkflowCompleter in project coprhd-controller by CoprHD.

the class FileOrchestrationDeviceController method assignFileSnapshotPolicyToProjects.

@Override
public void assignFileSnapshotPolicyToProjects(Map<URI, List<URI>> vpoolToStorageSystemMap, List<URI> projectURIs, URI filePolicyToAssign, String taskId) {
    FilePolicy filePolicy = s_dbClient.queryObject(FilePolicy.class, filePolicyToAssign);
    String opName = ResourceOperationTypeEnum.ASSIGN_FILE_POLICY.getName();
    URI projectVpool = null;
    if (vpoolToStorageSystemMap != null && !vpoolToStorageSystemMap.isEmpty()) {
        Set<URI> vpoolUris = vpoolToStorageSystemMap.keySet();
        // For project assignment, there would be a single vpool!!
        projectVpool = vpoolUris.toArray(new URI[vpoolUris.size()])[0];
    }
    FilePolicyAssignWorkflowCompleter completer = new FilePolicyAssignWorkflowCompleter(filePolicyToAssign, projectURIs, projectVpool, taskId);
    try {
        String waitFor = 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);
        for (URI vpoolURI : vpoolToStorageSystemMap.keySet()) {
            s_logger.info("Generating steps for assigning file policy {} to project: {}.", filePolicyToAssign, vpoolURI);
            List<URI> storageSystemURIList = vpoolToStorageSystemMap.get(vpoolURI);
            if (storageSystemURIList != null && !storageSystemURIList.isEmpty()) {
                for (URI storageSystemURI : storageSystemURIList) {
                    if (projectURIs != null && !projectURIs.isEmpty()) {
                        for (URI projectURI : projectURIs) {
                            // Get the eligible nas server for given project from the storage system!!!
                            List<URI> vNASURIList = FileOrchestrationUtils.getVNASServersOfStorageSystemAndVarrayOfVpool(s_dbClient, storageSystemURI, vpoolURI, projectURI);
                            if (vNASURIList != null && !vNASURIList.isEmpty()) {
                                for (URI vNASURI : vNASURIList) {
                                    String stepId = workflow.createStepId();
                                    String stepDes = String.format("Assigning file policy: %s, to project: %s on storage system: %s", filePolicy.getId(), vpoolURI, storageSystemURI);
                                    Object[] args = new Object[] { storageSystemURI, vNASURI, filePolicyToAssign, vpoolURI, projectURI };
                                    // Let the all workflow steps be executed
                                    // workflow completer should handle the unsuccessful steps
                                    _fileDeviceController.createMethod(workflow, waitFor, ASSIGN_FILE_SNAPSHOT_POLICY_TO_PROJECTS_METHOD, stepId, stepDes, storageSystemURI, args);
                                }
                            }
                            StorageSystem storagesystem = s_dbClient.queryObject(StorageSystem.class, storageSystemURI);
                            // Create policy, if physical nas is eligible for provisioning!!
                            if (storagesystem.getSystemType().equals(Type.isilon.toString())) {
                                if (usePhysicalNAS) {
                                    s_logger.info("Generating step for assigning file policy {} to project on physical NAS server: {}.", filePolicyToAssign, vpoolURI);
                                    String stepId = workflow.createStepId();
                                    String stepDes = String.format("Assigning file policy: %s, to project: %s on storage system: %s", filePolicy.getId(), projectURI, storageSystemURI);
                                    Object[] args = new Object[] { storageSystemURI, null, filePolicyToAssign, vpoolURI, projectURI };
                                    // Let the all workflow steps be executed
                                    // workflow completer should handle the unsuccessful steps
                                    _fileDeviceController.createMethod(workflow, waitFor, ASSIGN_FILE_SNAPSHOT_POLICY_TO_PROJECTS_METHOD, stepId, stepDes, storageSystemURI, args);
                                }
                            }
                        }
                    }
                }
            } else {
                s_logger.info("No storage system(s) present for vpool: {}", vpoolURI);
            }
        }
        String successMessage = String.format("Assigning file policy : %s, to project(s) successful.", filePolicy.getId(), vpoolToStorageSystemMap);
        workflow.executePlan(completer, successMessage);
    } catch (Exception ex) {
        s_logger.error(String.format("Assigning file policy : %s to vpool(s) failed", filePolicy.getId()), ex);
        ServiceError serviceError = DeviceControllerException.errors.assignFilePolicyFailed(filePolicyToAssign.toString(), FilePolicyApplyLevel.project.name(), 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) 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 4 with FilePolicyAssignWorkflowCompleter

use of com.emc.storageos.volumecontroller.impl.file.FilePolicyAssignWorkflowCompleter in project coprhd-controller by CoprHD.

the class FileOrchestrationDeviceController method assignFileSnapshotPolicyToVirtualPools.

@Override
public void assignFileSnapshotPolicyToVirtualPools(Map<URI, List<URI>> vpoolToStorageSystemMap, URI filePolicyToAssign, String taskId) throws InternalException {
    FilePolicy filePolicy = s_dbClient.queryObject(FilePolicy.class, filePolicyToAssign);
    FilePolicyAssignWorkflowCompleter completer = new FilePolicyAssignWorkflowCompleter(filePolicyToAssign, vpoolToStorageSystemMap.keySet(), null, taskId);
    try {
        String waitFor = 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);
        for (URI vpoolURI : vpoolToStorageSystemMap.keySet()) {
            s_logger.info("Generating steps for assigning file policy {} to vpool: {}.", filePolicyToAssign, vpoolURI);
            List<URI> storageSystemURIList = vpoolToStorageSystemMap.get(vpoolURI);
            if (storageSystemURIList != null && !storageSystemURIList.isEmpty()) {
                for (URI storageSystemURI : storageSystemURIList) {
                    List<URI> vNASURIList = FileOrchestrationUtils.getVNASServersOfStorageSystemAndVarrayOfVpool(s_dbClient, storageSystemURI, vpoolURI, null);
                    if (vNASURIList != null && !vNASURIList.isEmpty()) {
                        for (URI vNASURI : vNASURIList) {
                            String stepId = workflow.createStepId();
                            String stepDes = String.format("Assigning file policy: %s, to vpool: %s on storage system: %s", filePolicy.getId(), vpoolURI, storageSystemURI);
                            Object[] args = new Object[] { storageSystemURI, vNASURI, filePolicyToAssign, vpoolURI };
                            // Let the all workflow steps be executed
                            // workflow completer should handle the unsuccessful steps
                            _fileDeviceController.createMethod(workflow, waitFor, ASSIGN_FILE_SNAPSHOT_POLICY_TO_VIRTUAL_POOLS_METHOD, stepId, stepDes, storageSystemURI, args);
                        }
                    }
                    StorageSystem storagesystem = s_dbClient.queryObject(StorageSystem.class, storageSystemURI);
                    if (storagesystem.getSystemType().equals(Type.isilon.toString())) {
                        if (usePhysicalNAS) {
                            s_logger.info("Generating step for assigning file policy {} to vpool on physical NAS server: {}.", filePolicyToAssign, vpoolURI);
                            String stepId = workflow.createStepId();
                            String stepDes = String.format("Assigning file policy: %s, to vpool: %s on storage system: %s", filePolicy.getId(), vpoolURI, storageSystemURI);
                            Object[] args = new Object[] { storageSystemURI, null, filePolicyToAssign, vpoolURI };
                            // Let the all workflow steps be executed
                            // workflow completer should handle the unsuccessful steps
                            _fileDeviceController.createMethod(workflow, waitFor, ASSIGN_FILE_SNAPSHOT_POLICY_TO_VIRTUAL_POOLS_METHOD, stepId, stepDes, storageSystemURI, args);
                        }
                    }
                }
            } else {
                s_logger.info("No storage system(s) present for vpool: {}", vpoolURI);
            }
        }
        String successMessage = String.format("Assigning file policy : %s, to vpool(s) successful.", filePolicy.getId(), vpoolToStorageSystemMap);
        workflow.executePlan(completer, successMessage);
    } catch (Exception ex) {
        s_logger.error(String.format("Assigning file policy : %s to vpool(s) failed", filePolicy.getId()), ex);
        ServiceError serviceError = DeviceControllerException.errors.assignFilePolicyFailed(filePolicyToAssign.toString(), FilePolicyApplyLevel.vpool.name(), 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) 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) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

FileObject (com.emc.storageos.db.client.model.FileObject)4 FilePolicy (com.emc.storageos.db.client.model.FilePolicy)4 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)4 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)4 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)4 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)4 ControllerException (com.emc.storageos.volumecontroller.ControllerException)4 FilePolicyAssignWorkflowCompleter (com.emc.storageos.volumecontroller.impl.file.FilePolicyAssignWorkflowCompleter)4 Workflow (com.emc.storageos.workflow.Workflow)4 WorkflowException (com.emc.storageos.workflow.WorkflowException)4 URI (java.net.URI)4 TargetAssociation (com.emc.storageos.fileorchestrationcontroller.FileStorageSystemAssociation.TargetAssociation)2