Search in sources :

Example 1 with SaltMaster

use of com.sequenceiq.cloudbreak.orchestrator.salt.domain.SaltMaster in project cloudbreak by hortonworks.

the class SaltBootstrap method createBootstrap.

private SaltAction createBootstrap() {
    SaltAction saltAction = new SaltAction(SaltActionType.RUN);
    SaltAuth auth = new SaltAuth();
    auth.setPassword(sc.getSaltPassword());
    List<String> targetIps = targets.stream().map(Node::getPrivateIp).collect(Collectors.toList());
    for (GatewayConfig gatewayConfig : allGatewayConfigs) {
        String gatewayAddress = gatewayConfig.getPrivateAddress();
        if (targetIps.contains(gatewayAddress)) {
            Node saltMaster = targets.stream().filter(n -> n.getPrivateIp().equals(gatewayAddress)).findFirst().get();
            SaltMaster master = new SaltMaster();
            master.setAddress(gatewayAddress);
            master.setAuth(auth);
            master.setDomain(saltMaster.getDomain());
            master.setHostName(saltMaster.getHostname());
            // set due to compatibility reasons
            saltAction.setServer(gatewayAddress);
            saltAction.setMaster(master);
            saltAction.addMinion(createMinion(saltMaster));
            saltAction.addMaster(master);
        }
    }
    for (Node minion : targets.stream().filter(node -> !getGatewayPrivateIps().contains(node.getPrivateIp())).collect(Collectors.toList())) {
        saltAction.addMinion(createMinion(minion));
    }
    return saltAction;
}
Also used : GenericResponse(com.sequenceiq.cloudbreak.orchestrator.model.GenericResponse) Logger(org.slf4j.Logger) LoggerFactory(org.slf4j.LoggerFactory) SaltAuth(com.sequenceiq.cloudbreak.orchestrator.salt.domain.SaltAuth) Set(java.util.Set) SaltMaster(com.sequenceiq.cloudbreak.orchestrator.salt.domain.SaltMaster) Collectors(java.util.stream.Collectors) HashSet(java.util.HashSet) HttpStatus(org.springframework.http.HttpStatus) GenericResponses(com.sequenceiq.cloudbreak.orchestrator.model.GenericResponses) List(java.util.List) Minion(com.sequenceiq.cloudbreak.orchestrator.salt.domain.Minion) SaltStates(com.sequenceiq.cloudbreak.orchestrator.salt.states.SaltStates) CloudbreakOrchestratorFailedException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException) Node(com.sequenceiq.cloudbreak.orchestrator.model.Node) Map(java.util.Map) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig) OrchestratorBootstrap(com.sequenceiq.cloudbreak.orchestrator.OrchestratorBootstrap) Glob(com.sequenceiq.cloudbreak.orchestrator.salt.client.target.Glob) Collections(java.util.Collections) SaltAction(com.sequenceiq.cloudbreak.orchestrator.salt.domain.SaltAction) SaltConnector(com.sequenceiq.cloudbreak.orchestrator.salt.client.SaltConnector) SaltActionType(com.sequenceiq.cloudbreak.orchestrator.salt.client.SaltActionType) SaltAuth(com.sequenceiq.cloudbreak.orchestrator.salt.domain.SaltAuth) Node(com.sequenceiq.cloudbreak.orchestrator.model.Node) SaltMaster(com.sequenceiq.cloudbreak.orchestrator.salt.domain.SaltMaster) SaltAction(com.sequenceiq.cloudbreak.orchestrator.salt.domain.SaltAction) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)

Aggregations

OrchestratorBootstrap (com.sequenceiq.cloudbreak.orchestrator.OrchestratorBootstrap)1 CloudbreakOrchestratorFailedException (com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException)1 GatewayConfig (com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)1 GenericResponse (com.sequenceiq.cloudbreak.orchestrator.model.GenericResponse)1 GenericResponses (com.sequenceiq.cloudbreak.orchestrator.model.GenericResponses)1 Node (com.sequenceiq.cloudbreak.orchestrator.model.Node)1 SaltActionType (com.sequenceiq.cloudbreak.orchestrator.salt.client.SaltActionType)1 SaltConnector (com.sequenceiq.cloudbreak.orchestrator.salt.client.SaltConnector)1 Glob (com.sequenceiq.cloudbreak.orchestrator.salt.client.target.Glob)1 Minion (com.sequenceiq.cloudbreak.orchestrator.salt.domain.Minion)1 SaltAction (com.sequenceiq.cloudbreak.orchestrator.salt.domain.SaltAction)1 SaltAuth (com.sequenceiq.cloudbreak.orchestrator.salt.domain.SaltAuth)1 SaltMaster (com.sequenceiq.cloudbreak.orchestrator.salt.domain.SaltMaster)1 SaltStates (com.sequenceiq.cloudbreak.orchestrator.salt.states.SaltStates)1 Collections (java.util.Collections)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1