Search in sources :

Example 26 with IsilonApi

use of com.emc.storageos.isilon.restapi.IsilonApi 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);
    }
}
Also used : IsilonSyncTargetPolicy(com.emc.storageos.isilon.restapi.IsilonSyncTargetPolicy) StringSet(com.emc.storageos.db.client.model.StringSet) ArrayList(java.util.ArrayList) URI(java.net.URI) FileShare(com.emc.storageos.db.client.model.FileShare) IsilonApi(com.emc.storageos.isilon.restapi.IsilonApi) IsilonSyncPolicy(com.emc.storageos.isilon.restapi.IsilonSyncPolicy) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) IsilonException(com.emc.storageos.isilon.restapi.IsilonException)

Example 27 with IsilonApi

use of com.emc.storageos.isilon.restapi.IsilonApi 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);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) IsilonSyncJobStart(com.emc.storageos.volumecontroller.impl.isilon.job.IsilonSyncJobStart) JobState(com.emc.storageos.isilon.restapi.IsilonSyncPolicy.JobState) IsilonSyncJob(com.emc.storageos.isilon.restapi.IsilonSyncJob) IsilonApi(com.emc.storageos.isilon.restapi.IsilonApi) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) IsilonSyncPolicy(com.emc.storageos.isilon.restapi.IsilonSyncPolicy) 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 28 with IsilonApi

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

Example 29 with IsilonApi

use of com.emc.storageos.isilon.restapi.IsilonApi 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());
    }
}
Also used : BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) IsilonApi(com.emc.storageos.isilon.restapi.IsilonApi) FileShare(com.emc.storageos.db.client.model.FileShare) IsilonSyncPolicy(com.emc.storageos.isilon.restapi.IsilonSyncPolicy) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) IsilonException(com.emc.storageos.isilon.restapi.IsilonException)

Example 30 with IsilonApi

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

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