use of com.sequenceiq.cloudbreak.domain.json.Json in project cloudbreak by hortonworks.
the class GcsFileSystemConfiguratorTest method testGetScriptConfigsWhenPrivateKeyNotSet.
@Test
public void testGetScriptConfigsWhenPrivateKeyNotSet() throws JsonProcessingException {
Credential credential = new Credential();
credential.setAttributes(new Json(emptyMap()));
GcsFileSystemConfiguration notProcessed = null;
List<FileSystemScriptConfig> actual = underTest.getScriptConfigs(credential, notProcessed);
List<FileSystemScriptConfig> expected = Arrays.asList(new FileSystemScriptConfig("scripts/gcs-p12.sh", POST_AMBARI_START, ALL_NODES, singletonMap("P12KEY", "")), new FileSystemScriptConfig("scripts/gcs-connector-local.sh", POST_AMBARI_START, ALL_NODES), new FileSystemScriptConfig("scripts/gcs-connector-hdfs.sh", POST_CLUSTER_INSTALL, ONE_NODE));
Assert.assertEquals(expected, actual);
}
use of com.sequenceiq.cloudbreak.domain.json.Json in project cloudbreak by hortonworks.
the class GatewayViewTest method testInitializeGatewayView.
@Test
public void testInitializeGatewayView() throws JsonProcessingException {
GatewayView gatewayView = new GatewayView(TestUtil.gateway());
Assert.assertEquals(true, gatewayView.getEnableGateway());
Assert.assertEquals("signcert", gatewayView.getEscSignCert());
Assert.assertEquals("signkey", gatewayView.getEscSignKey());
Assert.assertEquals("signpub", gatewayView.getEscSignPub());
Assert.assertEquals("/path", gatewayView.getPath());
Assert.assertEquals("simple", gatewayView.getSsoProvider());
Assert.assertEquals("tokencert", gatewayView.getTokenCert());
Assert.assertEquals("topology", gatewayView.getTopologyName());
Assert.assertEquals(new Json("{}"), gatewayView.getExposedServices());
Assert.assertEquals(GatewayType.CENTRAL, gatewayView.getGatewayType());
Assert.assertEquals(SSOType.NONE, gatewayView.getSsoType());
}
use of com.sequenceiq.cloudbreak.domain.json.Json in project cloudbreak by hortonworks.
the class ClusterCreationSetupService method determineAmbariRepoConfig.
private ClusterComponent determineAmbariRepoConfig(Optional<Component> stackAmbariRepoConfig, AmbariRepoDetailsJson ambariRepoDetailsJson, Optional<Component> stackImageComponent, Cluster cluster) throws IOException {
Json json;
if (!stackAmbariRepoConfig.isPresent()) {
AmbariRepo ambariRepo = ambariRepoDetailsJson != null ? conversionService.convert(ambariRepoDetailsJson, AmbariRepo.class) : defaultAmbariRepoService.getDefault(getOsType(stackImageComponent));
if (ambariRepo == null) {
throw new BadRequestException(String.format("Couldn't determine Ambari repo for the stack: %s", cluster.getStack().getName()));
}
json = new Json(ambariRepo);
} else {
json = stackAmbariRepoConfig.get().getAttributes();
}
return new ClusterComponent(ComponentType.AMBARI_REPO_DETAILS, json, cluster);
}
use of com.sequenceiq.cloudbreak.domain.json.Json in project cloudbreak by hortonworks.
the class CredentialServiceTest method init.
@Before
public void init() throws Exception {
doNothing().when(authorizationService).hasWritePermission(any());
doNothing().when(notificationSender).send(any());
when(credentialAdapter.init(any(Credential.class))).then(invocation -> invocation.getArgumentAt(0, Credential.class));
credentialToModify = new Credential();
credentialToModify.setId(1L);
credentialToModify.setCloudPlatform(PLATFORM);
originalTopology = new Topology();
credentialToModify.setTopology(originalTopology);
originalDescription = "orig-desc";
credentialToModify.setDescription(originalDescription);
originalAttributes = new Json("test");
credentialToModify.setAttributes(originalAttributes);
when(credentialRepository.findByNameInUser(anyString(), anyString())).thenReturn(credentialToModify);
when(credentialRepository.findOneByName(anyString(), anyString())).thenReturn(credentialToModify);
when(credentialRepository.save(any(Credential.class))).then(invocation -> invocation.getArgumentAt(0, Credential.class));
user = new IdentityUser("asef", "asdf", "asdf", null, "ASdf", "asdf", new Date());
}
use of com.sequenceiq.cloudbreak.domain.json.Json in project cloudbreak by hortonworks.
the class ClusterBootstrapper method bootstrapOnHost.
@SuppressFBWarnings("REC_CATCH_EXCEPTION")
@SuppressWarnings("unchecked")
public void bootstrapOnHost(Stack stack) throws CloudbreakException {
Set<Node> nodes = new HashSet<>();
String domain = hostDiscoveryService.determineDomain(stack.getCustomDomain(), stack.getName(), stack.isClusterNameAsSubdomain());
for (InstanceMetaData im : stack.getRunningInstanceMetaData()) {
if (im.getPrivateIp() == null && im.getPublicIpWrapper() == null) {
LOGGER.warn("Skipping instance metadata because the public ip and private ips are null '{}'.", im);
} else {
String generatedHostName = hostDiscoveryService.generateHostname(stack.getCustomHostname(), im.getInstanceGroupName(), im.getPrivateId(), stack.isHostgroupNameAsHostname());
nodes.add(new Node(im.getPrivateIp(), im.getPublicIpWrapper(), generatedHostName, domain, im.getInstanceGroupName()));
}
}
try {
HostOrchestrator hostOrchestrator = hostOrchestratorResolver.get(stack.getOrchestrator().getType());
List<GatewayConfig> allGatewayConfig = new ArrayList<>();
Boolean enableKnox = stack.getCluster().getGateway().getEnableGateway();
for (InstanceMetaData gateway : stack.getGatewayInstanceMetadata()) {
GatewayConfig gatewayConfig = gatewayConfigService.getGatewayConfig(stack, gateway, enableKnox);
allGatewayConfig.add(gatewayConfig);
PollingResult bootstrapApiPolling = hostBootstrapApiPollingService.pollWithTimeoutSingleFailure(hostBootstrapApiCheckerTask, new HostBootstrapApiContext(stack, gatewayConfig, hostOrchestrator), POLL_INTERVAL, MAX_POLLING_ATTEMPTS);
validatePollingResultForCancellation(bootstrapApiPolling, "Polling of bootstrap API was cancelled.");
}
ClusterComponent saltComponent = clusterComponentProvider.getComponent(stack.getCluster().getId(), ComponentType.SALT_STATE);
if (saltComponent == null) {
byte[] stateConfigZip = hostOrchestrator.getStateConfigZip();
saltComponent = new ClusterComponent(ComponentType.SALT_STATE, new Json(singletonMap(ComponentType.SALT_STATE.name(), Base64.encodeBase64String(stateConfigZip))), stack.getCluster());
clusterComponentProvider.store(saltComponent);
}
hostOrchestrator.bootstrap(allGatewayConfig, nodes, clusterDeletionBasedModel(stack.getId(), null));
InstanceMetaData primaryGateway = stack.getPrimaryGatewayInstance();
GatewayConfig gatewayConfig = gatewayConfigService.getGatewayConfig(stack, primaryGateway, enableKnox);
String gatewayIp = gatewayConfigService.getGatewayIp(stack, primaryGateway);
PollingResult allNodesAvailabilityPolling = hostClusterAvailabilityPollingService.pollWithTimeoutSingleFailure(hostClusterAvailabilityCheckerTask, new HostOrchestratorClusterContext(stack, hostOrchestrator, gatewayConfig, nodes), POLL_INTERVAL, MAX_POLLING_ATTEMPTS);
validatePollingResultForCancellation(allNodesAvailabilityPolling, "Polling of all nodes availability was cancelled.");
Orchestrator orchestrator = stack.getOrchestrator();
orchestrator.setApiEndpoint(gatewayIp + ':' + stack.getGatewayPort());
orchestrator.setType(hostOrchestrator.name());
orchestratorRepository.save(orchestrator);
if (TIMEOUT.equals(allNodesAvailabilityPolling)) {
clusterBootstrapperErrorHandler.terminateFailedNodes(hostOrchestrator, null, stack, gatewayConfig, nodes);
}
} catch (Exception e) {
throw new CloudbreakException(e);
}
}
Aggregations