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();
}
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));
}
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();
}
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);
}
Aggregations