use of org.onosproject.yang.gen.v1.tapiconnectivity.rev20181210.tapiconnectivity.context.DefaultAugmentedTapiCommonContext 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.yang.gen.v1.tapiconnectivity.rev20181210.tapiconnectivity.context.DefaultAugmentedTapiCommonContext in project onos by opennetworkinglab.
the class TapiConnectivityContextHandler method getParentModelObjectId.
@Override
public ModelObjectId getParentModelObjectId() {
DefaultAugmentedTapiCommonContext context = new DefaultAugmentedTapiCommonContext();
context.connectivityContext(obj);
return ModelObjectId.builder().addChild(DefaultContext.class).build();
}
use of org.onosproject.yang.gen.v1.tapiconnectivity.rev20181210.tapiconnectivity.context.DefaultAugmentedTapiCommonContext in project onos by opennetworkinglab.
the class DcsBasedTapiDataProducerTest method makeTestData.
private void makeTestData() {
did1 = DeviceId.deviceId("netconf:127.0.0.1:11001");
did2 = DeviceId.deviceId("netconf:127.0.0.1:11002");
cp11 = new ConnectPoint(did1, PortNumber.portNumber(1, "TRANSCEIVER"));
cp12 = new ConnectPoint(did1, PortNumber.portNumber(2, "TRANSCEIVER"));
cp21 = new ConnectPoint(did2, PortNumber.portNumber(1, "TRANSCEIVER"));
cp22 = new ConnectPoint(did2, PortNumber.portNumber(2, "TRANSCEIVER"));
context = new DefaultContext();
topology = TapiTopologyHandler.create().getModelObject();
DefaultTopologyContext topologyContext = TapiTopologyContextHandler.create().getModelObject();
DefaultAugmentedTapiCommonContext augmentedTopologyContext = new DefaultAugmentedTapiCommonContext();
Augmentable augmentableContext = context;
augmentableContext.addAugmentation(augmentedTopologyContext);
augmentedTopologyContext.topologyContext(topologyContext);
topologyContext.addToTopology(topology);
node1 = TapiNodeHandler.create().setTopologyUuid(topology.uuid()).setDeviceId(did1).getModelObject();
node2 = TapiNodeHandler.create().setTopologyUuid(topology.uuid()).setDeviceId(did2).getModelObject();
sip11 = TapiSipHandler.create().setConnectPoint(cp11).getModelObject();
sip21 = TapiSipHandler.create().setConnectPoint(cp21).getModelObject();
nep11 = TapiNepHandler.create().setTopologyUuid(topology.uuid()).setNodeUuid(node1.uuid()).setConnectPoint(cp11).addSip(sip11.uuid()).getModelObject();
nep12 = TapiNepHandler.create().setTopologyUuid(topology.uuid()).setNodeUuid(node1.uuid()).setConnectPoint(cp12).getModelObject();
nep21 = TapiNepHandler.create().setTopologyUuid(topology.uuid()).setNodeUuid(node2.uuid()).setConnectPoint(cp21).addSip(sip21.uuid()).getModelObject();
nep22 = TapiNepHandler.create().setTopologyUuid(topology.uuid()).setNodeUuid(node2.uuid()).setConnectPoint(cp22).getModelObject();
}
use of org.onosproject.yang.gen.v1.tapiconnectivity.rev20181210.tapiconnectivity.context.DefaultAugmentedTapiCommonContext in project onos by opennetworkinglab.
the class DcsBasedTapiDataProducer method getNeps.
/**
* Extract Tapi Neps from context modelObject and convert them to NepRefs.
*
* @param context
* @return List of TapiNepRef
*/
private List<TapiNepRef> getNeps(DefaultContext context) {
DefaultAugmentedTapiCommonContext topologyContext = context.augmentation(DefaultAugmentedTapiCommonContext.class);
Topology topology = topologyContext.topologyContext().topology().get(0);
if (topology.node() == null) {
return Collections.emptyList();
}
List<TapiNepRef> ret = topology.node().stream().flatMap(node -> {
if (node.ownedNodeEdgePoint() == null) {
return null;
}
return node.ownedNodeEdgePoint().stream().map(nep -> {
TapiNepRef nepRef = DcsBasedTapiObjectRefFactory.create(topology, node, nep);
if (nep.name() != null) {
Map<String, String> kvs = new HashMap<>();
nep.name().forEach(kv -> kvs.put(kv.valueName(), kv.value()));
String onosConnectPoint = kvs.getOrDefault(ONOS_CP, null);
String portType = kvs.getOrDefault(ODTN_PORT_TYPE, null);
String connectionId = kvs.getOrDefault(CONNECTION_ID, null);
nepRef.setConnectPoint(ConnectPoint.fromString(onosConnectPoint)).setPortType(portType).setConnectionId(connectionId);
}
if (nep.mappedServiceInterfacePoint() != null) {
nep.mappedServiceInterfacePoint().stream().forEach(sip -> {
nepRef.setSipId(sip.serviceInterfacePointUuid().toString());
});
}
DefaultAugmentedTapiTopologyOwnedNodeEdgePoint augmentNep = nep.augmentation(DefaultAugmentedTapiTopologyOwnedNodeEdgePoint.class);
try {
if (augmentNep.cepList().connectionEndPoint() != null) {
List<String> cepIds = augmentNep.cepList().connectionEndPoint().stream().map(cep -> cep.uuid().toString()).collect(Collectors.toList());
nepRef.setCepIds(cepIds);
}
} catch (NullPointerException e) {
log.warn("Augmented ownedNodeEdgePoint is not found.");
}
return nepRef;
});
}).collect(Collectors.toList());
return ret;
}
use of org.onosproject.yang.gen.v1.tapiconnectivity.rev20181210.tapiconnectivity.context.DefaultAugmentedTapiCommonContext in project onos by opennetworkinglab.
the class TapiTopologyContextHandler method getParentModelObjectId.
@Override
public ModelObjectId getParentModelObjectId() {
DefaultAugmentedTapiCommonContext context = new DefaultAugmentedTapiCommonContext();
context.topologyContext(obj);
return ModelObjectId.builder().addChild(DefaultContext.class).build();
}
Aggregations