use of com.vmware.photon.controller.model.tasks.EndpointAllocationTaskService.EndpointAllocationTaskState 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.tasks.EndpointAllocationTaskService.EndpointAllocationTaskState in project photon-model by vmware.
the class TestAWSSetupUtils method createEndpointAllocationRequest.
private static EndpointAllocationTaskState createEndpointAllocationRequest(EndpointState endpoint) {
EndpointAllocationTaskState endpointAllocationTaskState = new EndpointAllocationTaskState();
endpointAllocationTaskState.endpointState = endpoint;
endpointAllocationTaskState.tenantLinks = endpoint.tenantLinks;
return endpointAllocationTaskState;
}
use of com.vmware.photon.controller.model.tasks.EndpointAllocationTaskService.EndpointAllocationTaskState 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.tasks.EndpointAllocationTaskService.EndpointAllocationTaskState in project photon-model by vmware.
the class BaseVSphereAdapterTest method createEndpoint.
protected EndpointState createEndpoint(Consumer<ComputeState> cs, Consumer<ComputeDescription> desc) throws Throwable {
EndpointAllocationTaskState validateEndpoint = new EndpointAllocationTaskState();
EndpointState endpoint = new EndpointState();
validateEndpoint.endpointState = endpoint;
endpoint.endpointType = PhotonModelConstants.EndpointType.vsphere.name();
endpoint.name = PhotonModelConstants.EndpointType.vsphere.name();
endpoint.regionId = this.datacenterId;
endpoint.endpointProperties = new HashMap<>();
endpoint.endpointProperties.put(PRIVATE_KEYID_KEY, this.vcUsername != null ? this.vcUsername : "username");
endpoint.endpointProperties.put(PRIVATE_KEY_KEY, this.vcPassword != null ? this.vcPassword : "password");
endpoint.endpointProperties.put(HOST_NAME_KEY, this.vcUrl != null ? URI.create(this.vcUrl).toURL().getHost() : "hostname");
validateEndpoint.options = isMock() ? EnumSet.of(TaskOption.IS_MOCK) : null;
configureEndpoint(endpoint);
EndpointAllocationTaskState outTask = TestUtils.doPost(this.host, validateEndpoint, EndpointAllocationTaskState.class, UriUtils.buildUri(this.host, EndpointAllocationTaskService.FACTORY_LINK));
this.host.waitForFinishedTask(EndpointAllocationTaskState.class, outTask.documentSelfLink);
EndpointAllocationTaskState taskState = this.host.getServiceState(EnumSet.noneOf(TestProperty.class), EndpointAllocationTaskState.class, UriUtils.buildUri(this.host, outTask.documentSelfLink));
if (cs != null) {
cs.accept(this.host.getServiceState(EnumSet.noneOf(TestProperty.class), ComputeState.class, UriUtils.buildUri(this.host, taskState.endpointState.computeLink)));
}
if (desc != null) {
desc.accept(this.host.getServiceState(EnumSet.noneOf(TestProperty.class), ComputeDescription.class, UriUtils.buildUri(this.host, taskState.endpointState.computeDescriptionLink)));
}
this.resourcePool = this.host.getServiceState(EnumSet.noneOf(TestProperty.class), ResourcePoolState.class, UriUtils.buildUri(this.host, taskState.endpointState.resourcePoolLink));
this.auth = this.host.getServiceState(EnumSet.noneOf(TestProperty.class), AuthCredentialsServiceState.class, UriUtils.buildUri(this.host, taskState.endpointState.authCredentialsLink));
return taskState.endpointState;
}
use of com.vmware.photon.controller.model.tasks.EndpointAllocationTaskService.EndpointAllocationTaskState in project photon-model by vmware.
the class AzureSubscriptionsEnumerationServiceTest method setUp.
@Before
public void setUp() throws Exception {
this.host = VerificationHost.create(0);
this.isMock = true;
this.createdComputeLinks = new ArrayList<>();
try {
this.host.start();
PhotonModelServices.startServices(this.host);
PhotonModelMetricServices.startServices(this.host);
PhotonModelAdaptersRegistryAdapters.startServices(this.host);
PhotonModelTaskServices.startServices(this.host);
AzureAdaptersTestUtils.startServicesSynchronouslyAzure(this.host);
AzureAdaptersTestUtils.startServicesSynchronouslyEaAzure(this.host);
this.host.waitForServiceAvailable(PhotonModelServices.LINKS);
this.host.waitForServiceAvailable(PhotonModelTaskServices.LINKS);
this.host.waitForServiceAvailable(PhotonModelMetricServices.LINKS);
this.host.setTimeoutSeconds(600);
// Create Azure non-ea endpoints
EndpointState nonEaEp1 = createNonEaEndpointState(SUBSCRIPTION_EXISTING_1);
EndpointAllocationTaskState state1 = createEndpoint(nonEaEp1);
this.existingSubsComputeLink1 = state1.endpointState.computeLink;
EndpointState nonEaEp2 = createNonEaEndpointState(SUBSCRIPTION_EXISTING_2);
EndpointAllocationTaskState state2 = createEndpoint(nonEaEp2);
this.existingSubsComputeLink2 = state2.endpointState.computeLink;
// Create an Azure endpoint which will act as Azure EA endpoint
EndpointState ep = createEaEndpointState();
EndpointAllocationTaskState taskState = createEndpoint(ep);
this.computeLink = taskState.endpointState.computeLink;
this.compute = getServiceSynchronously(this.computeLink, ComputeState.class);
} catch (Throwable e) {
throw new Exception(e);
}
}
Aggregations