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);
}
}
Aggregations