Search in sources :

Example 6 with ApplyResponse

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

the class ModifyGrainBase method submit.

@Override
public String submit(SaltConnector saltConnector) {
    ApplyResponse response;
    response = addGrain ? SaltStates.addGrain(saltConnector, new Compound(getTarget(), compoundType), key, value) : SaltStates.removeGrain(saltConnector, new Compound(getTarget(), compoundType), key, value);
    Set<String> missingIps = collectMissingNodes(collectNodes(response));
    setTarget(missingIps);
    return missingIps.toString();
}
Also used : Compound(com.sequenceiq.cloudbreak.orchestrator.salt.client.target.Compound) ApplyResponse(com.sequenceiq.cloudbreak.orchestrator.salt.domain.ApplyResponse)

Example 7 with ApplyResponse

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

the class SaltStatesTest method highstateTest.

@Test
public void highstateTest() {
    String jobId = "1";
    ApplyResponse response = new ApplyResponse();
    List<Map<String, Object>> result = new ArrayList<>();
    Map<String, Object> resultMap = new HashMap<>();
    resultMap.put("jid", jobId);
    result.add(resultMap);
    response.setResult(result);
    when(saltConnector.run(any(), eq("state.highstate"), any(), eq(ApplyResponse.class))).thenReturn(response);
    String jid = SaltStates.highstate(saltConnector);
    assertEquals(jobId, jid);
    verify(saltConnector, times(1)).run(eq(Glob.ALL), eq("state.highstate"), eq(LOCAL_ASYNC), eq(ApplyResponse.class));
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) HashMap(java.util.HashMap) Map(java.util.Map) ApplyResponse(com.sequenceiq.cloudbreak.orchestrator.salt.domain.ApplyResponse) Test(org.junit.Test)

Example 8 with ApplyResponse

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

the class SyncGrainsRunner method submit.

@Override
public String submit(SaltConnector saltConnector) {
    ApplyResponse grainsResult = SaltStates.syncGrains(saltConnector);
    Set<String> strings = collectMissingNodes(collectNodes(grainsResult));
    setTarget(strings);
    return strings.toString();
}
Also used : ApplyResponse(com.sequenceiq.cloudbreak.orchestrator.salt.domain.ApplyResponse)

Example 9 with ApplyResponse

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

the class SaltApiRunPostResponse method saltUtilSyncGrainsResponse.

protected Object saltUtilSyncGrainsResponse() throws JsonProcessingException {
    ApplyResponse applyResponse = new ApplyResponse();
    List<Map<String, Object>> responseList = new ArrayList<>();
    Map<String, Object> hostMap = new HashMap<>();
    for (Entry<String, CloudVmMetaDataStatus> stringCloudVmMetaDataStatusEntry : instanceMap.entrySet()) {
        CloudVmMetaDataStatus cloudVmMetaDataStatus = stringCloudVmMetaDataStatusEntry.getValue();
        if (InstanceStatus.STARTED == cloudVmMetaDataStatus.getCloudVmInstanceStatus().getStatus()) {
            String privateIp = cloudVmMetaDataStatus.getMetaData().getPrivateIp();
            hostMap.put("host-" + privateIp.replace(".", "-"), privateIp);
        }
    }
    responseList.add(hostMap);
    applyResponse.setResult(responseList);
    return objectMapper.writeValueAsString(applyResponse);
}
Also used : HashMap(java.util.HashMap) CloudVmMetaDataStatus(com.sequenceiq.cloudbreak.cloud.model.CloudVmMetaDataStatus) ArrayList(java.util.ArrayList) HashMap(java.util.HashMap) Map(java.util.Map) ApplyResponse(com.sequenceiq.cloudbreak.orchestrator.salt.domain.ApplyResponse)

Aggregations

ApplyResponse (com.sequenceiq.cloudbreak.orchestrator.salt.domain.ApplyResponse)9 ArrayList (java.util.ArrayList)6 HashMap (java.util.HashMap)6 Map (java.util.Map)6 Test (org.junit.Test)4 Node (com.sequenceiq.cloudbreak.orchestrator.model.Node)3 SaltConnector (com.sequenceiq.cloudbreak.orchestrator.salt.client.SaltConnector)3 CloudVmMetaDataStatus (com.sequenceiq.cloudbreak.cloud.model.CloudVmMetaDataStatus)2 HashSet (java.util.HashSet)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 Compound (com.sequenceiq.cloudbreak.orchestrator.salt.client.target.Compound)1 Matchers.anyString (org.mockito.Matchers.anyString)1