Search in sources :

Example 11 with ResourceGroupState

use of com.vmware.photon.controller.model.resources.ResourceGroupService.ResourceGroupState in project photon-model by vmware.

the class TestGCPEnumerationAtScale method createResourcePoolAndComputeHost.

private void createResourcePoolAndComputeHost() throws Throwable {
    // Create a resource pool where the VM will be housed.
    this.outPool = createDefaultResourcePool(this.host);
    // Create a resource group for the GCP project.
    ResourceGroupState resourceGroup = createDefaultResourceGroup(this.host, this.projectID);
    // Create a compute host for the GCP VM.
    this.computeHost = createDefaultComputeHost(this.host, this.userEmail, this.privateKey, this.zoneID, this.outPool.documentSelfLink, resourceGroup.documentSelfLink);
}
Also used : ResourceGroupState(com.vmware.photon.controller.model.resources.ResourceGroupService.ResourceGroupState)

Example 12 with ResourceGroupState

use of com.vmware.photon.controller.model.resources.ResourceGroupService.ResourceGroupState in project photon-model by vmware.

the class TestGCPStatsCollection method createResourcePoolAndComputeHostState.

/**
 * Creates the state associated with the resource pool and compute host.
 * @throws Throwable Exception during creation of default resource pool and compute host.
 */
private void createResourcePoolAndComputeHostState() throws Throwable {
    // Create a resource pool where the VM will be housed.
    this.outPool = createDefaultResourcePool(this.host);
    // Create a resource group for the GCP project.
    ResourceGroupState resourceGroup = createDefaultResourceGroup(this.host, this.projectID);
    // Create a compute host for the GCP VM.
    this.computeHost = createDefaultComputeHost(this.host, this.userEmail, this.privateKey, this.zoneID, this.outPool.documentSelfLink, resourceGroup.documentSelfLink);
}
Also used : ResourceGroupState(com.vmware.photon.controller.model.resources.ResourceGroupService.ResourceGroupState)

Example 13 with ResourceGroupState

use of com.vmware.photon.controller.model.resources.ResourceGroupService.ResourceGroupState in project photon-model by vmware.

the class VSphereNetworkEnumerationHelper method makeNetworkGroup.

private static ResourceGroupState makeNetworkGroup(NetworkOverlay net, EnumerationProgress ctx) {
    ResourceGroupState res = new ResourceGroupState();
    res.id = net.getName();
    res.name = "Hosts connected to network '" + net.getName() + "'";
    res.endpointLink = ctx.getRequest().endpointLink;
    AdapterUtils.addToEndpointLinks(res, ctx.getRequest().endpointLink);
    res.tenantLinks = ctx.getTenantLinks();
    CustomProperties.of(res).put(CustomProperties.MOREF, net.getId()).put(CustomProperties.TARGET_LINK, ctx.getNetworkTracker().getSelfLink(net.getId()));
    res.documentSelfLink = VsphereEnumerationHelper.computeGroupStableLink(net.getId(), VSphereIncrementalEnumerationService.PREFIX_NETWORK, ctx.getRequest().endpointLink);
    return res;
}
Also used : ResourceGroupState(com.vmware.photon.controller.model.resources.ResourceGroupService.ResourceGroupState)

Example 14 with ResourceGroupState

use of com.vmware.photon.controller.model.resources.ResourceGroupService.ResourceGroupState in project photon-model by vmware.

the class VsphereDatastoreEnumerationHelper method makeStorageGroup.

private static ResourceGroupState makeStorageGroup(DatastoreOverlay ds, EnumerationProgress ctx) {
    ResourceGroupState res = new ResourceGroupState();
    res.id = ds.getName();
    res.name = "Hosts that can access datastore '" + ds.getName() + "'";
    res.endpointLink = ctx.getRequest().endpointLink;
    AdapterUtils.addToEndpointLinks(res, ctx.getRequest().endpointLink);
    res.tenantLinks = ctx.getTenantLinks();
    CustomProperties.of(res).put(CustomProperties.MOREF, ds.getId()).put(CustomProperties.TARGET_LINK, ctx.getDatastoreTracker().getSelfLink(ds.getId()));
    res.documentSelfLink = VsphereEnumerationHelper.computeGroupStableLink(ds.getId(), VSphereIncrementalEnumerationService.PREFIX_DATASTORE, ctx.getRequest().endpointLink);
    VsphereEnumerationHelper.populateResourceStateWithAdditionalProps(res, ctx.getVcUuid());
    return res;
}
Also used : ResourceGroupState(com.vmware.photon.controller.model.resources.ResourceGroupService.ResourceGroupState)

Example 15 with ResourceGroupState

use of com.vmware.photon.controller.model.resources.ResourceGroupService.ResourceGroupState in project photon-model by vmware.

the class VsphereFolderEnumerationHelper method createFolder.

private static void createFolder(VSphereIncrementalEnumerationService service, EnumerationProgress ctx, FolderOverlay folder, List<FolderOverlay> rootFolders, EnumerationClient client) throws InvalidPropertyFaultMsg, RuntimeFaultFaultMsg {
    ResourceGroupState state = makeFolderFromResults(ctx, folder, rootFolders, client);
    Operation.createPost(PhotonModelUriUtils.createInventoryUri(service.getHost(), ResourceGroupService.FACTORY_LINK)).setBody(state).setCompletion((o, e) -> {
        trackFolder(ctx, folder).handle(o, e);
        service.logInfo("Creating document for folder with name %s", folder.getName());
    }).sendWith(service);
}
Also used : AdapterUtils(com.vmware.photon.controller.model.adapters.util.AdapterUtils) ComputeProperties(com.vmware.photon.controller.model.ComputeProperties) ResourceState(com.vmware.photon.controller.model.resources.ResourceState) PhotonModelUriUtils(com.vmware.photon.controller.model.util.PhotonModelUriUtils) Operation(com.vmware.xenon.common.Operation) QueryTask(com.vmware.xenon.services.common.QueryTask) QueryUtils(com.vmware.photon.controller.model.query.QueryUtils) ObjectUpdateKind(com.vmware.vim25.ObjectUpdateKind) RuntimeFaultFaultMsg(com.vmware.vim25.RuntimeFaultFaultMsg) ResourceGroupState(com.vmware.photon.controller.model.resources.ResourceGroupService.ResourceGroupState) VimNames(com.vmware.photon.controller.model.adapters.vsphere.util.VimNames) ManagedObjectReference(com.vmware.vim25.ManagedObjectReference) VsphereEnumerationHelper.getSelfLinkFromOperation(com.vmware.photon.controller.model.adapters.vsphere.VsphereEnumerationHelper.getSelfLinkFromOperation) ResourceGroupService(com.vmware.photon.controller.model.resources.ResourceGroupService) List(java.util.List) InvalidPropertyFaultMsg(com.vmware.vim25.InvalidPropertyFaultMsg) VsphereEnumerationHelper.convertOnlyResultToDocument(com.vmware.photon.controller.model.adapters.vsphere.VsphereEnumerationHelper.convertOnlyResultToDocument) CompletionHandler(com.vmware.xenon.common.Operation.CompletionHandler) VsphereEnumerationHelper.withTaskResults(com.vmware.photon.controller.model.adapters.vsphere.VsphereEnumerationHelper.withTaskResults) ServiceDocumentQueryResult(com.vmware.xenon.common.ServiceDocumentQueryResult) Builder(com.vmware.xenon.services.common.QueryTask.Query.Builder) Collections(java.util.Collections) ResourceGroupState(com.vmware.photon.controller.model.resources.ResourceGroupService.ResourceGroupState)

Aggregations

ResourceGroupState (com.vmware.photon.controller.model.resources.ResourceGroupService.ResourceGroupState)31 Operation (com.vmware.xenon.common.Operation)10 QueryTask (com.vmware.xenon.services.common.QueryTask)10 ComputeProperties (com.vmware.photon.controller.model.ComputeProperties)9 QueryUtils (com.vmware.photon.controller.model.query.QueryUtils)9 ResourceState (com.vmware.photon.controller.model.resources.ResourceState)9 List (java.util.List)9 AdapterUtils (com.vmware.photon.controller.model.adapters.util.AdapterUtils)8 ResourceGroupService (com.vmware.photon.controller.model.resources.ResourceGroupService)8 StorageDescription (com.vmware.photon.controller.model.resources.StorageDescriptionService.StorageDescription)8 ManagedObjectReference (com.vmware.vim25.ManagedObjectReference)8 ServiceDocumentQueryResult (com.vmware.xenon.common.ServiceDocumentQueryResult)8 Collections (java.util.Collections)8 CompletionHandler (com.vmware.xenon.common.Operation.CompletionHandler)7 Utils (com.vmware.xenon.common.Utils)7 AuthCredentialsServiceState (com.vmware.xenon.services.common.AuthCredentialsService.AuthCredentialsServiceState)7 ArrayList (java.util.ArrayList)7 HashSet (java.util.HashSet)7 Builder (com.vmware.xenon.services.common.QueryTask.Query.Builder)6 VimNames (com.vmware.photon.controller.model.adapters.vsphere.util.VimNames)5