use of com.vmware.vim25.SharesInfo in project photon-model by vmware.
the class ClientUtils method getStorageIOAllocationInfo.
/**
* Constructs storage IO allocation if this is not already dictated by the storage policy that
* is chosen.
*/
public static StorageIOAllocationInfo getStorageIOAllocationInfo(DiskService.DiskStateExpanded diskState) throws NumberFormatException {
if (diskState.customProperties != null) {
String sharesLevel = diskState.customProperties.get(SHARES_LEVEL);
// set anything on the API for this. Hence default to null.
if (sharesLevel != null) {
try {
StorageIOAllocationInfo allocationInfo = new StorageIOAllocationInfo();
SharesInfo sharesInfo = new SharesInfo();
sharesInfo.setLevel(SharesLevel.fromValue(sharesLevel));
if (sharesInfo.getLevel() == SharesLevel.CUSTOM) {
// Set shares value
String sharesVal = diskState.customProperties.get(SHARES);
if (sharesVal == null || sharesVal.isEmpty()) {
// Reset to normal as nothing is specified for the shares
sharesInfo.setLevel(SharesLevel.NORMAL);
} else {
sharesInfo.setShares(Integer.parseInt(sharesVal));
}
}
allocationInfo.setShares(sharesInfo);
String limitIops = diskState.customProperties.get(LIMIT_IOPS);
if (limitIops != null && !limitIops.isEmpty()) {
allocationInfo.setLimit(Long.parseLong(limitIops));
}
return allocationInfo;
} catch (Exception e) {
logger.warn("Ignoring the storage IO allocation customization values due to {}", e.getMessage());
return null;
}
}
}
return null;
}
Aggregations