use of com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway in project cloudbreak by hortonworks.
the class GatewayToGatewayJsonConverterTest method testConvert.
@Test
public void testConvert() {
Gateway gateway = new Gateway();
gateway.setPath(PATH);
gateway.setSsoProvider(SSO_PROVIDER);
gateway.setSsoType(SSOType.SSO_PROVIDER);
gateway.setGatewayType(GatewayType.CENTRAL);
gateway.setTokenCert(TOKEN_CERT);
gateway.setSignKey(SIGN_KEY);
gateway.setSignCert(SIGN_CERT);
gateway.setTopologies(Sets.newHashSet(new GatewayTopology(), new GatewayTopology()));
GatewayV4Request result = underTest.convert(gateway);
assertEquals(SSOType.SSO_PROVIDER, result.getSsoType());
assertEquals(TOKEN_CERT, result.getTokenCert());
assertEquals(GatewayType.CENTRAL, result.getGatewayType());
assertEquals(result.getTopologies().size(), 2);
assertEquals(SSO_PROVIDER, result.getSsoProvider());
assertEquals(PATH, result.getPath());
assertEquals(2L, result.getTopologies().size());
}
use of com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway in project cloudbreak by hortonworks.
the class ClusterBootstrapperTest method doNotThrowDuplicateKeyNullIfVolumeResourceDontHaveInstanceId.
@Test
public void doNotThrowDuplicateKeyNullIfVolumeResourceDontHaveInstanceId() throws Exception {
doAnswer(invocation -> {
invocation.getArgument(0, Runnable.class).run();
return null;
}).when(transactionService).required(any(Runnable.class));
when(stackService.getByIdWithListsInTransaction(1L)).thenReturn(stack);
InstanceMetaData instanceMetaData = new InstanceMetaData();
instanceMetaData.setPrivateIp("1.1.1.1");
instanceMetaData.setPublicIp("2.2.2.2");
instanceMetaData.setDiscoveryFQDN("FQDN");
InstanceGroup instanceGroup = new InstanceGroup();
instanceGroup.setGroupName("master");
Template template = new Template();
template.setInstanceType("GATEWAY");
instanceGroup.setTemplate(template);
instanceMetaData.setInstanceGroup(instanceGroup);
when(stack.getId()).thenReturn(1L);
when(instanceMetaDataService.getReachableInstanceMetadataByStackId(stack.getId())).thenReturn(Set.of(instanceMetaData));
when(stack.getCustomDomain()).thenReturn("CUSTOM_DOMAIN");
Cluster cluster = new Cluster();
cluster.setGateway(new Gateway());
when(stack.getCluster()).thenReturn(cluster);
GatewayConfig gatewayConfig = new GatewayConfig("host1", "1.1.1.1", "1.1.1.1", 22, "i-1839", false);
when(gatewayConfigService.getAllGatewayConfigs(any())).thenReturn(List.of(gatewayConfig));
when(componentConfigProviderService.getImage(anyLong())).thenReturn(image);
when(hostClusterAvailabilityPollingService.pollWithAbsoluteTimeout(any(), any(), anyInt(), anyLong())).thenReturn(new ExtendedPollingResult.ExtendedPollingResultBuilder().success().build());
underTest.bootstrapNewNodes(1L, Set.of("1.1.1.1"));
verify(instanceMetaDataService).getReachableInstanceMetadataByStackId(1L);
verify(gatewayConfigService).getAllGatewayConfigs(stack);
verify(componentConfigProviderService).getImage(1L);
verify(instanceMetaDataService).saveAll(Set.of(instanceMetaData));
verify(hostOrchestrator, never()).removeDeadSaltMinions(gatewayConfig);
}
use of com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway in project cloudbreak by hortonworks.
the class ClusterV4RequestToClusterConverter method convertGateway.
private void convertGateway(ClusterV4Request source, Cluster cluster) {
GatewayV4Request gatewayRequest = source.getGateway();
if (gatewayRequest != null) {
if (StringUtils.isEmpty(gatewayRequest.getPath())) {
gatewayRequest.setPath(source.getName());
}
Gateway gateway = gatewayV4RequestToGatewayConverter.convert(gatewayRequest);
if (gateway != null) {
cluster.setGateway(gateway);
gateway.setCluster(cluster);
}
}
}
use of com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway in project cloudbreak by hortonworks.
the class StackV4RequestToTemplatePreparationObjectConverter method convert.
public TemplatePreparationObject convert(StackV4Request source) {
try {
CloudbreakUser cloudbreakUser = restRequestThreadLocalService.getCloudbreakUser();
User user = userService.getOrCreate(cloudbreakUser);
Workspace workspace = workspaceService.get(restRequestThreadLocalService.getRequestedWorkspaceId(), user);
DetailedEnvironmentResponse environment = environmentClientService.getByCrn(source.getEnvironmentCrn());
Credential credential = getCredential(source, environment);
LdapView ldapConfig = getLdapConfig(source, environment);
BaseFileSystemConfigurationsView fileSystemConfigurationView = getFileSystemConfigurationView(source, credential.getAttributes());
Set<RDSConfig> rdsConfigs = getRdsConfigs(source, workspace);
Blueprint blueprint = getBlueprint(source, workspace);
Set<HostgroupView> hostgroupViews = getHostgroupViews(source);
Gateway gateway = source.getCluster().getGateway() == null ? null : stackV4RequestToGatewayConverter.convert(source);
BlueprintView blueprintView = blueprintViewProvider.getBlueprintView(blueprint);
Optional<String> version = Optional.ofNullable(blueprintView.getVersion());
GeneralClusterConfigs generalClusterConfigs = generalClusterConfigsProvider.generalClusterConfigs(source, cloudbreakUser.getEmail(), blueprintService.getBlueprintVariant(blueprint));
String gatewaySignKey = null;
if (gateway != null) {
gatewaySignKey = gateway.getSignKey();
}
String envCrnForVirtualGroups = getEnvironmentCrnForVirtualGroups(environment);
VirtualGroupRequest virtualGroupRequest = new VirtualGroupRequest(envCrnForVirtualGroups, ldapConfig != null ? ldapConfig.getAdminGroup() : "");
Builder builder = Builder.builder().withCloudPlatform(source.getCloudPlatform()).withRdsConfigs(rdsConfigs).withHostgroupViews(hostgroupViews).withGateway(gateway, gatewaySignKey, exposedServiceCollector.getAllKnoxExposed(version)).withBlueprintView(blueprintView).withFileSystemConfigurationView(fileSystemConfigurationView).withGeneralClusterConfigs(generalClusterConfigs).withLdapConfig(ldapConfig).withCustomInputs(source.getInputs()).withKerberosConfig(getKerberosConfig(source, environment)).withStackType(source.getType()).withVirtualGroupView(virtualGroupRequest);
decorateBuilderWithPlacement(source, builder);
decorateBuilderWithAccountMapping(source, environment, credential, builder);
decorateBuilderWithProductDetails(source, builder);
decorateDatalakeView(source, builder);
return builder.build();
} catch (BlueprintProcessingException | IOException e) {
throw new CloudbreakServiceException(e.getMessage(), e);
}
}
use of com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway in project cloudbreak by hortonworks.
the class GatewayV4RequestToGatewayConverter method convert.
public Gateway convert(GatewayV4Request source) {
ValidationResult validationResult = gatewayJsonValidator.validate(source);
if (validationResult.hasError()) {
throw new BadRequestException(validationResult.getFormattedErrors());
}
if (CollectionUtils.isEmpty(source.getTopologies())) {
return null;
}
Gateway gateway = new Gateway();
gatewayConvertUtil.setBasicProperties(source, gateway);
gatewayConvertUtil.setTopologies(source, gateway);
gatewayConvertUtil.setGatewayPathAndSsoProvider(source, gateway);
CloudbreakUser cloudbreakUser = restRequestThreadLocalService.getCloudbreakUser();
User user = userService.getOrCreate(cloudbreakUser);
Workspace workspace = workspaceService.get(restRequestThreadLocalService.getRequestedWorkspaceId(), user);
gateway.setWorkspace(workspace);
return gateway;
}
Aggregations