Search in sources :

Example 6 with EndpointAllocationTaskState

use of com.vmware.photon.controller.model.tasks.EndpointAllocationTaskService.EndpointAllocationTaskState in project photon-model by vmware.

the class EndpointServiceTests method testShouldFailOnMissingData.

public void testShouldFailOnMissingData(EndpointService.EndpointState ep) throws Throwable {
    ep.endpointProperties.clear();
    EndpointAllocationTaskState validateEndpoint = new EndpointAllocationTaskState();
    validateEndpoint.endpointState = ep;
    validateEndpoint.options = this.isMock ? EnumSet.of(TaskOption.IS_MOCK) : null;
    EndpointAllocationTaskState outTask = TestUtils.doPost(this.host, validateEndpoint, EndpointAllocationTaskState.class, UriUtils.buildUri(this.host, EndpointAllocationTaskService.FACTORY_LINK));
    EndpointAllocationTaskState failedTask = this.host.waitForFailedTask(EndpointAllocationTaskState.class, outTask.documentSelfLink);
    assertEquals(failedTask.taskInfo.stage, TaskState.TaskStage.FAILED);
}
Also used : EndpointAllocationTaskState(com.vmware.photon.controller.model.tasks.EndpointAllocationTaskService.EndpointAllocationTaskState)

Example 7 with EndpointAllocationTaskState

use of com.vmware.photon.controller.model.tasks.EndpointAllocationTaskService.EndpointAllocationTaskState in project photon-model by vmware.

the class AWSPowerServiceTest method configureEndpoint.

private EndpointState configureEndpoint() throws Throwable {
    EndpointState ep = createEndpointState();
    EndpointAllocationTaskState configureEndpoint = new EndpointAllocationTaskState();
    configureEndpoint.endpointState = ep;
    configureEndpoint.options = this.isMock ? EnumSet.of(TaskOption.IS_MOCK) : null;
    configureEndpoint.taskInfo = new TaskState();
    configureEndpoint.taskInfo.isDirect = true;
    EndpointAllocationTaskState outTask = TestUtils.doPost(this.host, configureEndpoint, EndpointAllocationTaskState.class, UriUtils.buildUri(this.host, EndpointAllocationTaskService.FACTORY_LINK));
    // outTask.documentSelfLink);
    return outTask.endpointState;
}
Also used : EndpointState(com.vmware.photon.controller.model.resources.EndpointService.EndpointState) EndpointAllocationTaskState(com.vmware.photon.controller.model.tasks.EndpointAllocationTaskService.EndpointAllocationTaskState) EndpointAllocationTaskState(com.vmware.photon.controller.model.tasks.EndpointAllocationTaskService.EndpointAllocationTaskState) TaskState(com.vmware.xenon.common.TaskState) ProvisionComputeTaskState(com.vmware.photon.controller.model.tasks.ProvisionComputeTaskService.ProvisionComputeTaskState) ResourceRemovalTaskState(com.vmware.photon.controller.model.tasks.ResourceRemovalTaskService.ResourceRemovalTaskState)

Example 8 with EndpointAllocationTaskState

use of com.vmware.photon.controller.model.tasks.EndpointAllocationTaskService.EndpointAllocationTaskState in project photon-model by vmware.

the class AzureSubscriptionsEnumerationServiceTest method createEndpoint.

private EndpointAllocationTaskState createEndpoint(EndpointState endpointState) throws Throwable {
    EndpointAllocationTaskState validateEndpoint = new EndpointAllocationTaskState();
    validateEndpoint.endpointState = endpointState;
    validateEndpoint.options = this.isMock ? EnumSet.of(TaskOption.IS_MOCK) : null;
    validateEndpoint.tenantLinks = Collections.singletonList(TENANT_ID);
    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 = getServiceSynchronously(outTask.documentSelfLink, EndpointAllocationTaskState.class);
    return taskState;
}
Also used : EndpointAllocationTaskState(com.vmware.photon.controller.model.tasks.EndpointAllocationTaskService.EndpointAllocationTaskState)

Example 9 with EndpointAllocationTaskState

use of com.vmware.photon.controller.model.tasks.EndpointAllocationTaskService.EndpointAllocationTaskState in project photon-model by vmware.

the class AzureSubscriptionEndpointsEnumerationServiceTest method setUp.

@Before
public void setUp() throws Exception {
    this.host = VerificationHost.create(0);
    this.isMock = true;
    this.createdEndpointLinks = new ArrayList<>();
    try {
        this.host.start();
        PhotonModelServices.startServices(this.host);
        PhotonModelMetricServices.startServices(this.host);
        PhotonModelAdaptersRegistryAdapters.startServices(this.host);
        PhotonModelTaskServices.startServices(this.host);
        this.host.startService(new AzureSubscriptionEndpointsEnumerationService());
        AzureAdaptersTestUtils.startServicesSynchronouslyEaAzure(this.host);
        this.host.waitForServiceAvailable(PhotonModelServices.LINKS);
        this.host.waitForServiceAvailable(PhotonModelTaskServices.LINKS);
        this.host.waitForServiceAvailable(PhotonModelMetricServices.LINKS);
        this.host.waitForServiceAvailable(AzureSubscriptionEndpointsEnumerationService.SELF_LINK);
        this.host.setTimeoutSeconds(600);
        // Create an Azure endpoint which will act as Azure EA endpoint
        EndpointState ep = createEndpointState();
        EndpointAllocationTaskState validateEndpoint = new EndpointAllocationTaskState();
        validateEndpoint.endpointState = ep;
        validateEndpoint.options = this.isMock ? EnumSet.of(TaskOption.IS_MOCK) : null;
        validateEndpoint.tenantLinks = Collections.singletonList(TENANT_ID);
        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 = getServiceSynchronously(outTask.documentSelfLink, EndpointAllocationTaskState.class);
        this.endpointLink = taskState.endpointState.documentSelfLink;
        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)

Example 10 with EndpointAllocationTaskState

use of com.vmware.photon.controller.model.tasks.EndpointAllocationTaskService.EndpointAllocationTaskState in project photon-model by vmware.

the class AzureSubscriptionEndpointCreationServiceTest method setUp.

@Before
public void setUp() throws Exception {
    try {
        this.host.setMaintenanceIntervalMicros(TimeUnit.MILLISECONDS.toMicros(10));
        PhotonModelServices.startServices(this.host);
        PhotonModelAdaptersRegistryAdapters.startServices(this.host);
        PhotonModelMetricServices.startServices(this.host);
        PhotonModelTaskServices.startServices(this.host);
        this.host.startService(new AzureSubscriptionEndpointCreationService());
        AzureAdaptersTestUtils.startServicesSynchronouslyEaAzure(this.host);
        this.host.setTimeoutSeconds(300);
        this.host.waitForServiceAvailable(PhotonModelServices.LINKS);
        this.host.waitForServiceAvailable(PhotonModelTaskServices.LINKS);
        this.host.waitForServiceAvailable(AzureSubscriptionEndpointCreationService.SELF_LINK);
        EndpointState ep = createEndpointState();
        // Create the Azure Ea Endpoint for the test
        EndpointAllocationTaskState validateEndpoint = new EndpointAllocationTaskState();
        validateEndpoint.endpointState = ep;
        validateEndpoint.options = this.isMock ? EnumSet.of(TaskOption.IS_MOCK) : null;
        validateEndpoint.tenantLinks = Collections.singletonList(TENANT_ID);
        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 = getServiceSynchronously(outTask.documentSelfLink, EndpointAllocationTaskState.class);
        this.eaEndPointLink = taskState.endpointState.documentSelfLink;
    } catch (Throwable e) {
        throw new Exception(e);
    }
}
Also used : EndpointState(com.vmware.photon.controller.model.resources.EndpointService.EndpointState) 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