use of com.emc.storageos.db.client.model.FilePolicy 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);
}
}
use of com.emc.storageos.db.client.model.FilePolicy 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);
}
}
use of com.emc.storageos.db.client.model.FilePolicy in project coprhd-controller by CoprHD.
the class FileOrchestrationDeviceController method getProjectLevelPolices.
/**
* Get the valid policy templates which are applied at project level
*
* @param vpool
* @param project
* @return list of project level policies on the given vpool
*/
private static List<FilePolicy> getProjectLevelPolices(VirtualPool vpool, Project project) {
StringSet projectPolicies = project.getFilePolicies();
List<FilePolicy> filePoliciesToCreate = new ArrayList<FilePolicy>();
if (!CollectionUtils.isEmpty(projectPolicies)) {
for (String projectFilePolicy : projectPolicies) {
FilePolicy filePolicy = s_dbClient.queryObject(FilePolicy.class, URIUtil.uri(projectFilePolicy));
if (filePolicy != null && !filePolicy.getInactive()) {
// The policy should be of for the given vpool as well.
if (NullColumnValueGetter.isNullURI(filePolicy.getFilePolicyVpool()) || !filePolicy.getFilePolicyVpool().toString().equals(vpool.getId().toString())) {
continue;
}
filePoliciesToCreate.add(filePolicy);
}
}
}
return filePoliciesToCreate;
}
use of com.emc.storageos.db.client.model.FilePolicy in project coprhd-controller by CoprHD.
the class FileOrchestrationDeviceController method addStepsForApplyingPolicies.
public String addStepsForApplyingPolicies(Workflow workflow, String waitFor, List<FileDescriptor> fileDescriptors) {
FileDescriptor sourceDescriptors = FileDescriptor.filterByType(fileDescriptors, FileDescriptor.Type.FILE_DATA, FileDescriptor.Type.FILE_MIRROR_SOURCE).get(0);
FileShare sourceFS = s_dbClient.queryObject(FileShare.class, sourceDescriptors.getFsURI());
StorageSystem system = s_dbClient.queryObject(StorageSystem.class, sourceFS.getStorageDevice());
// applying policy is only supported by isilon
if (system != null && system.getSystemType().equalsIgnoreCase(Type.isilon.toString())) {
URI nasServer = null;
if (sourceFS.getVirtualNAS() != null) {
nasServer = sourceFS.getVirtualNAS();
} else {
// Get the physical NAS for the storage system!!
PhysicalNAS pNAS = FileOrchestrationUtils.getSystemPhysicalNAS(s_dbClient, system);
if (pNAS != null) {
nasServer = pNAS.getId();
}
}
if (nasServer == null) {
s_logger.error(String.format("Adding steps to apply policies failed : No Nas server found on system {}", system.getLabel()));
throw DeviceControllerException.exceptions.noNasServerFoundToAddStepsToApplyPolicy(system.getLabel());
}
// Add all the vpool and project level policies to the workflow steps.
// Verify the policy is already applied or not at device control level.
// Create storage device policy only if the policy was not applied for policy path on storage system!!
// Fail to create policy and/or file system, if any policy to be applied at path is invalid!!
VirtualPool vpool = s_dbClient.queryObject(VirtualPool.class, sourceFS.getVirtualPool());
List<FilePolicy> fileVpoolPolicies = getVpoolLevelPolices(vpool);
if (fileVpoolPolicies != null && !fileVpoolPolicies.isEmpty()) {
for (FilePolicy fileVpoolPolicy : fileVpoolPolicies) {
String stepDescription = String.format("creating file policy : %s at : %s level", fileVpoolPolicy.getId(), vpool.getLabel());
String applyFilePolicyStep = workflow.createStepId();
Object[] args = new Object[] { sourceFS.getStorageDevice(), sourceFS.getId(), fileVpoolPolicy.getId() };
waitFor = _fileDeviceController.createMethod(workflow, waitFor, APPLY_FILE_POLICY_METHOD, applyFilePolicyStep, stepDescription, system.getId(), args);
}
}
Project project = s_dbClient.queryObject(Project.class, sourceFS.getProject());
List<FilePolicy> fileProjectPolicies = getProjectLevelPolices(vpool, project);
if (fileProjectPolicies != null && !fileProjectPolicies.isEmpty()) {
for (FilePolicy fileProjectPolicy : fileProjectPolicies) {
String stepDescription = String.format("creating file policy : %s at : %s level", fileProjectPolicy.getId(), project.getLabel());
String applyFilePolicyStep = workflow.createStepId();
Object[] args = new Object[] { sourceFS.getStorageDevice(), sourceFS.getId(), fileProjectPolicy.getId() };
waitFor = _fileDeviceController.createMethod(workflow, waitFor, APPLY_FILE_POLICY_METHOD, applyFilePolicyStep, stepDescription, system.getId(), args);
}
}
}
return waitFor;
}
use of com.emc.storageos.db.client.model.FilePolicy in project coprhd-controller by CoprHD.
the class FileOrchestrationUtils method getReplicationPolices.
/**
* Gives list of replication policies assigned at vpool/project/fs levels
*
* @param dbClient
* @param vpool
* @param project
* @param fs
* @return
*/
public static List<FilePolicy> getReplicationPolices(DbClient dbClient, VirtualPool vpool, Project project, FileShare fs) {
List<FilePolicy> replicationPolicies = new ArrayList<FilePolicy>();
StringSet filePolicies = new StringSet();
// vPool policies
if (vpool.getFilePolicies() != null && !vpool.getFilePolicies().isEmpty()) {
filePolicies.addAll(vpool.getFilePolicies());
}
// Project policies
if (project.getFilePolicies() != null && !project.getFilePolicies().isEmpty()) {
for (String strPolicy : project.getFilePolicies()) {
FilePolicy policy = dbClient.queryObject(FilePolicy.class, URI.create(strPolicy));
if (!NullColumnValueGetter.isNullURI(policy.getFilePolicyVpool()) && policy.getFilePolicyVpool().toString().equalsIgnoreCase(vpool.getId().toString())) {
filePolicies.add(policy.getId().toString());
}
}
}
// fs policies
if (fs != null && fs.getFilePolicies() != null && !fs.getFilePolicies().isEmpty()) {
for (String strPolicy : fs.getFilePolicies()) {
FilePolicy policy = dbClient.queryObject(FilePolicy.class, URI.create(strPolicy));
if (!NullColumnValueGetter.isNullURI(policy.getFilePolicyVpool()) && policy.getFilePolicyVpool().toString().equalsIgnoreCase(vpool.getId().toString())) {
filePolicies.add(policy.getId().toString());
}
}
}
if (filePolicies != null && !filePolicies.isEmpty()) {
for (String strPolicy : filePolicies) {
FilePolicy filePolicy = dbClient.queryObject(FilePolicy.class, URIUtil.uri(strPolicy));
if (FilePolicyType.file_replication.name().equalsIgnoreCase(filePolicy.getFilePolicyType())) {
replicationPolicies.add(filePolicy);
}
}
} else {
if (fs != null) {
_log.info("No replication policy assigned to vpool {} , project {} and fs {}", vpool.getLabel(), project.getLabel(), fs.getLabel());
} else {
_log.info("No replication policy assigned to vpool {} and project {} ", vpool.getLabel(), project.getLabel());
}
}
return replicationPolicies;
}
Aggregations