Search in sources :

Example 6 with FloodlightResourceAddress

use of org.openkilda.testing.service.lockkeeper.model.FloodlightResourceAddress 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);
}
Also used : Arrays(java.util.Arrays) LinkDelayModify(org.openkilda.testing.service.lockkeeper.model.LinkDelayModify) Autowired(org.springframework.beans.factory.annotation.Autowired) TrafficControlData(org.openkilda.testing.service.lockkeeper.model.TrafficControlData) SCOPE_PROTOTYPE(org.springframework.beans.factory.config.ConfigurableBeanFactory.SCOPE_PROTOTYPE) FloodlightsHelper(org.openkilda.testing.service.floodlight.FloodlightsHelper) StringUtils(org.apache.commons.lang3.StringUtils) Scope(org.springframework.context.annotation.Scope) Switch(org.openkilda.testing.model.topology.TopologyDefinition.Switch) ContainerName(org.openkilda.testing.service.lockkeeper.model.ContainerName) FloodlightConnectMode(org.openkilda.testing.service.floodlight.model.FloodlightConnectMode) ChangeSwIpRequest(org.openkilda.testing.service.lockkeeper.model.ChangeSwIpRequest) FloodlightResourceAddress(org.openkilda.testing.service.lockkeeper.model.FloodlightResourceAddress) Value(org.springframework.beans.factory.annotation.Value) Pair(org.apache.commons.lang3.tuple.Pair) Service(org.springframework.stereotype.Service) TrafficControlRequest(org.openkilda.testing.service.lockkeeper.model.TrafficControlRequest) Qualifier(org.springframework.beans.factory.annotation.Qualifier) TopologyDefinition(org.openkilda.testing.model.topology.TopologyDefinition) RestTemplate(org.springframework.web.client.RestTemplate) MeterModify(org.openkilda.testing.service.lockkeeper.model.MeterModify) HttpHeaders(org.springframework.http.HttpHeaders) MediaType(org.springframework.http.MediaType) Floodlight(org.openkilda.testing.service.floodlight.model.Floodlight) HttpMethod(org.springframework.http.HttpMethod) SwitchModify(org.openkilda.testing.service.lockkeeper.model.SwitchModify) Profile(org.springframework.context.annotation.Profile) String.format(java.lang.String.format) ASwitchFlow(org.openkilda.testing.service.lockkeeper.model.ASwitchFlow) Collectors.toList(java.util.stream.Collectors.toList) Slf4j(lombok.extern.slf4j.Slf4j) HttpEntity(org.springframework.http.HttpEntity) List(java.util.List) Switch(org.openkilda.testing.model.topology.TopologyDefinition.Switch) Floodlight(org.openkilda.testing.service.floodlight.model.Floodlight) TrafficControlRequest(org.openkilda.testing.service.lockkeeper.model.TrafficControlRequest) FloodlightResourceAddress(org.openkilda.testing.service.lockkeeper.model.FloodlightResourceAddress)

Aggregations

FloodlightResourceAddress (org.openkilda.testing.service.lockkeeper.model.FloodlightResourceAddress)6 Switch (org.openkilda.testing.model.topology.TopologyDefinition.Switch)2 TrafficControlRequest (org.openkilda.testing.service.lockkeeper.model.TrafficControlRequest)2 HttpEntity (org.springframework.http.HttpEntity)2 String.format (java.lang.String.format)1 Arrays (java.util.Arrays)1 List (java.util.List)1 Collectors.toList (java.util.stream.Collectors.toList)1 Slf4j (lombok.extern.slf4j.Slf4j)1 StringUtils (org.apache.commons.lang3.StringUtils)1 Pair (org.apache.commons.lang3.tuple.Pair)1 TopologyDefinition (org.openkilda.testing.model.topology.TopologyDefinition)1 FloodlightsHelper (org.openkilda.testing.service.floodlight.FloodlightsHelper)1 Floodlight (org.openkilda.testing.service.floodlight.model.Floodlight)1 FloodlightConnectMode (org.openkilda.testing.service.floodlight.model.FloodlightConnectMode)1 ASwitchFlow (org.openkilda.testing.service.lockkeeper.model.ASwitchFlow)1 ChangeSwIpRequest (org.openkilda.testing.service.lockkeeper.model.ChangeSwIpRequest)1 ContainerName (org.openkilda.testing.service.lockkeeper.model.ContainerName)1 LinkDelayModify (org.openkilda.testing.service.lockkeeper.model.LinkDelayModify)1 MeterModify (org.openkilda.testing.service.lockkeeper.model.MeterModify)1