use of org.onosproject.net.DeviceId in project onos by opennetworkinglab.
the class ControlMessageEventTest method createControlMessages.
private Set<ControlMessage> createControlMessages() {
final DeviceId deviceId = DeviceId.deviceId("of:0000000000000001");
Set<ControlMessage> controlMessages = Sets.newConcurrentHashSet();
controlMessages.add(createControlMessage(INBOUND_PACKET, deviceId));
controlMessages.add(createControlMessage(OUTBOUND_PACKET, deviceId));
return controlMessages;
}
use of org.onosproject.net.DeviceId in project onos by opennetworkinglab.
the class DefaultControlMessageTest method testBasic.
/**
* Tests creation of a DefaultControlMessage using a regular constructor.
*/
@Test
public void testBasic() {
final DeviceId deviceId = DeviceId.deviceId("of:0000000000000001");
final DefaultControlMessage cm = new DefaultControlMessage(INBOUND_PACKET, deviceId, 0L, 1L, 2L, 3L);
assertThat(cm.type(), is(INBOUND_PACKET));
assertThat(cm.load(), is(0L));
assertThat(cm.rate(), is(1L));
assertThat(cm.count(), is(2L));
assertThat(cm.timestamp(), is(3L));
}
use of org.onosproject.net.DeviceId in project onos by opennetworkinglab.
the class GnpyManager method obtainConnectivity.
@Override
public Pair<IntentId, Double> obtainConnectivity(ConnectPoint ingress, ConnectPoint egress, boolean bidirectional) {
ByteArrayOutputStream connectivityRequest = createGnpyRequest(ingress, egress, bidirectional);
String response = gnpyHttpUtil.post(null, "/gnpy-experimental", new ByteArrayInputStream(connectivityRequest.toByteArray()), MediaType.APPLICATION_JSON_TYPE, String.class);
ObjectMapper om = new ObjectMapper();
final ObjectReader reader = om.reader();
JsonNode jsonNode;
try {
jsonNode = reader.readTree(response);
if (jsonNode == null) {
log.error("JsonNode is null for response {}", response);
return null;
}
log.info("Response {}", response);
String bestPath;
try {
bestPath = getBestOsnrPathKey(jsonNode);
} catch (IllegalStateException e) {
log.error("Exception while contacting GNPy", e);
return null;
}
OchSignal ochSignal = createOchSignal(jsonNode);
Map<DeviceId, Double> deviceAtoBPowerMap = new HashMap<>();
Map<DeviceId, Double> deviceBtoAPowerMap = new HashMap<>();
// TODO this list is currently only populated in the forward direction
List<DeviceId> deviceIds = getDeviceAndPopulatePowerMap(jsonNode, deviceAtoBPowerMap, deviceBtoAPowerMap, bestPath);
Path suggestedPath = createSuggestedPath(deviceIds);
log.info("Suggested path {}", suggestedPath);
Intent intent = createOpticalIntent(ingress, egress, deviceService, null, appId, bidirectional, ochSignal, suggestedPath);
intentsPowerMap.put(intent.id(), new GnpyPowerInfo(deviceAtoBPowerMap, deviceBtoAPowerMap, getLaunchPower(jsonNode), suggestedPath.links(), ingress, egress, ochSignal));
intentService.submit(intent);
return Pair.of(intent.id(), getOsnr(jsonNode, bestPath));
} catch (IOException e) {
log.error("Exception while reading response {}", response, e);
return null;
}
}
use of org.onosproject.net.DeviceId in project onos by opennetworkinglab.
the class DcsBasedTapiDataProducer method getNodes.
/**
* Extract Tapi Nodes from context modelObject and convert them to NodeRefs.
*
* @param context
* @return List of NodeRef
*/
private List<TapiNodeRef> getNodes(DefaultContext context) {
DefaultAugmentedTapiCommonContext topologyContext = context.augmentation(DefaultAugmentedTapiCommonContext.class);
Topology topology = topologyContext.topologyContext().topology().get(0);
if (topology.node() == null) {
return Collections.emptyList();
}
return topology.node().stream().map(node -> {
TapiNodeRef nodeRef = DcsBasedTapiObjectRefFactory.create(topology, node);
if (node.name() != null) {
String deviceId = node.name().stream().filter(kv -> kv.valueName().equals(DEVICE_ID)).findFirst().map(Name::value).get();
nodeRef.setDeviceId(DeviceId.deviceId(deviceId));
}
return nodeRef;
}).collect(Collectors.toList());
}
use of org.onosproject.net.DeviceId in project onos by opennetworkinglab.
the class GnpyManagerTest method testCreateSuggestedPath.
@Test
public void testCreateSuggestedPath() throws IOException {
Map<DeviceId, Double> deviceAtoBPowerMap = new HashMap<>();
Map<DeviceId, Double> deviceBtoAPowerMap = new HashMap<>();
List<DeviceId> deviceIds = manager.getDeviceAndPopulatePowerMap(reply, deviceAtoBPowerMap, deviceBtoAPowerMap, "second");
Path path = manager.createSuggestedPath(deviceIds);
assertTrue(path.links().contains(tx1rdm1Link));
assertTrue(path.links().contains(rmd1ln1Link));
assertTrue(path.links().contains(ln1ln2Link));
assertTrue(path.links().contains(ln2rdm2Link));
assertTrue(path.links().contains(tx2rmd2Link));
assertEquals(path.src(), tx2);
assertEquals(path.dst(), tx1);
}
Aggregations