+ public void updateTopologyWithNep(Uuid topoUuid, Uuid nodeUuid, Uuid nepUuid, OwnedNodeEdgePoint onep) {
+ // TODO: verify this is correct. Should we identify the context IID with the context UUID??
+ InstanceIdentifier<OwnedNodeEdgePoint> onepIID = InstanceIdentifier.builder(Context.class)
+ .augmentation(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.Context1.class)
+ .child(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.context.TopologyContext.class)
+ .child(Topology.class, new TopologyKey(topoUuid))
+ .child(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node.class,
+ new NodeKey(nodeUuid))
+ .child(OwnedNodeEdgePoint.class, new OwnedNodeEdgePointKey(nepUuid))
+ .build();
+ try {
+ Optional<OwnedNodeEdgePoint> optionalOnep = this.networkTransactionService.read(
+ LogicalDatastoreType.OPERATIONAL, onepIID).get();
+ if (optionalOnep.isPresent()) {
+ LOG.error("ONEP is already present in datastore");
+ return;
+ }
+ // merge in datastore
+ this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, onepIID,
+ onep);
+ this.networkTransactionService.commit().get();
+ LOG.info("NEP {} added successfully.", onep.getName().toString());
+ } catch (InterruptedException | ExecutionException e) {
+ LOG.error("Couldnt put NEP {} in topology, error = ", onep.getName().toString(), e);
+ }
+ }
+
+ public Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
+ .connectivity.context.ConnectionKey,
+ org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121
+ .connectivity.context.Connection> getConnectionFullMap() {
+ return this.connectionFullMap;
+ }
+
+ public ServiceCreateInput createORServiceInput(CreateConnectivityServiceInput input, Uuid serviceUuid) {
+ // TODO: not taking into account all the constraints. Only using EndPoints and Connectivity Constraint.
+ Map<org.opendaylight.yang.gen.v1.urn
+ .onf.otcc.yang.tapi.connectivity.rev221121.create.connectivity.service.input.EndPointKey,
+ org.opendaylight.yang.gen.v1.urn
+ .onf.otcc.yang.tapi.connectivity.rev221121.create.connectivity.service.input.EndPoint>
+ endPointMap = input.getEndPoint();
+ ConnectionType connType = null;
+ ServiceFormat serviceFormat = null;
+ String nodeAid = String.join("+", endPointMap.values().stream().findFirst().orElseThrow().getLocalId(),
+ TapiStringConstants.XPDR);
+ String nodeZid = String.join("+", endPointMap.values().stream().skip(1).findFirst().orElseThrow().getLocalId(),
+ TapiStringConstants.XPDR);
+ LOG.info("NodeAid = {}", nodeAid);
+ LOG.info("NodeZid = {}", nodeZid);
+ //switch (constraint.getServiceLayer().getIntValue()) {
+ switch (input.getLayerProtocolName().getIntValue()) {
+ case 0:
+ LOG.info("ODU");
+ connType = ConnectionType.Infrastructure;
+ serviceFormat = ServiceFormat.ODU;
+ break;
+ case 1:
+ LOG.info("ETH, no need to create OTU and ODU");
+ connType = ConnectionType.Service;
+ serviceFormat = ServiceFormat.Ethernet;
+ break;
+ case 2:
+ LOG.info("DSR, need to create OTU and ODU");
+ connType = ConnectionType.Service;
+ serviceFormat = ServiceFormat.Ethernet;
+ break;
+ case 3:
+ LOG.info("PHOTONIC");
+ connType = getConnectionTypePhtnc(endPointMap.values());
+ serviceFormat = getServiceFormatPhtnc(endPointMap.values());
+ LOG.debug("Node a photonic = {}", nodeAid);
+ LOG.debug("Node z photonic = {}", nodeZid);
+ break;
+ default:
+ LOG.info("Service type {} not supported", input.getLayerProtocolName().getName());
+ }
+ // Requested Capacity for connectivity service
+ Uint64 capacity = Uint64.valueOf(Math.abs(
+ input.getConnectivityConstraint().getRequestedCapacity().getTotalSize().getValue().intValue()));
+ // map endpoints into service end points. Map the type of service from TAPI to OR
+ ServiceAEnd serviceAEnd = tapiEndPointToServiceAPoint(endPointMap.values().stream().findFirst().orElseThrow(),
+ serviceFormat, nodeAid, capacity, input.getLayerProtocolName());
+ ServiceZEnd serviceZEnd = tapiEndPointToServiceZPoint(endPointMap.values().stream().skip(1).findFirst()
+ .orElseThrow(), serviceFormat, nodeZid, capacity, input.getLayerProtocolName());
+ if (serviceAEnd == null || serviceZEnd == null) {
+ LOG.error("Couldnt map endpoints to service end");
+ return null;
+ }
+ LOG.info("Service a end = {}", serviceAEnd);
+ LOG.info("Service z end = {}", serviceZEnd);
+ return new ServiceCreateInputBuilder()
+ .setServiceAEnd(serviceAEnd)
+ .setServiceZEnd(serviceZEnd)
+ .setConnectionType(connType)
+ .setServiceName(serviceUuid.getValue())
+ .setCommonId("common id")
+ .setSdncRequestHeader(new SdncRequestHeaderBuilder().setRequestId("request-1")
+ .setRpcAction(RpcActions.ServiceCreate).setNotificationUrl("notification url")
+ .setRequestSystemId("appname")
+ .build())
+ .setCustomer("customer")
+ .setDueDate(DateAndTime.getDefaultInstance("2018-06-15T00:00:01Z"))
+ .setOperatorContact("pw1234")
+ .build();
+ }
+
+ private static ServiceAEnd getServiceAEnd(GenericServiceEndpoint sepA, GenericServiceEndpoint sepZ) {
+ if (sepA.getType().equals(ServiceEndpointType.SERVICEAEND)) {
+ return new ServiceAEndBuilder(sepA.getValue()).build();
+ }
+ if (sepZ.getType().equals(ServiceEndpointType.SERVICEAEND)) {
+ return new ServiceAEndBuilder(sepZ.getValue()).build();
+ }
+ return null;
+ }
+
+ private static ServiceZEnd getServiceZEnd(GenericServiceEndpoint sepA, GenericServiceEndpoint sepZ) {
+ if (sepA.getType().equals(ServiceEndpointType.SERVICEZEND)) {
+ return new ServiceZEndBuilder(sepA.getValue()).build();
+ }
+ if (sepZ.getType().equals(ServiceEndpointType.SERVICEZEND)) {
+ return new ServiceZEndBuilder(sepZ.getValue()).build();
+ }
+ return null;
+ }
+
+ private LayerProtocolName mapServiceLayerToAend(
+ org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service.ServiceAEnd
+ serviceAEnd) {
+ ServiceFormat serviceFormat = serviceAEnd.getServiceFormat();
+ switch (serviceFormat) {
+ case OC:
+ case OTU:
+ return LayerProtocolName.PHOTONICMEDIA;
+ case ODU:
+ return LayerProtocolName.ODU;
+ case Ethernet:
+ if (getOpenroadmType(serviceAEnd.getTxDirection().values().stream().findFirst().orElseThrow().getPort()
+ .getPortDeviceName()).equals(OpenroadmNodeType.TPDR)) {
+ return LayerProtocolName.ETH;
+ }
+ return LayerProtocolName.DSR;
+ default:
+ LOG.info("Service layer mapping not supported for {}", serviceFormat.getName());
+ }
+ return null;
+ }
+
+ private LayerProtocolName mapServiceLayer(ServiceFormat serviceFormat, EndPoint endPoint1, EndPoint endPoint2) {
+ switch (serviceFormat) {
+ case OC:
+ case OTU:
+ return LayerProtocolName.PHOTONICMEDIA;
+ case ODU:
+ return LayerProtocolName.ODU;
+ case Ethernet:
+ String node1 = endPoint1.getLocalId();
+ String node2 = endPoint2.getLocalId();
+ if (getOpenroadmType(node1).equals(OpenroadmNodeType.TPDR)
+ && getOpenroadmType(node2).equals(OpenroadmNodeType.TPDR)) {
+ return LayerProtocolName.ETH;
+ }
+ return LayerProtocolName.DSR;
+ default:
+ LOG.info("Service layer mapping not supported for {}", serviceFormat.getName());
+ }
+ return null;
+ }
+
+ private OpenroadmNodeType getOpenroadmType(String nodeName) {
+ LOG.info("Node name = {}", nodeName);
+ Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+",nodeName, TapiStringConstants.XPDR))
+ .getBytes(StandardCharsets.UTF_8)).toString());
+ org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node tapiNode
+ = this.tapiContext.getTapiNode(this.tapiTopoUuid, nodeUuid);
+ if (tapiNode != null) {
+ return OpenroadmNodeType.forName(tapiNode.getName().get(new NameKey("Node Type"))
+ .getValue());
+ }
+ return null;
+ }
+
+ private Map<ConnectionKey, Connection> createXpdrCepsAndConnectionsEth(List<String> xpdrClientTplist,
+ List<String> xpdrNodelist,
+ Map<ConnectionKey, Connection> lowerConn) {
+ // TODO: do we need to create cross connection between iODU and eODU??
+ // add the lower connections of the previous steps for this kind of service
+ Map<LowerConnectionKey, LowerConnection> xcMap = new HashMap<>();
+ for (Connection lowConn: lowerConn.values()) {
+ LowerConnection conn = new LowerConnectionBuilder().setConnectionUuid(lowConn.getConnectionUuid()).build();
+ xcMap.put(conn.key(), conn);
+ }
+ Map<ConnectionKey, Connection> connServMap = new HashMap<>();
+ Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.cep.list.ConnectionEndPointKey,
+ ConnectionEndPoint> cepMapDsr = new HashMap<>();
+ // Create 1 cep per Xpdr in the CLIENT
+ // 1 top connection DSR between the CLIENT xpdrs
+ for (String xpdr:xpdrNodelist) {
+ LOG.info("Creating ceps and xc for xpdr {}", xpdr);
+ String spcXpdrClient = xpdrClientTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst()
+ .orElseThrow();
+ ConnectionEndPoint netCep1 = createCepXpdr(spcXpdrClient, TapiStringConstants.DSR, TapiStringConstants.XPDR,
+ LayerProtocolName.DSR);
+ putXpdrCepInTopologyContext(xpdr, spcXpdrClient, TapiStringConstants.DSR,
+ TapiStringConstants.XPDR, netCep1);
+
+ cepMapDsr.put(netCep1.key(), netCep1);
+ }
+ String spcXpdr1 = xpdrClientTplist.stream().filter(adp -> adp.contains(xpdrNodelist
+ .get(0))).findFirst().orElseThrow();
+ String spcXpdr2 = xpdrClientTplist.stream().filter(adp -> adp.contains(xpdrNodelist
+ .get(xpdrNodelist.size() - 1))).findFirst().orElseThrow();
+
+ // DSR top connection between edge xpdr CLIENT DSR
+ org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection
+ connectionDsr = createTopConnection(spcXpdr1, spcXpdr2, cepMapDsr, TapiStringConstants.DSR,
+ LayerProtocolName.DSR, xcMap, this.topConnXpdrXpdrPhtn);
+ this.connectionFullMap.put(connectionDsr.key(), connectionDsr);
+
+ // DSR top connection that will be added to the service object
+ Connection conn1 = new ConnectionBuilder().setConnectionUuid(connectionDsr.getUuid()).build();
+ connServMap.put(conn1.key(), conn1);
+
+ return connServMap;
+ }
+