use of com.emc.storageos.isilon.restapi.IsilonSyncPolicy8Above in project coprhd-controller by CoprHD.
the class IsilonFileStorageDevice method updateStorageSystemFileReplicationPolicy.
private BiosCommandResult updateStorageSystemFileReplicationPolicy(IsilonApi isi, PolicyStorageResource policyRes, FilePolicy viprPolicy, FilePolicyUpdateParam policyUpdateParam, boolean isVersion8above) {
try {
IsilonSyncPolicy syncpolicyAtPath = getSyncPolicy(isi, policyRes);
if (syncpolicyAtPath != null) {
_log.info("Found SyncIQ policy{} for path {} ", syncpolicyAtPath.getName(), syncpolicyAtPath.getSourceRootPath());
boolean bModifyPolicy = false;
// Temp policy to store modified values.
IsilonSyncPolicy modifiedPolicy = new IsilonSyncPolicy();
modifiedPolicy.setName(syncpolicyAtPath.getName());
if (policyUpdateParam.getNumWorkerThreads() > 0 && syncpolicyAtPath.getWorkersPerNode() != policyUpdateParam.getNumWorkerThreads()) {
_log.debug("Changing NumWorkerThreads to {} ", policyUpdateParam.getNumWorkerThreads());
modifiedPolicy.setWorkersPerNode(policyUpdateParam.getNumWorkerThreads());
bModifyPolicy = true;
}
if (policyUpdateParam.getPolicyDescription() != null && !policyUpdateParam.getPolicyDescription().isEmpty() && !policyUpdateParam.getPolicyDescription().equalsIgnoreCase(syncpolicyAtPath.getDescription())) {
modifiedPolicy.setDescription(policyUpdateParam.getPolicyDescription());
bModifyPolicy = true;
}
if (policyUpdateParam.getReplicationPolicyParams() != null) {
FileReplicationPolicyParam replParam = policyUpdateParam.getReplicationPolicyParams();
if (replParam.getReplicationCopyMode() != null && !replParam.getReplicationCopyMode().isEmpty() && !FileReplicationCopyMode.ASYNC.name().equalsIgnoreCase(replParam.getReplicationCopyMode())) {
_log.warn("Replication copy mode {} is not supported by Isilon {} ", replParam.getReplicationCopyMode());
}
if (replParam.getPolicySchedule() != null) {
String strSchedule = getIsilonPolicySchedule(replParam.getPolicySchedule());
if (strSchedule != null && !strSchedule.isEmpty() && !strSchedule.equalsIgnoreCase(syncpolicyAtPath.getSchedule())) {
modifiedPolicy.setSchedule(strSchedule);
bModifyPolicy = true;
}
}
}
/*
* Changes made for addressing new fields added in sync Policy in OneFSv 8.0 and above
*/
IsilonSyncPolicy8Above modifiedPolicycopy = new IsilonSyncPolicy8Above();
IsilonSyncPolicy8Above syncpolicyAtPath8 = null;
if (isVersion8above && policyUpdateParam.getPriority() != null) {
syncpolicyAtPath8 = isi.getReplicationPolicy8above(syncpolicyAtPath.getName());
modifiedPolicycopy = modifiedPolicycopy.copy(modifiedPolicy);
if (syncpolicyAtPath8 != null) {
if (FilePolicyPriority.valueOf(policyUpdateParam.getPriority()).ordinal() != syncpolicyAtPath8.getPriority()) {
modifiedPolicycopy.setPriority(FilePolicyPriority.valueOf(policyUpdateParam.getPriority()).ordinal());
bModifyPolicy = true;
}
}
}
if (bModifyPolicy) {
JobState policyState = syncpolicyAtPath.getLastJobState();
if (!policyState.equals(JobState.running) && !policyState.equals(JobState.paused)) {
if (isVersion8above) {
// Possible NPE..syncpolicyAtPath8 can be null here if policyUpdateParam.getPriority() is NULL..
// Better to use syncpolicyAtPath.getName()..
isi.modifyReplicationPolicy8above(syncpolicyAtPath.getName(), modifiedPolicycopy);
_log.info("Modify Replication Policy- {} finished successfully", syncpolicyAtPath.getName());
} else {
isi.modifyReplicationPolicy(syncpolicyAtPath.getName(), modifiedPolicy);
_log.info("Modify Replication Policy- {} finished successfully", syncpolicyAtPath.getName());
}
// set native id and policy existing and then update the DB
if (null == policyRes.getName()) {
// before fix,
policyRes.setLabel(policyRes.getPolicyNativeId());
policyRes.setName(syncpolicyAtPath.getName());
policyRes.setPolicyNativeId(syncpolicyAtPath.getId());
_dbClient.updateObject(policyRes);
} else {
policyRes.setName(syncpolicyAtPath.getName());
_dbClient.updateObject(policyRes);
}
return BiosCommandResult.createSuccessfulResult();
} else {
_log.error("Replication Policy - {} can't be MODIFIED because policy has an active job", syncpolicyAtPath.getName());
ServiceError error = DeviceControllerErrors.isilon.jobFailed("doModifyReplicationPolicy as : The policy has an active job and cannot be modified.");
return BiosCommandResult.createErrorResult(error);
}
} else {
_log.info("No parameters changed to modify Replication Policy- {} finished successfully", syncpolicyAtPath.getName());
return BiosCommandResult.createSuccessfulResult();
}
} else {
_log.error("No SyncIQ policy found at path {} , Hence can't be MODIFIED", policyRes.getResourcePath());
ServiceError error = DeviceControllerErrors.isilon.jobFailed("doModifyReplicationPolicy as : No SyncIQ policy found at given path.");
return BiosCommandResult.createErrorResult(error);
}
} catch (IsilonException e) {
return BiosCommandResult.createErrorResult(e);
}
}
use of com.emc.storageos.isilon.restapi.IsilonSyncPolicy8Above in project coprhd-controller by CoprHD.
the class IsilonFileStorageDevice method doApplyFileReplicationPolicy.
private BiosCommandResult doApplyFileReplicationPolicy(FilePolicy filePolicy, FileDeviceInputOutput args, FileShare fs, StorageSystem storageObj) {
IsilonApi isi = getIsilonDevice(storageObj);
FileShare targetFS = null;
String sourcePath = generatePathForPolicy(filePolicy, fs, args);
String scheduleValue = getIsilonPolicySchedule(filePolicy);
String targetPath = null;
String targetHost = null;
StorageSystem targetSystem = null;
NASServer targetNasServer = null;
if (fs.getPersonality() != null && PersonalityTypes.SOURCE.name().equalsIgnoreCase(fs.getPersonality())) {
String targetFs = fs.getMirrorfsTargets().iterator().next();
targetFS = _dbClient.queryObject(FileShare.class, URI.create(targetFs));
targetPath = generatePathForPolicy(filePolicy, targetFS, args);
// Add the suffix only for local replication policy at higher level
if (filePolicy.getFileReplicationType().equalsIgnoreCase(FileReplicationType.LOCAL.name()) && !FilePolicyApplyLevel.file_system.name().equalsIgnoreCase(filePolicy.getApplyAt())) {
targetPath = targetPath + "_localTarget";
}
// Get the target smart connect zone!!
targetHost = FileOrchestrationUtils.getTargetHostPortForReplication(_dbClient, targetFS);
targetSystem = _dbClient.queryObject(StorageSystem.class, targetFS.getStorageDevice());
if (targetFS.getVirtualNAS() != null) {
targetNasServer = _dbClient.queryObject(VirtualNAS.class, targetFS.getVirtualNAS());
}
}
IsilonApi isiApiOfTarget = getIsilonDevice(targetSystem);
String targetClusterName = isiApiOfTarget.getClusterConfig().getName();
String sourceClustername = isi.getClusterConfig().getName();
String policyName = FileOrchestrationUtils.generateNameForSyncIQPolicy(sourceClustername, targetClusterName, filePolicy, fs, args, sourcePath);
IsilonSyncPolicy isiSynIQPolicy = getEquivalentIsilonSyncIQPolicy(isi, sourcePath);
PolicyStorageResource policyStorageResource = null;
if (isiSynIQPolicy != null) {
boolean validPolicy = validateIsilonReplicationPolicy(isiSynIQPolicy, filePolicy, targetPath, targetSystem, storageObj);
if (validPolicy) {
_log.info("File Policy {} is already applied and running.", filePolicy.toString());
// Verify the policy was mapped to FileStorageResource
if (null == FileOrchestrationUtils.findPolicyStorageResourceByNativeId(_dbClient, storageObj, filePolicy, args, sourcePath)) {
_log.info("Isilon policy found for {}, creating policy storage resouce to further management", filePolicy.getFilePolicyName());
// update the policy object in DB
policyStorageResource = FileOrchestrationUtils.updatePolicyStorageResource(_dbClient, storageObj, filePolicy, args, sourcePath, isiSynIQPolicy.getName(), isiSynIQPolicy.getId(), targetSystem, targetNasServer, targetPath);
// for existing policy's on device
// label - label is generated from ViPR
policyStorageResource.setLabel(policyName);
_dbClient.updateObject(policyStorageResource);
}
return BiosCommandResult.createSuccessfulResult();
} else {
throw DeviceControllerException.exceptions.assignFilePolicyFailed(filePolicy.getFilePolicyName(), filePolicy.getApplyAt(), "File policy and Isilon syncIQ policy differs for path: " + sourcePath);
}
} else {
IsilonSyncPolicy policy = new IsilonSyncPolicy(policyName, sourcePath, targetPath, targetHost, IsilonSyncPolicy.Action.sync);
IsilonSyncPolicy8Above policycopy = new IsilonSyncPolicy8Above();
if (scheduleValue != null && !scheduleValue.isEmpty()) {
policy.setSchedule(scheduleValue);
}
if (filePolicy.getFilePolicyDescription() != null) {
policy.setDescription(filePolicy.getFilePolicyDescription());
}
if (filePolicy.getNumWorkerThreads() != null && filePolicy.getNumWorkerThreads() > 0) {
policy.setWorkersPerNode(filePolicy.getNumWorkerThreads().intValue());
}
policy.setEnabled(true);
String policyId = null;
if (VersionChecker.verifyVersionDetails(ONEFS_V8, storageObj.getFirmwareVersion()) >= 0) {
if (filePolicy.getPriority() != null) {
policycopy = policycopy.copy(policy);
policycopy.setPriority(FilePolicyPriority.valueOf(filePolicy.getPriority()).ordinal());
}
policyId = isi.createReplicationPolicy8above(policycopy);
} else {
policyId = isi.createReplicationPolicy(policy);
}
if (policyId != null) {
_log.info("Isilon File Policy {} created successfully with id {}", policyName, policyId);
// update the policy object in DB
FileOrchestrationUtils.updatePolicyStorageResource(_dbClient, storageObj, filePolicy, args, sourcePath, policyName, policyId, targetSystem, targetNasServer, targetPath);
return BiosCommandResult.createSuccessfulResult();
}
}
return BiosCommandResult.createSuccessfulResult();
}
use of com.emc.storageos.isilon.restapi.IsilonSyncPolicy8Above in project coprhd-controller by CoprHD.
the class IsilonFileStorageDevice method createIsilonSyncPolicy.
private String createIsilonSyncPolicy(StorageSystem storageObj, StorageSystem targetStorage, FilePolicy filePolicy, String sourcePath, String targetPath, String syncPolicyName, FileDeviceInputOutput sourceSystemArgs, FileDeviceInputOutput targetSystemArgs) {
String scheduleValue = getIsilonPolicySchedule(filePolicy);
_log.info("File replication policy : {} creation started", filePolicy.toString());
try {
VirtualNAS targetVNas = targetSystemArgs.getvNAS();
URI targetVNasURI = null;
if (targetVNas != null) {
targetVNasURI = targetVNas.getId();
}
String targetHost = FileOrchestrationUtils.getTargetHostPortForReplication(_dbClient, targetStorage.getId(), targetSystemArgs.getVarray().getId(), targetVNasURI);
IsilonApi isi = getIsilonDevice(storageObj);
isi.createDir(sourcePath, true);
IsilonSyncPolicy replicationPolicy = new IsilonSyncPolicy(syncPolicyName, sourcePath, targetPath, targetHost, Action.sync);
if (scheduleValue != null && !scheduleValue.isEmpty()) {
replicationPolicy.setSchedule(scheduleValue);
}
if (filePolicy.getFilePolicyDescription() != null) {
replicationPolicy.setDescription(filePolicy.getFilePolicyDescription());
}
if (filePolicy.getNumWorkerThreads() != null && filePolicy.getNumWorkerThreads() > 0) {
replicationPolicy.setWorkersPerNode(filePolicy.getNumWorkerThreads().intValue());
}
replicationPolicy.setEnabled(true);
replicationPolicy.setSchedule(scheduleValue);
String scheduleId;
if (VersionChecker.verifyVersionDetails(ONEFS_V8, storageObj.getFirmwareVersion()) >= 0) {
IsilonSyncPolicy8Above replicationPolicyCopy = new IsilonSyncPolicy8Above();
replicationPolicyCopy = replicationPolicyCopy.copy(replicationPolicy);
if (filePolicy.getPriority() != null) {
replicationPolicyCopy.setPriority(FilePolicyPriority.valueOf(filePolicy.getPriority()).ordinal());
}
scheduleId = isi.createReplicationPolicy8above(replicationPolicyCopy);
} else {
scheduleId = isi.createReplicationPolicy(replicationPolicy);
}
FileOrchestrationUtils.updatePolicyStorageResource(_dbClient, storageObj, filePolicy, sourceSystemArgs, sourcePath, syncPolicyName, scheduleId, targetStorage, targetSystemArgs.getvNAS(), targetPath);
return scheduleId;
} catch (IsilonException e) {
throw e;
}
}
Aggregations