本文整理汇总了Java中com.vmware.xenon.common.UriUtils.buildUri方法的典型用法代码示例。如果您正苦于以下问题:Java UriUtils.buildUri方法的具体用法?Java UriUtils.buildUri怎么用?Java UriUtils.buildUri使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.vmware.xenon.common.UriUtils
的用法示例。
在下文中一共展示了UriUtils.buildUri方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getComputeByAWSId
import com.vmware.xenon.common.UriUtils; //导入方法依赖的package包/类
/**
* Lookup a Compute by aws Id
*/
public static ComputeState getComputeByAWSId(VerificationHost host, String awsId)
throws Throwable {
URI computesURI = UriUtils.buildUri(host, ComputeService.FACTORY_LINK);
computesURI = UriUtils.buildExpandLinksQueryUri(computesURI);
computesURI = UriUtils.appendQueryParam(computesURI, "$filter",
String.format("id eq %s", awsId));
Operation op = host.waitForResponse(Operation.createGet(computesURI));
ServiceDocumentQueryResult result = op.getBody(ServiceDocumentQueryResult.class);
assertNotNull(result);
assertNotNull(result.documents);
assertEquals(1, result.documents.size());
return Utils.fromJson(result.documents.values().iterator().next(), ComputeState.class);
}
示例2: doSubStageDiskOperation
import com.vmware.xenon.common.UriUtils; //导入方法依赖的package包/类
private void doSubStageDiskOperation(ProvisionDiskTaskState updatedState,
ProvisionDiskTaskState.SubStage nextStage, DiskInstanceRequest.DiskRequestType diskRequestType) {
Operation.CompletionHandler c = (o, e) -> {
if (e != null) {
failTask(e);
return;
}
DiskInstanceRequest cr = new DiskInstanceRequest();
cr.resourceReference = createInventoryUri(this.getHost(), updatedState.diskLink);
cr.requestType = diskRequestType;
ServiceDocument subTask = o.getBody(ServiceDocument.class);
cr.taskReference = UriUtils.buildUri(this.getHost(), subTask.documentSelfLink);
cr.isMockRequest = updatedState.isMockRequest;
sendHostServiceRequest(cr, updatedState.diskAdapterReference);
};
// after setting boot order and rebooting, we want the sub
// task to patch us, the main task, to the "next" state
createSubTask(c, nextStage, updatedState);
}
示例3: postNetwork
import com.vmware.xenon.common.UriUtils; //导入方法依赖的package包/类
public static void postNetwork(VerificationHost host, NetworkState state, Operation response)
throws Throwable {
URI networkFactory = UriUtils.buildUri(host, NetworkService.FACTORY_LINK);
host.testStart(1);
Operation startPost = Operation.createPost(networkFactory)
.setBody(state)
.setCompletion((o, e) -> {
if (e != null) {
host.failIteration(e);
return;
}
response.setBody(o.getBody(NetworkState.class));
host.completeIteration();
});
host.send(startPost);
host.testWait();
}
示例4: testGetAvailableRegions
import com.vmware.xenon.common.UriUtils; //导入方法依赖的package包/类
@Test
public void testGetAvailableRegions() {
Assume.assumeFalse(this.isMock);
URI uri = UriUtils.buildUri(
ServiceHost.LOCAL_HOST,
host.getPort(),
UriPaths.AdapterTypePath.REGION_ENUMERATION_ADAPTER.adapterLink(
PhotonModelConstants.EndpointType.azure.toString().toLowerCase()), null);
Operation post = Operation.createPost(uri);
post.setBody(endpointState);
Operation operation = host.getTestRequestSender().sendAndWait(post);
RegionEnumerationResponse result = operation.getBody(RegionEnumerationResponse.class);
assertTrue(!result.regions.isEmpty());
}
示例5: performResourceStatsCollection
import com.vmware.xenon.common.UriUtils; //导入方法依赖的package包/类
/**
* Performs stats collection for given resourcePoolLink.
*/
public static StatsCollectionTaskState performResourceStatsCollection(
VerificationHost host, EnumSet<TaskOption> options, String resourcePoolLink)
throws Throwable {
StatsCollectionTaskState statsCollectionTaskState = new StatsCollectionTaskState();
statsCollectionTaskState.resourcePoolLink = resourcePoolLink;
statsCollectionTaskState.options = EnumSet.noneOf(TaskOption.class);
if (options != null) {
statsCollectionTaskState.options = options;
}
URI uri = UriUtils.buildUri(host, StatsCollectionTaskService.FACTORY_LINK);
StatsCollectionTaskState statsTask = TestUtils.doPost(
host, statsCollectionTaskState, StatsCollectionTaskState.class, uri);
return statsTask;
}
示例6: createNetworkState
import com.vmware.xenon.common.UriUtils; //导入方法依赖的package包/类
private NetworkState createNetworkState(String id) throws Throwable {
NetworkState networkState = new NetworkState();
networkState.name = id;
networkState.id = id;
networkState.endpointLink = this.endpointState.documentSelfLink;
networkState.endpointLinks = new HashSet<String>();
networkState.endpointLinks.add(this.endpointState.documentSelfLink);
networkState.tenantLinks = this.endpointState.tenantLinks;
networkState.instanceAdapterReference = UriUtils
.buildUri(this.host, AWSNetworkService.SELF_LINK);
networkState.resourcePoolLink = this.endpointState.resourcePoolLink;
networkState.regionId = this.endpointState.regionId;
return postServiceSynchronously(NetworkService.FACTORY_LINK, networkState,
NetworkState.class);
}
示例7: createCloneDescription
import com.vmware.xenon.common.UriUtils; //导入方法依赖的package包/类
protected ComputeDescriptionService.ComputeDescription createCloneDescription(String
templateComputeLink) throws Throwable {
ComputeDescriptionService.ComputeDescription computeDesc = new ComputeDescriptionService.ComputeDescription();
computeDesc.id = nextName("cloned-vm");
computeDesc.regionId = this.datacenterId;
computeDesc.documentSelfLink = computeDesc.id;
computeDesc.supportedChildren = new ArrayList<>();
computeDesc.instanceAdapterReference = UriUtils
.buildUri(this.host, VSphereUriPaths.INSTANCE_SERVICE);
computeDesc.authCredentialsLink = this.auth.documentSelfLink;
computeDesc.name = computeDesc.id;
computeDesc.dataStoreId = this.dataStoreId;
// set default cpu and memory
computeDesc.cpuCount = 1;
computeDesc.totalMemoryBytes = 1024 * 1024 * 1024; // 1GB
CustomProperties.of(computeDesc)
.put(CustomProperties.TEMPLATE_LINK, templateComputeLink);
return doPost(this.host, computeDesc,
ComputeDescriptionService.ComputeDescription.class,
UriUtils.buildUri(this.host, ComputeDescriptionService.FACTORY_LINK));
}
示例8: postStats
import com.vmware.xenon.common.UriUtils; //导入方法依赖的package包/类
/**
* Send stats for persistence.
* @param context Holds data to be posted for persistence in
* {@code context.statsResponse.statsList}
*/
private void postStats(Context context) {
if (!context.isFinalBatch && context.statsResponse.statsList.size() == 0) {
return;
}
SingleResourceStatsCollectionTaskState respBody =
new SingleResourceStatsCollectionTaskState();
respBody.taskStage = SingleResourceTaskCollectionStage
.valueOf(context.statsRequest.nextStage);
respBody.statsAdapterReference = UriUtils.buildUri(getHost(), SELF_LINK);
respBody.statsList = context.statsResponse.statsList;
respBody.computeLink = context.computeHostDesc.documentSelfLink;
respBody.isFinalBatch = context.isFinalBatch;
sendRequest(Operation.createPatch(context.statsRequest.taskReference).setBody(respBody)
.setCompletion((operation, exception) -> {
if (exception != null) {
handleError(context, null, exception, false);
}
}));
context.statsResponse.statsList = new ArrayList<>();
}
示例9: createVmDescription
import com.vmware.xenon.common.UriUtils; //导入方法依赖的package包/类
private ComputeDescription createVmDescription() throws Throwable {
ComputeDescription computeDesc = new ComputeDescription();
computeDesc.id = nextName("vm");
computeDesc.regionId = this.datacenterId;
computeDesc.documentSelfLink = computeDesc.id;
computeDesc.supportedChildren = new ArrayList<>();
computeDesc.instanceAdapterReference = UriUtils
.buildUri(this.host, VSphereUriPaths.INSTANCE_SERVICE);
computeDesc.authCredentialsLink = this.auth.documentSelfLink;
computeDesc.name = computeDesc.id;
computeDesc.dataStoreId = this.dataStoreId;
computeDesc.cpuCount = 2;
// 1G
computeDesc.totalMemoryBytes = 1024 * 1024 * 1024;
return TestUtils.doPost(this.host, computeDesc,
ComputeDescription.class,
UriUtils.buildUri(this.host, ComputeDescriptionService.FACTORY_LINK));
}
示例10: createVmDescription
import com.vmware.xenon.common.UriUtils; //导入方法依赖的package包/类
private ComputeDescription createVmDescription() throws Throwable {
ComputeDescription computeDesc = new ComputeDescription();
computeDesc.id = nextName("vm");
computeDesc.regionId = this.datacenterId;
computeDesc.documentSelfLink = computeDesc.id;
computeDesc.supportedChildren = new ArrayList<>();
computeDesc.instanceAdapterReference = UriUtils
.buildUri(this.host, VSphereUriPaths.INSTANCE_SERVICE);
computeDesc.authCredentialsLink = this.auth.documentSelfLink;
computeDesc.name = computeDesc.id;
computeDesc.dataStoreId = this.dataStoreId;
computeDesc.cpuCount = 2;
// 1G
computeDesc.totalMemoryBytes = 1024 * 1024 * 1024;
computeDesc.dataStoreId = dataStoreId;
return TestUtils.doPost(this.host, computeDesc,
ComputeDescription.class,
UriUtils.buildUri(this.host, ComputeDescriptionService.FACTORY_LINK));
}
示例11: testConfigServiceValidation
import com.vmware.xenon.common.UriUtils; //导入方法依赖的package包/类
/**
* This test validates negative cases for the GatewayConfigService.
*/
@Test
public void testConfigServiceValidation() throws Throwable {
GatewayConfigService.State state = new GatewayConfigService.State();
state.forwardingUri = new URI("http://127.0.0.1:8001");
URI factoryUri = UriUtils.buildUri(
this.gatewayHost.getConfigHost(), GatewayConfigService.FACTORY_LINK);
Operation postOp = Operation
.createPost(factoryUri)
.setBody(state);
TestRequestSender.FailureResponse response = this.sender.sendAndWaitFailure(postOp);
assertEquals(Operation.STATUS_CODE_BAD_REQUEST, response.op.getStatusCode());
}
示例12: testSwaggerUiAvailable
import com.vmware.xenon.common.UriUtils; //导入方法依赖的package包/类
@Test
public void testSwaggerUiAvailable() throws Throwable {
TestRequestSender sender = host.getTestRequestSender();
URI uri = UriUtils.buildUri(host, SwaggerDescriptorService.SELF_LINK + ServiceUriPaths.UI_PATH_SUFFIX);
Operation op = Operation
.createGet(new URI(uri.toString() + "/"))
.setReferer(host.getUri());
Operation result = sender.sendAndWait(op);
assertSwaggerUiAvailable(result);
}
示例13: createAzureEndpointsForSubscriptions
import com.vmware.xenon.common.UriUtils; //导入方法依赖的package包/类
private void createAzureEndpointsForSubscriptions(Collection<AzureSubscription> subscriptions) {
AzureSubscriptionEndpointsEnumerationRequest request =
new AzureSubscriptionEndpointsEnumerationRequest();
request.resourceReference = UriUtils.buildUri(this.host, this.computeLink);
request.azureSubscriptions = subscriptions;
TestRequestSender sender = new TestRequestSender(this.host);
Operation op = Operation.createPatch(this.host,
AzureSubscriptionEndpointsEnumerationService.SELF_LINK)
.setBody(request);
sender.sendAndWait(op);
}
示例14: validateDiskAndStart
import com.vmware.xenon.common.UriUtils; //导入方法依赖的package包/类
private void validateDiskAndStart(ProvisionDiskTaskState state, Operation startPost) {
URI diskUri = UriUtils.buildUri(getHost(), state.diskLink);
sendRequest(Operation.createGet(diskUri)
.addPragmaDirective(Operation.PRAGMA_DIRECTIVE_QUEUE_FOR_SERVICE_AVAILABILITY)
.setCompletion((o, e) -> {
if (e != null) {
logWarning(() ->
String.format("Failure retrieving disk state (%s): %s", diskUri,
e.toString()));
o.complete();
failTask(e);
return;
}
DiskState disk = o.getBody(DiskState.class);
state.diskAdapterReference = disk.diskAdapterReference;
startPost.complete();
if (disk.capacityMBytes < 0) {
failTask(new IllegalArgumentException(
"disk capacity is mandatory for a disk"));
return;
}
if (state.taskSubStage == ProvisionDiskTaskState.SubStage.CREATING_DISK
&& state.diskAdapterReference == null) {
failTask(new IllegalArgumentException(
"diskState does not have create service specified"));
return;
}
sendSelfPatch(TaskStage.STARTED, state.taskSubStage, null);
}));
}
示例15: buildComputeHostUri
import com.vmware.xenon.common.UriUtils; //导入方法依赖的package包/类
private URI buildComputeHostUri(ProvisionComputeTaskState updatedState) {
URI computeHost = UriUtils
.buildUri(getHost(), updatedState.computeLink);
computeHost = ComputeService.ComputeStateWithDescription
.buildUri(computeHost);
return computeHost;
}