Search in sources :

Example 16 with IsilonException

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

the class IsilonFileStorageDevice method doDeleteFS.

@Override
public BiosCommandResult doDeleteFS(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
    try {
        _log.info("IsilonFileStorageDevice doDeleteFS {} - start", args.getFsId());
        IsilonApi isi = getIsilonDevice(storage);
        isiDeleteFS(isi, args);
        _log.info("IsilonFileStorageDevice doDeleteFS {} - complete", args.getFsId());
        return BiosCommandResult.createSuccessfulResult();
    } catch (IsilonException e) {
        _log.error("doDeleteFS failed.", e);
        return BiosCommandResult.createErrorResult(e);
    }
}
Also used : IsilonApi(com.emc.storageos.isilon.restapi.IsilonApi) IsilonException(com.emc.storageos.isilon.restapi.IsilonException)

Example 17 with IsilonException

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

the class IsilonFileStorageDevice method doesNFSExportExistsForFSPath.

private boolean doesNFSExportExistsForFSPath(StorageSystem storageSystem, String isilonAccessZone, String path) throws IsilonCollectionException {
    URI storageSystemId = storageSystem.getId();
    String resumeToken = null;
    try {
        _log.info("Checking NFS export for path {}  on Isilon storage system: {} in access zone {} - start", path, storageSystem.getLabel(), isilonAccessZone);
        IsilonApi isilonApi = getIsilonDevice(storageSystem);
        do {
            IsilonApi.IsilonList<IsilonExport> isilonExports = isilonApi.listExports(resumeToken, isilonAccessZone);
            List<IsilonExport> exports = isilonExports.getList();
            for (IsilonExport exp : exports) {
                if (exp.getPaths() == null || exp.getPaths().isEmpty()) {
                    _log.info("Ignoring export {} as it is not having any path", exp);
                    continue;
                }
                // Ignore Export with multiple paths
                if (exp.getPaths().size() > 1) {
                    _log.info("Isilon Export: {} has multiple paths. So ingnore it.", exp);
                    continue;
                }
                String exportPath = exp.getPaths().get(0);
                if (exportPath.equals(path)) {
                    _log.info("Found NFS export with path {} on Ision: {} in access zone: {}", path, storageSystem.getLabel(), isilonAccessZone);
                    return true;
                }
            }
            resumeToken = isilonExports.getToken();
        } while (resumeToken != null);
        _log.info("NFS export not found with path {} on Ision: {} in access zone: {}", path, storageSystem.getLabel(), isilonAccessZone);
        return false;
    } catch (IsilonException ie) {
        _log.error("doesNFSExportExistsForFSPath failed. Storage system: {}", storageSystemId, ie);
        IsilonCollectionException ice = new IsilonCollectionException("doesNFSExportExistsForFSPath failed. Storage system: " + storageSystemId);
        ice.initCause(ie);
        throw ice;
    } catch (Exception e) {
        _log.error("doesNFSExportExistsForFSPath failed. Storage system: {}", storageSystemId, e);
        IsilonCollectionException ice = new IsilonCollectionException("doesNFSExportExistsForFSPath failed. Storage system: " + storageSystemId);
        ice.initCause(e);
        throw ice;
    }
}
Also used : IsilonExport(com.emc.storageos.isilon.restapi.IsilonExport) IsilonCollectionException(com.emc.storageos.plugins.metering.isilon.IsilonCollectionException) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) IsilonApi(com.emc.storageos.isilon.restapi.IsilonApi) 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) IsilonException(com.emc.storageos.isilon.restapi.IsilonException)

Example 18 with IsilonException

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

the class IsilonFileStorageDevice method updateStorageSystemFileSnapshotPolicy.

private BiosCommandResult updateStorageSystemFileSnapshotPolicy(IsilonApi isi, PolicyStorageResource policyRes, FilePolicy viprPolicy, FilePolicyUpdateParam policyUpdateParam) {
    try {
        ArrayList<IsilonSnapshotSchedule> isiSnapshotPolicies = isi.getSnapshotSchedules().getList();
        IsilonSnapshotSchedule snapPolicyAtPath = null;
        _log.info("Checking the right snapshotIQ policy ...");
        for (IsilonSnapshotSchedule snapPolicy : isiSnapshotPolicies) {
            // Hence identify the storage system policy in either way
            if (snapPolicy.getPath() != null && snapPolicy.getPath().equalsIgnoreCase(policyRes.getResourcePath()) && policyRes.getPolicyNativeId() != null && (policyRes.getPolicyNativeId().equalsIgnoreCase(snapPolicy.getName()) || policyRes.getPolicyNativeId().equalsIgnoreCase(snapPolicy.getId().toString()))) {
                snapPolicyAtPath = snapPolicy;
                break;
            }
        }
        if (snapPolicyAtPath != null) {
            _log.info("Found SnapshotIQ policy{} for path {} ", snapPolicyAtPath.getName(), snapPolicyAtPath.getPath());
            boolean bModifyPolicy = false;
            // Temp policy to store modified values.
            IsilonSnapshotSchedule modifiedPolicy = new IsilonSnapshotSchedule();
            modifiedPolicy.setName(snapPolicyAtPath.getName());
            if (policyUpdateParam.getSnapshotPolicyPrams() != null) {
                FileSnapshotPolicyParam snapParam = policyUpdateParam.getSnapshotPolicyPrams();
                if (snapParam.getSnapshotExpireParams() != null) {
                    Integer expireTime = getSnapshotExpireValue(snapParam.getSnapshotExpireParams());
                    if (expireTime != null && snapPolicyAtPath.getDuration() != null) {
                        if (snapPolicyAtPath.getDuration().intValue() != expireTime.intValue()) {
                            modifiedPolicy.setDuration(expireTime);
                            bModifyPolicy = true;
                        }
                    } else if (expireTime != null && snapPolicyAtPath.getDuration() == null) {
                        modifiedPolicy.setDuration(expireTime);
                        bModifyPolicy = true;
                    } else if (snapPolicyAtPath.getDuration() != null) {
                        modifiedPolicy.setDuration(0);
                        bModifyPolicy = true;
                    }
                }
                if (snapParam.getPolicySchedule() != null) {
                    String strSchedule = getIsilonPolicySchedule(snapParam.getPolicySchedule());
                    if (strSchedule != null && !strSchedule.isEmpty() && !strSchedule.equalsIgnoreCase(snapPolicyAtPath.getSchedule())) {
                        modifiedPolicy.setSchedule(strSchedule);
                        bModifyPolicy = true;
                    }
                }
            }
            if (bModifyPolicy) {
                isi.modifySnapshotSchedule(snapPolicyAtPath.getName(), modifiedPolicy);
                // if the existing policy is modified save policy details in db
                policyRes.setPolicyNativeId(snapPolicyAtPath.getId().toString());
                policyRes.setName(snapPolicyAtPath.getName());
                _dbClient.updateObject(policyRes);
                _log.info("Modify Snapshot Policy- {} finished successfully", snapPolicyAtPath.getName());
                return BiosCommandResult.createSuccessfulResult();
            } else {
                _log.info("No parameters changed to modify Snapshot Policy- {} finished successfully", snapPolicyAtPath.getName());
                return BiosCommandResult.createSuccessfulResult();
            }
        } else {
            _log.error("No SnapshotIQ policy found at path {} , Hence can't be MODIFIED", policyRes.getResourcePath());
            ServiceError error = DeviceControllerErrors.isilon.jobFailed("Modify Snapshot policy Failed as : No SnapshotIQ policy found at given path.");
            return BiosCommandResult.createErrorResult(error);
        }
    } catch (IsilonException e) {
        return BiosCommandResult.createErrorResult(e);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) FileSnapshotPolicyParam(com.emc.storageos.model.file.policy.FileSnapshotPolicyParam) IsilonSnapshotSchedule(com.emc.storageos.isilon.restapi.IsilonSnapshotSchedule) IsilonException(com.emc.storageos.isilon.restapi.IsilonException)

Example 19 with IsilonException

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

the class IsilonFileStorageDevice method doReduceFS.

@Override
public BiosCommandResult doReduceFS(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
    try {
        _log.info("IsilonFileStorageDevice doReduceFS {} - start", args.getFsId());
        IsilonApi isi = getIsilonDevice(storage);
        String quotaId = null;
        if (args.getFsExtensions() != null && args.getFsExtensions().get(QUOTA) != null) {
            quotaId = args.getFsExtensions().get(QUOTA);
            Long capacity = args.getNewFSCapacity();
            IsilonSmartQuota quota = isi.getQuota(quotaId);
            // new capacity should be less than usage capacity of a filehare
            if (capacity.compareTo(quota.getUsagePhysical()) < 0) {
                Double dUsageSize = SizeUtil.translateSize(quota.getUsagePhysical(), SizeUtil.SIZE_GB);
                Double dNewCapacity = SizeUtil.translateSize(capacity, SizeUtil.SIZE_GB);
                String msg = String.format("as requested reduced size [%.1fGB] is smaller than used capacity [%.1fGB] for filesystem %s", dNewCapacity, dUsageSize, args.getFs().getName());
                _log.error(msg);
                final ServiceError serviceError = DeviceControllerErrors.isilon.unableUpdateQuotaDirectory(msg);
                return BiosCommandResult.createErrorResult(serviceError);
            } else {
                isiReduceFS(isi, quotaId, args);
            }
        } else {
            // when policy is applied at higher level, we will ignore the target filesystem
            FileShare fileShare = args.getFs();
            if (null != fileShare.getPersonality() && PersonalityTypes.TARGET.name().equals(fileShare.getPersonality()) && null == fileShare.getExtensions()) {
                _log.info("Quota id is not found, so ignore the reduce filesystem ", fileShare.getLabel());
                return BiosCommandResult.createSuccessfulResult();
            }
            final ServiceError serviceError = DeviceControllerErrors.isilon.doReduceFSFailed(args.getFsId());
            _log.error(serviceError.getMessage());
            return BiosCommandResult.createErrorResult(serviceError);
        }
        _log.info("IsilonFileStorageDevice doReduceFS {} - complete", args.getFsId());
        return BiosCommandResult.createSuccessfulResult();
    } catch (IsilonException e) {
        _log.error("doReduceFS failed.", e);
        return BiosCommandResult.createErrorResult(e);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) IsilonSmartQuota(com.emc.storageos.isilon.restapi.IsilonSmartQuota) IsilonApi(com.emc.storageos.isilon.restapi.IsilonApi) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) IsilonException(com.emc.storageos.isilon.restapi.IsilonException)

Example 20 with IsilonException

use of com.emc.storageos.isilon.restapi.IsilonException 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)

Aggregations

IsilonException (com.emc.storageos.isilon.restapi.IsilonException)62 IsilonApi (com.emc.storageos.isilon.restapi.IsilonApi)53 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)15 URISyntaxException (java.net.URISyntaxException)15 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)12 IsilonSyncPolicy (com.emc.storageos.isilon.restapi.IsilonSyncPolicy)12 IsilonCollectionException (com.emc.storageos.plugins.metering.isilon.IsilonCollectionException)12 URI (java.net.URI)12 ArrayList (java.util.ArrayList)10 FileShare (com.emc.storageos.db.client.model.FileShare)9 Test (org.junit.Test)8 FilePolicy (com.emc.storageos.db.client.model.FilePolicy)7 ControllerException (com.emc.storageos.volumecontroller.ControllerException)7 BiosCommandResult (com.emc.storageos.volumecontroller.impl.BiosCommandResult)7 NamedURI (com.emc.storageos.db.client.model.NamedURI)6 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)6 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)5 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)5 FileDeviceInputOutput (com.emc.storageos.volumecontroller.FileDeviceInputOutput)5 IOException (java.io.IOException)5