Search in sources :

Example 1 with SharesInfo

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;
}
Also used : StorageIOAllocationInfo(com.vmware.vim25.StorageIOAllocationInfo) SharesInfo(com.vmware.vim25.SharesInfo) FinderException(com.vmware.photon.controller.model.adapters.vsphere.util.finders.FinderException) KeyManagementException(java.security.KeyManagementException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) URISyntaxException(java.net.URISyntaxException)

Aggregations

FinderException (com.vmware.photon.controller.model.adapters.vsphere.util.finders.FinderException)1 SharesInfo (com.vmware.vim25.SharesInfo)1 StorageIOAllocationInfo (com.vmware.vim25.StorageIOAllocationInfo)1 URISyntaxException (java.net.URISyntaxException)1 KeyManagementException (java.security.KeyManagementException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1