Search in sources :

Example 6 with IsilonSyncPolicy

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

the class IsilonFileStorageDevice method updateStorageSystemFileReplicationPolicy.

private BiosCommandResult updateStorageSystemFileReplicationPolicy(IsilonApi isi, PolicyStorageResource policyRes, FilePolicy viprPolicy, FilePolicyUpdateParam policyUpdateParam, boolean isVersion8above) {
    try {
        IsilonSyncPolicy syncpolicyAtPath = getSyncPolicy(isi, policyRes);
        if (syncpolicyAtPath != null) {
            _log.info("Found SyncIQ policy{} for path {} ", syncpolicyAtPath.getName(), syncpolicyAtPath.getSourceRootPath());
            boolean bModifyPolicy = false;
            // Temp policy to store modified values.
            IsilonSyncPolicy modifiedPolicy = new IsilonSyncPolicy();
            modifiedPolicy.setName(syncpolicyAtPath.getName());
            if (policyUpdateParam.getNumWorkerThreads() > 0 && syncpolicyAtPath.getWorkersPerNode() != policyUpdateParam.getNumWorkerThreads()) {
                _log.debug("Changing NumWorkerThreads to {} ", policyUpdateParam.getNumWorkerThreads());
                modifiedPolicy.setWorkersPerNode(policyUpdateParam.getNumWorkerThreads());
                bModifyPolicy = true;
            }
            if (policyUpdateParam.getPolicyDescription() != null && !policyUpdateParam.getPolicyDescription().isEmpty() && !policyUpdateParam.getPolicyDescription().equalsIgnoreCase(syncpolicyAtPath.getDescription())) {
                modifiedPolicy.setDescription(policyUpdateParam.getPolicyDescription());
                bModifyPolicy = true;
            }
            if (policyUpdateParam.getReplicationPolicyParams() != null) {
                FileReplicationPolicyParam replParam = policyUpdateParam.getReplicationPolicyParams();
                if (replParam.getReplicationCopyMode() != null && !replParam.getReplicationCopyMode().isEmpty() && !FileReplicationCopyMode.ASYNC.name().equalsIgnoreCase(replParam.getReplicationCopyMode())) {
                    _log.warn("Replication copy mode {} is not supported by Isilon {} ", replParam.getReplicationCopyMode());
                }
                if (replParam.getPolicySchedule() != null) {
                    String strSchedule = getIsilonPolicySchedule(replParam.getPolicySchedule());
                    if (strSchedule != null && !strSchedule.isEmpty() && !strSchedule.equalsIgnoreCase(syncpolicyAtPath.getSchedule())) {
                        modifiedPolicy.setSchedule(strSchedule);
                        bModifyPolicy = true;
                    }
                }
            }
            /*
                 * Changes made for addressing new fields added in sync Policy in OneFSv 8.0 and above
                 */
            IsilonSyncPolicy8Above modifiedPolicycopy = new IsilonSyncPolicy8Above();
            IsilonSyncPolicy8Above syncpolicyAtPath8 = null;
            if (isVersion8above && policyUpdateParam.getPriority() != null) {
                syncpolicyAtPath8 = isi.getReplicationPolicy8above(syncpolicyAtPath.getName());
                modifiedPolicycopy = modifiedPolicycopy.copy(modifiedPolicy);
                if (syncpolicyAtPath8 != null) {
                    if (FilePolicyPriority.valueOf(policyUpdateParam.getPriority()).ordinal() != syncpolicyAtPath8.getPriority()) {
                        modifiedPolicycopy.setPriority(FilePolicyPriority.valueOf(policyUpdateParam.getPriority()).ordinal());
                        bModifyPolicy = true;
                    }
                }
            }
            if (bModifyPolicy) {
                JobState policyState = syncpolicyAtPath.getLastJobState();
                if (!policyState.equals(JobState.running) && !policyState.equals(JobState.paused)) {
                    if (isVersion8above) {
                        // Possible NPE..syncpolicyAtPath8 can be null here if policyUpdateParam.getPriority() is NULL..
                        // Better to use syncpolicyAtPath.getName()..
                        isi.modifyReplicationPolicy8above(syncpolicyAtPath.getName(), modifiedPolicycopy);
                        _log.info("Modify Replication Policy- {} finished successfully", syncpolicyAtPath.getName());
                    } else {
                        isi.modifyReplicationPolicy(syncpolicyAtPath.getName(), modifiedPolicy);
                        _log.info("Modify Replication Policy- {} finished successfully", syncpolicyAtPath.getName());
                    }
                    // set native id and policy existing and then update the DB
                    if (null == policyRes.getName()) {
                        // before fix,
                        policyRes.setLabel(policyRes.getPolicyNativeId());
                        policyRes.setName(syncpolicyAtPath.getName());
                        policyRes.setPolicyNativeId(syncpolicyAtPath.getId());
                        _dbClient.updateObject(policyRes);
                    } else {
                        policyRes.setName(syncpolicyAtPath.getName());
                        _dbClient.updateObject(policyRes);
                    }
                    return BiosCommandResult.createSuccessfulResult();
                } else {
                    _log.error("Replication Policy - {} can't be MODIFIED because policy has an active job", syncpolicyAtPath.getName());
                    ServiceError error = DeviceControllerErrors.isilon.jobFailed("doModifyReplicationPolicy as : The policy has an active job and cannot be modified.");
                    return BiosCommandResult.createErrorResult(error);
                }
            } else {
                _log.info("No parameters changed to modify Replication Policy- {} finished successfully", syncpolicyAtPath.getName());
                return BiosCommandResult.createSuccessfulResult();
            }
        } else {
            _log.error("No SyncIQ policy found at path {} , Hence can't be MODIFIED", policyRes.getResourcePath());
            ServiceError error = DeviceControllerErrors.isilon.jobFailed("doModifyReplicationPolicy as : No SyncIQ policy found at given path.");
            return BiosCommandResult.createErrorResult(error);
        }
    } catch (IsilonException e) {
        return BiosCommandResult.createErrorResult(e);
    }
}
Also used : FileReplicationPolicyParam(com.emc.storageos.model.file.policy.FileReplicationPolicyParam) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) JobState(com.emc.storageos.isilon.restapi.IsilonSyncPolicy.JobState) IsilonSyncPolicy8Above(com.emc.storageos.isilon.restapi.IsilonSyncPolicy8Above) IsilonSyncPolicy(com.emc.storageos.isilon.restapi.IsilonSyncPolicy) IsilonException(com.emc.storageos.isilon.restapi.IsilonException)

Example 7 with IsilonSyncPolicy

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

the class IsilonFileStorageDevice method doResumeLink.

@Override
public BiosCommandResult doResumeLink(StorageSystem system, FileShare source, TaskCompleter completer) {
    IsilonSyncPolicy syncPolicy = null;
    PolicyStorageResource policyStrRes = getEquivalentPolicyStorageResource(source, _dbClient);
    if (policyStrRes != null) {
        syncPolicy = policyNativeIdValidation(system, policyStrRes);
        String policyId = syncPolicy.getId();
        return mirrorOperations.doResumeReplicationPolicy(system, policyId);
    }
    ServiceError serviceError = DeviceControllerErrors.isilon.unableToCreateFileShare();
    return BiosCommandResult.createErrorResult(serviceError);
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) PolicyStorageResource(com.emc.storageos.db.client.model.PolicyStorageResource) IsilonSyncPolicy(com.emc.storageos.isilon.restapi.IsilonSyncPolicy)

Example 8 with IsilonSyncPolicy

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

the class IsilonFileStorageDevice method policyNativeIdValidation.

/**
 * validate policy name
 *
 * @param system - storage system
 * @param policyStrRes -replication policy resource
 */
private IsilonSyncPolicy policyNativeIdValidation(StorageSystem system, PolicyStorageResource policyStrRes) {
    IsilonSyncPolicy syncPolicy = mirrorOperations.getIsilonSyncPolicy(system, policyStrRes.getPolicyNativeId());
    // if policy name is null then name-> nativeid. then update policy details in DB with policy id generated in Isilon device.
    if (policyStrRes.getName() == null || policyStrRes.getName().isEmpty()) {
        _log.info("Replication policy name is null and Updating policy object with name {} and policy id {}", syncPolicy.getName(), policyStrRes.getPolicyNativeId());
        // policy name that is generated from ViPR
        policyStrRes.setLabel(policyStrRes.getPolicyNativeId());
        // get new policy name
        policyStrRes.setName(syncPolicy.getName());
        // policy id generated by isilon device.
        policyStrRes.setPolicyNativeId(syncPolicy.getId());
        _dbClient.updateObject(policyStrRes);
    } else {
        if (!policyStrRes.getName().equals(syncPolicy.getName())) {
            _log.info("Updated the Replication old policy name {} to new policy name {}", policyStrRes.getName(), syncPolicy.getName());
            policyStrRes.setName(syncPolicy.getName());
            _dbClient.updateObject(policyStrRes);
        }
    }
    return syncPolicy;
}
Also used : IsilonSyncPolicy(com.emc.storageos.isilon.restapi.IsilonSyncPolicy)

Example 9 with IsilonSyncPolicy

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

the class IsilonFileStorageDevice method getSyncPolicy.

/**
 * Get Synciq policy from policyStorageResource
 *
 * @param isi - isilonapi object
 * @param policyRes - synciq policy resource
 * @return IsilonSyncPolicy
 */
private IsilonSyncPolicy getSyncPolicy(IsilonApi isi, PolicyStorageResource policyRes) {
    IsilonSyncPolicy syncpolicyAtPath = null;
    // if it existing policy and policy object not updated
    if (null == policyRes.getName() || policyRes.getName().isEmpty()) {
        ArrayList<IsilonSyncPolicy> isiSyncIQPolicies = isi.getReplicationPolicies().getList();
        _log.info("Checking the right syncIQ policy ...");
        for (IsilonSyncPolicy syncIqPolicy : isiSyncIQPolicies) {
            // check for policy path
            if (syncIqPolicy.getSourceRootPath() != null && syncIqPolicy.getSourceRootPath().equalsIgnoreCase(policyRes.getResourcePath()) && syncIqPolicy.getName() != null && syncIqPolicy.getName().equalsIgnoreCase(policyRes.getPolicyNativeId())) {
                syncpolicyAtPath = syncIqPolicy;
                break;
            }
        }
        return syncpolicyAtPath;
    } else {
        return isi.getReplicationPolicy(policyRes.getPolicyNativeId());
    }
}
Also used : IsilonSyncPolicy(com.emc.storageos.isilon.restapi.IsilonSyncPolicy)

Example 10 with IsilonSyncPolicy

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

the class IsilonMirrorOperations method doStopReplicationPolicy.

/**
 * Call to device to stop policy
 *
 * @param system
 * @param policyName
 * @return
 */
public BiosCommandResult doStopReplicationPolicy(IsilonApi isi, String policyName) {
    try {
        IsilonSyncPolicy policy = isi.getReplicationPolicy(policyName);
        if (policy.getLastJobState().equals(JobState.running)) {
            BiosCommandResult cmdResult = doCancelReplicationPolicy(isi, policyName);
            if (!cmdResult.isCommandSuccess()) {
                return cmdResult;
            } else {
                // if the replication still running through exception
                policy = isi.getReplicationPolicy(policyName);
                if (policy.getLastJobState().equals(JobState.running)) {
                    ServiceError error = DeviceControllerErrors.isilon.jobFailed("Unable Stop Replication policy and policy state  :" + policy.getLastJobState().toString());
                    return BiosCommandResult.createErrorResult(error);
                }
            }
        }
        // disable the policy
        if (policy.getEnabled()) {
            IsilonSyncPolicy modifiedPolicy = new IsilonSyncPolicy();
            modifiedPolicy.setEnabled(false);
            isi.modifyReplicationPolicy(policyName, modifiedPolicy);
            _log.info("Sleeping for 40 seconds for stop operation to complete...");
            TimeUnit.SECONDS.sleep(40);
            _log.info("Replication Policy -{}  disabled successfully.", policy.toString());
            return BiosCommandResult.createSuccessfulResult();
        } else {
            _log.info("Replication Policy - {} can't be STOPPED because policy is already DISABLED", policy.toString());
            return BiosCommandResult.createSuccessfulResult();
        }
    } catch (IsilonException e) {
        return BiosCommandResult.createErrorResult(e);
    } catch (InterruptedException ex) {
        _log.warn("Stoping ReplicationPolicy - {} Interrupted", policyName);
        ServiceError error = DeviceControllerErrors.isilon.jobFailed("Stoping ReplicationPolicy is Failed with Interrupt exception and message :" + ex.getMessage());
        return BiosCommandResult.createErrorResult(error);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) IsilonSyncPolicy(com.emc.storageos.isilon.restapi.IsilonSyncPolicy) 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