Search in sources :

Example 1 with Minion

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

the class SaltBootstrap method createMinion.

private Minion createMinion(Node node) {
    Minion minion = new Minion();
    minion.setAddress(node.getPrivateIp());
    minion.setHostGroup(node.getHostGroup());
    minion.setHostName(node.getHostname());
    minion.setDomain(node.getDomain());
    minion.setServers(getGatewayPrivateIps());
    // set due to compatibility reasons
    minion.setServer(getGatewayPrivateIps().get(0));
    return minion;
}
Also used : Minion(com.sequenceiq.cloudbreak.orchestrator.salt.domain.Minion)

Example 2 with Minion

use of com.sequenceiq.cloudbreak.orchestrator.salt.domain.Minion 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)

Example 3 with Minion

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

the class SaltStates method stopMinions.

public static void stopMinions(SaltConnector sc, Map<String, String> privateIPsByFQDN) {
    SaltAction saltAction = new SaltAction(SaltActionType.STOP);
    for (Entry<String, String> entry : privateIPsByFQDN.entrySet()) {
        Minion minion = new Minion();
        minion.setAddress(entry.getValue());
        saltAction.addMinion(minion);
    }
    sc.action(saltAction);
}
Also used : Minion(com.sequenceiq.cloudbreak.orchestrator.salt.domain.Minion) SaltAction(com.sequenceiq.cloudbreak.orchestrator.salt.domain.SaltAction)

Aggregations

Minion (com.sequenceiq.cloudbreak.orchestrator.salt.domain.Minion)3 SaltAction (com.sequenceiq.cloudbreak.orchestrator.salt.domain.SaltAction)2 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 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