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();
}
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();
}
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);
}
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();
}
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();
}
Aggregations