Search in sources :

Example 6 with Builder

use of com.vmware.xenon.services.common.QueryTask.Query.Builder in project photon-model by vmware.

the class VsphereComputeResourceEnumerationHelper method queryForServerDisks.

private static QueryTask queryForServerDisks(EnumerationProgress ctx, HostScsiDisk serverDisk) {
    QueryTask.Query.Builder builder = QueryTask.Query.Builder.create().addKindFieldClause(DiskService.DiskState.class).addFieldClause(ResourceState.FIELD_NAME_NAME, serverDisk.getDisplayName()).addCompositeFieldClause(ResourceState.FIELD_NAME_CUSTOM_PROPERTIES, CustomProperties.TYPE, TYPE_SERVER_DISK);
    QueryUtils.addEndpointLink(builder, DiskService.DiskState.class, ctx.getRequest().endpointLink);
    QueryUtils.addTenantLinks(builder, ctx.getTenantLinks());
    return QueryTask.Builder.createDirectTask().setQuery(builder.build()).build();
}
Also used : Builder(com.vmware.xenon.services.common.QueryTask.Query.Builder) DiskService(com.vmware.photon.controller.model.resources.DiskService)

Example 7 with Builder

use of com.vmware.xenon.services.common.QueryTask.Query.Builder in project photon-model by vmware.

the class VSphereVMSnapshotEnumerationHelper method queryForSnapshot.

static QueryTask queryForSnapshot(EnumerationProgress ctx, String id, String vmSelfLink) {
    Builder builder = Builder.create().addKindFieldClause(SnapshotState.class).addFieldClause(SnapshotState.FIELD_NAME_ID, id).addFieldClause(SnapshotState.FIELD_NAME_COMPUTE_LINK, vmSelfLink);
    QueryUtils.addEndpointLink(builder, SnapshotState.class, ctx.getRequest().endpointLink);
    QueryUtils.addTenantLinks(builder, ctx.getTenantLinks());
    return QueryTask.Builder.createDirectTask().setQuery(builder.build()).build();
}
Also used : Builder(com.vmware.xenon.services.common.QueryTask.Query.Builder)

Example 8 with Builder

use of com.vmware.xenon.services.common.QueryTask.Query.Builder in project photon-model by vmware.

the class VSphereVirtualMachineEnumerationHelper method queryByPortGroupIdOrByOpaqueNetworkId.

/**
 * Query sub networks and networks for distributed port group id and opaque network id
 * @param service
 * @param ctx The context
 * @param fieldKey The field key to query
 * @param fieldValue The field value to query
 * @param type The type
 * @return The query task operation
 */
static Operation queryByPortGroupIdOrByOpaqueNetworkId(VSphereIncrementalEnumerationService service, EnumerationProgress ctx, String fieldKey, String fieldValue, Class<? extends ServiceDocument> type) {
    Builder builder = Builder.create().addKindFieldClause(type).addCompositeFieldClause(ResourceState.FIELD_NAME_CUSTOM_PROPERTIES, fieldKey, fieldValue);
    QueryUtils.addEndpointLink(builder, NetworkState.class, ctx.getRequest().endpointLink);
    QueryUtils.addTenantLinks(builder, ctx.getTenantLinks());
    QueryTask queryTask = QueryTask.Builder.createDirectTask().setQuery(builder.build()).setResultLimit(1).addOption(QueryTask.QuerySpecification.QueryOption.EXPAND_CONTENT).build();
    return QueryUtils.createQueryTaskOperation(service, queryTask, ServiceTypeCluster.INVENTORY_SERVICE);
}
Also used : QueryTask(com.vmware.xenon.services.common.QueryTask) Builder(com.vmware.xenon.services.common.QueryTask.Query.Builder)

Example 9 with Builder

use of com.vmware.xenon.services.common.QueryTask.Query.Builder in project photon-model by vmware.

the class VSphereVirtualMachineEnumerationHelper method queryForVm.

/**
 * Builds a query for finding a ComputeState by instanceUuid from vsphere and parent compute
 * link.
 */
static QueryTask queryForVm(EnumerationProgress ctx, String parentComputeLink, String instanceUuid, ManagedObjectReference moref) {
    Builder builder = Builder.create().addKindFieldClause(ComputeState.class).addFieldClause(ComputeState.FIELD_NAME_PARENT_LINK, parentComputeLink);
    if (null != instanceUuid) {
        builder.addFieldClause(ComputeState.FIELD_NAME_ID, instanceUuid);
    } else {
        builder.addCompositeFieldClause(ComputeState.FIELD_NAME_CUSTOM_PROPERTIES, CustomProperties.MOREF, VimUtils.convertMoRefToString(moref), QueryTask.Query.Occurance.MUST_OCCUR);
    }
    QueryUtils.addEndpointLink(builder, ComputeState.class, ctx.getRequest().endpointLink);
    QueryUtils.addTenantLinks(builder, ctx.getTenantLinks());
    return QueryTask.Builder.createDirectTask().setQuery(builder.build()).build();
}
Also used : ComputeState(com.vmware.photon.controller.model.resources.ComputeService.ComputeState) Builder(com.vmware.xenon.services.common.QueryTask.Query.Builder)

Example 10 with Builder

use of com.vmware.xenon.services.common.QueryTask.Query.Builder in project photon-model by vmware.

the class VsphereComputeResourceEnumerationHelper method queryForCluster.

private static QueryTask queryForCluster(EnumerationProgress ctx, String parentComputeLink, String moRefId) {
    Builder builder = Builder.create().addKindFieldClause(ComputeState.class).addFieldClause(ComputeState.FIELD_NAME_PARENT_LINK, parentComputeLink).addFieldClause(ComputeState.FIELD_NAME_ID, moRefId);
    QueryUtils.addEndpointLink(builder, ComputeState.class, ctx.getRequest().endpointLink);
    QueryUtils.addTenantLinks(builder, ctx.getTenantLinks());
    return QueryTask.Builder.createDirectTask().setQuery(builder.build()).build();
}
Also used : Builder(com.vmware.xenon.services.common.QueryTask.Query.Builder)

Aggregations

Builder (com.vmware.xenon.services.common.QueryTask.Query.Builder)14 QueryByPages (com.vmware.photon.controller.model.query.QueryUtils.QueryByPages)3 ResourceGroupState (com.vmware.photon.controller.model.resources.ResourceGroupService.ResourceGroupState)3 SubnetState (com.vmware.photon.controller.model.resources.SubnetService.SubnetState)3 NetworkState (com.vmware.photon.controller.model.resources.NetworkService.NetworkState)2 QueryTask (com.vmware.xenon.services.common.QueryTask)2 URI (java.net.URI)2 ApplicationTokenCredentials (com.microsoft.azure.credentials.ApplicationTokenCredentials)1 ComputeProperties (com.vmware.photon.controller.model.ComputeProperties)1 ComputeEnumerateResourceRequest (com.vmware.photon.controller.model.adapterapi.ComputeEnumerateResourceRequest)1 EnumerationAction (com.vmware.photon.controller.model.adapterapi.EnumerationAction)1 AzureUriPaths (com.vmware.photon.controller.model.adapters.azure.AzureUriPaths)1 AzureConstants (com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants)1 AUTH_HEADER_BEARER_PREFIX (com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.AUTH_HEADER_BEARER_PREFIX)1 AzureResourceType (com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.AzureResourceType)1 DEFAULT_INSTANCE_ADAPTER_REFERENCE (com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.DEFAULT_INSTANCE_ADAPTER_REFERENCE)1 LIST_VIRTUAL_NETWORKS_URI (com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.LIST_VIRTUAL_NETWORKS_URI)1 NETWORK_REST_API_VERSION (com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.NETWORK_REST_API_VERSION)1 QUERY_PARAM_API_VERSION (com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.QUERY_PARAM_API_VERSION)1 ResourceGroupStateType (com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.ResourceGroupStateType)1