use of com.emc.storageos.isilon.restapi.IsilonApi in project coprhd-controller by CoprHD.
the class IsilonMirrorOperations method doFailover.
/**
* Call to device to failover the policy
*
* @param system
* @param policyName
* @param taskCompleter
* @return
*/
public BiosCommandResult doFailover(StorageSystem system, String policyName, TaskCompleter taskCompleter) {
_log.info("IsilonMirrorOperations - doFailover started ");
try {
IsilonApi isi = getIsilonDevice(system);
IsilonSyncTargetPolicy syncTargetPolicy = isi.getTargetReplicationPolicy(policyName);
if (syncTargetPolicy.getFoFbState().equals(FOFB_STATES.writes_enabled)) {
_log.info("can't perform failover operation on policy: {} because failover is done already", syncTargetPolicy.getName());
return BiosCommandResult.createSuccessfulResult();
}
IsilonSyncJob job = new IsilonSyncJob();
job.setId(policyName);
job.setAction(Action.allow_write);
isi.modifyReplicationJob(job);
IsilonSyncJobFailover isiSyncJobFailover = new IsilonSyncJobFailover(policyName, system.getId(), taskCompleter, policyName);
try {
ControllerServiceImpl.enqueueJob(new QueueJob(isiSyncJobFailover));
return BiosCommandResult.createPendingResult();
} catch (Exception ex) {
_log.error("Failover to Secondary Cluster Failed", ex);
ServiceError error = DeviceControllerErrors.isilon.jobFailed("Failover to Secondary Cluster Failed as :" + ex.getMessage());
if (taskCompleter != null) {
taskCompleter.error(_dbClient, error);
}
return BiosCommandResult.createErrorResult(error);
}
} catch (IsilonException e) {
return BiosCommandResult.createErrorResult(e);
}
}
use of com.emc.storageos.isilon.restapi.IsilonApi in project coprhd-controller by CoprHD.
the class IsilonMirrorOperations method getIsilonDevice.
/**
* Get isilon device represented by the StorageDevice
*
* @param device
* StorageDevice object
* @return IsilonApi object
* @throws IsilonException
*/
private IsilonApi getIsilonDevice(StorageSystem device) throws IsilonException {
IsilonApi isilonAPI;
URI deviceURI;
try {
deviceURI = new URI("https", null, device.getIpAddress(), device.getPortNumber(), "/", null, null);
} catch (URISyntaxException ex) {
throw IsilonException.exceptions.errorCreatingServerURL(device.getIpAddress(), device.getPortNumber(), ex);
}
if (device.getUsername() != null && !device.getUsername().isEmpty()) {
isilonAPI = _factory.getRESTClient(deviceURI, device.getUsername(), device.getPassword());
} else {
isilonAPI = _factory.getRESTClient(deviceURI);
}
return isilonAPI;
}
use of com.emc.storageos.isilon.restapi.IsilonApi in project coprhd-controller by CoprHD.
the class IsilonSyncJobFailover method getIsilonRestClient.
/**
* Get Isilon API client
*
* @param jobContext
* @return
*/
public IsilonApi getIsilonRestClient(JobContext jobContext) {
StorageSystem device = jobContext.getDbClient().queryObject(StorageSystem.class, _storageSystemUri);
if (jobContext.getIsilonApiFactory() != null) {
IsilonApi isilonAPI;
URI deviceURI;
try {
deviceURI = new URI("https", null, device.getIpAddress(), device.getPortNumber(), "/", null, null);
} catch (URISyntaxException ex) {
throw IsilonException.exceptions.errorCreatingServerURL(device.getIpAddress(), device.getPortNumber(), ex);
}
// get rest client
if (device.getUsername() != null && !device.getUsername().isEmpty()) {
isilonAPI = jobContext.getIsilonApiFactory().getRESTClient(deviceURI, device.getUsername(), device.getPassword());
} else {
isilonAPI = jobContext.getIsilonApiFactory().getRESTClient(deviceURI);
}
return isilonAPI;
}
return null;
}
use of com.emc.storageos.isilon.restapi.IsilonApi in project coprhd-controller by CoprHD.
the class IsilonSyncJobFailover method poll.
@Override
public JobPollResult poll(JobContext jobContext, long trackingPeriodInMillis) {
String currentJob = _jobIds.get(0);
try {
IsilonApi isiApiClient = getIsilonRestClient(jobContext);
if (isiApiClient == null) {
String errorMessage = "No Isilon REST API client found for: " + _storageSystemUri;
processTransientError(currentJob, trackingPeriodInMillis, errorMessage, null);
} else {
_pollResult.setJobName(_jobName);
_pollResult.setJobId(_taskCompleter.getOpId());
IsilonSyncTargetPolicy policy = null;
IsilonSyncPolicy.JobState policyState = null;
policy = isiApiClient.getTargetReplicationPolicy(currentJob);
policyState = policy.getLastJobState();
if (policyState != null && policyState.equals(JobState.running) || policy.equals(FOFB_STATES.enabling_writes)) {
_status = JobStatus.IN_PROGRESS;
} else if (policyState != null && policyState.equals(JobState.finished)) {
_status = JobStatus.SUCCESS;
_pollResult.setJobPercentComplete(100);
_logger.info("IsilonSyncIQJob: {} succeeded", currentJob);
} else if (policyState != null && policyState.equals(JobState.failed)) {
_errorDescription = isiGetReportErrMsg(isiApiClient.getTargetReplicationPolicyReports(currentJob).getList());
_pollResult.setJobPercentComplete(100);
_pollResult.setErrorDescription(_errorDescription);
_status = JobStatus.FAILED;
_logger.error("IsilonSyncIQJob: {} failed; Details: {}", currentJob, _errorDescription);
}
}
} catch (Exception e) {
processTransientError(currentJob, 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.IsilonApi 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;
}
Aggregations