use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response in project cloudbreak by hortonworks.
the class StackToStackV4ResponseConverter method convert.
public StackV4Response convert(Stack source) {
StackV4Response response = new StackV4Response();
try {
restRequestThreadLocalService.setWorkspace(source.getWorkspace());
Image image = imageService.getImage(source.getId());
response.setImage(imageToStackImageV4ResponseConverter.convert(image));
} catch (CloudbreakImageNotFoundException exc) {
LOGGER.debug(exc.getMessage());
}
response.setName(source.getName());
response.setAuthentication(stackAuthenticationToStackAuthenticationV4ResponseConverter.convert(source.getStackAuthentication()));
response.setCrn(source.getResourceCrn());
response.setId(source.getId());
response.setEnvironmentCrn(source.getEnvironmentCrn());
response.setCloudPlatform(CloudPlatform.valueOf(source.getCloudPlatform()));
response.setPlacement(stackToPlacementSettingsV4ResponseConverter.convert(source));
response.setStatus(source.getStatus());
response.setTerminated(source.getTerminated());
response.setStatusReason(source.getStatusReason());
response.setInstanceGroups(getInstanceGroups(source));
response.setTunnel(source.getTunnel());
response.setCluster(clusterToClusterV4ResponseConverter.convert(source.getCluster()));
response.setNetwork(networkToNetworkV4ResponseConverter.convert(source));
providerParameterCalculator.parse(new HashMap<>(source.getParameters()), response);
response.setCreated(source.getCreated());
response.setGatewayPort(source.getGatewayPort());
response.setCustomDomains(stackToCustomDomainsSettingsV4Response.convert(source));
response.setWorkspace(workspaceToWorkspaceResourceV4ResponseConverter.convert(source.getWorkspace()));
addNodeCount(source, response);
convertComponentConfig(response, source);
convertTelemetryComponent(response, source);
response.setTags(getTags(source.getTags()));
response.setTimeToLive(getStackTimeToLive(source));
response.setVariant(Strings.isNullOrEmpty(source.getPlatformVariant()) ? source.getCloudPlatform() : source.getPlatformVariant());
response.setExternalDatabase(externalDatabaseToDatabaseResponseConverter.convert(source.getExternalDatabaseCreationType(), source.getExternalDatabaseEngineVersion()));
datalakeService.addSharedServiceResponse(source, response);
filterExposedServicesByType(source.getType(), response.getCluster());
response.setLoadBalancers(convertLoadBalancers(source.getId()));
if (!source.getLoadBalancers().isEmpty()) {
response.setEnableLoadBalancer(true);
}
return response;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response in project cloudbreak by hortonworks.
the class DatalakeServiceTest method testAddSharedServiceResponseWhenDatalakeCrnIsNotNull.
@Test
public void testAddSharedServiceResponseWhenDatalakeCrnIsNotNull() {
ResourceBasicView resourceBasicView = mock(ResourceBasicView.class);
when(resourceBasicView.getId()).thenReturn(1L);
when(resourceBasicView.getName()).thenReturn("teststack");
lenient().when(stackService.getResourceBasicViewByResourceCrn(anyString())).thenReturn(Optional.of(resourceBasicView));
Stack source = new Stack();
source.setDatalakeCrn("crn");
StackV4Response x = new StackV4Response();
underTest.addSharedServiceResponse(source, x);
verify(stackService, times(1)).getResourceBasicViewByResourceCrn("crn");
assertEquals(1L, x.getSharedService().getSharedClusterId());
assertEquals("teststack", x.getSharedService().getSharedClusterName());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response in project cloudbreak by hortonworks.
the class StackService method getJsonByCrn.
public StackV4Response getJsonByCrn(String crn, Collection<String> entry) {
try {
return transactionService.required(() -> {
Stack stack = getByCrnWithLists(crn);
StackV4Response stackResponse = stackToStackV4ResponseConverter.convert(stack);
stackResponse = stackResponseDecorator.decorate(stackResponse, stack, entry);
return stackResponse;
});
} catch (TransactionExecutionException e) {
throw new TransactionRuntimeExecutionException(e);
}
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response in project cloudbreak by hortonworks.
the class StackService method getByCrnInWorkspaceWithEntries.
public StackV4Response getByCrnInWorkspaceWithEntries(String crn, Long workspaceId, Set<String> entries, User user, StackType stackType) {
try {
return transactionService.required(() -> {
Workspace workspace = workspaceService.get(workspaceId, user);
ShowTerminatedClustersAfterConfig showTerminatedClustersAfterConfig = showTerminatedClusterConfigService.get();
Optional<Stack> stack = findByCrnAndWorkspaceIdWithLists(crn, workspace.getId(), stackType, showTerminatedClustersAfterConfig);
if (stack.isEmpty()) {
throw new NotFoundException(format("Stack not found by crn '%s'", crn));
}
StackV4Response stackResponse = stackToStackV4ResponseConverter.convert(stack.get());
stackResponse = stackResponseDecorator.decorate(stackResponse, stack.get(), entries);
return stackResponse;
});
} catch (TransactionExecutionException e) {
throw new TransactionRuntimeExecutionException(e);
}
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response in project cloudbreak by hortonworks.
the class StackResponseHardwareInfoProviderTest method testProviderEntriesToStackResponseEmptyInstanceGroup.
@Test
public void testProviderEntriesToStackResponseEmptyInstanceGroup() {
Stack stack = new Stack();
stack.setInstanceGroups(emptySet());
StackV4Response actual = underTest.providerEntriesToStackResponse(stack, new StackV4Response());
Assert.assertEquals(0L, actual.getHardwareInfoGroups().size());
}
Aggregations