Search in sources :

Example 21 with GatewayConfig

use of com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig in project cloudbreak by hortonworks.

the class ClusterHostServiceRunner method addAmbariServices.

@Transactional
public Map<String, String> addAmbariServices(Long stackId, String hostGroupName, Integer scalingAdjustment) throws CloudbreakException {
    Map<String, String> candidates;
    try {
        Stack stack = stackRepository.findOneWithLists(stackId);
        Cluster cluster = stack.getCluster();
        candidates = collectUpscaleCandidates(cluster.getId(), hostGroupName, scalingAdjustment);
        Set<Node> allNodes = collectNodes(stack);
        HostOrchestrator hostOrchestrator = hostOrchestratorResolver.get(stack.getOrchestrator().getType());
        List<GatewayConfig> gatewayConfigs = gatewayConfigService.getAllGatewayConfigs(stack);
        SaltConfig saltConfig = createSaltConfig(stack, cluster, gatewayConfigService.getPrimaryGatewayConfig(stack), gatewayConfigs);
        hostOrchestrator.runService(gatewayConfigs, allNodes, saltConfig, clusterDeletionBasedModel(stack.getId(), cluster.getId()));
    } catch (CloudbreakOrchestratorCancelledException e) {
        throw new CancellationException(e.getMessage());
    } catch (CloudbreakOrchestratorException | IOException e) {
        throw new CloudbreakException(e);
    }
    return candidates;
}
Also used : HostOrchestrator(com.sequenceiq.cloudbreak.orchestrator.host.HostOrchestrator) Node(com.sequenceiq.cloudbreak.orchestrator.model.Node) Cluster(com.sequenceiq.cloudbreak.domain.Cluster) SaltConfig(com.sequenceiq.cloudbreak.orchestrator.model.SaltConfig) IOException(java.io.IOException) Stack(com.sequenceiq.cloudbreak.domain.Stack) CloudbreakOrchestratorException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorException) CloudbreakOrchestratorCancelledException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorCancelledException) CancellationException(com.sequenceiq.cloudbreak.cloud.scheduler.CancellationException) CloudbreakException(com.sequenceiq.cloudbreak.service.CloudbreakException) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig) Transactional(javax.transaction.Transactional)

Example 22 with GatewayConfig

use of com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig in project cloudbreak by hortonworks.

the class OrchestratorRecipeExecutor method postInstall.

public void postInstall(Stack stack) throws CloudbreakException {
    HostOrchestrator hostOrchestrator = hostOrchestratorResolver.get(stack.getOrchestrator().getType());
    GatewayConfig gatewayConfig = gatewayConfigService.getPrimaryGatewayConfig(stack);
    try {
        hostOrchestrator.postInstallRecipes(gatewayConfig, collectNodes(stack), clusterDeletionBasedModel(stack.getId(), stack.getCluster().getId()));
    } catch (CloudbreakOrchestratorFailedException e) {
        throw new CloudbreakException(e);
    }
}
Also used : CloudbreakOrchestratorFailedException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException) HostOrchestrator(com.sequenceiq.cloudbreak.orchestrator.host.HostOrchestrator) CloudbreakException(com.sequenceiq.cloudbreak.service.CloudbreakException) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)

Example 23 with GatewayConfig

use of com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig in project cloudbreak by hortonworks.

the class OrchestratorRecipeExecutor method preTerminationRecipesOnNodes.

public void preTerminationRecipesOnNodes(Stack stack, Set<Node> nodes) throws CloudbreakException {
    if (stack.getCluster() == null) {
        throw new NotFoundException("Cluster does not found, pre-termination will not be run.");
    }
    HostOrchestrator hostOrchestrator = hostOrchestratorResolver.get(stack.getOrchestrator().getType());
    GatewayConfig gatewayConfig = gatewayConfigService.getPrimaryGatewayConfig(stack);
    try {
        hostOrchestrator.preTerminationRecipes(gatewayConfig, nodes, clusterDeletionBasedModel(stack.getId(), stack.getCluster().getId()));
    } catch (CloudbreakOrchestratorFailedException e) {
        throw new CloudbreakException(e);
    }
}
Also used : CloudbreakOrchestratorFailedException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException) HostOrchestrator(com.sequenceiq.cloudbreak.orchestrator.host.HostOrchestrator) NotFoundException(com.sequenceiq.cloudbreak.controller.NotFoundException) CloudbreakException(com.sequenceiq.cloudbreak.service.CloudbreakException) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)

Example 24 with GatewayConfig

use of com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig in project cloudbreak by hortonworks.

the class TlsSecurityService method buildGatewayConfig.

public GatewayConfig buildGatewayConfig(Long stackId, InstanceMetaData gatewayInstance, Integer gatewayPort, SaltClientConfig saltClientConfig, Boolean knoxGatewayEnabled) {
    SecurityConfig securityConfig = securityConfigRepository.findOneByStackId(stackId);
    String connectionIp = getGatewayIp(securityConfig, gatewayInstance);
    HttpClientConfig conf = buildTLSClientConfig(stackId, connectionIp, gatewayInstance);
    return new GatewayConfig(connectionIp, gatewayInstance.getPublicIpWrapper(), gatewayInstance.getPrivateIp(), gatewayInstance.getDiscoveryFQDN(), gatewayPort, conf.getServerCert(), conf.getClientCert(), conf.getClientKey(), saltClientConfig.getSaltPassword(), saltClientConfig.getSaltBootPassword(), saltClientConfig.getSignatureKeyPem(), knoxGatewayEnabled, InstanceMetadataType.GATEWAY_PRIMARY.equals(gatewayInstance.getInstanceMetadataType()), securityConfig.getSaltSignPrivateKeyDecoded(), securityConfig.getSaltSignPublicKeyDecoded());
}
Also used : HttpClientConfig(com.sequenceiq.cloudbreak.client.HttpClientConfig) SecurityConfig(com.sequenceiq.cloudbreak.domain.SecurityConfig) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)

Example 25 with GatewayConfig

use of com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig in project cloudbreak by hortonworks.

the class SaltBootstrapTest method setUp.

@Before
public void setUp() {
    saltConnector = mock(SaltConnector.class);
    gatewayConfig = new GatewayConfig("1.1.1.1", "10.0.0.1", "172.16.252.43", "10-0-0-1.example.com", 9443, "serverCert", "clientCert", "clientKey", "saltpasswd", "saltbootpassword", "signkey", false, true, null, null);
    GenericResponse response = new GenericResponse();
    response.setStatusCode(HttpStatus.OK.value());
    GenericResponses genericResponses = new GenericResponses();
    genericResponses.setResponses(Collections.singletonList(response));
    when(saltConnector.action(Mockito.any(SaltAction.class))).thenReturn(genericResponses);
    when(saltConnector.run(Mockito.any(), Mockito.eq("network.default_route"), Mockito.any(), Mockito.any())).thenReturn(new DefaultRouteResponse(Collections.emptyList()));
    NetworkInterfaceResponse networkInterfaceResponse = new NetworkInterfaceResponse();
    List<Map<String, String>> networkResultList = new ArrayList<>();
    networkMap = new HashMap<>();
    networkMap.put("host-10-0-0-1.example.com", "10.0.0.1");
    networkMap.put("host-10-0-0-2.example.com", "10.0.0.2");
    networkMap.put("host-10-0-0-3.example.com", "10.0.0.3");
    networkResultList.add(networkMap);
    networkInterfaceResponse.setResult(networkResultList);
    when(saltConnector.run(Mockito.any(), Mockito.eq("network.interface_ip"), Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(networkInterfaceResponse);
}
Also used : NetworkInterfaceResponse(com.sequenceiq.cloudbreak.orchestrator.salt.domain.NetworkInterfaceResponse) DefaultRouteResponse(com.sequenceiq.cloudbreak.orchestrator.salt.domain.DefaultRouteResponse) GenericResponse(com.sequenceiq.cloudbreak.orchestrator.model.GenericResponse) ArrayList(java.util.ArrayList) GenericResponses(com.sequenceiq.cloudbreak.orchestrator.model.GenericResponses) HashMap(java.util.HashMap) Map(java.util.Map) SaltConnector(com.sequenceiq.cloudbreak.orchestrator.salt.client.SaltConnector) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig) SaltAction(com.sequenceiq.cloudbreak.orchestrator.salt.domain.SaltAction) Before(org.junit.Before)

Aggregations

GatewayConfig (com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)29 HostOrchestrator (com.sequenceiq.cloudbreak.orchestrator.host.HostOrchestrator)17 CloudbreakOrchestratorFailedException (com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException)15 Node (com.sequenceiq.cloudbreak.orchestrator.model.Node)13 CloudbreakException (com.sequenceiq.cloudbreak.service.CloudbreakException)13 InstanceMetaData (com.sequenceiq.cloudbreak.domain.InstanceMetaData)12 CloudbreakOrchestratorException (com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorException)12 Stack (com.sequenceiq.cloudbreak.domain.Stack)11 ArrayList (java.util.ArrayList)10 SaltConnector (com.sequenceiq.cloudbreak.orchestrator.salt.client.SaltConnector)9 IOException (java.io.IOException)9 HashSet (java.util.HashSet)9 Map (java.util.Map)9 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)8 List (java.util.List)8 SaltConfig (com.sequenceiq.cloudbreak.orchestrator.model.SaltConfig)7 Set (java.util.Set)7 OrchestratorBootstrap (com.sequenceiq.cloudbreak.orchestrator.OrchestratorBootstrap)6 ExitCriteriaModel (com.sequenceiq.cloudbreak.orchestrator.state.ExitCriteriaModel)6 Collection (java.util.Collection)6