Search in sources :

Example 1 with VNXeFileSystemSnap

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;
}
Also used : StringMap(com.emc.storageos.db.client.model.StringMap) VNXeFileSystem(com.emc.storageos.vnxe.models.VNXeFileSystem) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) VNXeFileSystemSnap(com.emc.storageos.vnxe.models.VNXeFileSystemSnap) VNXeNfsShare(com.emc.storageos.vnxe.models.VNXeNfsShare) VNXeCifsShare(com.emc.storageos.vnxe.models.VNXeCifsShare)

Example 2 with VNXeFileSystemSnap

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);
    }
}
Also used : VNXeFileSystemSnap(com.emc.storageos.vnxe.models.VNXeFileSystemSnap) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) VNXeException(com.emc.storageos.vnxe.VNXeException)

Example 3 with VNXeFileSystemSnap

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");
            }
        }
    }
}
Also used : NamedURI(com.emc.storageos.db.client.model.NamedURI) ArrayList(java.util.ArrayList) OpStatusMap(com.emc.storageos.db.client.model.OpStatusMap) IOException(java.io.IOException) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) VNXeFileSystemSnap(com.emc.storageos.vnxe.models.VNXeFileSystemSnap) Snapshot(com.emc.storageos.db.client.model.Snapshot) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap)

Example 4 with VNXeFileSystemSnap

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);
    }
}
Also used : VNXeFileSystemSnap(com.emc.storageos.vnxe.models.VNXeFileSystemSnap) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) VNXeException(com.emc.storageos.vnxe.VNXeException)

Example 5 with VNXeFileSystemSnap

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;
    }
}
Also used : VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) VNXeException(com.emc.storageos.vnxe.VNXeException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) VNXeFileSystemSnap(com.emc.storageos.vnxe.models.VNXeFileSystemSnap) VNXeException(com.emc.storageos.vnxe.VNXeException) VNXeNfsShare(com.emc.storageos.vnxe.models.VNXeNfsShare) VNXeCifsShare(com.emc.storageos.vnxe.models.VNXeCifsShare) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Aggregations

VNXeFileSystemSnap (com.emc.storageos.vnxe.models.VNXeFileSystemSnap)8 VNXeApiClient (com.emc.storageos.vnxe.VNXeApiClient)3 VNXeException (com.emc.storageos.vnxe.VNXeException)3 VNXeNfsShare (com.emc.storageos.vnxe.models.VNXeNfsShare)3 VNXeCifsShare (com.emc.storageos.vnxe.models.VNXeCifsShare)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)1 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)1 FileShare (com.emc.storageos.db.client.model.FileShare)1 NamedURI (com.emc.storageos.db.client.model.NamedURI)1 OpStatusMap (com.emc.storageos.db.client.model.OpStatusMap)1 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)1 Snapshot (com.emc.storageos.db.client.model.Snapshot)1 StringMap (com.emc.storageos.db.client.model.StringMap)1 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)1 NfsShareCreateForSnapParam (com.emc.storageos.vnxe.models.NfsShareCreateForSnapParam)1 NfsShareModifyForShareParam (com.emc.storageos.vnxe.models.NfsShareModifyForShareParam)1 NFSShareDefaultAccessEnum (com.emc.storageos.vnxe.models.NfsShareParam.NFSShareDefaultAccessEnum)1 VNXeBase (com.emc.storageos.vnxe.models.VNXeBase)1