Search in sources :

Example 11 with IsilonSyncPolicy

use of com.emc.storageos.isilon.restapi.IsilonSyncPolicy 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 12 with IsilonSyncPolicy

use of com.emc.storageos.isilon.restapi.IsilonSyncPolicy 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 13 with IsilonSyncPolicy

use of com.emc.storageos.isilon.restapi.IsilonSyncPolicy 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 14 with IsilonSyncPolicy

use of com.emc.storageos.isilon.restapi.IsilonSyncPolicy in project coprhd-controller by CoprHD.

the class IsilonMirrorOperations method doEnableReplicationPolicy.

/**
 * Enable the Isilon syncIQ policy
 *
 * @param isi
 * @param policyName
 * @return
 */
IsilonSyncPolicy doEnableReplicationPolicy(IsilonApi isi, String policyName) {
    IsilonSyncPolicy modifiedPolicy = new IsilonSyncPolicy();
    modifiedPolicy.setEnabled(true);
    IsilonSyncPolicy policy = isi.getReplicationPolicy(policyName);
    if (null != policy && !policy.getEnabled()) {
        isi.modifyReplicationPolicy(policyName, modifiedPolicy);
        policy = isi.getReplicationPolicy(policyName);
    }
    _log.info("Replication Policy -{}  enabled successfully.", policy.toString());
    return policy;
}
Also used : IsilonSyncPolicy(com.emc.storageos.isilon.restapi.IsilonSyncPolicy)

Example 15 with IsilonSyncPolicy

use of com.emc.storageos.isilon.restapi.IsilonSyncPolicy 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)

Aggregations

IsilonSyncPolicy (com.emc.storageos.isilon.restapi.IsilonSyncPolicy)25 IsilonApi (com.emc.storageos.isilon.restapi.IsilonApi)13 IsilonException (com.emc.storageos.isilon.restapi.IsilonException)13 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)12 PolicyStorageResource (com.emc.storageos.db.client.model.PolicyStorageResource)8 JobState (com.emc.storageos.isilon.restapi.IsilonSyncPolicy.JobState)7 FileShare (com.emc.storageos.db.client.model.FileShare)6 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)6 BiosCommandResult (com.emc.storageos.volumecontroller.impl.BiosCommandResult)5 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)4 ArrayList (java.util.ArrayList)4 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)3 IsilonList (com.emc.storageos.isilon.restapi.IsilonApi.IsilonList)3 IsilonSyncPolicy8Above (com.emc.storageos.isilon.restapi.IsilonSyncPolicy8Above)3 URISyntaxException (java.net.URISyntaxException)3 List (java.util.List)3 FilePolicy (com.emc.storageos.db.client.model.FilePolicy)2 VirtualNAS (com.emc.storageos.db.client.model.VirtualNAS)2 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)2 IsilonSyncJob (com.emc.storageos.isilon.restapi.IsilonSyncJob)2