Search in sources :

Example 31 with IsilonApi

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);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) IsilonSyncTargetPolicy(com.emc.storageos.isilon.restapi.IsilonSyncTargetPolicy) IsilonSyncJob(com.emc.storageos.isilon.restapi.IsilonSyncJob) IsilonSyncJobFailover(com.emc.storageos.volumecontroller.impl.isilon.job.IsilonSyncJobFailover) IsilonApi(com.emc.storageos.isilon.restapi.IsilonApi) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) URISyntaxException(java.net.URISyntaxException) IsilonException(com.emc.storageos.isilon.restapi.IsilonException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) IsilonException(com.emc.storageos.isilon.restapi.IsilonException)

Example 32 with IsilonApi

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;
}
Also used : URISyntaxException(java.net.URISyntaxException) IsilonApi(com.emc.storageos.isilon.restapi.IsilonApi) URI(java.net.URI)

Example 33 with 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;
}
Also used : URISyntaxException(java.net.URISyntaxException) IsilonApi(com.emc.storageos.isilon.restapi.IsilonApi) URI(java.net.URI) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 34 with IsilonApi

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;
}
Also used : IsilonSyncTargetPolicy(com.emc.storageos.isilon.restapi.IsilonSyncTargetPolicy) JobState(com.emc.storageos.isilon.restapi.IsilonSyncPolicy.JobState) IsilonApi(com.emc.storageos.isilon.restapi.IsilonApi) IsilonSyncPolicy(com.emc.storageos.isilon.restapi.IsilonSyncPolicy) URISyntaxException(java.net.URISyntaxException) IsilonException(com.emc.storageos.isilon.restapi.IsilonException)

Example 35 with IsilonApi

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;
}
Also used : JobState(com.emc.storageos.isilon.restapi.IsilonSyncPolicy.JobState) IsilonApi(com.emc.storageos.isilon.restapi.IsilonApi) IsilonSyncPolicy(com.emc.storageos.isilon.restapi.IsilonSyncPolicy)

Aggregations

IsilonApi (com.emc.storageos.isilon.restapi.IsilonApi)81 IsilonException (com.emc.storageos.isilon.restapi.IsilonException)64 URISyntaxException (java.net.URISyntaxException)31 URI (java.net.URI)22 IsilonCollectionException (com.emc.storageos.plugins.metering.isilon.IsilonCollectionException)21 ArrayList (java.util.ArrayList)18 IsilonSyncPolicy (com.emc.storageos.isilon.restapi.IsilonSyncPolicy)14 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)13 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)12 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)12 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)12 IOException (java.io.IOException)12 JSONException (org.codehaus.jettison.json.JSONException)12 FileShare (com.emc.storageos.db.client.model.FileShare)11 BiosCommandResult (com.emc.storageos.volumecontroller.impl.BiosCommandResult)11 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)10 HashMap (java.util.HashMap)10 ControllerException (com.emc.storageos.volumecontroller.ControllerException)9 Test (org.junit.Test)8 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)7