use of org.onosproject.odtn.utils.tapi.TapiNepRef in project onos by opennetworkinglab.
the class DcsBasedTapiConnectivityRpc method createConnectivityService.
/**
* Service interface of createConnectivityService.
*
* @param inputVar input of service interface createConnectivityService
* @return output of service interface createConnectivityService
*/
@Override
public RpcOutput createConnectivityService(RpcInput inputVar) {
try {
TapiCreateConnectivityInputHandler input = new TapiCreateConnectivityInputHandler();
input.setRpcInput(inputVar);
log.info("input SIPs: {}", input.getSips());
// check SIP validation
if (!disjoint(getUsedSips(), input.getSips())) {
log.error("SIPS {} are already used, please use a different pair", input.getSips());
return new RpcOutput(RpcOutput.Status.RPC_FAILURE, null);
}
log.debug("check SIP validation : OK");
List<TapiNepRef> nepRefs = input.getSips().stream().map(sipId -> resolver.getNepRef(sipId)).collect(Collectors.toList());
// setup connections
TapiNepPair neps = TapiNepPair.create(nepRefs.get(0), nepRefs.get(1));
// Allocate a connectivity Service
TapiConnectivityServiceHandler connectivityServiceHandler = TapiConnectivityServiceHandler.create();
// This connectivity service will be supported over a single end-to-end connection
// Allocate a manager for that connection
DcsBasedTapiConnectionManager connectionManager = DcsBasedTapiConnectionManager.create();
TapiConnectionHandler connectionHandler = connectionManager.createConnection(neps);
// Add the supporting connection uuid to the service
connectivityServiceHandler.addConnection(connectionHandler.getModelObject().uuid());
neps.stream().map(nepRef -> TapiSepHandler.create().setSip(nepRef.getSipId())).forEach(sepBuilder -> {
connectivityServiceHandler.addSep(sepBuilder.getModelObject());
});
// build
connectionManager.apply();
connectivityServiceHandler.add();
// output
TapiCreateConnectivityOutputHandler output = TapiCreateConnectivityOutputHandler.create().addService(connectivityServiceHandler.getModelObject());
return new RpcOutput(RpcOutput.Status.RPC_SUCCESS, output.getDataNode());
} catch (Throwable e) {
log.error("Error:", e);
return new RpcOutput(RpcOutput.Status.RPC_FAILURE, null);
}
}
use of org.onosproject.odtn.utils.tapi.TapiNepRef 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.odtn.utils.tapi.TapiNepRef in project onos by opennetworkinglab.
the class DcsBasedTapiTopologyManager method addLink.
@Override
public void addLink(Link link) {
log.debug("Add link: {}", link);
// TODO: existence check
// link
TapiNepRef srcNepRef = tapiResolver.getNepRef(link.src());
TapiNepRef dstNepRef = tapiResolver.getNepRef(link.dst());
TapiLinkHandler.create().setTopologyUuid(topology.uuid()).addNep(srcNepRef).addNep(dstNepRef).add();
}
use of org.onosproject.odtn.utils.tapi.TapiNepRef in project onos by opennetworkinglab.
the class DefaultTapiPathComputer method mockPathCompute.
/**
* Mock to create path computation result.
*
* neps.left connection neps.right
* ■----------------------------------------------------■
* \ /
* \ /
* \ leftLowerConnection / rightLowerConnection
* \ /
* \ /
* ■ ■
* leftLineNep rightLineNep
*/
private TapiConnection mockPathCompute(TapiNepPair neps) {
TapiNepRef leftLineNep = mockGetTransponderLinePort(neps.left());
TapiNepRef rightLineNep = mockGetTransponderLinePort(neps.right());
TapiConnection leftLowerConnection = TapiConnection.create(TapiCepRef.create(neps.left(), neps.left().getCepIds().get(0)), TapiCepRef.create(leftLineNep, leftLineNep.getCepIds().get(0)));
TapiConnection rightLowerConnection = TapiConnection.create(TapiCepRef.create(neps.right(), neps.right().getCepIds().get(0)), TapiCepRef.create(rightLineNep, rightLineNep.getCepIds().get(0)));
TapiConnection connection = TapiConnection.create(TapiCepRef.create(neps.left(), neps.left().getCepIds().get(0)), TapiCepRef.create(neps.right(), neps.right().getCepIds().get(0)));
connection.addLowerConnection(leftLowerConnection).addLowerConnection(rightLowerConnection);
return connection;
}
use of org.onosproject.odtn.utils.tapi.TapiNepRef in project onos by opennetworkinglab.
the class DefaultTapiResolver method getNepRef.
@Override
public TapiNepRef getNepRef(TapiNepRef nepRef) throws NoSuchElementException {
updateCache();
TapiNepRef ret = null;
try {
ret = tapiNepRefList.stream().filter(nepRef::equals).findFirst().get();
} catch (NoSuchElementException e) {
log.error("Nep not found of {}", nepRef);
throw e;
}
return ret;
}
Aggregations