use of com.emc.storageos.vnxe.models.VNXUnityTreeQuota in project coprhd-controller by CoprHD.
the class FileSystemQuotaRequests method getByName.
/**
* Get quota details by it's name
*
* @param fsId
* id of associated fs
* @param quotaName
* name of the quota
* @return VNXUnityTreeQuota - the quota object
*/
public VNXUnityTreeQuota getByName(String fsId, String quotaName) {
MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
queryParams.add(VNXeConstants.FILTER, VNXeConstants.PATH_FILTER + "\"" + "/" + quotaName + "\"" + " and " + VNXeConstants.FILE_SYSTEM_FILTER_V31 + "\"" + fsId + "\"");
setQueryParameters(queryParams);
VNXUnityTreeQuota result = null;
_url = URL;
List<VNXUnityTreeQuota> quotaList = getDataForObjects(VNXUnityTreeQuota.class);
// it should just return 1
if (quotaList != null && !quotaList.isEmpty()) {
result = quotaList.get(0);
_logger.info("file system tree quota found using the name: " + quotaName);
} else {
_logger.info("No file system tree quota found using the name: " + quotaName);
}
return result;
}
use of com.emc.storageos.vnxe.models.VNXUnityTreeQuota in project coprhd-controller by CoprHD.
the class FileSystemQuotaRequests method updateFileSystemQuotaSync.
/**
* update file system quota in sync mode
*
* @param quotaId
* Id of the quota
* @param param
* FileSystemQuotaModifyParam
* @return VNXeCommandResult
* @throws VNXeException
*/
public VNXeCommandResult updateFileSystemQuotaSync(String quotaId, FileSystemQuotaModifyParam param) throws VNXeException {
_logger.info("Sync update quota with ID: " + quotaId);
MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
queryParams.add(VNXeConstants.TIMEOUT, "0");
setQueryParameters(queryParams);
VNXUnityTreeQuota quota = getFileSystemQuota(quotaId);
_url = URL_INSTANCE + quota.getId() + URL_MODIFY;
return postRequestSync(param);
}
use of com.emc.storageos.vnxe.models.VNXUnityTreeQuota in project coprhd-controller by CoprHD.
the class FileSystemQuotaRequests method updateFileSystemQuotaAsync.
/**
* update file system quota in Async mode
*
* @param quotaId
* Id of the quota
* @param param
* FileSystemQuotaModifyParam
* @return VNXeCommandResult
* @throws VNXeException
*/
public VNXeCommandJob updateFileSystemQuotaAsync(String quotaId, FileSystemQuotaModifyParam param) throws VNXeException {
_logger.info("Async update quota with ID: " + quotaId);
unsetQueryParameters();
MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
queryParams.add(VNXeConstants.TIMEOUT, "0");
VNXUnityTreeQuota quota = getFileSystemQuota(quotaId);
unsetQueryParameters();
setQueryParameters(queryParams);
_url = URL_INSTANCE + quota.getId() + URL_MODIFY;
return postRequestAsync(param);
}
use of com.emc.storageos.vnxe.models.VNXUnityTreeQuota in project coprhd-controller by CoprHD.
the class FileSystemQuotaRequests method updateFileSystemQuotaConfig.
/**
* update file system quota config
*
* @param quotaId
* Id of the quota whose quota config is to updated
* @param param
* FileSystemQuotaConfigParam
* @return VNXeCommandResult
* @throws VNXeException
*/
public VNXeCommandJob updateFileSystemQuotaConfig(String quotaId, FileSystemQuotaConfigParam param) throws VNXeException {
VNXUnityTreeQuota quotaObj = null;
if (quotaId != null) {
quotaObj = getFileSystemQuota(quotaId);
}
FileSystemQuotaConfigRequests req = new FileSystemQuotaConfigRequests(_client);
_logger.info("updating quota config for quota ID: " + quotaId);
return req.updateFileSystemQuotaConfig(quotaObj.getQuotaConfigId(), param);
}
use of com.emc.storageos.vnxe.models.VNXUnityTreeQuota 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();
}
}
Aggregations