Search in sources :

Example 1 with VNXUnityQuotaConfig

use of com.emc.storageos.vnxe.models.VNXUnityQuotaConfig in project coprhd-controller by CoprHD.

the class VNXUnityUnManagedObjectDiscoverer method discoverAllTreeQuotas.

public void discoverAllTreeQuotas(AccessProfile accessProfile, DbClient dbClient, PartitionManager partitionManager) {
    StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, accessProfile.getSystemId());
    VNXeApiClient apiClient = getVnxUnityClient(accessProfile);
    log.info("discoverAllTreeQuotas for storage system {} - start", storageSystem.getId());
    unManagedTreeQuotaInsert = new ArrayList<UnManagedFileQuotaDirectory>();
    unManagedTreeQuotaUpdate = new ArrayList<UnManagedFileQuotaDirectory>();
    List<VNXUnityTreeQuota> treeQuotas = apiClient.getAllTreeQuotas();
    for (VNXUnityTreeQuota quota : treeQuotas) {
        log.info("Discovered fS tree quota {}", quota.toString());
        VNXeFileSystem fs = null;
        if (quota.getFilesystem() != null) {
            fs = apiClient.getFileSystemByFSId(quota.getFilesystem().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;
                }
                String nativeUnmanagedGUID = NativeGUIDGenerator.generateNativeGuidForPreExistingQuotaDirectory(storageSystem.getSystemType(), storageSystem.getSerialNumber(), quota.getId());
                VNXUnityQuotaConfig qc = apiClient.getQuotaConfigById(quota.getQuotaConfigId());
                UnManagedFileQuotaDirectory unManagedFileQuotaDirectory = getExistingUnManagedQuotaDirectory(dbClient, nativeUnmanagedGUID);
                boolean existingUnManagedQD = true;
                if (unManagedFileQuotaDirectory == null) {
                    unManagedFileQuotaDirectory = new UnManagedFileQuotaDirectory();
                    existingUnManagedQD = false;
                    unManagedFileQuotaDirectory.setId(URIUtil.createId(UnManagedFileQuotaDirectory.class));
                }
                unManagedFileQuotaDirectory.setLabel(quota.getPath().substring(1));
                unManagedFileQuotaDirectory.setNativeGuid(nativeUnmanagedGUID);
                unManagedFileQuotaDirectory.setParentFSNativeGuid(fsNativeGUID);
                unManagedFileQuotaDirectory.setSize(quota.getHardLimit());
                Long size = quota.getHardLimit() > 0 ? quota.getHardLimit() : fs.getSizeAllocated();
                Long softLimit = 0L;
                if (quota.getSoftLimit() > 0) {
                    softLimit = quota.getSoftLimit() * 100 / size;
                    int softGrace = qc.getGracePeriod() / (24 * 60 * 60);
                    unManagedFileQuotaDirectory.setSoftGrace(softGrace);
                }
                unManagedFileQuotaDirectory.setSoftLimit(softLimit.intValue());
                unManagedFileQuotaDirectory.setNotificationLimit(0);
                unManagedFileQuotaDirectory.setNativeId(quota.getId());
                if (!existingUnManagedQD) {
                    unManagedTreeQuotaInsert.add(unManagedFileQuotaDirectory);
                } else {
                    unManagedTreeQuotaUpdate.add(unManagedFileQuotaDirectory);
                }
            } catch (IOException e) {
                log.error("IOException occured in discoverAllTreeQuotas()", e);
            }
        }
    }
    if (!unManagedTreeQuotaInsert.isEmpty()) {
        // Add UnManagedFileSystem
        partitionManager.insertInBatches(unManagedTreeQuotaInsert, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_FILEQUOTADIR);
        unManagedTreeQuotaInsert.clear();
    }
    if (!unManagedTreeQuotaUpdate.isEmpty()) {
        // Update UnManagedFilesystem
        partitionManager.updateInBatches(unManagedTreeQuotaUpdate, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_FILEQUOTADIR);
        unManagedTreeQuotaUpdate.clear();
    }
}
Also used : VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) VNXeFileSystem(com.emc.storageos.vnxe.models.VNXeFileSystem) UnManagedFileQuotaDirectory(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileQuotaDirectory) IOException(java.io.IOException) VNXUnityTreeQuota(com.emc.storageos.vnxe.models.VNXUnityTreeQuota) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) VNXUnityQuotaConfig(com.emc.storageos.vnxe.models.VNXUnityQuotaConfig)

Aggregations

AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)1 ContainmentConstraint (com.emc.storageos.db.client.constraint.ContainmentConstraint)1 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)1 UnManagedFileQuotaDirectory (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileQuotaDirectory)1 VNXeApiClient (com.emc.storageos.vnxe.VNXeApiClient)1 VNXUnityQuotaConfig (com.emc.storageos.vnxe.models.VNXUnityQuotaConfig)1 VNXUnityTreeQuota (com.emc.storageos.vnxe.models.VNXUnityTreeQuota)1 VNXeFileSystem (com.emc.storageos.vnxe.models.VNXeFileSystem)1 IOException (java.io.IOException)1