use of com.emc.storageos.vnxe.models.VNXeNfsShare in project coprhd-controller by CoprHD.
the class VNXUnityCommunicationInterface method populateDbMetrics.
/**
* Calculate nas server metrics
*
* @param nasServer
* @param apiClient
* @return StringMap containing calculated metrics
*/
private StringMap populateDbMetrics(final VNXeNasServer nasServer, VNXeApiClient client) {
StringMap dbMetrics = new StringMap();
long totalProvCap = 0L;
long totalFsCount = 0L;
// get total exports
int nfsSharesCount = 0;
int cifsSharesCount = 0;
List<VNXeFileSystem> fileSystemList = client.getFileSystemsForNasServer(nasServer.getId());
if (fileSystemList != null && !fileSystemList.isEmpty()) {
for (VNXeFileSystem fs : fileSystemList) {
totalProvCap = totalProvCap + fs.getSizeTotal();
totalFsCount++;
List<VNXeNfsShare> nfsShares = client.getNfsSharesForFileSystem(fs.getId());
if (nfsShares != null && !nfsShares.isEmpty()) {
nfsSharesCount = nfsSharesCount + nfsShares.size();
}
List<VNXeCifsShare> cifsShares = client.getCifsSharesForFileSystem(fs.getId());
if (cifsShares != null && !cifsShares.isEmpty()) {
cifsSharesCount = cifsSharesCount + cifsShares.size();
}
List<VNXeFileSystemSnap> snapshotsList = client.getFileSystemSnaps(fs.getId());
if (snapshotsList != null && !snapshotsList.isEmpty()) {
for (VNXeFileSystemSnap snap : snapshotsList) {
totalProvCap = totalProvCap + snap.getSize();
totalFsCount++;
List<VNXeNfsShare> snapNfsShares = client.getNfsSharesForSnap(snap.getId());
if (snapNfsShares != null && !snapNfsShares.isEmpty()) {
nfsSharesCount = nfsSharesCount + snapNfsShares.size();
}
List<VNXeCifsShare> snapCifsShares = client.getCifsSharesForSnap(snap.getId());
if (snapCifsShares != null && !snapCifsShares.isEmpty()) {
cifsSharesCount = cifsSharesCount + snapCifsShares.size();
}
}
}
}
}
if (totalProvCap > 0) {
totalProvCap = (totalProvCap / KB_IN_BYTES);
}
_logger.info("Total fs Count {} for nas server : {}", String.valueOf(totalFsCount), nasServer.getName());
_logger.info("Total fs Capacity {} for nas server : {}", String.valueOf(totalProvCap), nasServer.getName());
// Set max limits in dbMetrics
StringMap maxDbMetrics = getMaxDbMetrics(client);
dbMetrics.putAll(maxDbMetrics);
// set total nfs and cifs exports for this nas server
dbMetrics.put(MetricsKeys.totalNfsExports.name(), String.valueOf(nfsSharesCount));
dbMetrics.put(MetricsKeys.totalCifsShares.name(), String.valueOf(cifsSharesCount));
// set total fs objects and their sum of capacity for this nas server
dbMetrics.put(MetricsKeys.storageObjects.name(), String.valueOf(totalFsCount));
dbMetrics.put(MetricsKeys.usedStorageCapacity.name(), String.valueOf(totalProvCap));
Long maxExports = MetricsKeys.getLong(MetricsKeys.maxExports, dbMetrics);
Long maxStorObjs = MetricsKeys.getLong(MetricsKeys.maxStorageObjects, dbMetrics);
Long maxCapacity = MetricsKeys.getLong(MetricsKeys.maxStorageCapacity, dbMetrics);
Long totalExports = Long.valueOf(nfsSharesCount + 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 dbMetrics;
}
use of com.emc.storageos.vnxe.models.VNXeNfsShare in project coprhd-controller by CoprHD.
the class VNXeStorageDevice method extraExportRuleFromArray.
/**
* Get the export rule which are present in array but not in CoprHD Database.
*
* @param storage
* @param args
* @return map with security flavor and export rule
*/
private Map<String, ExportRule> extraExportRuleFromArray(StorageSystem storage, FileDeviceInputOutput args) {
// map to store the export rule grouped by sec flavor
Map<String, ExportRule> exportRuleMap = new HashMap<>();
List<VNXeNfsShare> exportsList = new ArrayList<VNXeNfsShare>();
Set<String> arrayReadOnlyHost = new HashSet<>();
Set<String> arrayReadWriteHost = new HashSet<>();
Set<String> arrayRootHost = new HashSet<>();
Set<String> dbReadOnlyHost = new HashSet<>();
Set<String> dbReadWriteHost = new HashSet<>();
Set<String> dbRootHost = new HashSet<>();
// get all export rule from CoprHD data base
List<ExportRule> existingDBExportRules = args.getExistingDBExportRules();
// get the all the export from the storage system.
VNXeApiClient apiClient = getVnxeClient(storage);
for (ExportRule exportRule : existingDBExportRules) {
if (exportRule.getReadOnlyHosts() != null) {
dbReadOnlyHost.addAll(exportRule.getReadOnlyHosts());
}
if (exportRule.getReadWriteHosts() != null) {
dbReadWriteHost.addAll(exportRule.getReadWriteHosts());
}
if (exportRule.getRootHosts() != null) {
dbRootHost.addAll(exportRule.getRootHosts());
}
String vnxeExportId = exportRule.getDeviceExportId();
if (vnxeExportId != null) {
List<VNXeNfsShare> vnxeExports = null;
vnxeExports = apiClient.getNfsSharesForFileSystem(args.getFs().getNativeId());
exportsList.addAll(vnxeExports);
for (VNXeNfsShare vnXeNfsShare : vnxeExports) {
List<VNXeBase> hostIdReadOnly = vnXeNfsShare.getReadOnlyHosts();
for (VNXeBase vnXeBase : hostIdReadOnly) {
VNXeHost host = apiClient.getHostById(vnXeBase.getId());
arrayReadOnlyHost.add(host.getName());
}
List<VNXeBase> hostIdReadWrite = vnXeNfsShare.getReadWriteHosts();
for (VNXeBase vnXeBase : hostIdReadWrite) {
VNXeHost host = apiClient.getHostById(vnXeBase.getId());
arrayReadWriteHost.add(host.getName());
}
List<VNXeBase> hostIdRootHost = vnXeNfsShare.getRootAccessHosts();
for (VNXeBase vnXeBase : hostIdRootHost) {
VNXeHost host = apiClient.getHostById(vnXeBase.getId());
arrayRootHost.add(host.getName());
}
}
}
// find out the change between array and CoprHD database.
Set<String> arrayExtraReadOnlyHost = Sets.difference(arrayReadOnlyHost, dbReadOnlyHost);
Set<String> arrayExtraReadWriteHost = Sets.difference(arrayReadWriteHost, dbReadWriteHost);
Set<String> arrayExtraRootHost = Sets.difference(arrayRootHost, dbRootHost);
// if change found update the exportRuleMap
if (!arrayExtraReadOnlyHost.isEmpty() || !arrayExtraReadWriteHost.isEmpty() || !arrayExtraRootHost.isEmpty()) {
ExportRule extraRuleFromArray = new ExportRule();
extraRuleFromArray.setDeviceExportId(exportRule.getDeviceExportId());
extraRuleFromArray.setAnon(exportRule.getAnon());
extraRuleFromArray.setSecFlavor(exportRule.getSecFlavor());
extraRuleFromArray.setExportPath(exportRule.getExportPath());
extraRuleFromArray.setReadOnlyHosts(arrayExtraReadOnlyHost);
extraRuleFromArray.setReadWriteHosts(arrayExtraReadWriteHost);
extraRuleFromArray.setRootHosts(arrayExtraRootHost);
exportRuleMap.put(exportRule.getSecFlavor(), extraRuleFromArray);
}
}
return exportRuleMap;
}
use of com.emc.storageos.vnxe.models.VNXeNfsShare in project coprhd-controller by CoprHD.
the class VNXeUnManagedObjectDiscoverer method discoverAllExportRules.
public void discoverAllExportRules(AccessProfile accessProfile, DbClient dbClient, PartitionManager partitionManager) {
StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, accessProfile.getSystemId());
VNXeApiClient apiClient = getVnxeClient(accessProfile);
log.info("discoverAllExportRules for storage system {} - start", storageSystem.getId());
unManagedExportRulesInsert = new ArrayList<UnManagedFileExportRule>();
unManagedExportRulesUpdate = new ArrayList<UnManagedFileExportRule>();
unManagedFilesystemsUpdate = new ArrayList<UnManagedFileSystem>();
List<VNXeNfsShare> nfsExports = apiClient.getAllNfsShares();
// Verification Utility
UnManagedExportVerificationUtility validationUtility = new UnManagedExportVerificationUtility(dbClient);
for (VNXeNfsShare exp : nfsExports) {
log.info("Discovered fS export {}", exp.toString());
VNXeFileSystem fs = null;
if (exp.getParentFilesystem() != null) {
fs = apiClient.getFileSystemByFSId(exp.getParentFilesystem().getId());
String fsNativeGuid = NativeGUIDGenerator.generateNativeGuid(storageSystem.getSystemType(), storageSystem.getSerialNumber(), fs.getId());
try {
if (checkStorageFileSystemExistsInDB(fsNativeGuid, dbClient)) {
log.info("Skipping file system {} as it is already managed by ViPR", fsNativeGuid);
continue;
}
// Create UnManaged FS
String fsUnManagedFsNativeGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingFileSystem(storageSystem.getSystemType(), storageSystem.getSerialNumber().toUpperCase(), fs.getId());
UnManagedFileSystem unManagedFs = checkUnManagedFileSystemExistsInDB(dbClient, fsUnManagedFsNativeGuid);
StoragePort storagePort = getStoragePortPool(storageSystem, dbClient, apiClient, fs);
String mountPath = extractValueFromStringSet(SupportedFileSystemInformation.MOUNT_PATH.toString(), unManagedFs.getFileSystemInformation());
String exportPath = exp.getPath();
if (!exportPath.equalsIgnoreCase("/")) {
mountPath = mountPath + exportPath;
}
String mountPoint = storagePort.getPortNetworkId() + ":" + mountPath;
String nfsShareId = exp.getId();
String fsUnManagedFileExportRuleNativeGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingFileExportRule(storageSystem, nfsShareId);
log.info("Native GUID {}", fsUnManagedFileExportRuleNativeGuid);
UnManagedFileExportRule unManagedExportRule = checkUnManagedFsExportRuleExistsInDB(dbClient, fsUnManagedFileExportRuleNativeGuid);
UnManagedFileExportRule unManagedExpRule = null;
List<UnManagedFileExportRule> unManagedExportRules = new ArrayList<UnManagedFileExportRule>();
if (unManagedExportRule == null) {
unManagedExportRule = new UnManagedFileExportRule();
unManagedExportRule.setNativeGuid(fsUnManagedFileExportRuleNativeGuid);
unManagedExportRule.setFileSystemId(unManagedFs.getId());
unManagedExportRule.setId(URIUtil.createId(UnManagedFileExportRule.class));
unManagedExpRule = createExportRules(unManagedFs.getId(), apiClient, exp, unManagedExportRule, mountPath, mountPoint, nfsShareId, storagePort.getPortName());
unManagedExportRulesInsert.add(unManagedExpRule);
} else {
unManagedExpRule = createExportRules(unManagedFs.getId(), apiClient, exp, unManagedExportRule, mountPath, mountPoint, nfsShareId, storagePort.getPortName());
unManagedExportRulesUpdate.add(unManagedExpRule);
}
log.info("Unmanaged File Export Rule : {}", unManagedExportRule);
// Build all export rules list.
unManagedExportRules.add(unManagedExpRule);
// apply as per API SVC Validations.
if (!unManagedExportRules.isEmpty()) {
boolean isAllRulesValid = validationUtility.validateUnManagedExportRules(unManagedExportRules, false);
if (isAllRulesValid) {
log.info("Validating rules success for export {}", unManagedFs.getPath());
unManagedFs.setHasExports(true);
unManagedFs.putFileSystemCharacterstics(UnManagedFileSystem.SupportedFileSystemCharacterstics.IS_FILESYSTEM_EXPORTED.toString(), Boolean.TRUE.toString());
unManagedFilesystemsUpdate.add(unManagedFs);
log.info("File System {} has Exports and their size is {}", unManagedFs.getId(), unManagedExportRules.size());
} else {
log.warn("Validating rules failed for export {}. Ignroing to import these rules into ViPR DB", unManagedFs);
unManagedFs.setInactive(true);
unManagedFilesystemsUpdate.add(unManagedFs);
}
}
} catch (IOException e) {
log.error("IOException occured in discoverAllExportRules()", e);
}
}
if (!unManagedExportRulesInsert.isEmpty() && unManagedExportRulesInsert.size() >= Constants.DEFAULT_PARTITION_SIZE) {
// Add UnManage export rules
partitionManager.insertInBatches(unManagedExportRulesInsert, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_EXPORT_RULE);
unManagedExportRulesInsert.clear();
}
if (!unManagedExportRulesUpdate.isEmpty() && unManagedExportRulesUpdate.size() >= Constants.DEFAULT_PARTITION_SIZE) {
// Update UnManage export rules
partitionManager.updateInBatches(unManagedExportRulesUpdate, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_EXPORT_RULE);
unManagedExportRulesUpdate.clear();
}
if (!unManagedFilesystemsUpdate.isEmpty() && unManagedFilesystemsUpdate.size() >= Constants.DEFAULT_PARTITION_SIZE) {
// Update UnManagedFilesystem
partitionManager.updateInBatches(unManagedFilesystemsUpdate, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_FILESYSTEM);
unManagedFilesystemsUpdate.clear();
}
}
if (!unManagedExportRulesInsert.isEmpty()) {
// Add UnManage export rules
partitionManager.insertInBatches(unManagedExportRulesInsert, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_EXPORT_RULE);
unManagedExportRulesInsert.clear();
}
if (!unManagedExportRulesUpdate.isEmpty()) {
// Update UnManage export rules
partitionManager.updateInBatches(unManagedExportRulesUpdate, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_EXPORT_RULE);
unManagedExportRulesUpdate.clear();
}
if (!unManagedFilesystemsUpdate.isEmpty()) {
// Update UnManagedFilesystem
partitionManager.updateInBatches(unManagedFilesystemsUpdate, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_FILESYSTEM);
unManagedFilesystemsUpdate.clear();
}
}
use of com.emc.storageos.vnxe.models.VNXeNfsShare in project coprhd-controller by CoprHD.
the class VNXUnityFileStorageDevice method extraExportRuleFromArray.
/**
* Get the export rule which are present in array but not in CoprHD Database.
*
* @param storage
* @param args
* @return map with security flavor and export rule
*/
private Map<String, ExportRule> extraExportRuleFromArray(StorageSystem storage, FileDeviceInputOutput args) {
// map to store the export rule grouped by sec flavor
Map<String, ExportRule> exportRuleMap = new HashMap<>();
List<VNXeNfsShare> exportsList = new ArrayList<VNXeNfsShare>();
Set<String> arrayReadOnlyHost = new HashSet<>();
Set<String> arrayReadWriteHost = new HashSet<>();
Set<String> arrayRootHost = new HashSet<>();
Set<String> dbReadOnlyHost = new HashSet<>();
Set<String> dbReadWriteHost = new HashSet<>();
Set<String> dbRootHost = new HashSet<>();
// get all export rule from CoprHD data base
List<ExportRule> existingDBExportRules = args.getExistingDBExportRules();
// get the all the export from the storage system.
VNXeApiClient apiClient = getVnxUnityClient(storage);
for (ExportRule exportRule : existingDBExportRules) {
if (exportRule.getReadOnlyHosts() != null) {
dbReadOnlyHost.addAll(exportRule.getReadOnlyHosts());
}
if (exportRule.getReadWriteHosts() != null) {
dbReadWriteHost.addAll(exportRule.getReadWriteHosts());
}
if (exportRule.getRootHosts() != null) {
dbRootHost.addAll(exportRule.getRootHosts());
}
String vnxeExportId = exportRule.getDeviceExportId();
if (vnxeExportId != null) {
List<VNXeNfsShare> vnxeExports = null;
vnxeExports = apiClient.getNfsSharesForFileSystem(args.getFs().getNativeId());
exportsList.addAll(vnxeExports);
for (VNXeNfsShare vnXeNfsShare : vnxeExports) {
List<VNXeBase> hostIdReadOnly = vnXeNfsShare.getReadOnlyHosts();
for (VNXeBase vnXeBase : hostIdReadOnly) {
VNXeHost host = apiClient.getHostById(vnXeBase.getId());
arrayReadOnlyHost.add(host.getName());
}
List<VNXeBase> hostIdReadWrite = vnXeNfsShare.getReadWriteHosts();
for (VNXeBase vnXeBase : hostIdReadWrite) {
VNXeHost host = apiClient.getHostById(vnXeBase.getId());
arrayReadWriteHost.add(host.getName());
}
List<VNXeBase> hostIdRootHost = vnXeNfsShare.getRootAccessHosts();
for (VNXeBase vnXeBase : hostIdRootHost) {
VNXeHost host = apiClient.getHostById(vnXeBase.getId());
arrayRootHost.add(host.getName());
}
}
}
// find out the change between array and CoprHD database.
Set<String> arrayExtraReadOnlyHost = Sets.difference(arrayReadOnlyHost, dbReadOnlyHost);
Set<String> arrayExtraReadWriteHost = Sets.difference(arrayReadWriteHost, dbReadWriteHost);
Set<String> arrayExtraRootHost = Sets.difference(arrayRootHost, dbRootHost);
// if change found update the exportRuleMap
if (!arrayExtraReadOnlyHost.isEmpty() || !arrayExtraReadWriteHost.isEmpty() || !arrayExtraRootHost.isEmpty()) {
ExportRule extraRuleFromArray = new ExportRule();
extraRuleFromArray.setDeviceExportId(exportRule.getDeviceExportId());
extraRuleFromArray.setAnon(exportRule.getAnon());
extraRuleFromArray.setSecFlavor(exportRule.getSecFlavor());
extraRuleFromArray.setExportPath(exportRule.getExportPath());
extraRuleFromArray.setReadOnlyHosts(arrayExtraReadOnlyHost);
extraRuleFromArray.setReadWriteHosts(arrayExtraReadWriteHost);
extraRuleFromArray.setRootHosts(arrayExtraRootHost);
exportRuleMap.put(exportRule.getSecFlavor(), extraRuleFromArray);
}
}
return exportRuleMap;
}
use of com.emc.storageos.vnxe.models.VNXeNfsShare in project coprhd-controller by CoprHD.
the class VNXUnityFileStorageDevice method doCheckFSDependencies.
@Override
public BiosCommandResult doCheckFSDependencies(StorageSystem storage, FileDeviceInputOutput args) {
VNXeApiClient apiClient = getVnxUnityClient(storage);
_logger.info("Checking file system {} has dependencies in storage array: {}", args.getFsName(), storage.getLabel());
boolean hasDependency = true;
FileShare fs = args.getFs();
try {
String fsMountPath = args.getFsMountPath();
List<VNXeNfsShare> nfsShares = apiClient.getNfsSharesForFileSystem(fs.getNativeId());
hasDependency = (nfsShares != null && !nfsShares.isEmpty());
if (!hasDependency) {
List<VNXeCifsShare> cifsShares = apiClient.getCifsSharesForFileSystem(fs.getNativeId());
hasDependency = (cifsShares != null && !cifsShares.isEmpty());
}
if (!hasDependency) {
List<VNXeFileSystemSnap> snapshots = apiClient.getFileSystemSnaps(fs.getNativeId());
hasDependency = (snapshots != null && !snapshots.isEmpty());
}
if (hasDependency) {
_logger.error("File system has dependencies on array: {}", args.getFsName());
DeviceControllerException e = DeviceControllerException.exceptions.fileSystemHasDependencies(fsMountPath);
return BiosCommandResult.createErrorResult(e);
}
_logger.info("File system has no dependencies on array: {}", args.getFsName());
return BiosCommandResult.createSuccessfulResult();
} catch (VNXeException e) {
_logger.error("Checking FS dependencies failed.", e);
throw e;
} catch (Exception ex) {
_logger.error("Checking FS dependencies failed.", ex);
throw ex;
}
}
Aggregations