Search in sources :

Example 26 with Json

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);
}
Also used : Credential(com.sequenceiq.cloudbreak.domain.Credential) FileSystemScriptConfig(com.sequenceiq.cloudbreak.blueprint.filesystem.FileSystemScriptConfig) GcsFileSystemConfiguration(com.sequenceiq.cloudbreak.api.model.GcsFileSystemConfiguration) Json(com.sequenceiq.cloudbreak.domain.json.Json) Test(org.junit.Test)

Example 27 with Json

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());
}
Also used : Json(com.sequenceiq.cloudbreak.domain.json.Json) Test(org.junit.Test)

Example 28 with Json

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);
}
Also used : ClusterComponent(com.sequenceiq.cloudbreak.domain.ClusterComponent) AmbariRepoDetailsJson(com.sequenceiq.cloudbreak.api.model.AmbariRepoDetailsJson) AmbariStackDetailsJson(com.sequenceiq.cloudbreak.api.model.AmbariStackDetailsJson) Json(com.sequenceiq.cloudbreak.domain.json.Json) AmbariRepo(com.sequenceiq.cloudbreak.cloud.model.AmbariRepo)

Example 29 with Json

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());
}
Also used : IdentityUser(com.sequenceiq.cloudbreak.common.model.user.IdentityUser) Credential(com.sequenceiq.cloudbreak.domain.Credential) Topology(com.sequenceiq.cloudbreak.domain.Topology) Json(com.sequenceiq.cloudbreak.domain.json.Json) Date(java.util.Date) Before(org.junit.Before)

Example 30 with Json

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);
    }
}
Also used : HostOrchestratorClusterContext(com.sequenceiq.cloudbreak.core.bootstrap.service.host.context.HostOrchestratorClusterContext) HostOrchestrator(com.sequenceiq.cloudbreak.orchestrator.host.HostOrchestrator) ClusterComponent(com.sequenceiq.cloudbreak.domain.ClusterComponent) Node(com.sequenceiq.cloudbreak.orchestrator.model.Node) ArrayList(java.util.ArrayList) HostBootstrapApiContext(com.sequenceiq.cloudbreak.core.bootstrap.service.host.context.HostBootstrapApiContext) Json(com.sequenceiq.cloudbreak.domain.json.Json) Orchestrator(com.sequenceiq.cloudbreak.domain.Orchestrator) HostOrchestrator(com.sequenceiq.cloudbreak.orchestrator.host.HostOrchestrator) CloudbreakException(com.sequenceiq.cloudbreak.service.CloudbreakException) CloudbreakOrchestratorCancelledException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorCancelledException) CloudbreakOrchestratorException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorException) CancellationException(com.sequenceiq.cloudbreak.cloud.scheduler.CancellationException) InstanceMetaData(com.sequenceiq.cloudbreak.domain.InstanceMetaData) PollingResult(com.sequenceiq.cloudbreak.service.PollingResult) CloudbreakException(com.sequenceiq.cloudbreak.service.CloudbreakException) HashSet(java.util.HashSet) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Aggregations

Json (com.sequenceiq.cloudbreak.domain.json.Json)50 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)21 BadRequestException (com.sequenceiq.cloudbreak.controller.BadRequestException)11 Credential (com.sequenceiq.cloudbreak.domain.Credential)7 ArrayList (java.util.ArrayList)7 HashMap (java.util.HashMap)7 BlueprintInputJson (com.sequenceiq.cloudbreak.api.model.BlueprintInputJson)6 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)6 IOException (java.io.IOException)6 Test (org.junit.Test)6 ClusterComponent (com.sequenceiq.cloudbreak.domain.ClusterComponent)5 AmbariRepoDetailsJson (com.sequenceiq.cloudbreak.api.model.AmbariRepoDetailsJson)4 BlueprintParameterJson (com.sequenceiq.cloudbreak.api.model.BlueprintParameterJson)4 Component (com.sequenceiq.cloudbreak.domain.Component)4 HashSet (java.util.HashSet)4 GatewayJson (com.sequenceiq.cloudbreak.api.model.GatewayJson)3 Gateway (com.sequenceiq.cloudbreak.domain.Gateway)3 AmbariStackDetailsJson (com.sequenceiq.cloudbreak.api.model.AmbariStackDetailsJson)2 GcsFileSystemConfiguration (com.sequenceiq.cloudbreak.api.model.GcsFileSystemConfiguration)2 HostGroupAdjustmentJson (com.sequenceiq.cloudbreak.api.model.HostGroupAdjustmentJson)2