use of com.emc.storageos.isilon.restapi.IsilonSyncPolicy in project coprhd-controller by CoprHD.
the class IsilonMirrorOperations method doResumeReplicationPolicy.
/**
* Call to isilon to resume replication session
*
* @param system
* @param policyName
* @return
*/
public BiosCommandResult doResumeReplicationPolicy(StorageSystem system, String policyName) {
_log.info("IsilonMirrorOperations - do RESUME ReplicationPolicy started on storagesystem {}", system.getLabel());
try {
IsilonApi isi = getIsilonDevice(system);
IsilonSyncPolicy policy = isi.getReplicationPolicy(policyName);
if (!policy.getEnabled()) {
policy = doEnableReplicationPolicy(isi, policyName);
if (policy.getEnabled()) {
_log.info("Replication Policy - {} ENABLED successfully", policy.toString());
}
}
return BiosCommandResult.createSuccessfulResult();
} catch (IsilonException e) {
_log.error("doStartReplicationPolicy failed.", e);
return BiosCommandResult.createErrorResult(e);
}
}
use of com.emc.storageos.isilon.restapi.IsilonSyncPolicy in project coprhd-controller by CoprHD.
the class IsilonSyncJobResync method poll.
@Override
public JobPollResult poll(JobContext jobContext, long trackingPeriodInMillis) {
try {
IsilonApi isiApiClient = getIsilonRestClient(jobContext);
if (isiApiClient == null) {
String errorMessage = "No Isilon REST API client found for: " + _storageSystemUri;
processTransientError(policyName, trackingPeriodInMillis, errorMessage, null);
} else {
_pollResult.setJobName(_jobName);
_pollResult.setJobId(_taskCompleter.getOpId());
IsilonSyncPolicy policy = isiApiClient.getReplicationPolicy(policyName);
IsilonSyncPolicy.JobState policyState = policy.getLastJobState();
if (policyState.equals(JobState.running)) {
_status = JobStatus.IN_PROGRESS;
} else if (policyState.equals(JobState.finished) && !policy.getEnabled()) {
_status = JobStatus.SUCCESS;
_pollResult.setJobPercentComplete(100);
_logger.info("IsilonSyncIQJob resync-prep for policy: {} succeeded", policyName);
} else if (policyState.equals(JobState.failed)) {
_errorDescription = isiGetReportErrMsg(isiApiClient.getTargetReplicationPolicyReports(policyName).getList());
_pollResult.setJobPercentComplete(100);
_pollResult.setErrorDescription(_errorDescription);
_status = JobStatus.FAILED;
_logger.error("IsilonSyncIQJob: {} failed; Details: {}", policyName, _errorDescription);
}
}
} catch (Exception e) {
processTransientError(policyName, trackingPeriodInMillis, e.getMessage(), e);
} finally {
try {
updateStatus(jobContext);
} catch (Exception e) {
setErrorStatus(e.getMessage());
_logger.error("Problem while trying to update status", e);
}
}
_pollResult.setJobStatus(_status);
return _pollResult;
}
use of com.emc.storageos.isilon.restapi.IsilonSyncPolicy 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.IsilonSyncPolicy 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;
}
}
use of com.emc.storageos.isilon.restapi.IsilonSyncPolicy in project coprhd-controller by CoprHD.
the class IsilonFileStorageDevice method doStartMirrorLink.
@Override
public BiosCommandResult doStartMirrorLink(StorageSystem system, FileShare fs, TaskCompleter completer) {
FileShare sourceFS = null;
FileShare targetFS = null;
StorageSystem sourceSystem = null;
StorageSystem targetSystem = null;
boolean isMirrorPolicy = false;
if (fs.getPersonality().equals(PersonalityTypes.TARGET.name())) {
sourceFS = _dbClient.queryObject(FileShare.class, fs.getParentFileShare());
targetFS = fs;
isMirrorPolicy = true;
} else if (fs.getPersonality().equals(PersonalityTypes.SOURCE.name())) {
sourceFS = fs;
List<String> targetfileUris = new ArrayList<String>();
targetfileUris.addAll(fs.getMirrorfsTargets());
if (!targetfileUris.isEmpty()) {
targetFS = _dbClient.queryObject(FileShare.class, URI.create(targetfileUris.get(0)));
} else {
ServiceError serviceError = DeviceControllerErrors.isilon.unableToGetTargetFileSystem(sourceFS.getLabel());
return BiosCommandResult.createErrorResult(serviceError);
}
}
sourceSystem = _dbClient.queryObject(StorageSystem.class, sourceFS.getStorageDevice());
targetSystem = _dbClient.queryObject(StorageSystem.class, targetFS.getStorageDevice());
PolicyStorageResource policyStrRes = getEquivalentPolicyStorageResource(sourceFS, _dbClient);
if (policyStrRes != null) {
// get the policy details by policy native id
IsilonSyncPolicy syncPolicy = policyNativeIdValidation(sourceSystem, policyStrRes);
String policyName = syncPolicy.getName();
// In case of fail back we need to append _mirror name since we are starting the target FS mirror policy
if (isMirrorPolicy) {
String mirrorPolicyName = syncPolicy.getName();
mirrorPolicyName = mirrorPolicyName.concat(MIRROR_POLICY);
// call start operation on mirror policy from target system to source system
return doStartTargetMirrorPolicy(sourceSystem, policyName, targetSystem, mirrorPolicyName, completer);
} else {
// call action 'start' on source policy
return mirrorOperations.doStartReplicationPolicy(system, policyName, completer);
}
}
ServiceError serviceError = DeviceControllerErrors.isilon.unableToCreateFileShare();
return BiosCommandResult.createErrorResult(serviceError);
}
Aggregations