Search in sources :

Example 1 with IsilonSmartQuota

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

the class IsilonFileStorageDevice method doUpdateQuotaDirectory.

@Override
public BiosCommandResult doUpdateQuotaDirectory(StorageSystem storage, FileDeviceInputOutput args, QuotaDirectory quotaDir) throws ControllerException {
    // Get Parent FS mount path
    // Get Quota Directory Name
    // Get Quota Size
    // Call Update Quota (Aways use that quota for updating the size)
    QuotaDirectory quotaDirObj = null;
    String fsMountPath = args.getFsMountPath();
    Long qDirSize = quotaDir.getSize();
    String qDirPath = fsMountPath + "/" + quotaDir.getName();
    _log.info("IsilonFileStorageDevice doUpdateQuotaDirectory {} with size {} - start", qDirPath, qDirSize);
    try {
        IsilonApi isi = getIsilonDevice(storage);
        URI qtreeURI = quotaDir.getId();
        quotaDirObj = _dbClient.queryObject(QuotaDirectory.class, qtreeURI);
        String quotaId = null;
        if (quotaDirObj.getExtensions() != null) {
            quotaId = quotaDirObj.getExtensions().get(QUOTA);
        }
        if (quotaId != null) {
            // Isilon does not allow to update quota directory to zero.
            IsilonSmartQuota isiCurrentSmartQuota = isi.getQuota(quotaId);
            long quotaUsageSpace = isiCurrentSmartQuota.getUsagePhysical();
            if (qDirSize > 0 && qDirSize.compareTo(quotaUsageSpace) > 0) {
                _log.info("IsilonFileStorageDevice doUpdateQuotaDirectory , Update Quota {} with Capacity {}", quotaId, qDirSize);
                IsilonSmartQuota expandedQuota = getQuotaDirectoryExpandedSmartQuota(quotaDir, qDirSize, args.getFsCapacity(), isi);
                isi.modifyQuota(quotaId, expandedQuota);
            } else {
                Double dUsage = SizeUtil.translateSize(quotaUsageSpace, SizeUtil.SIZE_GB);
                Double dQuotaSize = SizeUtil.translateSize(qDirSize, SizeUtil.SIZE_GB);
                String msg = String.format("as requested reduced size [%.1fGB] is smaller than used capacity [%.1fGB] for filesystem %s", dQuotaSize, dUsage, args.getFs().getName());
                _log.error("doUpdateQuotaDirectory : " + msg);
                ServiceError error = DeviceControllerErrors.isilon.unableUpdateQuotaDirectory(msg);
                return BiosCommandResult.createErrorResult(error);
            }
        } else {
            // Create a new Quota
            String qid = checkThresholdAndcreateQuota(quotaDir, qDirSize, qDirPath, null, isi);
            if (args.getQuotaDirExtensions() == null) {
                args.initQuotaDirExtensions();
            }
            args.getQuotaDirExtensions().put(QUOTA, qid);
        }
        _log.info("IsilonFileStorageDevice doUpdateQuotaDirectory {} with size {} - complete", qDirPath, qDirSize);
        return BiosCommandResult.createSuccessfulResult();
    } catch (IsilonException e) {
        _log.error("doUpdateQuotaDirectory failed.", e);
        return BiosCommandResult.createErrorResult(e);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) IsilonSmartQuota(com.emc.storageos.isilon.restapi.IsilonSmartQuota) QuotaDirectory(com.emc.storageos.db.client.model.QuotaDirectory) IsilonApi(com.emc.storageos.isilon.restapi.IsilonApi) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) IsilonException(com.emc.storageos.isilon.restapi.IsilonException)

Example 2 with IsilonSmartQuota

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

the class IsilonFileStorageDevice method isiExpandFS.

private void isiExpandFS(IsilonApi isi, String quotaId, FileDeviceInputOutput args) throws ControllerException, IsilonException {
    // get quota from Isilon and check that requested capacity is larger than the current capacity
    Long capacity = args.getNewFSCapacity();
    IsilonSmartQuota quota = isi.getQuota(quotaId);
    Long hard = quota.getThresholds().getHard();
    if (capacity.compareTo(hard) < 0) {
        String msg = String.format("In expanding Isilon FS requested capacity is less than current capacity of file system. Path: %s, current capacity: %d", quota.getPath(), quota.getThresholds().getHard());
        _log.error(msg);
        throw IsilonException.exceptions.expandFsFailedinvalidParameters(quota.getPath(), quota.getThresholds().getHard());
    }
    // Modify quota for file system.
    IsilonSmartQuota expandedQuota = getExpandedQuota(isi, args, capacity);
    isi.modifyQuota(quotaId, expandedQuota);
}
Also used : IsilonSmartQuota(com.emc.storageos.isilon.restapi.IsilonSmartQuota)

Example 3 with IsilonSmartQuota

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

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

the class IsilonCommunicationInterface method populateDbMetricsAz.

/**
 * process dbmetrics for total count and capacity
 *
 * @param azName
 * @param isilonApi
 * @param dbMetrics
 */
private void populateDbMetricsAz(final IsilonAccessZone accessZone, IsilonApi isilonApi, StringMap dbMetrics) {
    long totalProvCap = 0L;
    long totalFsCount = 0L;
    String resumeToken = null;
    String zoneName = accessZone.getName();
    String baseDirPath = accessZone.getPath() + "/";
    // filesystems count & used Capacity
    IsilonList<IsilonSmartQuota> quotas = null;
    do {
        quotas = isilonApi.listQuotas(resumeToken, baseDirPath);
        if (quotas != null && !quotas.getList().isEmpty()) {
            for (IsilonSmartQuota quota : quotas.getList()) {
                totalProvCap = totalProvCap + quota.getUsagePhysical();
                totalFsCount++;
            }
        }
        resumeToken = quotas.getToken();
    } while (resumeToken != null);
    // create a list of access zone for which base dir is not same as system access zone.
    // we get all snapshot list at once. baseDirPaths list is used to
    // find snaphot belong to which access zone.
    List<String> baseDirPaths = null;
    if (accessZone.isSystem() == true) {
        List<IsilonAccessZone> isilonAccessZoneList = isilonApi.getAccessZones(resumeToken);
        baseDirPaths = new ArrayList<String>();
        for (IsilonAccessZone isiAccessZone : isilonAccessZoneList) {
            if (!baseDirPath.equals(IFS_ROOT + "/")) {
                baseDirPaths.add(isiAccessZone.getPath() + "/");
            }
        }
    }
    // snapshots count & snap capacity
    resumeToken = null;
    IsilonList<IsilonSnapshot> snapshots = null;
    do {
        snapshots = isilonApi.listSnapshots(resumeToken);
        if (snapshots != null && !snapshots.getList().isEmpty()) {
            if (!baseDirPath.equals(IFS_ROOT + "/")) {
                // if it is not system access zone then compare
                // with fs path with base dir path
                _log.info("access zone base directory path {}", baseDirPath);
                for (IsilonSnapshot isilonSnap : snapshots.getList()) {
                    if (isilonSnap.getPath().startsWith(baseDirPath)) {
                        totalProvCap = totalProvCap + Long.valueOf(isilonSnap.getSize());
                        totalFsCount++;
                    }
                }
            } else {
                // process the snapshots for system access zone
                boolean snapSystem = true;
                for (IsilonSnapshot isilonSnap : snapshots.getList()) {
                    snapSystem = true;
                    // first check fs path with user defined AZ's paths
                    if (baseDirPaths != null && !baseDirPaths.isEmpty()) {
                        for (String basePath : baseDirPaths) {
                            if (isilonSnap.getPath().startsWith(basePath)) {
                                snapSystem = false;
                                break;
                            }
                        }
                    }
                    // it then it is belongs to access zone with basedir same as system access zone.
                    if (snapSystem) {
                        totalProvCap = totalProvCap + Long.valueOf(isilonSnap.getSize());
                        totalFsCount++;
                        _log.info("Access zone base directory path: {}", accessZone.getPath());
                    }
                }
            }
            resumeToken = snapshots.getToken();
        }
    } while (resumeToken != null);
    if (totalProvCap > 0) {
        totalProvCap = (totalProvCap / KB_IN_BYTES);
    }
    _log.info("Total fs Count {} for access zone : {}", String.valueOf(totalFsCount), accessZone.getName());
    _log.info("Total fs Capacity {} for access zone : {}", String.valueOf(totalProvCap), accessZone.getName());
    // get total exports
    int nfsExportsCount = 0;
    int cifsSharesCount = 0;
    resumeToken = null;
    IsilonList<IsilonExport> isilonNfsExports = null;
    do {
        isilonNfsExports = isilonApi.listExports(resumeToken, zoneName);
        if (isilonNfsExports != null) {
            nfsExportsCount = nfsExportsCount + isilonNfsExports.size();
            resumeToken = isilonNfsExports.getToken();
        }
    } while (resumeToken != null);
    _log.info("Total NFS exports {} for access zone : {}", String.valueOf(nfsExportsCount), accessZone.getName());
    // get cifs exports for given access zone
    resumeToken = null;
    IsilonList<IsilonSMBShare> isilonCifsExports = null;
    do {
        isilonCifsExports = isilonApi.listShares(resumeToken, zoneName);
        if (isilonCifsExports != null) {
            cifsSharesCount = cifsSharesCount + isilonCifsExports.size();
            resumeToken = isilonCifsExports.getToken();
        }
    } while (resumeToken != null);
    _log.info("Total CIFS sharess {} for access zone : {}", String.valueOf(cifsSharesCount), accessZone.getName());
    if (dbMetrics == null) {
        dbMetrics = new StringMap();
    }
    // set total nfs and cifs exports for give AZ
    dbMetrics.put(MetricsKeys.totalNfsExports.name(), String.valueOf(nfsExportsCount));
    dbMetrics.put(MetricsKeys.totalCifsShares.name(), String.valueOf(cifsSharesCount));
    // set total fs objects and their sum of capacity for give AZ
    dbMetrics.put(MetricsKeys.storageObjects.name(), String.valueOf(totalFsCount));
    dbMetrics.put(MetricsKeys.usedStorageCapacity.name(), String.valueOf(totalProvCap));
    Long maxExports = MetricsKeys.getLong(MetricsKeys.maxNFSExports, dbMetrics) + MetricsKeys.getLong(MetricsKeys.maxCifsShares, dbMetrics);
    Long maxStorObjs = MetricsKeys.getLong(MetricsKeys.maxStorageObjects, dbMetrics);
    Long maxCapacity = MetricsKeys.getLong(MetricsKeys.maxStorageCapacity, dbMetrics);
    Long totalExports = Long.valueOf(nfsExportsCount + cifsSharesCount);
    // setting overLoad factor (true or false)
    String overLoaded = FALSE;
    if (totalExports >= maxExports || totalProvCap >= maxCapacity || totalFsCount >= maxStorObjs) {
        overLoaded = TRUE;
    }
    double percentageLoadExports = 0.0;
    // percentage calculator
    if (totalExports > 0.0) {
        percentageLoadExports = ((double) (totalExports) / maxExports) * 100;
    }
    double percentageLoadStorObj = ((double) (totalProvCap) / maxCapacity) * 100;
    double percentageLoad = (percentageLoadExports + percentageLoadStorObj) / 2;
    dbMetrics.put(MetricsKeys.percentLoad.name(), String.valueOf(percentageLoad));
    dbMetrics.put(MetricsKeys.overLoaded.name(), overLoaded);
    return;
}
Also used : IsilonExport(com.emc.storageos.isilon.restapi.IsilonExport) StringMap(com.emc.storageos.db.client.model.StringMap) IsilonSmartQuota(com.emc.storageos.isilon.restapi.IsilonSmartQuota) IsilonAccessZone(com.emc.storageos.isilon.restapi.IsilonAccessZone) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) IsilonSMBShare(com.emc.storageos.isilon.restapi.IsilonSMBShare) IsilonSnapshot(com.emc.storageos.isilon.restapi.IsilonSnapshot)

Example 5 with IsilonSmartQuota

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

the class IsilonFileStorageDevice method isiReduceFS.

/**
 * restapi request for reduction of fileshare size.
 *
 * @param isi
 * @param quotaId
 * @param args
 * @throws ControllerException
 * @throws IsilonException
 */
private void isiReduceFS(IsilonApi isi, String quotaId, FileDeviceInputOutput args) throws ControllerException, IsilonException {
    Long capacity = args.getNewFSCapacity();
    IsilonSmartQuota quota = isi.getQuota(quotaId);
    // Modify quoties for fileshare
    quota = getExpandedQuota(isi, args, capacity);
    isi.modifyQuota(quotaId, quota);
}
Also used : IsilonSmartQuota(com.emc.storageos.isilon.restapi.IsilonSmartQuota)

Aggregations

IsilonSmartQuota (com.emc.storageos.isilon.restapi.IsilonSmartQuota)8 IsilonApi (com.emc.storageos.isilon.restapi.IsilonApi)5 IsilonException (com.emc.storageos.isilon.restapi.IsilonException)5 FileShare (com.emc.storageos.db.client.model.FileShare)3 IsilonCollectionException (com.emc.storageos.plugins.metering.isilon.IsilonCollectionException)3 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)3 URI (java.net.URI)3 URISyntaxException (java.net.URISyntaxException)3 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)2 ContainmentConstraint (com.emc.storageos.db.client.constraint.ContainmentConstraint)2 UnManagedSMBFileShare (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedSMBFileShare)2 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)2 IsilonAccessZone (com.emc.storageos.isilon.restapi.IsilonAccessZone)2 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 JSONException (org.codehaus.jettison.json.JSONException)2 DataObject (com.emc.storageos.db.client.model.DataObject)1 DiscoveredDataObject (com.emc.storageos.db.client.model.DiscoveredDataObject)1 NamedURI (com.emc.storageos.db.client.model.NamedURI)1