Search in sources :

Example 6 with IsilonSmartQuota

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

the class IsilonFileStorageDevice method doModifyFS.

@Override
public BiosCommandResult doModifyFS(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
    try {
        _log.info("IsilonFileStorageDevice doModifyFS {} - start", args.getFsId());
        IsilonApi isi = getIsilonDevice(storage);
        String quotaId = null;
        if (args.getFsExtensions() != null && args.getFsExtensions().get(QUOTA) != null) {
            quotaId = args.getFsExtensions().get(QUOTA);
        } else {
            final ServiceError serviceError = DeviceControllerErrors.isilon.unableToUpdateFileSystem(args.getFsId());
            _log.error(serviceError.getMessage());
            return BiosCommandResult.createErrorResult(serviceError);
        }
        IsilonSmartQuota expandedQuota = getExpandedQuota(isi, args, args.getFsCapacity());
        isi.modifyQuota(quotaId, expandedQuota);
        _log.info("IsilonFileStorageDevice doModifyFS {} - complete", args.getFsId());
        return BiosCommandResult.createSuccessfulResult();
    } catch (IsilonException e) {
        _log.error("doModifyFS failed.", e);
        return BiosCommandResult.createErrorResult(e);
    } catch (Exception e) {
        _log.error("doModifyFS failed.", e);
        // convert this to a ServiceError and create/or reuse a service
        // code
        ServiceError serviceError = DeviceControllerErrors.isilon.unableToUpdateFileSystem(args.getFsId());
        return BiosCommandResult.createErrorResult(serviceError);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) IsilonSmartQuota(com.emc.storageos.isilon.restapi.IsilonSmartQuota) 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 7 with IsilonSmartQuota

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

the class IsilonCommunicationInterface method discoverAllFileSystem.

private HashMap<String, Object> discoverAllFileSystem(StorageSystem storageSystem, String resumetoken, String umfsDiscoverPath) {
    URI storageSystemId = storageSystem.getId();
    try {
        _log.info("discoverAllFileSystem for storage system {} - start", storageSystemId);
        IsilonApi isilonApi = getIsilonDevice(storageSystem);
        List<IsilonAccessZone> accessZones = isilonApi.getAccessZones(null);
        List<String> tempAccessZonePath = new ArrayList<>();
        for (IsilonAccessZone accessZone : accessZones) {
            if (!accessZone.isSystem()) {
                tempAccessZonePath.add(accessZone.getPath() + "/");
            }
        }
        HashSet<String> fsPathSet = new HashSet<>();
        HashSet<String> fsQuotaPathSet = new HashSet<>();
        HashMap<String, IsilonSmartQuota> tempQuotaMap = new HashMap<>();
        IsilonApi.IsilonList<FileShare> isilonFSList = new IsilonApi.IsilonList<>();
        int accessZoneDiscPathLength = computeCustomConfigPathLengths(umfsDiscoverPath);
        IsilonApi.IsilonList<IsilonSmartQuota> quotas = isilonApi.listQuotas(resumetoken, umfsDiscoverPath);
        isilonFSList.setToken(quotas.getToken());
        for (IsilonSmartQuota quota : quotas.getList()) {
            if (quota.getType().compareTo("directory") != 0) {
                _log.debug("ignore quota path {} with quota id {}:", quota.getPath(), quota.getId() + " and quota type" + quota.getType());
                continue;
            }
            if ("/ifs/".equals(umfsDiscoverPath) && isQuotaUnderAccessZonePath(quota.getPath(), tempAccessZonePath)) {
                continue;
            }
            String fsNativeId = quota.getPath();
            if (isUnderUnmanagedDiscoveryPath(fsNativeId)) {
                int fsPathType = isQuotaOrFile(fsNativeId, accessZoneDiscPathLength);
                if (fsPathType == PATH_IS_FILE) {
                    tempQuotaMap.put(quota.getPath(), quota);
                    fsPathSet.add(fsNativeId);
                }
                if (fsPathType == PATH_IS_QUOTA) {
                    tempQuotaMap.put(quota.getPath(), quota);
                    fsQuotaPathSet.add(fsNativeId);
                }
            }
        }
        /*
             * Associate Quota directories with correct File paths
             */
        HashMap<String, Set<String>> fileQuotas = new HashMap<>();
        for (String filePath : fsPathSet) {
            HashSet<String> qdPaths = new HashSet<>();
            for (String qdPath : fsQuotaPathSet) {
                if (qdPath.startsWith(filePath + "/")) {
                    qdPaths.add(qdPath);
                }
            }
            if (!qdPaths.isEmpty()) {
                fsQuotaPathSet.removeAll(qdPaths);
                fileQuotas.put(filePath, qdPaths);
            }
        }
        HashMap<String, FileShare> fsWithQuotaMap = new HashMap<>();
        HashMap<String, UnManagedFileQuotaDirectory> qdMap = new HashMap<>();
        for (String fsNativeId : fsPathSet) {
            IsilonSmartQuota fileFsQuota = tempQuotaMap.get(fsNativeId);
            FileShare fs = extractFileShare(fsNativeId, fileFsQuota, storageSystem);
            _log.debug("quota id {} with capacity {}", fsNativeId + ":QUOTA:" + fileFsQuota.getId(), fs.getCapacity() + " used capacity " + fs.getUsedCapacity());
            fsWithQuotaMap.put(fsNativeId, fs);
            Set<String> fsQuotaIds = fileQuotas.get(fsNativeId);
            if (null != fsQuotaIds) {
                for (String quotaNativeId : fsQuotaIds) {
                    IsilonSmartQuota qdQuota = tempQuotaMap.get(quotaNativeId);
                    if (null != qdQuota) {
                        UnManagedFileQuotaDirectory qd = getUnManagedFileQuotaDirectory(fs.getNativeGuid(), qdQuota, storageSystem);
                        qdMap.put(quotaNativeId, qd);
                    }
                }
            }
        }
        List<FileShare> discoveredFS = new ArrayList<>();
        discoveredFS.addAll(fsWithQuotaMap.values());
        isilonFSList.addList(discoveredFS);
        List<UnManagedFileQuotaDirectory> discoverdQuotaDirectory = new ArrayList<>();
        discoverdQuotaDirectory.addAll(qdMap.values());
        HashMap<String, Object> discoveredFileDetails = new HashMap<>();
        discoveredFileDetails.put(UMFS_DETAILS, isilonFSList);
        discoveredFileDetails.put(UMFSQD_DETAILS, discoverdQuotaDirectory);
        discoveredFileDetails.put(UMFS_QD_MAP, fileQuotas);
        return discoveredFileDetails;
    } catch (IsilonException ie) {
        _log.error("discoverAllFileSystem failed. Storage system: {}", storageSystemId, ie);
        throw ie;
    } catch (Exception e) {
        _log.error("discoverAllFileSystem failed. Storage system: {}", storageSystemId, e);
        IsilonCollectionException ice = new IsilonCollectionException("discoverAllFileSystem failed. Storage system: " + storageSystemId);
        ice.initCause(e);
        throw ice;
    }
}
Also used : Set(java.util.Set) TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) StringSet(com.emc.storageos.db.client.model.StringSet) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) IsilonSmartQuota(com.emc.storageos.isilon.restapi.IsilonSmartQuota) ArrayList(java.util.ArrayList) IsilonCollectionException(com.emc.storageos.plugins.metering.isilon.IsilonCollectionException) URI(java.net.URI) IsilonList(com.emc.storageos.isilon.restapi.IsilonApi.IsilonList) IsilonApi(com.emc.storageos.isilon.restapi.IsilonApi) HashSet(java.util.HashSet) UnManagedFileQuotaDirectory(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileQuotaDirectory) IsilonAccessZone(com.emc.storageos.isilon.restapi.IsilonAccessZone) FileShare(com.emc.storageos.db.client.model.FileShare) UnManagedSMBFileShare(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedSMBFileShare) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) IsilonException(com.emc.storageos.isilon.restapi.IsilonException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) IOException(java.io.IOException) JSONException(org.codehaus.jettison.json.JSONException) URISyntaxException(java.net.URISyntaxException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) IsilonCollectionException(com.emc.storageos.plugins.metering.isilon.IsilonCollectionException) DiscoveredDataObject(com.emc.storageos.db.client.model.DiscoveredDataObject) DataObject(com.emc.storageos.db.client.model.DataObject) IsilonException(com.emc.storageos.isilon.restapi.IsilonException)

Example 8 with IsilonSmartQuota

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

the class IsilonCommunicationInterface method collectStatisticsInformation.

@Override
public void collectStatisticsInformation(AccessProfile accessProfile) throws BaseCollectionException {
    URI storageSystemId = null;
    StorageSystem isilonCluster = null;
    long statsCount = 0;
    try {
        _log.info("Metering for {} using ip {}", accessProfile.getSystemId(), accessProfile.getIpAddress());
        IsilonApi api = getIsilonDevice(accessProfile);
        long latestSampleTime = accessProfile.getLastSampleTime();
        storageSystemId = accessProfile.getSystemId();
        isilonCluster = _dbClient.queryObject(StorageSystem.class, storageSystemId);
        String serialNumber = isilonCluster.getSerialNumber();
        String deviceType = isilonCluster.getSystemType();
        initializeKeyMap(accessProfile);
        boolean fsChanged = false;
        List<Stat> stats = new ArrayList<Stat>();
        List<FileShare> modifiedFileSystems = new ArrayList<FileShare>();
        ZeroRecordGenerator zeroRecordGenerator = new FileZeroRecordGenerator();
        CassandraInsertion statsColumnInjector = new FileDBInsertion();
        // get usage stats from quotas
        IsilonStatsRecorder recorder = new IsilonStatsRecorder(zeroRecordGenerator, statsColumnInjector);
        _keyMap.put(Constants._TimeCollected, System.currentTimeMillis());
        // compute static load processor code
        computeStaticLoadMetrics(storageSystemId);
        Map<String, String> fileSystemsMap = getStorageSystemFileShares(storageSystemId);
        if (fileSystemsMap.isEmpty()) {
            // No file shares for the storage system,
            // ignore stats collection for the system!!!
            _log.info("No file systems found for storage device {}. Hence metering stats collection ignored.", storageSystemId);
            return;
        }
        // Process IsilonQuotas page by page (MAX 1000) in a page...
        String resumeToken = null;
        do {
            IsilonApi.IsilonList<IsilonSmartQuota> quotas = api.listQuotas(resumeToken);
            resumeToken = quotas.getToken();
            for (IsilonSmartQuota quota : quotas.getList()) {
                String fsNativeId = quota.getPath();
                String fsNativeGuid = NativeGUIDGenerator.generateNativeGuid(deviceType, serialNumber, fsNativeId);
                String fsId = fileSystemsMap.get(fsNativeGuid);
                if (fsId == null || fsId.isEmpty()) {
                    // No file shares found for the quota
                    // ignore stats collection for the file system!!!
                    _log.debug("File System does not exists with nativeid {}. Hence ignoring stats collection.", fsNativeGuid);
                    continue;
                }
                Stat stat = recorder.addUsageStat(quota, _keyMap, fsId, api);
                fsChanged = false;
                if (null != stat) {
                    stats.add(stat);
                    // Persists the file system, only if change in used capacity.
                    FileShare fileSystem = _dbClient.queryObject(FileShare.class, stat.getResourceId());
                    if (fileSystem != null) {
                        if (!fileSystem.getInactive()) {
                            if (null != fileSystem.getUsedCapacity() && null != stat.getAllocatedCapacity() && !fileSystem.getUsedCapacity().equals(stat.getAllocatedCapacity())) {
                                fileSystem.setUsedCapacity(stat.getAllocatedCapacity());
                                fsChanged = true;
                            }
                            if (null != fileSystem.getSoftLimit() && null != fileSystem.getSoftLimitExceeded() && null != quota.getThresholds() && null != quota.getThresholds().getsoftExceeded() && !fileSystem.getSoftLimitExceeded().equals(quota.getThresholds().getsoftExceeded())) {
                                // softLimitExceeded
                                fileSystem.setSoftLimitExceeded(quota.getThresholds().getsoftExceeded());
                                fsChanged = true;
                            }
                            if (fsChanged) {
                                modifiedFileSystems.add(fileSystem);
                            }
                        }
                    }
                }
                // Each batch with MAX_RECORDS_SIZE - 100 records!!!
                if (modifiedFileSystems.size() >= MAX_RECORDS_SIZE) {
                    _dbClient.updateObject(modifiedFileSystems);
                    _log.info("Processed {} file systems stats ", modifiedFileSystems.size());
                    modifiedFileSystems.clear();
                }
                if (stats.size() >= MAX_RECORDS_SIZE) {
                    _log.info("Processed {} stats", stats.size());
                    persistStatsInDB(stats);
                }
            }
            statsCount = statsCount + quotas.size();
            _log.info("Processed {} file system stats for device {} ", quotas.size(), storageSystemId);
        } while (resumeToken != null);
        zeroRecordGenerator.identifyRecordstobeZeroed(_keyMap, stats, FileShare.class);
        // write the remaining records!!
        if (!modifiedFileSystems.isEmpty()) {
            _dbClient.updateObject(modifiedFileSystems);
            _log.info("Processed {} file systems stats ", modifiedFileSystems.size());
            modifiedFileSystems.clear();
        }
        if (!stats.isEmpty()) {
            _log.info("Processed {} stats", stats.size());
            persistStatsInDB(stats);
        }
        latestSampleTime = System.currentTimeMillis();
        accessProfile.setLastSampleTime(latestSampleTime);
        _log.info("Done metering device {}, processed {} file system stats ", storageSystemId, statsCount);
    } catch (Exception e) {
        if (isilonCluster != null) {
            cleanupDiscovery(isilonCluster);
        }
        _log.error("CollectStatisticsInformation failed. Storage system: " + storageSystemId, e);
        throw (new IsilonCollectionException(e.getMessage()));
    }
}
Also used : IsilonSmartQuota(com.emc.storageos.isilon.restapi.IsilonSmartQuota) ArrayList(java.util.ArrayList) IsilonCollectionException(com.emc.storageos.plugins.metering.isilon.IsilonCollectionException) FileZeroRecordGenerator(com.emc.storageos.volumecontroller.impl.plugins.metering.file.FileZeroRecordGenerator) URI(java.net.URI) FileShare(com.emc.storageos.db.client.model.FileShare) UnManagedSMBFileShare(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedSMBFileShare) IsilonException(com.emc.storageos.isilon.restapi.IsilonException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) IOException(java.io.IOException) JSONException(org.codehaus.jettison.json.JSONException) URISyntaxException(java.net.URISyntaxException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) IsilonCollectionException(com.emc.storageos.plugins.metering.isilon.IsilonCollectionException) IsilonStatsRecorder(com.emc.storageos.volumecontroller.impl.plugins.metering.isilon.IsilonStatsRecorder) Stat(com.emc.storageos.db.client.model.Stat) CassandraInsertion(com.emc.storageos.volumecontroller.impl.plugins.metering.CassandraInsertion) IsilonApi(com.emc.storageos.isilon.restapi.IsilonApi) FileZeroRecordGenerator(com.emc.storageos.volumecontroller.impl.plugins.metering.file.FileZeroRecordGenerator) ZeroRecordGenerator(com.emc.storageos.volumecontroller.impl.plugins.metering.ZeroRecordGenerator) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) FileDBInsertion(com.emc.storageos.volumecontroller.impl.plugins.metering.file.FileDBInsertion)

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