Search in sources :

Example 11 with EndpointAllocationTaskState

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);
}
Also used : EndpointState(com.vmware.photon.controller.model.resources.EndpointService.EndpointState) EndpointAllocationTaskState(com.vmware.photon.controller.model.tasks.EndpointAllocationTaskService.EndpointAllocationTaskState) ServiceDocument(com.vmware.xenon.common.ServiceDocument) Operation(com.vmware.xenon.common.Operation)

Example 12 with EndpointAllocationTaskState

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;
}
Also used : EndpointAllocationTaskState(com.vmware.photon.controller.model.tasks.EndpointAllocationTaskService.EndpointAllocationTaskState)

Example 13 with 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;
}
Also used : EndpointState(com.vmware.photon.controller.model.resources.EndpointService.EndpointState) HashMap(java.util.HashMap) EndpointAllocationTaskState(com.vmware.photon.controller.model.tasks.EndpointAllocationTaskService.EndpointAllocationTaskState) EndpointType(com.vmware.photon.controller.model.constants.PhotonModelConstants.EndpointType) EndpointAllocationTaskState(com.vmware.photon.controller.model.tasks.EndpointAllocationTaskService.EndpointAllocationTaskState) TaskState(com.vmware.xenon.common.TaskState)

Example 14 with EndpointAllocationTaskState

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;
}
Also used : EndpointState(com.vmware.photon.controller.model.resources.EndpointService.EndpointState) ComputeState(com.vmware.photon.controller.model.resources.ComputeService.ComputeState) ResourcePoolState(com.vmware.photon.controller.model.resources.ResourcePoolService.ResourcePoolState) AuthCredentialsServiceState(com.vmware.xenon.services.common.AuthCredentialsService.AuthCredentialsServiceState) ComputeDescription(com.vmware.photon.controller.model.resources.ComputeDescriptionService.ComputeDescription) EndpointAllocationTaskState(com.vmware.photon.controller.model.tasks.EndpointAllocationTaskService.EndpointAllocationTaskState) TestProperty(com.vmware.xenon.common.test.TestProperty)

Example 15 with EndpointAllocationTaskState

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);
    }
}
Also used : EndpointState(com.vmware.photon.controller.model.resources.EndpointService.EndpointState) ComputeState(com.vmware.photon.controller.model.resources.ComputeService.ComputeState) EndpointAllocationTaskState(com.vmware.photon.controller.model.tasks.EndpointAllocationTaskService.EndpointAllocationTaskState) Before(org.junit.Before)

Aggregations

EndpointAllocationTaskState (com.vmware.photon.controller.model.tasks.EndpointAllocationTaskService.EndpointAllocationTaskState)21 EndpointState (com.vmware.photon.controller.model.resources.EndpointService.EndpointState)14 ServiceDocument (com.vmware.xenon.common.ServiceDocument)6 ComputeState (com.vmware.photon.controller.model.resources.ComputeService.ComputeState)4 TaskState (com.vmware.xenon.common.TaskState)4 ResourcePoolState (com.vmware.photon.controller.model.resources.ResourcePoolService.ResourcePoolState)3 Before (org.junit.Before)3 EndpointType (com.vmware.photon.controller.model.constants.PhotonModelConstants.EndpointType)2 BaseModelTest (com.vmware.photon.controller.model.helpers.BaseModelTest)2 EndpointService (com.vmware.photon.controller.model.resources.EndpointService)2 Operation (com.vmware.xenon.common.Operation)2 QueryTask (com.vmware.xenon.services.common.QueryTask)2 HashMap (java.util.HashMap)2 ComputeStatsRequest (com.vmware.photon.controller.model.adapterapi.ComputeStatsRequest)1 ComputeStats (com.vmware.photon.controller.model.adapterapi.ComputeStatsResponse.ComputeStats)1 EndpointConfigRequest (com.vmware.photon.controller.model.adapterapi.EndpointConfigRequest)1 INSTANCE_1_SELF_LINK (com.vmware.photon.controller.model.adapters.awsadapter.MockCostStatsAdapterService.INSTANCE_1_SELF_LINK)1 INSTANCE_2_SELF_LINK (com.vmware.photon.controller.model.adapters.awsadapter.MockCostStatsAdapterService.INSTANCE_2_SELF_LINK)1 AwsServices (com.vmware.photon.controller.model.adapters.awsadapter.util.AWSCsvBillParser.AwsServices)1 AWSStatsNormalizer (com.vmware.photon.controller.model.adapters.awsadapter.util.AWSStatsNormalizer)1