use of org.openkilda.testing.model.topology.TopologyDefinition.TraffGenConfig in project open-kilda by telstra.
the class TraffExamServiceImpl method initializePools.
@PostConstruct
void initializePools() {
baseUrl = labEndpoint + "/api/" + topology.getLabId() + "/traffgen/";
hostsPool = new ConcurrentHashMap<>();
for (TraffGen traffGen : topology.getActiveTraffGens()) {
URI controlEndpoint;
try {
controlEndpoint = new URI(traffGen.getControlEndpoint());
} catch (URISyntaxException e) {
throw new IllegalArgumentException(String.format("Invalid traffGen(%s) REST endpoint address \"%s\": %s", traffGen.getName(), traffGen.getControlEndpoint(), e.getMessage()), e);
}
UUID id = UUID.randomUUID();
Host host = new Host(id, traffGen.getIfaceName(), controlEndpoint, traffGen.getName());
try {
restTemplate.headForHeaders(makeHostUri(host).path("endpoint").build());
} catch (RestClientException ex) {
throw new IllegalArgumentException(String.format("The traffGen(%s) REST endpoint address \"%s\" can't be reached: %s", traffGen.getName(), traffGen.getControlEndpoint(), ex.getMessage()), ex);
}
hostsPool.put(id, host);
}
TraffGenConfig config = topology.getTraffGenConfig();
Inet4Network network;
try {
network = new Inet4Network((Inet4Address) Inet4Address.getByName(config.getAddressPoolBase()), config.getAddressPoolPrefixLen());
} catch (Inet4ValueException | UnknownHostException e) {
throw new InputMismatchException(String.format("Invalid traffGen address pool \"%s:%s\": %s", config.getAddressPoolBase(), config.getAddressPoolPrefixLen(), e));
}
addressPool = new Inet4NetworkPool(network, 30);
}
Aggregations