Search in sources :

Example 21 with BiosCommandResult

use of com.emc.storageos.volumecontroller.impl.BiosCommandResult in project coprhd-controller by CoprHD.

the class IsilonFileStorageDevice method doFailoverMirrorPolicy.

/**
 * Failover on target mirror policy that enable write on source system.
 * allow writes on source filesystem and on target system trasfer the controller to source system
 * on write will be disable and next step resync-prep on target will sync source policy
 *
 * @param sourceSystem - source system
 * @param policyName - source to target policy
 * @param targetSystem - target system
 * @param mirrorPolicyName - target to source mirror policy on failback operation
 * @param completer
 * @return
 */
private BiosCommandResult doFailoverMirrorPolicy(StorageSystem sourceSystem, String policyName, StorageSystem targetSystem, String mirrorPolicyName, TaskCompleter completer) {
    IsilonSyncTargetPolicy policy = null;
    IsilonSyncTargetPolicy mirrorPolicy = null;
    // if policy enables on target storage then We should disable it before failback job
    BiosCommandResult result = mirrorOperations.doStopReplicationPolicy(targetSystem, mirrorPolicyName);
    if (!result.isCommandSuccess()) {
        return result;
    }
    // get source policy details of local target on target system (policy : source -> target)
    mirrorPolicy = mirrorOperations.getIsilonSyncTargetPolicy(sourceSystem, mirrorPolicyName);
    // get target mirror policy details of local target on source system (policy : target -> source)
    policy = mirrorOperations.getIsilonSyncTargetPolicy(targetSystem, policyName);
    // always source policy should be in 'resync_policy_create' state
    if (JobState.finished.equals(policy.getLastJobState()) && FOFB_STATES.resync_policy_created.equals(policy.getFoFbState()) && JobState.finished.equals(mirrorPolicy.getLastJobState()) && FOFB_STATES.writes_enabled.equals(mirrorPolicy.getFoFbState())) {
        _log.info("Skipped the failover action on mirror policy : {}", mirrorPolicyName);
        _log.info(String.format("Source policy details : - %s and Target policy details :- %s", policy.toString(), mirrorPolicy.toString()));
        return BiosCommandResult.createSuccessfulResult();
    // if policy is in error state then call to get error reports from device.
    } else if (JobState.failed.equals(mirrorPolicy.getLastJobState()) || JobState.needs_attention.equals(mirrorPolicy.getLastJobState())) {
        return getSyncPolicyErrorReport(sourceSystem, mirrorPolicy);
    // get source policy error reports
    } else if (JobState.failed.equals(policy.getLastJobState()) || JobState.needs_attention.equals(policy.getLastJobState())) {
        return getSyncPolicyErrorReport(targetSystem, policy);
    } else {
        // on failover of target mirror policy, the target local policy will be "writes enabled"
        return mirrorOperations.doFailover(sourceSystem, mirrorPolicyName, completer);
    }
}
Also used : IsilonSyncTargetPolicy(com.emc.storageos.isilon.restapi.IsilonSyncTargetPolicy) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult)

Example 22 with BiosCommandResult

use of com.emc.storageos.volumecontroller.impl.BiosCommandResult 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 23 with BiosCommandResult

use of com.emc.storageos.volumecontroller.impl.BiosCommandResult 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 24 with BiosCommandResult

use of com.emc.storageos.volumecontroller.impl.BiosCommandResult in project coprhd-controller by CoprHD.

the class IsilonFileStorageDevice method checkFilePolicyExistsOrCreate.

@Override
public BiosCommandResult checkFilePolicyExistsOrCreate(StorageSystem storageObj, FileDeviceInputOutput args) {
    FilePolicy filePolicy = args.getFileProtectionPolicy();
    BiosCommandResult result = null;
    try {
        IsilonApi isi = getIsilonDevice(storageObj);
        String clusterName = isi.getClusterConfig().getName();
        String filePolicyBasePath = getFilePolicyPath(storageObj, filePolicy.getApplyAt(), args);
        checkAppliedResourceNamePartOfFilePolicyPath(filePolicyBasePath, filePolicy, args);
        String snapshotPolicyScheduleName = FileOrchestrationUtils.generateNameForSnapshotIQPolicy(clusterName, filePolicy, null, args, filePolicyBasePath);
        IsilonSnapshotSchedule isilonSnapshotSchedule = getEquivalentIsilonSnapshotSchedule(isi, filePolicyBasePath);
        if (isilonSnapshotSchedule != null) {
            String filePolicySnapshotSchedule = getIsilonPolicySchedule(filePolicy);
            _log.info("Comparing snapshot schedule between CoprHD policy: {} and Isilon policy: {}.", filePolicySnapshotSchedule, isilonSnapshotSchedule.getSchedule());
            if (isilonSnapshotSchedule.getSchedule().equalsIgnoreCase(filePolicySnapshotSchedule)) {
                // Verify the policy was mapped to FileStorageResource
                if (null == FileOrchestrationUtils.findPolicyStorageResourceByNativeId(_dbClient, storageObj, filePolicy, args, filePolicyBasePath)) {
                    _log.info("Isilon policy found for {}, creating policy storage resouce to further management", filePolicy.getFilePolicyName());
                    FileOrchestrationUtils.updatePolicyStorageResource(_dbClient, storageObj, filePolicy, args, filePolicyBasePath, isilonSnapshotSchedule.getName(), isilonSnapshotSchedule.getId().toString(), null, null, null);
                }
                result = 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, filePolicyBasePath, snapshotPolicyScheduleName, args, filePolicyBasePath);
                result = BiosCommandResult.createSuccessfulResult();
            }
        } else {
            // Create snapshot policy.
            createIsilonSnapshotPolicySchedule(storageObj, filePolicy, filePolicyBasePath, snapshotPolicyScheduleName, args, filePolicyBasePath);
            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) IsilonSnapshotSchedule(com.emc.storageos.isilon.restapi.IsilonSnapshotSchedule) IsilonException(com.emc.storageos.isilon.restapi.IsilonException)

Example 25 with BiosCommandResult

use of com.emc.storageos.volumecontroller.impl.BiosCommandResult in project coprhd-controller by CoprHD.

the class DataDomainFileStorageDevice method doModifyFS.

@Override
public BiosCommandResult doModifyFS(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
    BiosCommandResult result = new BiosCommandResult();
    result.setCommandSuccess(false);
    result.setCommandStatus(Operation.Status.error.name());
    result.setMessage("Modify FS NOT supported for DataDomain.");
    return result;
}
Also used : BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult)

Aggregations

BiosCommandResult (com.emc.storageos.volumecontroller.impl.BiosCommandResult)135 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)76 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)69 ControllerException (com.emc.storageos.volumecontroller.ControllerException)64 NetAppException (com.emc.storageos.netapp.NetAppException)34 ArrayList (java.util.ArrayList)34 NetworkDeviceControllerException (com.emc.storageos.networkcontroller.exceptions.NetworkDeviceControllerException)28 NetAppCException (com.emc.storageos.netappc.NetAppCException)19 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)18 NetAppApi (com.emc.storageos.netapp.NetAppApi)18 NetAppClusterApi (com.emc.storageos.netappc.NetAppClusterApi)18 URI (java.net.URI)16 VNXException (com.emc.storageos.vnx.xmlapi.VNXException)15 XMLApiResult (com.emc.storageos.vnx.xmlapi.XMLApiResult)15 VNXFileCommApi (com.emc.storageos.volumecontroller.impl.plugins.provisioning.VNXFileCommApi)15 ApplicationContext (org.springframework.context.ApplicationContext)15 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)15 FileShare (com.emc.storageos.db.client.model.FileShare)14 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)14 NetworkSystem (com.emc.storageos.db.client.model.NetworkSystem)11