use of com.emc.storageos.vnxe.models.VNXeFileSystemSnap 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.VNXeFileSystemSnap in project coprhd-controller by CoprHD.
the class VNXeStorageDevice method getFSSnapshotList.
@Override
public BiosCommandResult getFSSnapshotList(StorageSystem storage, FileDeviceInputOutput fd, List<String> snapshots) throws ControllerException {
_logger.info("getFSSnapshotList {} - start", fd.getFsId());
VNXeApiClient client = getVnxeClient(storage);
try {
List<VNXeFileSystemSnap> snaps = client.getFileSystemSnaps(fd.getFsNativeId());
for (VNXeFileSystemSnap snap : snaps) {
snapshots.add(snap.getName());
}
return BiosCommandResult.createSuccessfulResult();
} catch (VNXeException e) {
_logger.error("getFSSnapshotList failed.", e);
return BiosCommandResult.createErrorResult(e);
}
}
use of com.emc.storageos.vnxe.models.VNXeFileSystemSnap in project coprhd-controller by CoprHD.
the class VNXeRestoreFileSystemSnapshotJob method syncSnapshots.
private void syncSnapshots(DbClient dbClient, FileShare fsObj, VNXeApiClient vnxeApiClient) {
// Retrieve all snapshots from DB that belong to this file system
URIQueryResultList results = new URIQueryResultList();
dbClient.queryByConstraint(ContainmentConstraint.Factory.getFileshareSnapshotConstraint(fsObj.getId()), results);
// Setup snapshot name-object map
Map<String, Snapshot> snapshotsInDB = new ConcurrentHashMap<String, Snapshot>();
while (results.iterator().hasNext()) {
URI uri = results.iterator().next();
Snapshot snap = dbClient.queryObject(Snapshot.class, uri);
String nativeId = snap.getNativeId();
if (nativeId == null || nativeId.isEmpty()) {
// no nativeId set in the snap, remove it from db.
snap.setInactive(true);
dbClient.persistObject(snap);
_logger.info("No nativeId, removing the snapshot: {}", snap.getId());
continue;
} else {
snapshotsInDB.put(nativeId, snap);
}
}
// Retrieve list of valid snapshot names from the device
List<VNXeFileSystemSnap> snapshots = vnxeApiClient.getFileSystemSnaps(fsObj.getNativeId());
List<String> snapIdsOnDevice = new ArrayList<String>();
for (VNXeFileSystemSnap snap : snapshots) {
snapIdsOnDevice.add(snap.getId());
}
// Iterate through the snapshots in the DB and if name not found in
// the list returned by the device, mark snapshot in DB as inactive
Set<String> snapshotNativeIds = snapshotsInDB.keySet();
for (String snapshotId : snapshotNativeIds) {
if (!snapIdsOnDevice.contains(snapshotId)) {
_logger.info("Removing the snapshot: {}", snapshotId);
snapshotsInDB.get(snapshotId).setInactive(true);
dbClient.persistObject(snapshotsInDB.get(snapshotId));
}
}
// newly discovered snapshot to the DB.
for (VNXeFileSystemSnap snap : snapshots) {
if (!snapshotNativeIds.contains(snap.getId())) {
_logger.info("adding the snapshot: {}", snap.getId());
Snapshot newSnap = new Snapshot();
newSnap.setCreationTime(Calendar.getInstance());
newSnap.setId(URIUtil.createId(Snapshot.class));
newSnap.setParent(new NamedURI(fsObj.getId(), fsObj.getLabel()));
newSnap.setLabel(snap.getName());
newSnap.setOpStatus(new OpStatusMap());
newSnap.setProject(new NamedURI(fsObj.getProject().getURI(), fsObj.getProject().getName()));
newSnap.setNativeId(snap.getId());
try {
newSnap.setNativeGuid(NativeGUIDGenerator.generateNativeGuid(dbClient, newSnap));
} catch (IOException e) {
_logger.info("Exception while setting snap's nativeGUID");
}
}
}
}
use of com.emc.storageos.vnxe.models.VNXeFileSystemSnap in project coprhd-controller by CoprHD.
the class VNXUnityFileStorageDevice method getFSSnapshotList.
@Override
public BiosCommandResult getFSSnapshotList(StorageSystem storage, FileDeviceInputOutput fd, List<String> snapshots) throws ControllerException {
_logger.info("getFSSnapshotList {} - start", fd.getFsId());
VNXeApiClient client = getVnxUnityClient(storage);
try {
List<VNXeFileSystemSnap> snaps = client.getFileSystemSnaps(fd.getFsNativeId());
for (VNXeFileSystemSnap snap : snaps) {
snapshots.add(snap.getName());
}
return BiosCommandResult.createSuccessfulResult();
} catch (VNXeException e) {
_logger.error("getFSSnapshotList failed.", e);
return BiosCommandResult.createErrorResult(e);
}
}
use of com.emc.storageos.vnxe.models.VNXeFileSystemSnap 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