use of com.emc.storageos.isilon.restapi.IsilonException in project coprhd-controller by CoprHD.
the class IsilonMirrorOperations method doTestReplicationPolicy.
/**
* Test Replication Connection and policy
*
* @param system
* @param policyName
* @return
*/
public BiosCommandResult doTestReplicationPolicy(StorageSystem system, String policyName) {
try {
IsilonApi isi = getIsilonDevice(system);
isi.getReplicationPolicy(policyName);
} catch (IsilonException ie) {
ServiceError error = DeviceControllerErrors.isilon.jobFailed("Unable to get the ReplicationPolicy details and message :" + ie.getMessage());
return BiosCommandResult.createErrorResult(error);
}
return BiosCommandResult.createSuccessfulResult();
}
use of com.emc.storageos.isilon.restapi.IsilonException in project coprhd-controller by CoprHD.
the class IsilonMirrorOperations method doRefreshMirrorFileShareLink.
public BiosCommandResult doRefreshMirrorFileShareLink(StorageSystem system, FileShare source, String policyName) throws DeviceControllerException {
IsilonSyncPolicy policy;
IsilonSyncTargetPolicy localTarget = null;
StringSet targets = source.getMirrorfsTargets();
List<URI> targetFSURI = new ArrayList<>();
for (String target : targets) {
targetFSURI.add(URI.create(target));
}
FileShare target = _dbClient.queryObject(FileShare.class, targetFSURI.get(0));
StorageSystem systemTarget = _dbClient.queryObject(StorageSystem.class, target.getStorageDevice());
try {
IsilonApi isiPrimary = getIsilonDevice(system);
IsilonApi isiSecondary = getIsilonDevice(systemTarget);
policy = isiPrimary.getReplicationPolicy(policyName);
if (policy.getLastStarted() != null) {
localTarget = isiSecondary.getTargetReplicationPolicy(policyName);
}
if (policy.getLastStarted() == null) {
source.setMirrorStatus(MirrorStatus.UNKNOWN.toString());
} else if (!policy.getEnabled() || policy.getLastJobState().equals(JobState.paused)) {
source.setMirrorStatus(MirrorStatus.PAUSED.toString());
} else if (localTarget.getFoFbState().equals(FOFB_STATES.writes_enabled)) {
source.setMirrorStatus(MirrorStatus.FAILED_OVER.toString());
} else if (policy.getEnabled() && policy.getLastJobState().equals(JobState.finished) && localTarget.getFoFbState().equals(FOFB_STATES.writes_disabled)) {
source.setMirrorStatus(MirrorStatus.SYNCHRONIZED.toString());
} else if (policy.getLastJobState().equals(JobState.running)) {
source.setMirrorStatus(MirrorStatus.IN_SYNC.toString());
} else if (policy.getLastJobState().equals(JobState.failed) || policy.getLastJobState().equals(JobState.needs_attention)) {
source.setMirrorStatus(MirrorStatus.ERROR.toString());
}
_dbClient.updateObject(source);
return BiosCommandResult.createSuccessfulResult();
} catch (IsilonException e) {
_log.error("refresh mirror satus failed.", e);
return BiosCommandResult.createErrorResult(e);
}
}
use of com.emc.storageos.isilon.restapi.IsilonException in project coprhd-controller by CoprHD.
the class IsilonMirrorOperations method doStartReplicationPolicy.
/**
* Call to isilon to start replication session
*
* @param system
* @param policyName
* @return
*/
public BiosCommandResult doStartReplicationPolicy(StorageSystem system, String policyName, TaskCompleter taskCompleter) {
_log.info("IsilonMirrorOperations - doStartReplicationPolicy started on storagesystem {}", system.getLabel());
try {
IsilonApi isi = getIsilonDevice(system);
IsilonSyncPolicy policy = isi.getReplicationPolicy(policyName);
IsilonSyncPolicy.JobState policyState = policy.getLastJobState();
if (!policy.getEnabled()) {
policy = doEnableReplicationPolicy(isi, policyName);
if (policy.getEnabled()) {
_log.info("Replication Policy - {} ENABLED successfully", policy.toString());
}
}
if (!policyState.equals(JobState.running) || !policyState.equals(JobState.paused) || !policyState.equals(JobState.resumed)) {
IsilonSyncJob job = new IsilonSyncJob();
job.setId(policyName);
isi.modifyReplicationJob(job);
policy = isi.getReplicationPolicy(policyName);
IsilonSyncJobStart isiSyncJobStart = new IsilonSyncJobStart(policyName, system.getId(), taskCompleter, policyName);
try {
ControllerServiceImpl.enqueueJob(new QueueJob(isiSyncJobStart));
return BiosCommandResult.createPendingResult();
} catch (Exception ex) {
_log.error("Start Replication Job Failed ", ex);
ServiceError error = DeviceControllerErrors.isilon.jobFailed("Start Replication Job Failed as:" + ex.getMessage());
if (taskCompleter != null) {
taskCompleter.error(_dbClient, error);
}
return BiosCommandResult.createErrorResult(error);
}
} else {
_log.error("Replication Policy - {} can't be STARTED because policy is in {} state", policyName, policyState);
ServiceError error = DeviceControllerErrors.isilon.jobFailed("doStartReplicationPolicy as : Replication Policy can't be STARTED because " + "policy is already in Active state");
return BiosCommandResult.createErrorResult(error);
}
} catch (IsilonException e) {
_log.error("doStartReplicationPolicy failed.", e);
return BiosCommandResult.createErrorResult(e);
}
}
use of com.emc.storageos.isilon.restapi.IsilonException in project coprhd-controller by CoprHD.
the class IsilonMirrorOperations method doResyncPrep.
/**
* Call to resync-prep
*
* @param system
* @param policyName
* @param completer
* @return
* @throws IsilonException
*/
public BiosCommandResult doResyncPrep(StorageSystem system, String policyName, TaskCompleter completer) throws IsilonException {
try {
_log.info("resync-prep between source file system to target file system started and device ip:", system.getIpAddress());
IsilonApi isi = getIsilonDevice(system);
IsilonSyncPolicy syncPolicy = isi.getReplicationPolicy(policyName);
// Before 'resync-prep' operation, Original source to target policy should be enabled.
if (!syncPolicy.getEnabled()) {
_log.info("Policy {} is in disabled state, enabling the policy before do resync-prep", policyName);
syncPolicy = doEnableReplicationPolicy(isi, policyName);
_log.info("Sleeping for 40 seconds for cancel operation to complete...");
TimeUnit.SECONDS.sleep(40);
syncPolicy = isi.getReplicationPolicy(policyName);
_log.info("Replication Policy -{} Enabled successfully.", syncPolicy.toString());
}
IsilonSyncJob job = new IsilonSyncJob();
job.setId(policyName);
job.setAction(Action.resync_prep);
isi.modifyReplicationJob(job);
IsilonSyncJobResync isilonSyncJobResync = new IsilonSyncJobResync(policyName, system.getId(), completer);
ControllerServiceImpl.enqueueJob(new QueueJob(isilonSyncJobResync));
return BiosCommandResult.createPendingResult();
} catch (Exception ex) {
_log.error("Resync-Prep Failed", ex);
ServiceError error = DeviceControllerErrors.isilon.jobFailed("Resync-Prep FAILED as : " + ex.getMessage());
if (completer != null) {
completer.error(_dbClient, error);
}
return BiosCommandResult.createErrorResult(error);
}
}
use of com.emc.storageos.isilon.restapi.IsilonException in project coprhd-controller by CoprHD.
the class IsilonMirrorOperations method deleteMirrorFileShareLink.
public void deleteMirrorFileShareLink(StorageSystem system, URI source, URI target, TaskCompleter completer) throws DeviceControllerException {
IsilonSyncPolicy policy;
IsilonApi isi = null;
BiosCommandResult cmdResult = null;
FileShare targetFileShare = _dbClient.queryObject(FileShare.class, target);
FileShare sourceFileShare = _dbClient.queryObject(FileShare.class, source);
String policyName = targetFileShare.getLabel();
StorageSystem sourceStorageSystem = _dbClient.queryObject(StorageSystem.class, sourceFileShare.getStorageDevice());
isi = getIsilonDevice(sourceStorageSystem);
try {
policy = isi.getReplicationPolicy(policyName);
} catch (IsilonException e) {
_log.info("Not able to get policy : {} due to : {} ", policyName, e.getMessage());
completer.ready(_dbClient);
WorkflowStepCompleter.stepSucceded(completer.getOpId());
return;
}
if (policy != null) {
cmdResult = dodeleteReplicationPolicy(system, policyName);
}
// Check if mirror policy exists on target system if yes, delete it..
if (cmdResult != null && cmdResult.getCommandSuccess()) {
StorageSystem targetStorageSystem = _dbClient.queryObject(StorageSystem.class, targetFileShare.getStorageDevice());
isi = getIsilonDevice(targetStorageSystem);
String mirrorPolicyName = policyName.concat("_mirror");
try {
policy = isi.getReplicationPolicy(mirrorPolicyName);
} catch (IsilonException e) {
_log.info("Mirror policy named : {} not found on the target system", mirrorPolicyName);
completer.ready(_dbClient);
WorkflowStepCompleter.stepSucceded(completer.getOpId());
return;
}
if (policy != null) {
cmdResult = dodeleteReplicationPolicy(targetStorageSystem, mirrorPolicyName);
}
}
if (cmdResult != null && cmdResult.getCommandSuccess()) {
completer.ready(_dbClient);
WorkflowStepCompleter.stepSucceded(completer.getOpId());
} else {
completer.error(_dbClient, cmdResult.getServiceCoded());
}
}
Aggregations