use of com.vmware.photon.controller.model.resources.ResourceGroupService.ResourceGroupState in project photon-model by vmware.
the class VsphereFolderEnumerationHelper method makeFolderFromChanges.
private static ResourceGroupState makeFolderFromChanges(FolderOverlay folder, EnumerationClient client) throws InvalidPropertyFaultMsg, RuntimeFaultFaultMsg {
ResourceGroupState state = new ResourceGroupState();
// Folder name change
state.name = folder.getNameOrNull();
// Folder parent change
if (null != folder.getParentOrNull()) {
// retrieve parent folder Moref
ManagedObjectReference parent = folder.getParentOrNull();
// retrieve parent of parent folder
ManagedObjectReference parentOfParentFolder = client.getParentOfFolder(parent);
// if the parent of parent folder is DC, then the parent is root folder. Add parent of parent during this scenario.
if (parentOfParentFolder.getType().equals(VimNames.TYPE_DATACENTER)) {
CustomProperties.of(state).put(CustomProperties.PARENT_ID, VimUtils.convertMoRefToString(parentOfParentFolder));
} else {
CustomProperties.of(state).put(CustomProperties.PARENT_ID, VimUtils.convertMoRefToString(parent));
}
}
return state;
}
use of com.vmware.photon.controller.model.resources.ResourceGroupService.ResourceGroupState in project photon-model by vmware.
the class VsphereFolderEnumerationHelper method updateFolder.
private static void updateFolder(VSphereIncrementalEnumerationService service, EnumerationProgress ctx, FolderOverlay folder, ResourceGroupState oldDocument, List<FolderOverlay> rootFolders, EnumerationClient client, boolean fullUpdate) throws InvalidPropertyFaultMsg, RuntimeFaultFaultMsg {
ResourceGroupState state;
if (fullUpdate) {
state = makeFolderFromResults(ctx, folder, rootFolders, client);
} else {
state = makeFolderFromChanges(folder, client);
}
state.documentSelfLink = oldDocument.documentSelfLink;
Operation.createPatch(PhotonModelUriUtils.createInventoryUri(service.getHost(), state.documentSelfLink)).setBody(state).setCompletion((o, e) -> {
trackFolder(ctx, folder).handle(o, e);
service.logInfo("updating document for folder: %s ", folder.getName());
}).sendWith(service);
}
use of com.vmware.photon.controller.model.resources.ResourceGroupService.ResourceGroupState in project photon-model by vmware.
the class VsphereStoragePolicyEnumerationHelper method makeStoragePolicyFromResults.
static ResourceGroupState makeStoragePolicyFromResults(ComputeEnumerateResourceRequest request, StoragePolicyOverlay sp, final String dcLink) {
ResourceGroupState res = new ResourceGroupState();
res.id = sp.getProfileId();
res.name = sp.getName();
res.desc = sp.getDescription();
res.endpointLink = request.endpointLink;
AdapterUtils.addToEndpointLinks(res, request.endpointLink);
res.customProperties = sp.getCapabilities();
CustomProperties.of(res).put(ComputeProperties.RESOURCE_TYPE_KEY, sp.getType()).put(CustomProperties.DATACENTER_SELF_LINK, dcLink).put(ComputeProperties.ENDPOINT_LINK_PROP_NAME, request.endpointLink);
return res;
}
use of com.vmware.photon.controller.model.resources.ResourceGroupService.ResourceGroupState in project photon-model by vmware.
the class VsphereStoragePolicyEnumerationHelper method updateStoragePolicy.
static void updateStoragePolicy(VSphereIncrementalEnumerationService service, ResourceGroupState oldDocument, EnumerationProgress enumerationProgress, StoragePolicyOverlay sp) {
ComputeEnumerateResourceRequest request = enumerationProgress.getRequest();
ResourceGroupState rgState = makeStoragePolicyFromResults(request, sp, enumerationProgress.getDcLink());
rgState.documentSelfLink = oldDocument.documentSelfLink;
if (oldDocument.tenantLinks == null) {
rgState.tenantLinks = enumerationProgress.getTenantLinks();
}
service.logFine(() -> String.format("Syncing Storage %s", sp.getName()));
Operation.createPatch(PhotonModelUriUtils.createInventoryUri(service.getHost(), rgState.documentSelfLink)).setBody(rgState).setCompletion((o, e) -> {
trackStoragePolicy(service, enumerationProgress, sp).handle(o, e);
if (e == null) {
// 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.resources.ResourceGroupService.ResourceGroupState in project photon-model by vmware.
the class BaseVSphereAdapterTest method createResourceGroupState.
/**
* Creates storage policy as resource group state
*/
protected ResourceGroupState createResourceGroupState() throws Throwable {
ResourceGroupState rg = new ResourceGroupState();
rg.id = this.spId != null ? this.spId : "testRG";
rg.name = this.spName != null ? this.spName : "testRG";
rg = TestUtils.doPost(this.host, rg, ResourceGroupState.class, UriUtils.buildUri(this.host, ResourceGroupService.FACTORY_LINK));
return rg;
}
Aggregations