Search in sources :

Example 16 with IsilonApi

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

the class IsilonFileStorageDevice method getCustomPath.

/**
 * Gets the file system custom path value from controller configuration
 *
 * @param storage
 *            Isilon storage system
 * @param args
 *            FileDeviceInputOutput object
 * @return evaluated custom path
 */
private String getCustomPath(StorageSystem storage, FileDeviceInputOutput args) {
    String path = "";
    IsilonApi isi = getIsilonDevice(storage);
    String clusterName = isi.getClusterConfig().getName();
    FileShare fs = args.getFs();
    // source cluster name should be included in target path instead of target cluster name.
    if (fs != null && fs.getPersonality() != null && fs.getPersonality().equalsIgnoreCase(PersonalityTypes.TARGET.name())) {
        FileShare sourceFS = _dbClient.queryObject(FileShare.class, fs.getParentFileShare());
        if (sourceFS != null && sourceFS.getStorageDevice() != null) {
            StorageSystem sourceSystem = _dbClient.queryObject(StorageSystem.class, sourceFS.getStorageDevice());
            if (sourceSystem != null) {
                IsilonApi sourceCluster = getIsilonDevice(sourceSystem);
                clusterName = sourceCluster.getClusterConfig().getName();
                // if the replication happens from user defined access zone to system access zone!!
                if (sourceFS.getVirtualNAS() != null) {
                    VirtualNAS sourcevNAS = _dbClient.queryObject(VirtualNAS.class, sourceFS.getVirtualNAS());
                    if (sourcevNAS != null) {
                        String vNASName = sourcevNAS.getNasName();
                        vNASName = getNameWithNoSpecialCharacters(vNASName, args);
                        clusterName = clusterName + vNASName;
                        _log.info("Source file system is on virtual NAS {}", vNASName);
                    }
                }
                _log.debug("Generating path for target and the source cluster is is  {}", clusterName);
            }
        }
    } else if (args.isTarget()) {
        if (args.getSourceSystem() != null) {
            IsilonApi sourceCluster = getIsilonDevice(args.getSourceSystem());
            clusterName = sourceCluster.getClusterConfig().getName();
        }
        // if the replication happens from user defined access zone to system access zone!!
        if (args.getSourceVNAS() != null && args.getvNAS() == null) {
            VirtualNAS sourcevNAS = args.getSourceVNAS();
            String vNASName = sourcevNAS.getNasName();
            vNASName = getNameWithNoSpecialCharacters(vNASName, args);
            clusterName = clusterName + vNASName;
        }
        _log.debug("Generating path for target and the source cluster is is  {}", clusterName);
    }
    DataSource dataSource = dataSourceFactory.createIsilonFileSystemPathDataSource(args.getProject(), args.getVPool(), args.getTenantOrg(), storage);
    dataSource.addProperty(CustomConfigConstants.ISILON_CLUSTER_NAME, clusterName);
    String configPath = customConfigHandler.getComputedCustomConfigValue(CustomConfigConstants.ISILON_PATH_CUSTOMIZATION, "isilon", dataSource);
    _log.debug("The isilon user defined custom path is  {}", configPath);
    if (configPath != null && !configPath.isEmpty()) {
        path = args.getPathWithoutSpecialCharacters(configPath);
    }
    return path;
}
Also used : VirtualNAS(com.emc.storageos.db.client.model.VirtualNAS) IsilonApi(com.emc.storageos.isilon.restapi.IsilonApi) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) DataSource(com.emc.storageos.customconfigcontroller.DataSource)

Example 17 with IsilonApi

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

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

the class IsilonFileStorageDevice method getSyncPolicyErrorReport.

/**
 * get the error reports from device
 *
 * @param device - storage system
 * @param syncPolicy - synciq policy name
 * @return
 */
private BiosCommandResult getSyncPolicyErrorReport(StorageSystem device, IsilonSyncTargetPolicy policy) {
    List<IsilonSyncPolicyReport> listMirrorPolicyReports = null;
    StringBuffer errorMsgBuff = new StringBuffer();
    errorMsgBuff.append(String.format("Policy details  - failback-failover state : [%s] and policy status: [%s] ", policy.getFoFbState().toString(), policy.getLastJobState()));
    // get policy reports from device.
    IsilonApi isi = getIsilonDevice(device);
    listMirrorPolicyReports = isi.getReplicationPolicyReports(policy.getName()).getList();
    String errorMsg = mirrorOperations.isiGetReportErrMsg(listMirrorPolicyReports);
    errorMsgBuff.append(String.format("Policy Error Report details: %s", errorMsg));
    ServiceError serviceError = DeviceControllerErrors.isilon.unableToResyncPrepPolicy(device.getIpAddress(), policy.getName(), errorMsgBuff.toString());
    _log.error(errorMsgBuff.toString());
    return BiosCommandResult.createErrorResult(serviceError);
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) IsilonApi(com.emc.storageos.isilon.restapi.IsilonApi) IsilonSyncPolicyReport(com.emc.storageos.isilon.restapi.IsilonSyncPolicyReport)

Example 19 with IsilonApi

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

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

IsilonApi (com.emc.storageos.isilon.restapi.IsilonApi)81 IsilonException (com.emc.storageos.isilon.restapi.IsilonException)64 URISyntaxException (java.net.URISyntaxException)31 URI (java.net.URI)22 IsilonCollectionException (com.emc.storageos.plugins.metering.isilon.IsilonCollectionException)21 ArrayList (java.util.ArrayList)18 IsilonSyncPolicy (com.emc.storageos.isilon.restapi.IsilonSyncPolicy)14 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)13 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)12 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)12 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)12 IOException (java.io.IOException)12 JSONException (org.codehaus.jettison.json.JSONException)12 FileShare (com.emc.storageos.db.client.model.FileShare)11 BiosCommandResult (com.emc.storageos.volumecontroller.impl.BiosCommandResult)11 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)10 HashMap (java.util.HashMap)10 ControllerException (com.emc.storageos.volumecontroller.ControllerException)9 Test (org.junit.Test)8 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)7