use of com.sequenceiq.cloudbreak.orchestrator.salt.domain.ApplyResponse in project cloudbreak by hortonworks.
the class SaltApiRunPostResponse method grainsResponse.
protected Object grainsResponse() 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);
}
use of com.sequenceiq.cloudbreak.orchestrator.salt.domain.ApplyResponse in project cloudbreak by hortonworks.
the class BaseSaltJobRunnerTest method collectNodesTest.
@Test
public void collectNodesTest() {
Set<Node> allNode = allNodeWithPostFix();
baseSaltJobRunner = new BaseSaltJobRunner(targets, allNode) {
@Override
public String submit(SaltConnector saltConnector) {
return "";
}
};
ApplyResponse applyResponse = new ApplyResponse();
List<Map<String, Object>> resultList = new ArrayList<>();
Map<String, Object> resultMap = new HashMap<>();
resultMap.put("host-10-0-0-1.example.com", "10.0.0.1");
resultMap.put("host-10-0-0-2.example.com", "10.0.0.2");
resultMap.put("host-10-0-0-3.example.com", "10.0.0.3");
resultList.add(resultMap);
applyResponse.setResult(resultList);
Set<String> collectedNodes = baseSaltJobRunner.collectNodes(applyResponse);
Assert.assertEquals(3, collectedNodes.size());
Assert.assertTrue(collectedNodes.contains("host-10-0-0-1.example.com"));
Assert.assertTrue(collectedNodes.contains("host-10-0-0-2.example.com"));
Assert.assertTrue(collectedNodes.contains("host-10-0-0-3.example.com"));
}
use of com.sequenceiq.cloudbreak.orchestrator.salt.domain.ApplyResponse in project cloudbreak by hortonworks.
the class GrainAddRunnerTest method submitTest.
@Test
public void submitTest() {
Set<String> targets = new HashSet<>();
targets.add("10.0.0.1");
targets.add("10.0.0.2");
targets.add("10.0.0.3");
Set<Node> allNode = new HashSet<>();
allNode.add(new Node("10.0.0.1", "5.5.5.1", "10-0-0-1.example.com", "hg"));
allNode.add(new Node("10.0.0.2", "5.5.5.2", "10-0-0-2.example.com", "hg"));
allNode.add(new Node("10.0.0.3", "5.5.5.3", "10-0-0-3.example.com", "hg"));
PowerMockito.mockStatic(SaltStates.class);
ApplyResponse applyResponse = new ApplyResponse();
List<Map<String, Object>> result = new ArrayList<>();
Map<String, Object> nodes = new HashMap<>();
nodes.put("10-0-0-1.example.com", "something");
nodes.put("10-0-0-2.example.com", "something");
result.add(nodes);
applyResponse.setResult(result);
PowerMockito.when(SaltStates.addGrain(any(), any(), anyString(), any())).thenReturn(applyResponse);
GrainAddRunner addRoleChecker = new GrainAddRunner(targets, allNode, "ambari_server");
SaltConnector saltConnector = Mockito.mock(SaltConnector.class);
String missingIps = addRoleChecker.submit(saltConnector);
assertThat(addRoleChecker.getTarget(), hasItems("10.0.0.3"));
assertEquals("[10.0.0.3]", missingIps);
}
use of com.sequenceiq.cloudbreak.orchestrator.salt.domain.ApplyResponse in project cloudbreak by hortonworks.
the class SyncGrainsRunnerTest method submit.
@Test
public void submit() {
Set<String> targets = new HashSet<>();
targets.add("10.0.0.1");
targets.add("10.0.0.2");
targets.add("10.0.0.3");
Set<Node> allNode = new HashSet<>();
allNode.add(new Node("10.0.0.1", "5.5.5.1", "10-0-0-1.example.com", "hg"));
allNode.add(new Node("10.0.0.2", "5.5.5.2", "10-0-0-2.example.com", "hg"));
allNode.add(new Node("10.0.0.3", "5.5.5.3", "10-0-0-3.example.com", "hg"));
PowerMockito.mockStatic(SaltStates.class);
ApplyResponse applyResponse = new ApplyResponse();
List<Map<String, Object>> result = new ArrayList<>();
Map<String, Object> nodes = new HashMap<>();
nodes.put("10-0-0-1.example.com", "something");
nodes.put("10-0-0-2.example.com", "something");
result.add(nodes);
applyResponse.setResult(result);
PowerMockito.when(SaltStates.syncGrains(any())).thenReturn(applyResponse);
SyncGrainsRunner syncGrainsRunner = new SyncGrainsRunner(targets, allNode);
SaltConnector saltConnector = Mockito.mock(SaltConnector.class);
String missingIps = syncGrainsRunner.submit(saltConnector);
assertThat(syncGrainsRunner.getTarget(), hasItems("10.0.0.3"));
assertEquals("[10.0.0.3]", missingIps);
}
use of com.sequenceiq.cloudbreak.orchestrator.salt.domain.ApplyResponse in project cloudbreak by hortonworks.
the class MineUpdateRunner method submit.
@Override
public String submit(SaltConnector saltConnector) {
ApplyResponse grainsResult = SaltStates.updateMine(saltConnector);
Set<String> strings = collectMissingNodes(collectNodes(grainsResult));
setTarget(strings);
return strings.toString();
}
Aggregations