use of com.vmware.photon.controller.model.adapterapi.ComputeEnumerateResourceRequest in project photon-model by vmware.
the class VsphereDatastoreEnumerationHelper method updateStorageDescription.
private static void updateStorageDescription(VSphereIncrementalEnumerationService service, StorageDescription oldDocument, EnumerationProgress enumerationProgress, DatastoreOverlay ds, boolean fullUpdate) {
ComputeEnumerateResourceRequest request = enumerationProgress.getRequest();
String regionId = enumerationProgress.getRegionId();
StorageDescription desc;
if (fullUpdate) {
desc = makeStorageFromResults(request, ds, regionId, enumerationProgress);
} else {
desc = makeStorageFromChanges(ds, oldDocument);
}
desc.documentSelfLink = oldDocument.documentSelfLink;
desc.resourcePoolLink = null;
if (oldDocument.tenantLinks == null) {
desc.tenantLinks = enumerationProgress.getTenantLinks();
}
service.logFine(() -> String.format("Syncing Storage %s", ds.getName()));
Operation.createPatch(PhotonModelUriUtils.createInventoryUri(service.getHost(), desc.documentSelfLink)).setBody(desc).setCompletion((o, e) -> {
trackDatastore(enumerationProgress, ds).handle(o, e);
if (e == null) {
VsphereEnumerationHelper.submitWorkToVSpherePool(service, () -> {
VsphereEnumerationHelper.updateLocalTags(service, enumerationProgress, ds, o.getBody(ResourceState.class));
updateStorageStats(service, ds, o.getBody(ServiceDocument.class).documentSelfLink);
});
}
}).sendWith(service);
}
use of com.vmware.photon.controller.model.adapterapi.ComputeEnumerateResourceRequest in project photon-model by vmware.
the class VsphereStoragePolicyEnumerationHelper method createNewStoragePolicy.
static void createNewStoragePolicy(VSphereIncrementalEnumerationService service, EnumerationProgress enumerationProgress, StoragePolicyOverlay sp) {
ComputeEnumerateResourceRequest request = enumerationProgress.getRequest();
ResourceGroupState rgState = makeStoragePolicyFromResults(request, sp, enumerationProgress.getDcLink());
rgState.tenantLinks = enumerationProgress.getTenantLinks();
service.logFine(() -> String.format("Found new Storage Policy %s", sp.getName()));
Operation.createPost(PhotonModelUriUtils.createInventoryUri(service.getHost(), ResourceGroupService.FACTORY_LINK)).setBody(rgState).setCompletion((o, e) -> {
trackStoragePolicy(service, enumerationProgress, sp).handle(o, e);
// Update all compatible datastores group link with the self link of this
// storage policy
updateDataStoreWithStoragePolicyGroup(service, enumerationProgress, sp, o.getBody(ResourceGroupState.class).documentSelfLink);
}).sendWith(service);
}
use of com.vmware.photon.controller.model.adapterapi.ComputeEnumerateResourceRequest in project photon-model by vmware.
the class VSphereNetworkEnumerationHelper method makeNetworkStateFromResults.
private static NetworkState makeNetworkStateFromResults(VSphereIncrementalEnumerationService service, EnumerationProgress enumerationProgress, NetworkOverlay net) {
ComputeEnumerateResourceRequest request = enumerationProgress.getRequest();
ComputeStateWithDescription parent = enumerationProgress.getParent();
NetworkState state = new NetworkState();
state.documentSelfLink = NetworkService.FACTORY_LINK + "/" + service.getHost().nextUUID();
state.id = state.name = net.getName();
state.endpointLink = enumerationProgress.getRequest().endpointLink;
AdapterUtils.addToEndpointLinks(state, enumerationProgress.getRequest().endpointLink);
state.regionId = enumerationProgress.getRegionId();
state.resourcePoolLink = request.resourcePoolLink;
state.adapterManagementReference = request.adapterManagementReference;
state.authCredentialsLink = parent.description.authCredentialsLink;
URI ref = parent.description.instanceAdapterReference;
state.instanceAdapterReference = AdapterUriUtil.buildAdapterUri(ref.getPort(), VSphereUriPaths.DVS_NETWORK_SERVICE);
CustomProperties custProp = CustomProperties.of(state).put(CustomProperties.MOREF, net.getId()).put(CustomProperties.DATACENTER_SELF_LINK, enumerationProgress.getDcLink()).put(CustomProperties.TYPE, net.getId().getType());
if (net.getSummary() instanceof OpaqueNetworkSummary) {
OpaqueNetworkSummary ons = (OpaqueNetworkSummary) net.getSummary();
custProp.put(NsxProperties.OPAQUE_NET_ID, ons.getOpaqueNetworkId());
custProp.put(NsxProperties.OPAQUE_NET_TYPE, ons.getOpaqueNetworkType());
}
if (net.getId().getType().equals(VimNames.TYPE_DVS)) {
// dvs'es have a stable link
state.documentSelfLink = buildStableDvsLink(net.getId(), request.endpointLink);
custProp.put(DvsProperties.DVS_UUID, net.getDvsUuid());
}
VsphereEnumerationHelper.populateResourceStateWithAdditionalProps(state, enumerationProgress.getVcUuid());
return state;
}
use of com.vmware.photon.controller.model.adapterapi.ComputeEnumerateResourceRequest in project photon-model by vmware.
the class VSphereResourcePoolEnumerationHelper method processFoundResourcePool.
public static void processFoundResourcePool(VSphereIncrementalEnumerationService service, EnumerationProgress enumerationProgress, ResourcePoolOverlay rp, String ownerName, EnumerationClient client) {
ComputeEnumerateResourceRequest request = enumerationProgress.getRequest();
String selfLink = buildStableResourcePoolLink(rp.getId(), request.endpointLink);
Operation.createGet(PhotonModelUriUtils.createInventoryUri(service.getHost(), selfLink)).setCompletion((o, e) -> {
try {
if (e == null) {
updateResourcePool(service, enumerationProgress, ownerName, selfLink, rp, true, client);
} else if (e instanceof ServiceNotFoundException || o.getStatusCode() == Operation.STATUS_CODE_NOT_FOUND) {
createNewResourcePool(service, enumerationProgress, ownerName, selfLink, rp, client);
} else {
enumerationProgress.getResourcePoolTracker().track();
}
} catch (Exception ex) {
enumerationProgress.getResourcePoolTracker().track(rp.getId(), ResourceTracker.ERROR);
}
}).sendWith(service);
}
Aggregations