use of com.vmware.photon.controller.model.resources.EndpointService.EndpointState in project photon-model by vmware.
the class AWSInstanceTypeServiceTest method createEndpointState.
private EndpointState createEndpointState() throws Throwable {
EndpointType endpointType = EndpointType.aws;
EndpointState endpoint;
{
endpoint = new EndpointState();
endpoint.endpointType = endpointType.name();
endpoint.id = endpointType.name() + "-id";
endpoint.name = endpointType.name() + "-name";
endpoint.endpointProperties = new HashMap<>();
endpoint.endpointProperties.put(PRIVATE_KEY_KEY, this.secretKey);
endpoint.endpointProperties.put(PRIVATE_KEYID_KEY, this.accessKey);
endpoint.endpointProperties.put(REGION_KEY, Regions.US_EAST_1.getName());
}
EndpointAllocationTaskState allocateEndpoint = new EndpointAllocationTaskState();
allocateEndpoint.endpointState = endpoint;
allocateEndpoint.options = this.isMock ? EnumSet.of(TaskOption.IS_MOCK) : null;
allocateEndpoint.taskInfo = new TaskState();
allocateEndpoint.taskInfo.isDirect = true;
allocateEndpoint.tenantLinks = Collections.singletonList(endpointType.name() + "-tenant");
allocateEndpoint = com.vmware.photon.controller.model.tasks.TestUtils.doPost(this.host, allocateEndpoint, EndpointAllocationTaskState.class, UriUtils.buildUri(this.host, EndpointAllocationTaskService.FACTORY_LINK));
return allocateEndpoint.endpointState;
}
use of com.vmware.photon.controller.model.resources.EndpointService.EndpointState in project photon-model by vmware.
the class AWSPowerServiceTest method test.
@Test
public void test() throws Throwable {
EndpointState endpoint = configureEndpoint();
assertNotNull(endpoint.resourcePoolLink);
ComputeState computeHost = this.host.getServiceState(null, ComputeState.class, UriUtils.buildUri(this.host, endpoint.computeLink));
assertNotNull(computeHost);
ComputeDescription computeHostDesc = this.host.getServiceState(null, ComputeDescription.class, UriUtils.buildUri(this.host, endpoint.computeDescriptionLink));
assertNotNull(computeHostDesc);
assertNotNull("Power addpter must be configured", computeHostDesc.powerAdapterReference);
boolean addNonExistingSecurityGroup = false;
ComputeState cs = TestAWSSetupUtils.createAWSVMResource(this.host, computeHost, endpoint, getClass(), "trainingVM", zoneId, this.regionId, null, this.singleNicSpec, addNonExistingSecurityGroup, this.awsTestContext);
this.computesToRemove.add(cs.documentSelfLink);
assertEquals(PowerState.UNKNOWN, cs.powerState);
ProvisionComputeTaskState state = new ProvisionComputeTaskState();
state.computeLink = cs.documentSelfLink;
state.isMockRequest = this.isMock;
state.taskSubStage = ProvisionComputeTaskState.SubStage.CREATING_HOST;
state = TestUtils.doPost(this.host, state, ProvisionComputeTaskState.class, UriUtils.buildUri(this.host, ProvisionComputeTaskService.FACTORY_LINK));
this.host.waitForFinishedTask(ProvisionComputeTaskState.class, state.documentSelfLink);
ComputeState compute = this.host.getServiceState(null, ComputeState.class, UriUtils.buildUri(this.host, cs.documentSelfLink));
changePowerState(computeHostDesc, compute.documentSelfLink, PowerState.OFF);
if (!this.isMock) {
waitForInstancesToBeStopped(this.client, this.host, Arrays.asList(compute.id));
}
changePowerState(computeHostDesc, compute.documentSelfLink, PowerState.ON);
if (!this.isMock) {
final int errorRate = 0;
waitForProvisioningToComplete(Arrays.asList(compute.id), this.host, this.client, errorRate);
}
}
use of com.vmware.photon.controller.model.resources.EndpointService.EndpointState in project photon-model by vmware.
the class AWSSubnetTaskServiceTest method createEndpointState.
private EndpointState createEndpointState() throws Throwable {
EndpointState endpoint = new EndpointState();
String endpointType = EndpointType.aws.name();
endpoint.id = endpointType + "Id";
endpoint.name = endpointType + "Name";
endpoint.endpointType = endpointType;
endpoint.tenantLinks = singletonList(endpointType + "Tenant");
endpoint.authCredentialsLink = createAuthCredentialsState().documentSelfLink;
return postServiceSynchronously(EndpointService.FACTORY_LINK, endpoint, EndpointState.class);
}
use of com.vmware.photon.controller.model.resources.EndpointService.EndpointState in project photon-model by vmware.
the class TestAWSEndpointService method newEndpointState.
private EndpointState newEndpointState() {
EndpointState endpoint = new EndpointState();
endpoint.endpointType = EndpointType.aws.name();
endpoint.name = EndpointType.aws.name();
endpoint.regionId = this.regionId;
endpoint.endpointProperties = new HashMap<>();
endpoint.endpointProperties.put(PRIVATE_KEY_KEY, this.secretKey);
endpoint.endpointProperties.put(PRIVATE_KEYID_KEY, this.accessKey);
return endpoint;
}
use of com.vmware.photon.controller.model.resources.EndpointService.EndpointState in project photon-model by vmware.
the class TestAWSEndpointService method testCreateAndThenValidate.
@Test
public void testCreateAndThenValidate() throws Throwable {
this.endpointTestsRunner.testCreateAndThenValidate(this.endpointState);
// Tests that EndpointService QueryTasks can use SELECT_LINKS + EXPAND_LINKS
Query query = Builder.create().addKindFieldClause(EndpointState.class).build();
QueryTask queryTask = QueryTask.Builder.createDirectTask().addOptions(EnumSet.of(QueryOption.EXPAND_CONTENT, QueryOption.SELECT_LINKS, QueryOption.EXPAND_LINKS)).addLinkTerm(EndpointState.FIELD_NAME_AUTH_CREDENTIALS_LINK).setQuery(query).build();
this.host.createQueryTaskService(queryTask, false, true, queryTask, null);
ServiceDocumentQueryResult results = queryTask.results;
assertEquals(Long.valueOf(1), results.documentCount);
assertEquals(1, results.selectedLinks.size());
assertEquals(1, results.selectedDocuments.size());
QueryResultsProcessor processor = QueryResultsProcessor.create(results);
for (EndpointState endpoint : processor.documents(EndpointState.class)) {
String authCredentialSelfLink = endpoint.authCredentialsLink;
assertNotNull(authCredentialSelfLink);
assertNotNull(processor.selectedDocument(authCredentialSelfLink, AuthCredentialsServiceState.class));
}
}
Aggregations