use of com.emc.storageos.isilon.restapi.IsilonSyncPolicy.JobState in project coprhd-controller by CoprHD.
the class IsilonFileStorageDevice method doUnassignFilePolicy.
@Override
public BiosCommandResult doUnassignFilePolicy(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
try {
IsilonApi isi = getIsilonDevice(storage);
FilePolicy filePolicy = args.getFileProtectionPolicy();
PolicyStorageResource policyResource = args.getPolicyStorageResource();
if (filePolicy.getFilePolicyType().equals(FilePolicyType.file_replication.name())) {
// Get the policy details by id
IsilonSyncPolicy isiSyncPolicy = isi.getReplicationPolicy(policyResource.getPolicyNativeId());
if (isiSyncPolicy != null) {
_log.info("deleting Isilon replication policy: {}", isiSyncPolicy.toString());
String policyName = isiSyncPolicy.getName();
JobState policyState = isiSyncPolicy.getLastJobState();
if (policyState.equals(JobState.running) || policyState.equals(JobState.paused)) {
_log.info("Canceling Replication Policy -{} because policy is in - {} state ", policyName, policyState);
// If the policy is running, Cancel the job before unassign policy!!
BiosCommandResult cmdResult = mirrorOperations.doCancelReplicationPolicy(isi, isiSyncPolicy.getName());
if (!cmdResult.isCommandSuccess()) {
return cmdResult;
} else {
// If the replication job still running through exception
isiSyncPolicy = isi.getReplicationPolicy(isiSyncPolicy.getName());
if (isiSyncPolicy.getLastJobState().equals(JobState.running)) {
ServiceError error = DeviceControllerErrors.isilon.jobFailed("Unable Stop Replication policy and policy state :" + isiSyncPolicy.getLastJobState().toString());
return BiosCommandResult.createErrorResult(error);
}
}
}
// delete replication policy using policy id
isi.deleteReplicationPolicy(isiSyncPolicy.getId());
} else {
_log.info("replication policy: {} doesn't exists on storage system", filePolicy.toString());
}
return BiosCommandResult.createSuccessfulResult();
} else if (filePolicy.getFilePolicyType().equals(FilePolicyType.file_snapshot.name())) {
IsilonSnapshotSchedule isiSchedulePolicy = getEquivalentIsilonSnapshotSchedule(isi, policyResource.getResourcePath());
if (isiSchedulePolicy != null) {
_log.info("deleting Isilon Snapshot schedule: {}", isiSchedulePolicy.toString());
isi.deleteSnapshotSchedule(policyResource.getPolicyNativeId());
} else {
_log.info("snapshot schedule: {} doesn't exists on storage system", filePolicy.toString());
}
return BiosCommandResult.createSuccessfulResult();
}
return BiosCommandResult.createSuccessfulResult();
} catch (IsilonException e) {
_log.error("unassign file policy failed.", e);
return BiosCommandResult.createErrorResult(e);
}
}
use of com.emc.storageos.isilon.restapi.IsilonSyncPolicy.JobState 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.IsilonSyncPolicy.JobState in project coprhd-controller by CoprHD.
the class IsilonFileStorageDevice method doPauseLink.
@Override
public BiosCommandResult doPauseLink(StorageSystem system, FileShare source) {
IsilonSyncPolicy syncpolicy = null;
PolicyStorageResource policyStrRes = getEquivalentPolicyStorageResource(source, _dbClient);
if (policyStrRes != null) {
syncpolicy = policyNativeIdValidation(system, policyStrRes);
String policyId = syncpolicy.getId();
JobState policyState = syncpolicy.getLastJobState();
if (policyState.equals(JobState.running) || policyState.equals(JobState.paused)) {
mirrorOperations.doCancelReplicationPolicy(system, policyId);
}
return mirrorOperations.doStopReplicationPolicy(system, policyId);
}
ServiceError serviceError = DeviceControllerErrors.isilon.unableToCreateFileShare();
return BiosCommandResult.createErrorResult(serviceError);
}
use of com.emc.storageos.isilon.restapi.IsilonSyncPolicy.JobState in project coprhd-controller by CoprHD.
the class IsilonMirrorOperations method dodeleteReplicationPolicy.
/**
* Call to device to delete the policy
*
* @param system
* @param policyName
* @return
*/
public BiosCommandResult dodeleteReplicationPolicy(StorageSystem system, String policyName) {
try {
IsilonApi isi = getIsilonDevice(system);
IsilonSyncPolicy policy = isi.getReplicationPolicy(policyName);
JobState policyState = policy.getLastJobState();
if (policyState.equals(JobState.running) || policyState.equals(JobState.paused)) {
_log.info("Canceling Replication Policy -{} because policy is in - {} state ", policyName, policyState);
IsilonSyncPolicy modifiedPolicy = new IsilonSyncPolicy();
modifiedPolicy.setName(policyName);
modifiedPolicy.setLastJobState(JobState.canceled);
isi.modifyReplicationPolicy(policyName, modifiedPolicy);
}
isi.deleteReplicationPolicy(policyName);
_log.info("dodeleteReplicationPolicy - {} finished succesfully", policy.toString());
_log.info("Sleeping for 10 seconds for detach mirror to complete...");
TimeUnit.SECONDS.sleep(10);
return BiosCommandResult.createSuccessfulResult();
} catch (IsilonException e) {
return BiosCommandResult.createErrorResult(e);
} catch (InterruptedException e) {
_log.warn("dodeleteReplicationPolicy - {} Interrupted");
return BiosCommandResult.createSuccessfulResult();
}
}
Aggregations