use of com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway in project cloudbreak by hortonworks.
the class StackV4RequestToGatewayConverter method convert.
public Gateway convert(StackV4Request source) {
Gateway gateway = new Gateway();
GatewayV4Request gatewayJson = source.getCluster().getGateway();
ValidationResult validationResult = gatewayJsonValidator.validate(gatewayJson);
if (validationResult.hasError()) {
throw new BadRequestException(validationResult.getFormattedErrors());
}
convertUtil.setBasicProperties(gatewayJson, gateway);
convertUtil.setTopologies(gatewayJson, gateway);
convertUtil.setGatewayPathAndSsoProvider(gatewayJson, gateway);
return gateway;
}
use of com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway in project cloudbreak by hortonworks.
the class ClusterService method saveWithRef.
public Cluster saveWithRef(Cluster cluster) {
Cluster savedCluster;
try {
long start = System.currentTimeMillis();
if (cluster.getFileSystem() != null) {
cluster.getFileSystem().setWorkspace(cluster.getWorkspace());
fileSystemConfigService.pureSave(cluster.getFileSystem());
}
if (cluster.getAdditionalFileSystem() != null) {
cluster.getAdditionalFileSystem().setWorkspace(cluster.getWorkspace());
fileSystemConfigService.pureSave(cluster.getAdditionalFileSystem());
}
savedCluster = save(cluster);
Gateway gateway = cluster.getGateway();
if (gateway != null) {
gateway.setCluster(savedCluster);
gatewayService.save(gateway);
}
List<ClusterComponent> store = clusterComponentConfigProvider.store(cluster.getComponents(), savedCluster);
savedCluster.setComponents(new HashSet<>(store));
LOGGER.info("Cluster object saved in {} ms with cluster id {}", System.currentTimeMillis() - start, cluster.getId());
} catch (DataIntegrityViolationException ex) {
String msg = String.format("Error with resource [%s], %s", APIResourceType.CLUSTER, getProperSqlErrorMessage(ex));
throw new BadRequestException(msg, ex);
}
return savedCluster;
}
use of com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway in project cloudbreak by hortonworks.
the class ClusterServiceRunner method generateGatewaySignKeys.
private void generateGatewaySignKeys(Cluster cluster) {
Gateway gateway = cluster.getGateway();
if (Objects.nonNull(gateway)) {
convertUtil.generateSignKeys(gateway);
gatewayService.save(gateway);
}
}
use of com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway in project cloudbreak by hortonworks.
the class ClusterHostServiceRunner method createKnoxRelatedGatewayCofniguration.
private Map<String, Object> createKnoxRelatedGatewayCofniguration(Cluster cluster, VirtualGroupRequest virtualGroupRequest, ClusterPreCreationApi connector) throws IOException {
Gateway clusterGateway = cluster.getGateway();
Map<String, Object> gateway = new HashMap<>();
if (clusterGateway != null) {
gateway.put("path", clusterGateway.getPath());
gateway.put("ssotype", clusterGateway.getSsoType());
gateway.put("ssoprovider", clusterGateway.getSsoProvider());
gateway.put("signpub", clusterGateway.getSignPub());
gateway.put("signcert", clusterGateway.getSignCert());
gateway.put("signkey", clusterGateway.getSignKey());
gateway.put("tokencert", clusterGateway.getTokenCert());
gateway.put("mastersecret", clusterGateway.getKnoxMasterSecret());
gateway.put("envAccessGroup", virtualGroupService.createOrGetVirtualGroup(virtualGroupRequest, UmsVirtualGroupRight.ENVIRONMENT_ACCESS));
List<Map<String, Object>> topologies = getTopologies(clusterGateway, cluster.getBlueprint().getStackVersion());
gateway.put("topologies", topologies);
if (cluster.getBlueprint() != null) {
Boolean autoTlsEnabled = cluster.getAutoTlsEnabled();
Map<String, Integer> servicePorts = connector.getServicePorts(cluster.getBlueprint(), autoTlsEnabled);
gateway.put("ports", servicePorts);
gateway.put("protocol", autoTlsEnabled ? "https" : "http");
}
if (SSOType.SSO_PROVIDER_FROM_UMS.equals(clusterGateway.getSsoType())) {
String accountId = ThreadBasedUserCrnProvider.getAccountId();
try {
String metadataXml = umsClient.getIdentityProviderMetadataXml(accountId, regionAwareInternalCrnGeneratorFactory);
gateway.put("saml", metadataXml);
} catch (Exception e) {
LOGGER.debug("Could not get SAML metadata file to set up IdP in KNOXSSO.", e);
throw new NotFoundException("Could not get SAML metadata file to set up IdP in KNOXSSO: " + e.getMessage());
}
}
} else {
gateway.put("ssotype", SSOType.NONE);
LOGGER.debug("Cluster gateway (Knox) is not set. Configure ssotype to 'NONE' for backward compatibility.");
}
return gateway;
}
use of com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway in project cloudbreak by hortonworks.
the class HdfsConfigProviderTest method getTemplatePreparationObject.
private TemplatePreparationObject getTemplatePreparationObject(boolean useS3FileSystem, boolean fillDynamoTableName, boolean includeLocations) {
HostgroupView master = new HostgroupView("master", 1, InstanceGroupType.GATEWAY, 1);
HostgroupView worker = new HostgroupView("worker", 2, InstanceGroupType.CORE, 2);
List<StorageLocationView> locations = new ArrayList<>();
if (includeLocations) {
locations.add(new StorageLocationView(getStorageLocation("hive.metastore.warehouse.dir", "s3a://bucket/warehouse/managed")));
locations.add(new StorageLocationView(getStorageLocation("hive.metastore.warehouse.external.dir", "s3a://bucket/warehouse/external")));
}
BaseFileSystemConfigurationsView fileSystemConfigurationsView;
if (useS3FileSystem) {
S3FileSystem s3FileSystem = new S3FileSystem();
if (fillDynamoTableName) {
s3FileSystem.setS3GuardDynamoTableName("dynamoTable");
}
fileSystemConfigurationsView = new S3FileSystemConfigurationsView(s3FileSystem, locations, false);
} else {
fileSystemConfigurationsView = new AdlsFileSystemConfigurationsView(new AdlsFileSystem(), locations, false);
}
Gateway gateway = TestUtil.gatewayEnabledWithExposedKnoxServices(ExposedServiceUtil.exposedService("NAMENODE").getKnoxService());
PlacementView placementView = new PlacementView("region", "az");
return Builder.builder().withFileSystemConfigurationView(fileSystemConfigurationsView).withHostgroupViews(Set.of(master, worker)).withGateway(gateway, "/cb/secret/signkey", new HashSet<>()).withPlacementView(placementView).withDefaultTags(Map.of("apple", "apple1")).withProductDetails(new ClouderaManagerRepo().withVersion("7.1.0"), List.of()).withStackType(StackType.DATALAKE).build();
}
Aggregations