Search in sources :

Example 1 with PbmProfile

use of com.vmware.pbm.PbmProfile in project photon-model by vmware.

the class VsphereStoragePolicyEnumerationHelper method createStorageProfileOverlays.

static List<StoragePolicyOverlay> createStorageProfileOverlays(VSphereIncrementalEnumerationService service, EnumerationClient client) {
    List<StoragePolicyOverlay> storagePolicies = new ArrayList<>();
    try {
        List<PbmProfile> pbmProfiles = client.retrieveStoragePolicies();
        if (!pbmProfiles.isEmpty()) {
            for (PbmProfile profile : pbmProfiles) {
                List<String> datastoreIds = client.getDatastores(profile.getProfileId());
                StoragePolicyOverlay spOverlay = new StoragePolicyOverlay(profile, datastoreIds);
                storagePolicies.add(spOverlay);
            }
        }
    } catch (Exception e) {
        // vSphere throws exception even if there are no storage policies found on the server.
        // Hence we can just log the message and continue, as with the datastore selection
        // still provisioning can proceed. Not marking the task to failure here.
        String msg = "Error processing Storage policy ";
        service.logWarning(() -> msg + ": " + e.toString());
    }
    return storagePolicies;
}
Also used : PbmProfile(com.vmware.pbm.PbmProfile) ArrayList(java.util.ArrayList)

Aggregations

PbmProfile (com.vmware.pbm.PbmProfile)1 ArrayList (java.util.ArrayList)1