Search in sources :

Example 31 with BiosCommandResult

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

the class IsilonFileStorageDevice method doRollbackMirrorLink.

/**
 * rollback the target filesystems
 */
@Override
public void doRollbackMirrorLink(StorageSystem system, List<URI> sources, List<URI> targets, TaskCompleter completer, String opId) {
    BiosCommandResult biosCommandResult = null;
    // delete the target objects
    if (targets != null && !targets.isEmpty()) {
        for (URI target : targets) {
            FileShare fileShare = _dbClient.queryObject(FileShare.class, target);
            StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, fileShare.getStorageDevice());
            URI uriParent = fileShare.getParentFileShare().getURI();
            if (sources.contains(uriParent) == true) {
                // Do not delete the file target file system with force flag
                biosCommandResult = rollbackCreatedFilesystem(storageSystem, target, opId, false);
                if (biosCommandResult.getCommandSuccess()) {
                    fileShare.getOpStatus().updateTaskStatus(opId, biosCommandResult.toOperation());
                    fileShare.setInactive(true);
                    _dbClient.updateObject(fileShare);
                }
            }
        }
    }
    completer.ready(_dbClient);
}
Also used : BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 32 with BiosCommandResult

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

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

the class IsilonFileStorageDevice method doResyncPrepSourcePolicy.

/**
 * this command issue on source system when source policy in failover state.
 * when resync-prep issue on source policy then it will create mirror policy.
 * this mirror policy will from source to target
 *
 * 'resync-prep' call on source policy will create new "*_mirror" policy
 *
 * @param sourceSystem - source system
 * @param targetSystem - target system
 * @param sourcePolicyName - source policy name from source to target
 * @param completer
 * @return
 */
private BiosCommandResult doResyncPrepSourcePolicy(StorageSystem sourceSystem, StorageSystem targetSystem, String policyName, TaskCompleter completer) {
    _log.info("doResyncPrepSourcePolicy - resync-prep action on source policy {} ", policyName);
    BiosCommandResult cmdResult = null;
    IsilonSyncTargetPolicy policy = null;
    // test the source policy details
    cmdResult = mirrorOperations.doTestReplicationPolicy(sourceSystem, policyName);
    if (cmdResult.isCommandSuccess()) {
        // get source policy details on target storage system
        policy = mirrorOperations.getIsilonSyncTargetPolicy(targetSystem, policyName);
        if (cmdResult.isCommandSuccess() && null != policy) {
            // enable the replication policy
            cmdResult = mirrorOperations.doEnablePolicy(sourceSystem, policyName);
            if (!cmdResult.isCommandSuccess()) {
                return cmdResult;
            }
            // get source policy details of local target on target system (policy : source -> target)
            if (JobState.finished.equals(policy.getLastJobState()) && FOFB_STATES.resync_policy_created.equals(policy.getFoFbState())) {
                _log.info("Skipped the resyncprep action on policy : {}", policyName);
                _log.info(String.format("Source policy details : - %s ", policy.toString()));
                return BiosCommandResult.createSuccessfulResult();
            // if policy is failed then we call to get the reports, return error
            } else if (JobState.failed.equals(policy.getLastJobState()) || JobState.needs_attention.equals(policy.getLastJobState())) {
                return getSyncPolicyErrorReport(sourceSystem, policy);
            } else {
                // call isilon api
                return mirrorOperations.doResyncPrep(sourceSystem, policyName, completer);
            }
        } else {
            return cmdResult;
        }
    } else {
        return cmdResult;
    }
}
Also used : BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) IsilonSyncTargetPolicy(com.emc.storageos.isilon.restapi.IsilonSyncTargetPolicy)

Example 34 with BiosCommandResult

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

the class IsilonFileStorageDevice method updateNfsACLs.

@Override
public BiosCommandResult updateNfsACLs(StorageSystem storage, FileDeviceInputOutput args) {
    try {
        // read nameToSid flag from controller config.
        Boolean sidEnable = customConfigHandler.getComputedCustomConfigBooleanValue(CustomConfigConstants.ISILON_USER_TO_SID_MAPPING_FOR_NFS_ENABLED, storage.getSystemType(), null);
        // get sid mapping based on Controller config and it belong to VirtualNAS.
        if (sidEnable && args.getvNAS() != null) {
            updateSidInfoForNfsACE(args, storage);
        }
        IsilonNFSACL isilonAcl = new IsilonNFSACL();
        ArrayList<Acl> aclCompleteList = new ArrayList<Acl>();
        List<NfsACE> aceToAdd = args.getNfsAclsToAdd();
        for (NfsACE nfsACE : aceToAdd) {
            Acl acl = getIsilonAclFromNfsACE(nfsACE);
            acl.setOp("add");
            aclCompleteList.add(acl);
        }
        List<NfsACE> aceToModify = args.getNfsAclsToModify();
        for (NfsACE nfsACE : aceToModify) {
            Acl acl = getIsilonAclFromNfsACE(nfsACE);
            acl.setOp("replace");
            aclCompleteList.add(acl);
        }
        List<NfsACE> aceToDelete = args.getNfsAclsToDelete();
        for (NfsACE nfsACE : aceToDelete) {
            Acl acl = getIsilonAclFromNfsACE(nfsACE);
            acl.setOp("delete");
            aclCompleteList.add(acl);
        }
        isilonAcl.setAction("update");
        isilonAcl.setAuthoritative("acl");
        isilonAcl.setAcl(aclCompleteList);
        String path = args.getFileSystemPath();
        if (args.getSubDirectory() != null && !args.getSubDirectory().isEmpty()) {
            path = path + "/" + args.getSubDirectory();
        }
        // Process new ACLs
        IsilonApi isi = getIsilonDevice(storage);
        _log.info("Calling Isilon API: modify NFS Acl for {}, acl  {}", args.getFileSystemPath(), isilonAcl);
        isi.modifyNFSACL(path, isilonAcl);
        _log.info("End updateNfsACLs");
        BiosCommandResult result = BiosCommandResult.createSuccessfulResult();
        return result;
    } catch (IsilonException e) {
        _log.error("updateNfsACLs failed ", e);
        return BiosCommandResult.createErrorResult(e);
    } catch (Exception e) {
        _log.error("updateNfsACLs failed ", e);
        final ServiceCoded serviceCoded = DeviceControllerException.errors.jobFailedOpMsg(OperationTypeEnum.UPDATE_FILE_SYSTEM_NFS_ACL.toString(), e.getMessage());
        return BiosCommandResult.createErrorResult(serviceCoded);
    }
}
Also used : NfsACE(com.emc.storageos.model.file.NfsACE) ArrayList(java.util.ArrayList) Acl(com.emc.storageos.isilon.restapi.IsilonNFSACL.Acl) IsilonException(com.emc.storageos.isilon.restapi.IsilonException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) URISyntaxException(java.net.URISyntaxException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) IsilonCollectionException(com.emc.storageos.plugins.metering.isilon.IsilonCollectionException) IsilonNFSACL(com.emc.storageos.isilon.restapi.IsilonNFSACL) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) ServiceCoded(com.emc.storageos.svcs.errorhandling.model.ServiceCoded) IsilonApi(com.emc.storageos.isilon.restapi.IsilonApi) IsilonException(com.emc.storageos.isilon.restapi.IsilonException)

Example 35 with BiosCommandResult

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

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