Search in sources :

Example 11 with Isl

use of org.openkilda.topology.domain.Isl in project open-kilda by telstra.

the class TopologyServiceImpl method network.

/**
 * {@inheritDoc}
 */
@Override
public Topology network(String correlationId) {
    logger.debug("Dumping topology: {}={}", CORRELATION_ID, correlationId);
    List<Isl> isls = islRepository.getAllIsl();
    logger.debug("Found isls: {}={}, {}", CORRELATION_ID, correlationId, isls);
    Iterable<Switch> switches = switchRepository.findAll();
    List<Node> nodes = new ArrayList<>();
    for (Switch sw : switches) {
        List<String> relationships = new ArrayList<>();
        for (Isl isl : isls) {
            if (isl.getSourceSwitch().equals(sw.getName())) {
                relationships.add(isl.getDestinationSwitch());
            }
        }
        nodes.add(new Node(sw.getName(), relationships));
    }
    return new Topology(nodes);
}
Also used : Isl(org.openkilda.topology.domain.Isl) Switch(org.openkilda.topology.domain.Switch) Node(org.openkilda.topology.model.Node) ArrayList(java.util.ArrayList) Topology(org.openkilda.topology.model.Topology)

Aggregations

Isl (org.openkilda.topology.domain.Isl)11 ArrayList (java.util.ArrayList)7 PathNode (org.openkilda.messaging.info.event.PathNode)7 Test (org.junit.Test)4 IslInfoData (org.openkilda.messaging.info.event.IslInfoData)4 Switch (org.openkilda.topology.domain.Switch)4 MessageException (org.openkilda.messaging.error.MessageException)2 Flow (org.openkilda.topology.domain.Flow)2 HashSet (java.util.HashSet)1 CommandMessage (org.openkilda.messaging.command.CommandMessage)1 Node (org.openkilda.topology.model.Node)1 Topology (org.openkilda.topology.model.Topology)1