use of org.onosproject.odtn.utils.tapi.TapiNodeRef 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.odtn.utils.tapi.TapiNodeRef in project onos by opennetworkinglab.
the class DefaultTapiResolver method getNodeRef.
@Override
public TapiNodeRef getNodeRef(ElementId deviceId) throws NoSuchElementException {
updateCache();
TapiNodeRef ret = null;
try {
ret = tapiNodeRefList.stream().filter(node -> node.getDeviceId() != null && node.getDeviceId().equals(deviceId)).findFirst().get();
} catch (NoSuchElementException e) {
log.error("Node not found associated with {}", deviceId);
throw e;
}
return ret;
}
use of org.onosproject.odtn.utils.tapi.TapiNodeRef in project onos by opennetworkinglab.
the class DcsBasedTapiTopologyManager method addPort.
@Override
public void addPort(Port port) {
log.debug("Add port: {}", port);
ConnectPoint cp = new ConnectPoint(port.element().id(), port.number());
if (tapiResolver.hasNepRef(cp)) {
return;
}
TapiNodeRef nodeRef = tapiResolver.getNodeRef(port.element().id());
String nodeId = nodeRef.getNodeId();
// nep
TapiNepHandler nepBuilder = TapiNepHandler.create().setPort(port).setTopologyUuid(topology.uuid()).setNodeUuid(Uuid.fromString(nodeId));
// cep
TapiCepHandler cepBuilder = TapiCepHandler.create().setTopologyUuid(topology.uuid()).setNodeUuid(Uuid.fromString(nodeId)).setNepUuid(nepBuilder.getId()).setParentNep();
nepBuilder.addCep(cepBuilder.getModelObject());
if (TapiSipHandler.isSip(port)) {
TapiSipHandler sipBuilder = TapiSipHandler.create().setPort(port);
nepBuilder.addSip(sipBuilder.getId());
sipBuilder.add();
}
nepBuilder.add();
}
use of org.onosproject.odtn.utils.tapi.TapiNodeRef in project onos by opennetworkinglab.
the class DefaultTapiResolver method getNodeRef.
@Override
public TapiNodeRef getNodeRef(TapiNodeRef nodeRef) throws NoSuchElementException {
updateCache();
TapiNodeRef ret = null;
try {
ret = tapiNodeRefList.stream().filter(nodeRef::equals).findFirst().get();
} catch (NoSuchElementException e) {
log.error("Node not found of {}", nodeRef);
throw e;
}
return ret;
}
Aggregations