Search in sources :

Example 1 with IsilonSyncPolicy

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

the class IsilonFileStorageDevice method checkFileReplicationPolicyExistsOrCreate.

@Override
public BiosCommandResult checkFileReplicationPolicyExistsOrCreate(StorageSystem sourceStorageObj, StorageSystem targetStorageObj, FileDeviceInputOutput sourceSytemArgs, FileDeviceInputOutput targetSytemArgs) {
    FilePolicy filePolicy = sourceSytemArgs.getFileProtectionPolicy();
    // Source Path
    String sourcePath = getFilePolicyPath(sourceStorageObj, filePolicy.getApplyAt(), sourceSytemArgs);
    String targetPath = getFilePolicyPath(targetStorageObj, filePolicy.getApplyAt(), targetSytemArgs);
    if (FileReplicationType.LOCAL.name().equalsIgnoreCase(filePolicy.getFileReplicationType())) {
        targetPath = targetPath + "_localTarget";
    }
    // Policy Name
    BiosCommandResult result = null;
    try {
        IsilonApi sourceIsi = getIsilonDevice(sourceStorageObj);
        IsilonApi targetIsi = getIsilonDevice(targetStorageObj);
        String sourceClusterName = sourceIsi.getClusterConfig().getName();
        String targetClusterName = targetIsi.getClusterConfig().getName();
        checkAppliedResourceNamePartOfFilePolicyPath(sourcePath, filePolicy, sourceSytemArgs);
        String policyName = FileOrchestrationUtils.generateNameForSyncIQPolicy(sourceClusterName, targetClusterName, filePolicy, null, sourceSytemArgs, sourcePath);
        ArrayList<IsilonSyncPolicy> isiReplicationPolicies = sourceIsi.getReplicationPolicies().getList();
        IsilonSyncPolicy isilonReplicationSchedule = checkForReplicationPolicyOnIsilon(isiReplicationPolicies, filePolicy, sourcePath, targetPath);
        if (isilonReplicationSchedule != null) {
            boolean validPolicy = validateIsilonReplicationPolicy(isilonReplicationSchedule, filePolicy, targetPath, targetStorageObj, sourceStorageObj);
            if (validPolicy) {
                // Verify the policy was mapped to FileStorageResource
                if (null == FileOrchestrationUtils.findPolicyStorageResourceByNativeId(_dbClient, sourceStorageObj, filePolicy, sourceSytemArgs, sourcePath)) {
                    _log.info("Isilon policy found for {}, creating policy storage resouce to further management", filePolicy.getFilePolicyName());
                    FileOrchestrationUtils.updatePolicyStorageResource(_dbClient, sourceStorageObj, filePolicy, sourceSytemArgs, sourcePath, isilonReplicationSchedule.getName(), isilonReplicationSchedule.getId(), targetStorageObj, targetSytemArgs.getvNAS(), targetPath);
                }
                result = BiosCommandResult.createSuccessfulResult();
            } else {
                throw DeviceControllerException.exceptions.assignFilePolicyFailed(filePolicy.getFilePolicyName(), filePolicy.getApplyAt(), "File policy and Isilon syncIQ policy differs for path: " + sourcePath);
            }
        } else {
            // to avoid DL
            if (targetIsi.existsDir(targetPath) && targetIsi.fsDirHasData(targetPath)) {
                // Fail to assign policy to target which has data in it!!!
                String errMsg = String.format("Target %s:%s directory has content in it", targetClusterName, targetPath);
                _log.error("Unable create policy due to, {}", errMsg);
                throw DeviceControllerException.exceptions.assignFilePolicyFailed(filePolicy.getFilePolicyName(), filePolicy.getApplyAt(), errMsg);
            }
            // Create replication sync policy.
            createIsilonSyncPolicy(sourceStorageObj, targetStorageObj, filePolicy, sourcePath, targetPath, policyName, sourceSytemArgs, targetSytemArgs);
            result = BiosCommandResult.createSuccessfulResult();
        }
    } catch (IsilonException e) {
        _log.error("Assigning file policy failed.", e);
        result = BiosCommandResult.createErrorResult(e);
    }
    return result;
}
Also used : FilePolicy(com.emc.storageos.db.client.model.FilePolicy) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) IsilonApi(com.emc.storageos.isilon.restapi.IsilonApi) IsilonSyncPolicy(com.emc.storageos.isilon.restapi.IsilonSyncPolicy) IsilonException(com.emc.storageos.isilon.restapi.IsilonException)

Example 2 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 3 with IsilonSyncPolicy

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

the class IsilonFileStorageDevice method getEquivalentIsilonSyncIQPolicy.

private static IsilonSyncPolicy getEquivalentIsilonSyncIQPolicy(IsilonApi isi, String path) {
    IsilonSyncPolicy isiSyncPolicy = null;
    ArrayList<IsilonSyncPolicy> isiSyncIQPolicies = isi.getReplicationPolicies().getList();
    if (isiSyncIQPolicies != null && !isiSyncIQPolicies.isEmpty()) {
        for (IsilonSyncPolicy isiSyncIQPolicy : isiSyncIQPolicies) {
            if (isiSyncIQPolicy.getSourceRootPath().equals(path)) {
                isiSyncPolicy = isiSyncIQPolicy;
            }
        }
    }
    return isiSyncPolicy;
}
Also used : IsilonSyncPolicy(com.emc.storageos.isilon.restapi.IsilonSyncPolicy)

Example 4 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 5 with IsilonSyncPolicy

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

the class IsilonFileStorageDevice method doUnassignFilePolicy.

@Override
public BiosCommandResult doUnassignFilePolicy(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
    try {
        IsilonApi isi = getIsilonDevice(storage);
        FilePolicy filePolicy = args.getFileProtectionPolicy();
        PolicyStorageResource policyResource = args.getPolicyStorageResource();
        if (filePolicy.getFilePolicyType().equals(FilePolicyType.file_replication.name())) {
            // Get the policy details by id
            IsilonSyncPolicy isiSyncPolicy = isi.getReplicationPolicy(policyResource.getPolicyNativeId());
            if (isiSyncPolicy != null) {
                _log.info("deleting Isilon replication policy: {}", isiSyncPolicy.toString());
                String policyName = isiSyncPolicy.getName();
                JobState policyState = isiSyncPolicy.getLastJobState();
                if (policyState.equals(JobState.running) || policyState.equals(JobState.paused)) {
                    _log.info("Canceling Replication Policy  -{} because policy is in - {} state ", policyName, policyState);
                    // If the policy is running, Cancel the job before unassign policy!!
                    BiosCommandResult cmdResult = mirrorOperations.doCancelReplicationPolicy(isi, isiSyncPolicy.getName());
                    if (!cmdResult.isCommandSuccess()) {
                        return cmdResult;
                    } else {
                        // If the replication job still running through exception
                        isiSyncPolicy = isi.getReplicationPolicy(isiSyncPolicy.getName());
                        if (isiSyncPolicy.getLastJobState().equals(JobState.running)) {
                            ServiceError error = DeviceControllerErrors.isilon.jobFailed("Unable Stop Replication policy and policy state  :" + isiSyncPolicy.getLastJobState().toString());
                            return BiosCommandResult.createErrorResult(error);
                        }
                    }
                }
                // delete replication policy using policy id
                isi.deleteReplicationPolicy(isiSyncPolicy.getId());
            } else {
                _log.info("replication policy: {} doesn't exists on storage system", filePolicy.toString());
            }
            return BiosCommandResult.createSuccessfulResult();
        } else if (filePolicy.getFilePolicyType().equals(FilePolicyType.file_snapshot.name())) {
            IsilonSnapshotSchedule isiSchedulePolicy = getEquivalentIsilonSnapshotSchedule(isi, policyResource.getResourcePath());
            if (isiSchedulePolicy != null) {
                _log.info("deleting Isilon Snapshot schedule: {}", isiSchedulePolicy.toString());
                isi.deleteSnapshotSchedule(policyResource.getPolicyNativeId());
            } else {
                _log.info("snapshot schedule: {} doesn't exists on storage system", filePolicy.toString());
            }
            return BiosCommandResult.createSuccessfulResult();
        }
        return BiosCommandResult.createSuccessfulResult();
    } catch (IsilonException e) {
        _log.error("unassign file policy failed.", e);
        return BiosCommandResult.createErrorResult(e);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) FilePolicy(com.emc.storageos.db.client.model.FilePolicy) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) JobState(com.emc.storageos.isilon.restapi.IsilonSyncPolicy.JobState) IsilonApi(com.emc.storageos.isilon.restapi.IsilonApi) PolicyStorageResource(com.emc.storageos.db.client.model.PolicyStorageResource) IsilonSyncPolicy(com.emc.storageos.isilon.restapi.IsilonSyncPolicy) IsilonSnapshotSchedule(com.emc.storageos.isilon.restapi.IsilonSnapshotSchedule) 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