Search in sources :

Example 6 with PolicyStorageResource

use of com.emc.storageos.db.client.model.PolicyStorageResource in project coprhd-controller by CoprHD.

the class IsilonFileStorageDevice method updateStorageSystemFileProtectionPolicy.

@Override
public BiosCommandResult updateStorageSystemFileProtectionPolicy(StorageSystem storage, FileDeviceInputOutput args) {
    FilePolicy existingPolicy = args.getFileProtectionPolicy();
    PolicyStorageResource policyRes = args.getPolicyStorageResource();
    FilePolicyUpdateParam policyUpdateParam = args.getFileProtectionPolicyUpdateParam();
    IsilonApi isi = getIsilonDevice(storage);
    BiosCommandResult result = null;
    try {
        if (existingPolicy.getFilePolicyType().equals(FilePolicy.FilePolicyType.file_replication.name())) {
            boolean isVersion8above = false;
            if (VersionChecker.verifyVersionDetails(ONEFS_V8, storage.getFirmwareVersion()) >= 0) {
                isVersion8above = true;
            }
            return updateStorageSystemFileReplicationPolicy(isi, policyRes, existingPolicy, policyUpdateParam, isVersion8above);
        } else if (existingPolicy.getFilePolicyType().equals(FilePolicy.FilePolicyType.file_snapshot.name())) {
            return updateStorageSystemFileSnapshotPolicy(isi, policyRes, existingPolicy, policyUpdateParam);
        } else {
            String errorMsg = "Invalid policy type {} " + existingPolicy.getFilePolicyType();
            _log.error(errorMsg);
            final ServiceCoded serviceCoded = DeviceControllerException.errors.jobFailedOpMsg(OperationTypeEnum.UPDATE_STORAGE_SYSTEM_POLICY_BY_POLICY_RESOURCE.toString(), errorMsg);
            result = BiosCommandResult.createErrorResult(serviceCoded);
            existingPolicy.getOpStatus().updateTaskStatus(args.getOpId(), result.toOperation());
            return result;
        }
    } catch (IsilonException e) {
        _log.error("Update storage system policy for file policy failed.", e);
        return BiosCommandResult.createErrorResult(e);
    }
}
Also used : FilePolicy(com.emc.storageos.db.client.model.FilePolicy) FilePolicyUpdateParam(com.emc.storageos.model.file.policy.FilePolicyUpdateParam) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) ServiceCoded(com.emc.storageos.svcs.errorhandling.model.ServiceCoded) PolicyStorageResource(com.emc.storageos.db.client.model.PolicyStorageResource) IsilonApi(com.emc.storageos.isilon.restapi.IsilonApi) IsilonException(com.emc.storageos.isilon.restapi.IsilonException)

Example 7 with PolicyStorageResource

use of com.emc.storageos.db.client.model.PolicyStorageResource 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 PolicyStorageResource

use of com.emc.storageos.db.client.model.PolicyStorageResource 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)

Example 9 with PolicyStorageResource

use of com.emc.storageos.db.client.model.PolicyStorageResource in project coprhd-controller by CoprHD.

the class IsilonFileStorageDevice method doApplyFileSnapshotPolicy.

private BiosCommandResult doApplyFileSnapshotPolicy(FilePolicy filePolicy, FileDeviceInputOutput args, FileShare fs, StorageSystem storageObj) {
    IsilonApi isi = getIsilonDevice(storageObj);
    String path = generatePathForPolicy(filePolicy, fs, args);
    String clusterName = isi.getClusterConfig().getName();
    String snapshotScheduleName = FileOrchestrationUtils.generateNameForSnapshotIQPolicy(clusterName, filePolicy, fs, args, path);
    IsilonSnapshotSchedule isiSnapshotSchedule = getEquivalentIsilonSnapshotSchedule(isi, path);
    if (isiSnapshotSchedule != null) {
        String filePolicySnapshotSchedule = getIsilonPolicySchedule(filePolicy);
        _log.info("Comparing snapshot schedule between CoprHD policy: {} and Isilon policy: {}.", filePolicySnapshotSchedule, isiSnapshotSchedule.getSchedule());
        if (isiSnapshotSchedule.getSchedule() != null && isiSnapshotSchedule.getSchedule().equalsIgnoreCase(filePolicySnapshotSchedule)) {
            // Verify the policy was mapped to FileStorageResource
            if (null == FileOrchestrationUtils.findPolicyStorageResourceByNativeId(_dbClient, storageObj, filePolicy, args, path)) {
                _log.info("Isilon snapshot policy found for {}, creating policy storage resouce to further management", filePolicy.getFilePolicyName());
                PolicyStorageResource policyResource = FileOrchestrationUtils.updatePolicyStorageResource(_dbClient, storageObj, filePolicy, args, path, isiSnapshotSchedule.getName(), isiSnapshotSchedule.getId().toString(), null, null, null);
                // for existing policy vipr generated label
                policyResource.setLabel(filePolicySnapshotSchedule);
                _dbClient.updateObject(policyResource);
                _log.info("File Policy {} is already applied and running.", filePolicy.getFilePolicyName());
            }
            return BiosCommandResult.createSuccessfulResult();
        } else {
            _log.info("Snapshot schedule differs between Isilon policy and CoprHD file policy. So, create policy in Isilon...");
            // Create snapshot policy.
            createIsilonSnapshotPolicySchedule(storageObj, filePolicy, path, snapshotScheduleName, args, path);
            return BiosCommandResult.createSuccessfulResult();
        }
    } else {
        // Create snapshot policy.
        createIsilonSnapshotPolicySchedule(storageObj, filePolicy, path, snapshotScheduleName, args, path);
        return BiosCommandResult.createSuccessfulResult();
    }
}
Also used : IsilonApi(com.emc.storageos.isilon.restapi.IsilonApi) PolicyStorageResource(com.emc.storageos.db.client.model.PolicyStorageResource) IsilonSnapshotSchedule(com.emc.storageos.isilon.restapi.IsilonSnapshotSchedule)

Example 10 with PolicyStorageResource

use of com.emc.storageos.db.client.model.PolicyStorageResource in project coprhd-controller by CoprHD.

the class IsilonFileStorageDevice method doFailoverLink.

/**
 * perform failover operation
 * systemTarget - failover to target system
 * fs - target filesystem
 * completer - task completer
 *
 * return BiosCommandResult
 */
@Override
public BiosCommandResult doFailoverLink(StorageSystem systemTarget, FileShare fs, TaskCompleter completer) {
    _log.info("IsilonFileStorageDevice -  doFailoverLink started ");
    FileShare sourceFS = null;
    FileShare targetFS = null;
    StorageSystem sourceSystem = null;
    StorageSystem targetSystem = null;
    boolean failback = false;
    if (fs.getPersonality().equals(PersonalityTypes.TARGET.name())) {
        sourceFS = _dbClient.queryObject(FileShare.class, fs.getParentFileShare());
        targetFS = fs;
    } else if (fs.getPersonality().equals(PersonalityTypes.SOURCE.name())) {
        sourceFS = fs;
        List<String> targetfileUris = new ArrayList<String>();
        targetfileUris.addAll(fs.getMirrorfsTargets());
        if (!targetfileUris.isEmpty()) {
            targetFS = _dbClient.queryObject(FileShare.class, URI.create(targetfileUris.get(0)));
        } else {
            ServiceError serviceError = DeviceControllerErrors.isilon.unableToFailoverFileSystem(systemTarget.getIpAddress(), "Unable to get target filesystem for source filesystem " + fs.getName());
            return BiosCommandResult.createErrorResult(serviceError);
        }
        failback = true;
    }
    sourceSystem = _dbClient.queryObject(StorageSystem.class, sourceFS.getStorageDevice());
    targetSystem = _dbClient.queryObject(StorageSystem.class, targetFS.getStorageDevice());
    PolicyStorageResource policyStrRes = getEquivalentPolicyStorageResource(sourceFS, _dbClient);
    if (policyStrRes != null) {
        IsilonSyncPolicy syncPolicy = policyNativeIdValidation(sourceSystem, policyStrRes);
        String policyName = syncPolicy.getName();
        BiosCommandResult cmdResult = null;
        // In case of failback we do failover on the source file system, so we need to append _mirror
        if (failback) {
            String mirrorPolicyName = syncPolicy.getName();
            mirrorPolicyName = mirrorPolicyName.concat(MIRROR_POLICY);
            // prepared policy for failback
            cmdResult = prepareFailbackOp(sourceSystem, policyName);
            if (!cmdResult.isCommandSuccess()) {
                return cmdResult;
            }
            // Call Isilon Api failback job
            return doFailoverMirrorPolicy(sourceSystem, policyName, targetSystem, mirrorPolicyName, completer);
        } else {
            // prepared policy for failover
            cmdResult = prepareFailoverOp(sourceSystem, policyName);
            if (!cmdResult.isCommandSuccess()) {
                _log.info("Unable to stop replication policy on source");
                _log.info("Proceeding with failover anyway");
            }
            // Call Isilon Api failover job
            return mirrorOperations.doFailover(targetSystem, syncPolicy.getId(), completer);
        }
    }
    ServiceError serviceError = DeviceControllerErrors.isilon.unableToFailoverFileSystem(systemTarget.getIpAddress(), "Unable to get the policy details for filesystem :" + fs.getName());
    return BiosCommandResult.createErrorResult(serviceError);
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) IsilonList(com.emc.storageos.isilon.restapi.IsilonApi.IsilonList) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) List(java.util.List) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) PolicyStorageResource(com.emc.storageos.db.client.model.PolicyStorageResource) IsilonSyncPolicy(com.emc.storageos.isilon.restapi.IsilonSyncPolicy) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

PolicyStorageResource (com.emc.storageos.db.client.model.PolicyStorageResource)29 FilePolicy (com.emc.storageos.db.client.model.FilePolicy)14 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)11 ArrayList (java.util.ArrayList)11 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)9 IsilonSyncPolicy (com.emc.storageos.isilon.restapi.IsilonSyncPolicy)8 FileShare (com.emc.storageos.db.client.model.FileShare)6 StringSet (com.emc.storageos.db.client.model.StringSet)6 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)5 NASServer (com.emc.storageos.db.client.model.NASServer)5 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)5 IsilonApi (com.emc.storageos.isilon.restapi.IsilonApi)5 URI (java.net.URI)5 PhysicalNAS (com.emc.storageos.db.client.model.PhysicalNAS)4 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)4 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)4 ControllerException (com.emc.storageos.volumecontroller.ControllerException)4 WorkflowException (com.emc.storageos.workflow.WorkflowException)4 FileReplicaPolicyTarget (com.emc.storageos.db.client.model.FileReplicaPolicyTarget)3 FileReplicaPolicyTargetMap (com.emc.storageos.db.client.model.FileReplicaPolicyTargetMap)3