use of com.sequenceiq.distrox.api.v1.distrox.model.DistroXV1Request in project cloudbreak by hortonworks.
the class DistroXServiceTest method testWithNotAvailableEnvironmentButFreeipaAvailableAndRunWithoutException.
@Test
void testWithNotAvailableEnvironmentButFreeipaAvailableAndRunWithoutException() throws IllegalAccessException {
String envName = "someAwesomeEnvironment";
DistroXV1Request request = new DistroXV1Request();
request.setEnvironmentName(envName);
DetailedEnvironmentResponse envResponse = new DetailedEnvironmentResponse();
envResponse.setEnvironmentStatus(START_DATAHUB_STARTED);
envResponse.setCrn("crn");
DescribeFreeIpaResponse freeipa = new DescribeFreeIpaResponse();
freeipa.setAvailabilityStatus(AvailabilityStatus.AVAILABLE);
freeipa.setStatus(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.Status.AVAILABLE);
when(freeipaClientService.getByEnvironmentCrn("crn")).thenReturn(freeipa);
when(environmentClientService.getByName(envName)).thenReturn(envResponse);
when(platformAwareSdxConnector.listSdxCrns(any(), any())).thenReturn(Set.of(DATALAKE_CRN));
underTest.post(request);
verify(platformAwareSdxConnector).listSdxCrns(any(), any());
}
use of com.sequenceiq.distrox.api.v1.distrox.model.DistroXV1Request in project cloudbreak by hortonworks.
the class ClusterTemplateViewToClusterTemplateViewV4ResponseConverter method convert.
public ClusterTemplateViewV4Response convert(ClusterTemplateView source) {
ClusterTemplateViewV4Response clusterTemplateViewV4Response = new ClusterTemplateViewV4Response();
clusterTemplateViewV4Response.setName(source.getName());
clusterTemplateViewV4Response.setDescription(source.getDescription());
clusterTemplateViewV4Response.setCrn(source.getResourceCrn());
clusterTemplateViewV4Response.setCloudPlatform(source.getCloudPlatform());
clusterTemplateViewV4Response.setStatus(source.getStatus());
clusterTemplateViewV4Response.setId(source.getId());
clusterTemplateViewV4Response.setDatalakeRequired(source.getDatalakeRequired());
clusterTemplateViewV4Response.setStatus(source.getStatus());
clusterTemplateViewV4Response.setType(source.getType());
clusterTemplateViewV4Response.setFeatureState(source.getFeatureState());
if (source.getStackTemplate() != null) {
ClusterTemplateStackApiView stackTemplate = source.getStackTemplate();
clusterTemplateViewV4Response.setNodeCount(getFullNodeCount(stackTemplate));
if (stackTemplate.getCluster() != null) {
ClusterTemplateClusterApiView cluster = stackTemplate.getCluster();
clusterTemplateViewV4Response.setStackType(cluster.getBlueprint() != null ? cluster.getBlueprint().getStackType() : "");
clusterTemplateViewV4Response.setStackVersion(cluster.getBlueprint() != null ? cluster.getBlueprint().getStackVersion() : "");
}
if (stackTemplate.getEnvironmentCrn() != null) {
clusterTemplateViewV4Response.setEnvironmentCrn(stackTemplate.getEnvironmentCrn());
}
} else if (source.getStatus().isDefault()) {
try {
DistroXV1Request distroXV1Request = new Json(getTemplateString(source.getTemplateContent())).get(DefaultClusterTemplateV4Request.class).getDistroXTemplate();
clusterTemplateViewV4Response.setNodeCount(getFullNodeCount(distroXV1Request));
clusterTemplateViewV4Response.setStackType("CDH");
clusterTemplateViewV4Response.setStackVersion(source.getClouderaRuntimeVersion());
} catch (IOException e) {
LOGGER.error("CDP was not able to convert back {} template: {}", source.getName(), e.getMessage());
throw new CloudbreakServiceException("CDP was not able to give back your template: ", e);
}
}
clusterTemplateViewV4Response.setCreated(source.getCreated());
return clusterTemplateViewV4Response;
}
use of com.sequenceiq.distrox.api.v1.distrox.model.DistroXV1Request in project cloudbreak by hortonworks.
the class ClusterTemplateTestUtil method createDistroXV1Request.
private static DistroXV1Request createDistroXV1Request() {
DistroXV1Request r = new DistroXV1Request();
r.setEnvironmentName(TEST_ENVIRONMENT_NAME);
return r;
}
use of com.sequenceiq.distrox.api.v1.distrox.model.DistroXV1Request in project cloudbreak by hortonworks.
the class ClusterTemplateLoaderServiceTest method clusterTemplateRequest.
private DefaultClusterTemplateV4Request clusterTemplateRequest(String templateName) {
DefaultClusterTemplateV4Request clusterTemplate = new DefaultClusterTemplateV4Request();
clusterTemplate.setName(templateName);
DistroXV1Request distrox = new DistroXV1Request();
DistroXClusterV1Request cluster = new DistroXClusterV1Request();
distrox.setCluster(cluster);
InstanceGroupV1Request instanceGroup = new InstanceGroupV1Request();
instanceGroup.setName("master");
distrox.setInstanceGroups(singleton(instanceGroup));
clusterTemplate.setDistroXTemplate(distrox);
return clusterTemplate;
}
use of com.sequenceiq.distrox.api.v1.distrox.model.DistroXV1Request in project cloudbreak by hortonworks.
the class DistroXV1RequestToStackV4RequestConverterTest method testWhenTagsProvidedTheyWillBePassedForStackConversion.
@Test
void testWhenTagsProvidedTheyWillBePassedForStackConversion() {
when(databaseRequestConverter.convert(any(DatabaseRequest.class))).thenReturn(createDistroXDatabaseRequest());
StackV4Request source = new StackV4Request();
source.setName("stackname");
DatabaseRequest databaseRequest = new DatabaseRequest();
databaseRequest.setAvailabilityType(DatabaseAvailabilityType.HA);
source.setExternalDatabase(databaseRequest);
TagsV4Request tags = createTagsV4Request();
source.setTags(tags);
DistroXV1Request result = underTest.convert(source);
assertThat(result.getExternalDatabase()).isNotNull();
assertThat(result.getExternalDatabase().getAvailabilityType()).isEqualTo(DistroXDatabaseAvailabilityType.HA);
checkTagsV4WithV1(tags, result.getTags());
}
Aggregations