sureshanaparti commented on code in PR #8407:
URL: https://github.com/apache/cloudstack/pull/8407#discussion_r1436954414
##########
plugins/storage/volume/linstor/src/main/java/org/apache/cloudstack/storage/datastore/util/LinstorUtil.java:
##########
@@ -136,28 +136,33 @@ public static String
getSnapshotPath(com.linbit.linstor.api.model.StoragePool sp
return path;
}
- public static long getCapacityBytes(String linstorUrl, String
rscGroupName) {
- DevelopersApi linstorApi = getLinstorAPI(linstorUrl);
- try {
- List<ResourceGroup> rscGrps = linstorApi.resourceGroupList(
+ public static List<StoragePool> getRscGroupStoragePools(DevelopersApi api,
String rscGroupName)
+ throws ApiException {
+ List<ResourceGroup> rscGrps = api.resourceGroupList(
Collections.singletonList(rscGroupName),
null,
null,
null);
- if (rscGrps.isEmpty()) {
- final String errMsg = String.format("Linstor: Resource group
'%s' not found", rscGroupName);
- s_logger.error(errMsg);
- throw new CloudRuntimeException(errMsg);
- }
+ if (rscGrps.isEmpty()) {
+ final String errMsg = String.format("Linstor: Resource group '%s'
not found", rscGroupName);
+ s_logger.error(errMsg);
+ throw new CloudRuntimeException(errMsg);
+ }
- List<StoragePool> storagePools = linstorApi.viewStoragePools(
+ return api.viewStoragePools(
Collections.emptyList(),
rscGrps.get(0).getSelectFilter().getStoragePoolList(),
null,
null,
null
- );
+ );
+ }
+
+ public static long getCapacityBytes(String linstorUrl, String
rscGroupName) {
+ DevelopersApi linstorApi = getLinstorAPI(linstorUrl);
+ try {
+ List<StoragePool> storagePools =
getRscGroupStoragePools(linstorApi, rscGroupName);
Review Comment:
Hi @rp- _getRscGroupStoragePools()_ / other api method calls can return
null? if so, in any case, pls handle them wherever applicable.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]