Search in sources :

Example 1 with IsilonSMBShare

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

the class IsilonFileStorageDevice method doesCIFSShareExistsForFSPath.

private boolean doesCIFSShareExistsForFSPath(final StorageSystem storageSystem, String isilonAccessZone, String path) {
    String resumeToken = null;
    URI storageSystemId = storageSystem.getId();
    _log.info("Checking CIFS share for path {}  on Isilon storage system: {} in access zone {} - start", path, storageSystem.getLabel(), isilonAccessZone);
    try {
        IsilonApi isilonApi = getIsilonDevice(storageSystem);
        do {
            IsilonApi.IsilonList<IsilonSMBShare> isilonShares = isilonApi.listShares(resumeToken, isilonAccessZone);
            List<IsilonSMBShare> isilonSMBShareList = isilonShares.getList();
            for (IsilonSMBShare share : isilonSMBShareList) {
                if (share.getPath().equals(path)) {
                    _log.info("Found CIFS share with path {} and name {} on Ision: {} in access zone: {}", path, share.getName(), storageSystem.getLabel(), isilonAccessZone);
                    return true;
                }
            }
            resumeToken = isilonShares.getToken();
        } while (resumeToken != null);
        _log.info("CIFS share not found with path {} on Ision: {} in access zone: {}", path, storageSystem.getLabel(), isilonAccessZone);
        return false;
    } catch (IsilonException ie) {
        _log.error("doesCIFSShareExistForFSPath failed. Storage system: {}", storageSystemId, ie);
        IsilonCollectionException ice = new IsilonCollectionException("doesCIFSShareExistForFSPath failed. Storage system: " + storageSystemId);
        ice.initCause(ie);
        throw ice;
    } catch (Exception e) {
        _log.error("doesCIFSShareExistForFSPath failed. Storage system: {}", storageSystemId, e);
        IsilonCollectionException ice = new IsilonCollectionException("doesCIFSShareExistForFSPath failed. Storage system: " + storageSystemId);
        ice.initCause(e);
        throw ice;
    }
}
Also used : IsilonSMBShare(com.emc.storageos.isilon.restapi.IsilonSMBShare) 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 2 with IsilonSMBShare

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

the class IsilonFileStorageDevice method getIsilonSMBShare.

/**
 * get share details
 *
 * @param isilonApi
 * @param shareId
 * @return
 */
private IsilonSMBShare getIsilonSMBShare(IsilonApi isilonApi, String shareId, String zoneName) {
    _log.debug("call getIsilonSMBShare for {} ", shareId);
    IsilonSMBShare isilonSMBShare = null;
    try {
        if (isilonApi != null) {
            isilonSMBShare = isilonApi.getShare(shareId, zoneName);
            _log.debug("call getIsilonSMBShare {}", isilonSMBShare.toString());
        }
    } catch (Exception e) {
        _log.error("Exception while getting SMBShare for {}", shareId);
    }
    return isilonSMBShare;
}
Also used : IsilonSMBShare(com.emc.storageos.isilon.restapi.IsilonSMBShare) 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)

Example 3 with IsilonSMBShare

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

the class IsilonCommunicationInterface method discoverAccessZoneSMBShares.

/**
 * Get all SMB shares of storagesystem
 *
 * @param storageSystem
 * @return
 */
private HashMap<String, HashSet<String>> discoverAccessZoneSMBShares(final StorageSystem storageSystem, String isilonAccessZone) {
    // Discover All FileShares
    String resumeToken = null;
    HashMap<String, HashSet<String>> allShares = new HashMap<String, HashSet<String>>();
    URI storageSystemId = storageSystem.getId();
    _log.info("discoverAllShares for storage system {} - start", storageSystemId);
    try {
        IsilonApi isilonApi = getIsilonDevice(storageSystem);
        do {
            IsilonApi.IsilonList<IsilonSMBShare> isilonShares = isilonApi.listShares(resumeToken, isilonAccessZone);
            List<IsilonSMBShare> isilonSMBShareList = isilonShares.getList();
            HashSet<String> sharesHashSet = null;
            for (IsilonSMBShare share : isilonSMBShareList) {
                // get the filesystem path and shareid
                String path = share.getPath();
                String shareId = share.getId();
                sharesHashSet = allShares.get(path);
                if (null == sharesHashSet) {
                    sharesHashSet = new HashSet<String>();
                    sharesHashSet.add(shareId);
                    allShares.put(path, sharesHashSet);
                } else {
                    // if shares already exist for path then add
                    sharesHashSet.add(shareId);
                    allShares.put(path, sharesHashSet);
                }
                _log.info("Discovered SMB Share name {} and path {}", shareId, path);
            }
            resumeToken = isilonShares.getToken();
        } while (resumeToken != null);
        _log.info("discoverd AllShares for access zone {} ", isilonAccessZone);
        return allShares;
    } catch (IsilonException ie) {
        _log.error("discoverAllShares failed. Storage system: {}", storageSystemId, ie);
        IsilonCollectionException ice = new IsilonCollectionException("discoverAllShares failed. Storage system: " + storageSystemId);
        ice.initCause(ie);
        throw ice;
    } catch (Exception e) {
        _log.error("discoverAllShares failed. Storage system: {}", storageSystemId, e);
        IsilonCollectionException ice = new IsilonCollectionException("discoverAllShares failed. Storage system: " + storageSystemId);
        ice.initCause(e);
        throw ice;
    }
}
Also used : ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) IsilonCollectionException(com.emc.storageos.plugins.metering.isilon.IsilonCollectionException) URI(java.net.URI) 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) IsilonSMBShare(com.emc.storageos.isilon.restapi.IsilonSMBShare) IsilonApi(com.emc.storageos.isilon.restapi.IsilonApi) HashSet(java.util.HashSet) IsilonException(com.emc.storageos.isilon.restapi.IsilonException)

Example 4 with IsilonSMBShare

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

the class IsilonCommunicationInterface method getIsilonSMBShare.

/**
 * get share details
 *
 * @param isilonApi
 * @param shareId
 * @return
 */
private IsilonSMBShare getIsilonSMBShare(IsilonApi isilonApi, String shareId, String zoneName) {
    _log.debug("call getIsilonSMBShare for {} ", shareId);
    IsilonSMBShare isilonSMBShare = null;
    try {
        if (isilonApi != null) {
            isilonSMBShare = isilonApi.getShare(shareId, zoneName);
            _log.debug("call getIsilonSMBShare {}", isilonSMBShare.toString());
        }
    } catch (Exception e) {
        _log.error("Exception while getting SMBShare for {}", shareId);
    }
    return isilonSMBShare;
}
Also used : IsilonSMBShare(com.emc.storageos.isilon.restapi.IsilonSMBShare) 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)

Example 5 with IsilonSMBShare

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

Aggregations

IsilonSMBShare (com.emc.storageos.isilon.restapi.IsilonSMBShare)10 IsilonApi (com.emc.storageos.isilon.restapi.IsilonApi)4 IsilonException (com.emc.storageos.isilon.restapi.IsilonException)4 IsilonCollectionException (com.emc.storageos.plugins.metering.isilon.IsilonCollectionException)4 URISyntaxException (java.net.URISyntaxException)4 Permission (com.emc.storageos.isilon.restapi.IsilonSMBShare.Permission)3 ShareACL (com.emc.storageos.model.file.ShareACL)3 HashMap (java.util.HashMap)3 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)2 ContainmentConstraint (com.emc.storageos.db.client.constraint.ContainmentConstraint)2 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)2 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)2 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)2 ControllerException (com.emc.storageos.volumecontroller.ControllerException)2 IOException (java.io.IOException)2 URI (java.net.URI)2 JSONException (org.codehaus.jettison.json.JSONException)2 NASServer (com.emc.storageos.db.client.model.NASServer)1 NamedURI (com.emc.storageos.db.client.model.NamedURI)1 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)1