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;
}
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;
}
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.");
}
}
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());
}
Aggregations