Search in sources :

Example 1 with TargetAssociation

use of com.emc.storageos.fileorchestrationcontroller.FileStorageSystemAssociation.TargetAssociation 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 TargetAssociation

use of com.emc.storageos.fileorchestrationcontroller.FileStorageSystemAssociation.TargetAssociation 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 TargetAssociation

use of com.emc.storageos.fileorchestrationcontroller.FileStorageSystemAssociation.TargetAssociation in project coprhd-controller by CoprHD.

the class FilePolicyService method convertRecommendationsToStorageSystemAssociations.

private List<FileStorageSystemAssociation> convertRecommendationsToStorageSystemAssociations(List<FileRecommendation> recs, String appliedAt, URI vPoolURI, URI projectURI) {
    List<FileStorageSystemAssociation> associations = new ArrayList<FileStorageSystemAssociation>();
    for (FileRecommendation rec : recs) {
        FileMirrorRecommendation mirrorRec = (FileMirrorRecommendation) rec;
        FileStorageSystemAssociation association = new FileStorageSystemAssociation();
        association.setSourceSystem(mirrorRec.getSourceStorageSystem());
        association.setSourceVNAS(mirrorRec.getvNAS());
        if (appliedAt.equalsIgnoreCase(FilePolicyApplyLevel.vpool.name())) {
            association.setAppliedAtResource(vPoolURI);
        } else if (appliedAt.equalsIgnoreCase(FilePolicyApplyLevel.project.name())) {
            association.setProjectvPool(vPoolURI);
            association.setAppliedAtResource(projectURI);
        }
        Map<URI, Target> virtualArrayTargetMap = mirrorRec.getVirtualArrayTargetMap();
        // Getting the first target because we support one-to-one replication now.
        URI targetVArray = virtualArrayTargetMap.entrySet().iterator().next().getKey();
        Target target = virtualArrayTargetMap.entrySet().iterator().next().getValue();
        URI targetStorageDevice = target.getTargetStorageDevice();
        URI targetVNasURI = target.getTargetvNASURI();
        TargetAssociation targetAssociation = new TargetAssociation();
        targetAssociation.setStorageSystemURI(targetStorageDevice);
        targetAssociation.setvArrayURI(targetVArray);
        targetAssociation.setvNASURI(targetVNasURI);
        association.addTargetAssociation(targetAssociation);
        associations.add(association);
    }
    return associations;
}
Also used : FileStorageSystemAssociation(com.emc.storageos.fileorchestrationcontroller.FileStorageSystemAssociation) Target(com.emc.storageos.api.service.impl.placement.FileMirrorRecommendation.Target) FileRecommendation(com.emc.storageos.api.service.impl.placement.FileRecommendation) TargetAssociation(com.emc.storageos.fileorchestrationcontroller.FileStorageSystemAssociation.TargetAssociation) ArrayList(java.util.ArrayList) FileMirrorRecommendation(com.emc.storageos.api.service.impl.placement.FileMirrorRecommendation) URI(java.net.URI)

Aggregations

TargetAssociation (com.emc.storageos.fileorchestrationcontroller.FileStorageSystemAssociation.TargetAssociation)3 URI (java.net.URI)3 FileObject (com.emc.storageos.db.client.model.FileObject)2 FilePolicy (com.emc.storageos.db.client.model.FilePolicy)2 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)2 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)2 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)2 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)2 ControllerException (com.emc.storageos.volumecontroller.ControllerException)2 FilePolicyAssignWorkflowCompleter (com.emc.storageos.volumecontroller.impl.file.FilePolicyAssignWorkflowCompleter)2 Workflow (com.emc.storageos.workflow.Workflow)2 WorkflowException (com.emc.storageos.workflow.WorkflowException)2 FileMirrorRecommendation (com.emc.storageos.api.service.impl.placement.FileMirrorRecommendation)1 Target (com.emc.storageos.api.service.impl.placement.FileMirrorRecommendation.Target)1 FileRecommendation (com.emc.storageos.api.service.impl.placement.FileRecommendation)1 FileStorageSystemAssociation (com.emc.storageos.fileorchestrationcontroller.FileStorageSystemAssociation)1 ArrayList (java.util.ArrayList)1