Search in sources :

Example 1 with EnvironmentClient

use of com.sequenceiq.it.cloudbreak.EnvironmentClient in project cloudbreak by hortonworks.

the class DistroXTestDtoBase method withPreferredSubnetsForInstanceNetworkIfMultiAzEnabledOrJustFirst.

public DistroXTestDtoBase<T> withPreferredSubnetsForInstanceNetworkIfMultiAzEnabledOrJustFirst() {
    if (StringUtils.isEmpty(getRequest().getEnvironmentName())) {
        throw new TestFailException("Cannot fetch the preferred subnet without env name, please add it");
    }
    try {
        EnvironmentClient envClient = getTestContext().getMicroserviceClient(EnvironmentClient.class);
        DetailedEnvironmentResponse envResponse = envClient.getDefaultClient().environmentV1Endpoint().getByName(getRequest().getEnvironmentName());
        InstanceGroupNetworkV1Request instanceGroupNetworkV1Request = new InstanceGroupNetworkV1Request();
        InstanceGroupAwsNetworkV1Parameters awsNetworkV1Parameters = new InstanceGroupAwsNetworkV1Parameters();
        if ("AWS_NATIVE".equals(getRequest().getVariant())) {
            awsNetworkV1Parameters.setSubnetIds(new ArrayList<>(envResponse.getNetwork().getPreferedSubnetIds()));
        } else {
            envResponse.getNetwork().getPreferedSubnetIds().stream().filter(s -> !s.equals(envResponse.getNetwork().getPreferedSubnetId())).findFirst().ifPresent(s -> awsNetworkV1Parameters.setSubnetIds(List.of(s)));
        }
        instanceGroupNetworkV1Request.setAws(awsNetworkV1Parameters);
        getRequest().getInstanceGroups().forEach(s -> s.setNetwork(instanceGroupNetworkV1Request));
    } catch (Exception e) {
        String message = "Cannot fetch preferred subnets from " + getRequest().getEnvironmentName();
        throw new TestFailException(message, e);
    }
    return this;
}
Also used : InstanceGroupAwsNetworkV1Parameters(com.sequenceiq.distrox.api.v1.distrox.model.network.aws.InstanceGroupAwsNetworkV1Parameters) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException) EnvironmentClient(com.sequenceiq.it.cloudbreak.EnvironmentClient) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) InstanceGroupNetworkV1Request(com.sequenceiq.distrox.api.v1.distrox.model.network.InstanceGroupNetworkV1Request) TestFailException(com.sequenceiq.it.cloudbreak.exception.TestFailException)

Example 2 with EnvironmentClient

use of com.sequenceiq.it.cloudbreak.EnvironmentClient in project cloudbreak by hortonworks.

the class TestContext method as.

public TestContext as(CloudbreakUser cloudbreakUser) {
    checkShutdown();
    LOGGER.info(" Acting user as: \ndisplay name: {} \naccess key: {} \nsecret key: {} \ncrn: {} \nadmin: {} ", cloudbreakUser.getDisplayName(), cloudbreakUser.getAccessKey(), cloudbreakUser.getSecretKey(), cloudbreakUser.getCrn(), cloudbreakUser.getAdmin());
    Log.as(LOGGER, cloudbreakUser.toString());
    setActingUser(cloudbreakUser);
    if (clients.get(cloudbreakUser.getAccessKey()) == null) {
        CloudbreakClient cloudbreakClient = CloudbreakClient.createProxyCloudbreakClient(testParameter, cloudbreakUser, regionAwareInternalCrnGeneratorFactory.iam());
        FreeIpaClient freeIpaClient = FreeIpaClient.createProxyFreeIpaClient(testParameter, cloudbreakUser, regionAwareInternalCrnGeneratorFactory.iam());
        EnvironmentClient environmentClient = EnvironmentClient.createProxyEnvironmentClient(testParameter, cloudbreakUser, regionAwareInternalCrnGeneratorFactory.iam());
        SdxClient sdxClient = SdxClient.createProxySdxClient(testParameter, cloudbreakUser);
        UmsClient umsClient = UmsClient.createProxyUmsClient(tracer, umsHost);
        SdxSaasItClient sdxSaasItClient = SdxSaasItClient.createProxySdxSaasClient(tracer, umsHost, regionAwareInternalCrnGeneratorFactory);
        RedbeamsClient redbeamsClient = RedbeamsClient.createProxyRedbeamsClient(testParameter, cloudbreakUser);
        Map<Class<? extends MicroserviceClient>, MicroserviceClient> clientMap = Map.of(CloudbreakClient.class, cloudbreakClient, FreeIpaClient.class, freeIpaClient, EnvironmentClient.class, environmentClient, SdxClient.class, sdxClient, RedbeamsClient.class, redbeamsClient, UmsClient.class, umsClient, SdxSaasItClient.class, sdxSaasItClient);
        clients.put(cloudbreakUser.getAccessKey(), clientMap);
        cloudbreakClient.setWorkspaceId(0L);
    }
    return this;
}
Also used : MicroserviceClient(com.sequenceiq.it.cloudbreak.MicroserviceClient) CloudbreakClient(com.sequenceiq.it.cloudbreak.CloudbreakClient) FreeIpaClient(com.sequenceiq.it.cloudbreak.FreeIpaClient) RedbeamsClient(com.sequenceiq.it.cloudbreak.RedbeamsClient) EnvironmentClient(com.sequenceiq.it.cloudbreak.EnvironmentClient) SdxClient(com.sequenceiq.it.cloudbreak.SdxClient) UmsClient(com.sequenceiq.it.cloudbreak.UmsClient) SdxSaasItClient(com.sequenceiq.it.cloudbreak.SdxSaasItClient)

Example 3 with EnvironmentClient

use of com.sequenceiq.it.cloudbreak.EnvironmentClient in project cloudbreak by hortonworks.

the class EnvironmentTestDto method deleteForCleanup.

@Override
public void deleteForCleanup() {
    try {
        EnvironmentClient client = getClientForCleanup();
        client.getDefaultClient().environmentV1Endpoint().deleteByCrn(getCrn(), true, false);
        getTestContext().awaitWithClient(this, Map.of("status", ARCHIVED), client);
    } catch (NotFoundException nfe) {
        LOGGER.info("resource not found, thus cleanup not needed.");
    }
}
Also used : EnvironmentClient(com.sequenceiq.it.cloudbreak.EnvironmentClient) NotFoundException(javax.ws.rs.NotFoundException)

Example 4 with EnvironmentClient

use of com.sequenceiq.it.cloudbreak.EnvironmentClient in project cloudbreak by hortonworks.

the class TestContext method initMicroserviceClientsForUMSAccountAdmin.

private void initMicroserviceClientsForUMSAccountAdmin(CloudbreakUser accountAdmin) {
    if (clients.get(accountAdmin.getAccessKey()) == null) {
        CloudbreakClient cloudbreakClient = CloudbreakClient.createProxyCloudbreakClient(testParameter, accountAdmin, regionAwareInternalCrnGeneratorFactory.iam());
        FreeIpaClient freeIpaClient = FreeIpaClient.createProxyFreeIpaClient(testParameter, accountAdmin, regionAwareInternalCrnGeneratorFactory.iam());
        EnvironmentClient environmentClient = EnvironmentClient.createProxyEnvironmentClient(testParameter, accountAdmin, regionAwareInternalCrnGeneratorFactory.iam());
        SdxClient sdxClient = SdxClient.createProxySdxClient(testParameter, accountAdmin);
        UmsClient umsClient = UmsClient.createProxyUmsClient(tracer, umsHost);
        SdxSaasItClient sdxSaasItClient = SdxSaasItClient.createProxySdxSaasClient(tracer, umsHost, regionAwareInternalCrnGeneratorFactory);
        RedbeamsClient redbeamsClient = RedbeamsClient.createProxyRedbeamsClient(testParameter, accountAdmin);
        Map<Class<? extends MicroserviceClient>, MicroserviceClient> clientMap = Map.of(CloudbreakClient.class, cloudbreakClient, FreeIpaClient.class, freeIpaClient, EnvironmentClient.class, environmentClient, SdxClient.class, sdxClient, RedbeamsClient.class, redbeamsClient, UmsClient.class, umsClient, SdxSaasItClient.class, sdxSaasItClient);
        clients.put(accountAdmin.getAccessKey(), clientMap);
    }
    LOGGER.info(" Microservice clients have been initialized successfully for UMS account admin:: \nDisplay name: {} \nAccess key: {} \nSecret key: {} " + "\nCrn: {} ", accountAdmin.getDisplayName(), accountAdmin.getAccessKey(), accountAdmin.getSecretKey(), accountAdmin.getCrn());
}
Also used : MicroserviceClient(com.sequenceiq.it.cloudbreak.MicroserviceClient) CloudbreakClient(com.sequenceiq.it.cloudbreak.CloudbreakClient) FreeIpaClient(com.sequenceiq.it.cloudbreak.FreeIpaClient) RedbeamsClient(com.sequenceiq.it.cloudbreak.RedbeamsClient) EnvironmentClient(com.sequenceiq.it.cloudbreak.EnvironmentClient) SdxClient(com.sequenceiq.it.cloudbreak.SdxClient) UmsClient(com.sequenceiq.it.cloudbreak.UmsClient) SdxSaasItClient(com.sequenceiq.it.cloudbreak.SdxSaasItClient)

Aggregations

EnvironmentClient (com.sequenceiq.it.cloudbreak.EnvironmentClient)4 CloudbreakClient (com.sequenceiq.it.cloudbreak.CloudbreakClient)2 FreeIpaClient (com.sequenceiq.it.cloudbreak.FreeIpaClient)2 MicroserviceClient (com.sequenceiq.it.cloudbreak.MicroserviceClient)2 RedbeamsClient (com.sequenceiq.it.cloudbreak.RedbeamsClient)2 SdxClient (com.sequenceiq.it.cloudbreak.SdxClient)2 SdxSaasItClient (com.sequenceiq.it.cloudbreak.SdxSaasItClient)2 UmsClient (com.sequenceiq.it.cloudbreak.UmsClient)2 InstanceGroupNetworkV1Request (com.sequenceiq.distrox.api.v1.distrox.model.network.InstanceGroupNetworkV1Request)1 InstanceGroupAwsNetworkV1Parameters (com.sequenceiq.distrox.api.v1.distrox.model.network.aws.InstanceGroupAwsNetworkV1Parameters)1 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)1 TestFailException (com.sequenceiq.it.cloudbreak.exception.TestFailException)1 NotFoundException (javax.ws.rs.NotFoundException)1