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;
}
}
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;
}
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;
}
}
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;
}
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;
}
Aggregations