Search in sources :

Example 1 with FileProtectionPolicyUpdateCompleter

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

the class FileOrchestrationDeviceController method updateFileProtectionPolicy.

@Override
public void updateFileProtectionPolicy(URI policy, FilePolicyUpdateParam param, String taskId) {
    FilePolicy filePolicy = s_dbClient.queryObject(FilePolicy.class, policy);
    String opName = ResourceOperationTypeEnum.UPDATE_FILE_PROTECTION_POLICY.getName();
    FileProtectionPolicyUpdateCompleter completer = new FileProtectionPolicyUpdateCompleter(policy, taskId);
    try {
        String waitFor = null;
        Workflow workflow = _workflowService.getNewWorkflow(this, UPDATE_FILE_POLICY_WF_NAME, false, taskId, completer);
        completer.setWorkFlowId(workflow.getWorkflowURI());
        // Get the file policy storage resources!!!
        List<PolicyStorageResource> policyStorageResources = FileOrchestrationUtils.getFilePolicyStorageResources(s_dbClient, filePolicy);
        if (policyStorageResources != null && !policyStorageResources.isEmpty()) {
            s_logger.info("Generating steps for updating file policy {} ", filePolicy.getFilePolicyName());
            for (PolicyStorageResource policyStorageRes : policyStorageResources) {
                StorageSystem system = s_dbClient.queryObject(StorageSystem.class, policyStorageRes.getStorageSystem());
                String stepId = workflow.createStepId();
                String stepDes = String.format("Updating policy on storage system %s, at path: %s", system.getLabel(), policyStorageRes.getResourcePath());
                Object[] args = new Object[] { policyStorageRes.getStorageSystem(), policy, policyStorageRes.getId(), param };
                // Try to update all storage system policies
                // Dont use waitFor for next step!!!
                _fileDeviceController.createMethod(workflow, waitFor, UPDATE_STORAGE_SYSTEM_FILE_PROTECTION_POLICY_METHOD, stepId, stepDes, policyStorageRes.getStorageSystem(), args);
            }
            String successMessage = String.format("Updating file policy {} is successful.", filePolicy.getFilePolicyName());
            workflow.executePlan(completer, successMessage);
        } else {
            s_logger.info("No File Policy Storage resource for policy {} to update", filePolicy.getFilePolicyName());
        }
    } catch (Exception ex) {
        s_logger.error(String.format("Updating file protection policy {} failed", filePolicy.getFilePolicyName()), ex);
        ServiceError serviceError = DeviceControllerException.errors.updateFilePolicyFailed(filePolicy.toString(), ex);
        completer.error(s_dbClient, _locker, serviceError);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) FilePolicy(com.emc.storageos.db.client.model.FilePolicy) FileProtectionPolicyUpdateCompleter(com.emc.storageos.volumecontroller.impl.file.FileProtectionPolicyUpdateCompleter) Workflow(com.emc.storageos.workflow.Workflow) FileObject(com.emc.storageos.db.client.model.FileObject) PolicyStorageResource(com.emc.storageos.db.client.model.PolicyStorageResource) 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)1 FilePolicy (com.emc.storageos.db.client.model.FilePolicy)1 PolicyStorageResource (com.emc.storageos.db.client.model.PolicyStorageResource)1 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)1 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)1 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)1 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)1 ControllerException (com.emc.storageos.volumecontroller.ControllerException)1 FileProtectionPolicyUpdateCompleter (com.emc.storageos.volumecontroller.impl.file.FileProtectionPolicyUpdateCompleter)1 Workflow (com.emc.storageos.workflow.Workflow)1 WorkflowException (com.emc.storageos.workflow.WorkflowException)1