use of com.emc.storageos.db.client.model.FilePolicy in project coprhd-controller by CoprHD.
the class IsilonFileStorageDevice method listSanpshotByPolicy.
@Override
public BiosCommandResult listSanpshotByPolicy(StorageSystem storageObj, FileDeviceInputOutput args) {
FilePolicy sp = args.getFileProtectionPolicy();
FileShare fs = args.getFs();
String snapshotScheduleName = sp.getFilePolicyName() + "_" + args.getFsName();
if (sp.getPolicyStorageResources() != null && !sp.getPolicyStorageResources().isEmpty()) {
for (String uriResource : sp.getPolicyStorageResources()) {
PolicyStorageResource policyRes = _dbClient.queryObject(PolicyStorageResource.class, URI.create(uriResource));
if (policyRes != null && policyRes.getStorageSystem().equals(storageObj.getId())) {
snapshotScheduleName = policyRes.getPolicyNativeId();
break;
}
}
}
IsilonApi isi = getIsilonDevice(storageObj);
String resumeToken = null;
try {
do {
IsilonList<IsilonSnapshot> snapshots = isi.listSnapshotsCreatedByPolicy(resumeToken, snapshotScheduleName);
if (snapshots != null) {
for (IsilonSnapshot islon_snap : snapshots.getList()) {
_log.info("file policy snapshot is : " + islon_snap.getName());
Snapshot snap = new Snapshot();
snap.setLabel(islon_snap.getName());
snap.setMountPath(islon_snap.getPath());
snap.setName(islon_snap.getName());
snap.setId(URIUtil.createId(Snapshot.class));
snap.setOpStatus(new OpStatusMap());
snap.setProject(new NamedURI(fs.getProject().getURI(), islon_snap.getName()));
snap.setMountPath(getSnapshotPath(islon_snap.getPath(), islon_snap.getName()));
snap.setParent(new NamedURI(fs.getId(), islon_snap.getName()));
StringMap map = new StringMap();
Long createdTime = Long.parseLong(islon_snap.getCreated()) * SEC_IN_MILLI;
String expiresTime = "Never";
if (islon_snap.getExpires() != null && !islon_snap.getExpires().isEmpty()) {
Long expTime = Long.parseLong(islon_snap.getExpires()) * SEC_IN_MILLI;
expiresTime = expTime.toString();
}
map.put("created", createdTime.toString());
map.put("expires", expiresTime);
map.put("schedule", sp.getFilePolicyName());
snap.setExtensions(map);
_dbClient.updateObject(snap);
}
resumeToken = snapshots.getToken();
}
} while (resumeToken != null && !resumeToken.equalsIgnoreCase("null"));
} catch (IsilonException e) {
_log.error("listing snapshot by file policy failed.", e);
return BiosCommandResult.createErrorResult(e);
}
Task task = TaskUtils.findTaskForRequestId(_dbClient, fs.getId(), args.getOpId());
// set task to completed and progress to 100 and store in DB, so waiting thread in apisvc can read it.
task.ready();
task.setProgress(100);
_dbClient.updateObject(task);
return BiosCommandResult.createSuccessfulResult();
}
use of com.emc.storageos.db.client.model.FilePolicy in project coprhd-controller by CoprHD.
the class IsilonFileStorageDevice method getEquivalentPolicyStorageResource.
public static PolicyStorageResource getEquivalentPolicyStorageResource(FileShare fs, DbClient dbClient) {
FilePolicy fp = getReplicationPolicyAppliedOnFS(fs, dbClient);
if (fp != null) {
StringSet policyStrResources = fp.getPolicyStorageResources();
List<URI> policyStrURIs = new ArrayList<>();
for (String policyStrResource : policyStrResources) {
policyStrURIs.add(URI.create(policyStrResource));
}
Iterator<PolicyStorageResource> iterator = dbClient.queryIterativeObjects(PolicyStorageResource.class, policyStrURIs, true);
while (iterator.hasNext()) {
PolicyStorageResource policyRes = iterator.next();
if (policyRes.getAppliedAt().equals(fs.getId()) && policyRes.getStorageSystem().equals(fs.getStorageDevice())) {
_log.info("Found replication policy:{} corresponding storage resource: {} applied to the file system: {}.", fp.getLabel(), policyRes.toString(), fs.getId());
return policyRes;
}
}
}
return null;
}
use of com.emc.storageos.db.client.model.FilePolicy in project coprhd-controller by CoprHD.
the class IsilonFileStorageDevice method updateLocalTargetFileSystemPath.
/**
* @param dbClient
* @param project
* @param storageSystem
* @return
*/
public void updateLocalTargetFileSystemPath(StorageSystem system, FileDeviceInputOutput args) {
VirtualPool vpool = args.getVPool();
Project project = args.getProject();
FileShare fs = args.getFs();
if (fs.getPersonality() != null && fs.getPersonality().equalsIgnoreCase(PersonalityTypes.TARGET.name())) {
List<FilePolicy> replicationPolicies = FileOrchestrationUtils.getReplicationPolices(_dbClient, vpool, project, null);
if (replicationPolicies != null && !replicationPolicies.isEmpty()) {
if (replicationPolicies.size() > 1) {
_log.warn("More than one replication policy found {}", replicationPolicies.size());
} else {
FilePolicy replPolicy = replicationPolicies.get(0);
if (replPolicy.getFileReplicationType().equalsIgnoreCase(FileReplicationType.LOCAL.name())) {
// For local replication, the path should be different
// add localTaget to file path at directory level where the policy is applied!!!
String mountPath = generatePathForLocalTarget(replPolicy, fs, args);
// replace extra forward slash with single one
mountPath = mountPath.replaceAll("/+", "/");
_log.info("Mount path to mount the Isilon File System {}", mountPath);
args.setFsMountPath(mountPath);
args.setFsNativeGuid(args.getFsMountPath());
args.setFsNativeId(args.getFsMountPath());
args.setFsPath(args.getFsMountPath());
}
}
} else if (fs.getLabel().contains("-localTarget")) {
String mountPath = fs.getNativeId() + "_localTarget";
// replace extra forward slash with single one
mountPath = mountPath.replaceAll("/+", "/");
_log.info("Mount path to mount the Isilon File System {}", mountPath);
args.setFsMountPath(mountPath);
args.setFsNativeGuid(args.getFsMountPath());
args.setFsNativeId(args.getFsMountPath());
args.setFsPath(args.getFsMountPath());
}
}
return;
}
use of com.emc.storageos.db.client.model.FilePolicy 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);
}
}
use of com.emc.storageos.db.client.model.FilePolicy 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);
}
}
Aggregations