use of org.openkilda.topology.model.Topology in project open-kilda by telstra.
the class TopologyServiceImplTest method clear.
@Test
public void clear() throws Exception {
Topology topology = topologyService.clear(DEFAULT_CORRELATION_ID);
assertEquals(new Topology(new ArrayList<>()), topology);
System.out.println(topology.toString());
}
use of org.openkilda.topology.model.Topology in project open-kilda by telstra.
the class TopologyServiceImplTest method network.
@Test
public void network() throws Exception {
List<Node> nodes = Arrays.asList(new Node(srcSwitchId, Collections.singletonList(firstTransitSwitchId)), new Node(firstTransitSwitchId, Arrays.asList(srcSwitchId, secondTransitSwitchId)), new Node(secondTransitSwitchId, Arrays.asList(firstTransitSwitchId, dstSwitchId)), new Node(dstSwitchId, Collections.singletonList(secondTransitSwitchId)));
Topology topology = topologyService.network(DEFAULT_CORRELATION_ID);
assertEquals(new Topology(nodes), topology);
System.out.println(topology.toString());
}
use of org.openkilda.topology.model.Topology in project open-kilda by telstra.
the class TopologyController method network.
/**
* Dumps topology.
*
* @param correlationId correlation ID header value
* @return network topology
*/
@RequestMapping(value = "/network", method = RequestMethod.GET, produces = APPLICATION_JSON_UTF8_VALUE)
public ResponseEntity<Topology> network(@RequestHeader(value = CORRELATION_ID, defaultValue = DEFAULT_CORRELATION_ID) String correlationId) {
logger.debug("Get topology: {}={}", CORRELATION_ID, correlationId);
Topology topology = topologyService.network(correlationId);
return new ResponseEntity<>(topology, new HttpHeaders(), HttpStatus.OK);
}
use of org.openkilda.topology.model.Topology in project open-kilda by telstra.
the class TopologyController method clear.
/**
* Cleans topology.
*
* @param correlationId correlation ID header value
* @return network topology
*/
@RequestMapping(value = "/clear", method = RequestMethod.GET, produces = APPLICATION_JSON_UTF8_VALUE)
public ResponseEntity<Topology> clear(@RequestHeader(value = CORRELATION_ID, defaultValue = DEFAULT_CORRELATION_ID) String correlationId) {
logger.debug("Clear topology: {}={}", CORRELATION_ID, correlationId);
Topology topology = topologyService.clear(correlationId);
return new ResponseEntity<>(topology, new HttpHeaders(), HttpStatus.OK);
}
use of org.openkilda.topology.model.Topology 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);
}
Aggregations