use of com.sequenceiq.cloudbreak.orchestrator.salt.domain.NetworkInterfaceResponse in project cloudbreak by hortonworks.
the class SaltApiRunPostResponse method networkInterfaceIp.
protected Object networkInterfaceIp() throws JsonProcessingException {
NetworkInterfaceResponse networkInterfaceResponse = new NetworkInterfaceResponse();
List<Map<String, String>> result = new ArrayList<>();
for (Entry<String, CloudVmMetaDataStatus> stringCloudVmMetaDataStatusEntry : instanceMap.entrySet()) {
CloudVmMetaDataStatus cloudVmMetaDataStatus = stringCloudVmMetaDataStatusEntry.getValue();
if (InstanceStatus.STARTED == cloudVmMetaDataStatus.getCloudVmInstanceStatus().getStatus()) {
String privateIp = cloudVmMetaDataStatus.getMetaData().getPrivateIp();
Map<String, String> networkHashMap = new HashMap<>();
networkHashMap.put("host-" + privateIp.replace(".", "-"), privateIp);
result.add(networkHashMap);
}
}
networkInterfaceResponse.setResult(result);
return objectMapper.writeValueAsString(networkInterfaceResponse);
}
use of com.sequenceiq.cloudbreak.orchestrator.salt.domain.NetworkInterfaceResponse in project cloudbreak by hortonworks.
the class SaltBootstrapTest method setUp.
@Before
public void setUp() {
saltConnector = mock(SaltConnector.class);
gatewayConfig = new GatewayConfig("1.1.1.1", "10.0.0.1", "172.16.252.43", "10-0-0-1.example.com", 9443, "serverCert", "clientCert", "clientKey", "saltpasswd", "saltbootpassword", "signkey", false, true, null, null);
GenericResponse response = new GenericResponse();
response.setStatusCode(HttpStatus.OK.value());
GenericResponses genericResponses = new GenericResponses();
genericResponses.setResponses(Collections.singletonList(response));
when(saltConnector.action(Mockito.any(SaltAction.class))).thenReturn(genericResponses);
when(saltConnector.run(Mockito.any(), Mockito.eq("network.default_route"), Mockito.any(), Mockito.any())).thenReturn(new DefaultRouteResponse(Collections.emptyList()));
NetworkInterfaceResponse networkInterfaceResponse = new NetworkInterfaceResponse();
List<Map<String, String>> networkResultList = new ArrayList<>();
networkMap = new HashMap<>();
networkMap.put("host-10-0-0-1.example.com", "10.0.0.1");
networkMap.put("host-10-0-0-2.example.com", "10.0.0.2");
networkMap.put("host-10-0-0-3.example.com", "10.0.0.3");
networkResultList.add(networkMap);
networkInterfaceResponse.setResult(networkResultList);
when(saltConnector.run(Mockito.any(), Mockito.eq("network.interface_ip"), Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(networkInterfaceResponse);
}
Aggregations