use of com.vmware.photon.controller.model.resources.EndpointService.EndpointState in project photon-model by vmware.
the class TestAWSImageEnumerationTask method testPrivateImageEnumeration_single.
/*
* The image that must be returned:
*
* https://console.aws.amazon.com/ec2/v2/home?region=us-east-1#Images:visibility=private-images;
* imageId=ami-caf25eb0;sort=name
*
* under prelude_test @ https://537227425989.signin.aws.amazon.com/console
*/
@Test
@Ignore("https://jira-hzn.eng.vmware.com/browse/VCOM-832")
public void testPrivateImageEnumeration_single() throws Throwable {
Assume.assumeFalse(this.isMock);
final EndpointState endpointState = createEndpointState();
kickOffImageEnumeration(endpointState, PRIVATE, AMAZON_PRIVATE_IMAGE_FILTER);
// Validate 1 image state is CREATED
ServiceDocumentQueryResult images = queryDocumentsAndAssertExpectedCount(getHost(), 1, ImageService.FACTORY_LINK, EXACT_COUNT);
ImageState image = Utils.fromJson(images.documents.values().iterator().next(), ImageState.class);
// Validate created image is correctly populated
Assert.assertNull("Private image must NOT have endpointType set.", image.endpointType);
Assert.assertEquals("Private image must have endpointLink set.", endpointState.documentSelfLink, image.endpointLink);
Assert.assertEquals("Private image must have tenantLinks set.", endpointState.tenantLinks, image.tenantLinks);
Assert.assertEquals("Private image id is incorrect.", "ami-caf25eb0", image.id);
Assert.assertEquals("Private image name is incorrect.", "tapestryPipelineServiceTestService", image.name);
Assert.assertEquals("Private image 'Name' tag is missing.", 1, image.tagLinks.size());
TagState nameTag = getServiceSynchronously(image.tagLinks.iterator().next(), TagState.class);
Assert.assertEquals(image.name, nameTag.value);
}
use of com.vmware.photon.controller.model.resources.EndpointService.EndpointState in project photon-model by vmware.
the class TestAWSSetupUtils method createAWSEndpointStateUsingAllocationTask.
/**
* Create endpoint using EndpointAllocationTaskService.
*/
public static EndpointState createAWSEndpointStateUsingAllocationTask(VerificationHost host, String authLink, String resPoolLink, String accessKey, String secretKey, String endpointName) throws Throwable {
EndpointState endpoint = createEndpointState(authLink, resPoolLink, accessKey, secretKey, endpointName);
EndpointAllocationTaskState startState = createEndpointAllocationRequest(endpoint);
EndpointAllocationTaskState returnState = TestUtils.doPost(host, startState, EndpointAllocationTaskState.class, UriUtils.buildUri(host, EndpointAllocationTaskService.FACTORY_LINK));
EndpointAllocationTaskState completeState = host.waitForFinishedTask(EndpointAllocationTaskState.class, returnState.documentSelfLink);
assertTrue(completeState.taskInfo.stage == TaskState.TaskStage.FINISHED);
Operation response = host.waitForResponse(Operation.createGet(host, completeState.documentSelfLink));
EndpointAllocationTaskState taskState = response.getBody(EndpointAllocationTaskState.class);
assertNotNull(taskState.endpointState);
ServiceDocument endpointState = taskState.endpointState;
assertNotNull(endpointState.documentSelfLink);
response = host.waitForResponse(Operation.createGet(host, endpointState.documentSelfLink));
return response.getBody(EndpointState.class);
}
use of com.vmware.photon.controller.model.resources.EndpointService.EndpointState in project photon-model by vmware.
the class VSphereAdapterImageEnumerationService method thenWithEndpointState.
private void thenWithEndpointState(ImageEnumerateRequest request, EndpointState endpoint, TaskManager mgr) {
URI parentUri = ComputeStateWithDescription.buildUri(UriUtils.buildUri(getHost(), endpoint.computeLink));
Operation.createGet(PhotonModelUriUtils.createInventoryUri(getHost(), parentUri)).setCompletion(o -> thenWithParentState(request, o.getBody(ComputeStateWithDescription.class), mgr), mgr).sendWith(this);
}
use of com.vmware.photon.controller.model.resources.EndpointService.EndpointState in project photon-model by vmware.
the class AWSLoadBalancerServiceTest 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 = Collections.singletonList(endpointType + "Tenant");
endpoint.authCredentialsLink = createAuthCredentialsState().documentSelfLink;
endpoint.resourcePoolLink = "dummy";
endpoint.regionId = this.regionId;
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 AWSInstanceTypeServiceTest method testGetInstanceTypesPositive.
@Test
public void testGetInstanceTypesPositive() throws Throwable {
EndpointState ep = createEndpointState();
TestContext ctx = this.host.testCreate(1);
Operation getOperation = Operation.createGet(UriUtils.buildUri(this.host, AWSInstanceTypeService.SELF_LINK + "?endpoint=" + ep.documentSelfLink)).setCompletion((operation, throwable) -> {
try {
if (throwable != null) {
ctx.failIteration(throwable);
return;
}
assertEquals(Operation.STATUS_CODE_OK, operation.getStatusCode());
InstanceTypeList instanceTypes = operation.getBody(InstanceTypeList.class);
assertNotNull("Tenant links should ne set.", instanceTypes.tenantLinks);
assertEquals("Tenant links size equal to endpoint tenant links size is " + "expecteed.", ep.tenantLinks.size(), instanceTypes.tenantLinks.size());
assertNotNull("Instance types should not be null.", instanceTypes.instanceTypes);
instanceTypes.instanceTypes.stream().filter(instanceType -> instanceType.id == null || instanceType.name == null).findFirst().ifPresent(instanceType -> fail("Found instance type without id " + "or name."));
// Validate that all types have cpu and memory extended data set.
instanceTypes.instanceTypes.stream().filter(instanceType -> instanceType.cpuCount == null || instanceType.memoryInMB == null).findFirst().ifPresent(instanceType -> fail("Found instance type without extended data present: " + instanceType.id));
// Check that one of the well known type is present.
InstanceTypeList.InstanceType t2MicroType = instanceTypes.instanceTypes.stream().filter(instanceType -> InstanceType.T2Micro.toString().equals(instanceType.id)).findFirst().orElseThrow(() -> new AssertionError("Unable to " + "find t2.micro instance type."));
assertEquals(1, t2MicroType.cpuCount.intValue());
assertEquals(1024, t2MicroType.memoryInMB.intValue());
assertNotNull(t2MicroType.storageType);
assertNotNull(t2MicroType.networkType);
ctx.completeIteration();
} catch (AssertionError err) {
ctx.failIteration(err);
}
});
this.send(getOperation);
this.testWait(ctx);
}
Aggregations