use of org.openkilda.testing.service.lockkeeper.model.TrafficControlRequest in project open-kilda by telstra.
the class LockKeeperServiceImpl method shapeSwitchesTraffic.
@Override
public void shapeSwitchesTraffic(List<Switch> switches, TrafficControlData tcData) {
log.debug("Add traffic control rules for switches {}", switches.stream().map(Switch::getDpId).collect(toList()));
switches.stream().flatMap(sw -> toFlResources(sw, sw.getRegions()).stream()).collect(Collectors.groupingBy(FloodlightResourceAddress::getRegion)).entrySet().parallelStream().forEach(resourcesPerRegion -> lockKeepersByRegion.get(resourcesPerRegion.getKey()).exchange("/floodlight/tc", HttpMethod.POST, new HttpEntity<>(new TrafficControlRequest(tcData, resourcesPerRegion.getValue()), buildJsonHeaders()), String.class));
}
use of org.openkilda.testing.service.lockkeeper.model.TrafficControlRequest in project open-kilda by telstra.
the class LockKeeperVirtualImpl method shapeSwitchesTraffic.
@Override
public void shapeSwitchesTraffic(List<Switch> switches, TrafficControlData tcData) {
log.debug("Add traffic control rules for switches {}", switches.stream().map(Switch::getDpId).collect(toList()));
List<FloodlightResourceAddress> swResources = switches.stream().flatMap(sw -> sw.getRegions().stream().map(region -> {
Floodlight fl = flHelper.getFlByRegion(region);
String swAddress = fl.getFloodlightService().getSwitches().stream().filter(s -> sw.getDpId().equals(s.getSwitchId())).findFirst().get().getAddress();
Pair<String, Integer> inetAddress = LockKeeperService.parseAddressPort(swAddress);
return new FloodlightResourceAddress(region, fl.getContainer(), inetAddress.getLeft(), inetAddress.getRight());
})).collect(toList());
restTemplate.exchange(getCurrentLabUrl() + "/lock-keeper/floodlight/tc", HttpMethod.POST, new HttpEntity<>(new TrafficControlRequest(tcData, swResources), buildJsonHeaders()), String.class);
}
Aggregations