X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=tapi%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Ftransportpce%2Ftapi%2Fconnectivity%2FConnectivityUtils.java;h=c9f60f4b3d10ae58b1eff02fcd572d919b8bfba6;hb=db87ba733190c2e59997e00e0fe9199c9c74234d;hp=e1d7d056f0170d56e019bb80ccf66c23cf2c9d94;hpb=2b289d6165a8098b20bc26db15f36dcf5653ec74;p=transportpce.git diff --git a/tapi/src/main/java/org/opendaylight/transportpce/tapi/connectivity/ConnectivityUtils.java b/tapi/src/main/java/org/opendaylight/transportpce/tapi/connectivity/ConnectivityUtils.java index e1d7d056f..c9f60f4b3 100644 --- a/tapi/src/main/java/org/opendaylight/transportpce/tapi/connectivity/ConnectivityUtils.java +++ b/tapi/src/main/java/org/opendaylight/transportpce/tapi/connectivity/ConnectivityUtils.java @@ -7,7 +7,9 @@ */ package org.opendaylight.transportpce.tapi.connectivity; +import java.math.BigDecimal; import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Collection; import java.util.Comparator; @@ -16,121 +18,145 @@ import java.util.List; import java.util.Map; import java.util.Optional; import java.util.UUID; +import java.util.concurrent.ExecutionException; import java.util.stream.Collectors; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; +import org.opendaylight.transportpce.common.network.NetworkTransactionService; import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations; -import org.opendaylight.transportpce.tapi.topology.TopologyUtils; +import org.opendaylight.transportpce.tapi.TapiStringConstants; import org.opendaylight.transportpce.tapi.utils.GenericServiceEndpoint; import org.opendaylight.transportpce.tapi.utils.ServiceEndpointType; import org.opendaylight.transportpce.tapi.utils.TapiContext; -import org.opendaylight.yang.gen.v1.http.org.openroadm.common.equipment.types.rev181130.OpticTypes; -import org.opendaylight.yang.gen.v1.http.org.openroadm.common.node.types.rev181130.NodeIdType; -import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.ConnectionType; -import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.RpcActions; -import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.Service; -import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.sdnc.request.header.SdncRequestHeaderBuilder; -import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.endpoint.RxDirectionBuilder; -import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.endpoint.SubrateEthSlaBuilder; -import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.endpoint.TxDirectionBuilder; -import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.lgx.LgxBuilder; -import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.port.PortBuilder; -import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev181130.ODU4; -import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev181130.OTU4; -import org.opendaylight.yang.gen.v1.http.org.openroadm.service.format.rev190531.ServiceFormat; -import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceCreateInput; -import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceCreateInputBuilder; -import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.create.input.ServiceAEnd; -import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.create.input.ServiceAEndBuilder; -import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.create.input.ServiceZEnd; -import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.create.input.ServiceZEndBuilder; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev201210.PathDescription; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev201210.path.description.atoz.direction.AToZ; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev201210.path.description.atoz.direction.AToZKey; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev201210.path.description.ztoa.direction.ZToA; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev201210.path.description.ztoa.direction.ZToAKey; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev201210.pce.resource.resource.resource.Node; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev201210.pce.resource.resource.resource.TerminationPoint; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220922.Network; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220922.mapping.Mapping; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220922.mapping.MappingKey; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220922.network.Nodes; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220922.network.NodesKey; +import org.opendaylight.yang.gen.v1.http.org.openroadm.common.equipment.types.rev191129.OpticTypes; +import org.opendaylight.yang.gen.v1.http.org.openroadm.common.node.types.rev210528.NodeIdType; +import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.ConnectionType; +import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.RpcActions; +import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.Service; +import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.ethernet.subrate.attributes.grp.EthernetAttributesBuilder; +import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.sdnc.request.header.SdncRequestHeaderBuilder; +import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service.endpoint.RxDirectionBuilder; +import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service.endpoint.RxDirectionKey; +import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service.endpoint.TxDirectionBuilder; +import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service.endpoint.TxDirectionKey; +import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service.lgx.LgxBuilder; +import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service.port.PortBuilder; +import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.subrate.eth.sla.SubrateEthSlaBuilder; +import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev230526.OpenroadmNodeType; +import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev210924.ODU4; +import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev210924.OTU4; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.format.rev191129.ServiceFormat; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceCreateInput; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceCreateInputBuilder; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.service.create.input.ServiceAEnd; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.service.create.input.ServiceAEndBuilder; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.service.create.input.ServiceZEnd; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.service.create.input.ServiceZEndBuilder; +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.PathDescription; +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.atoz.direction.AToZ; +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.atoz.direction.AToZKey; +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.ztoa.direction.ZToA; +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.ztoa.direction.ZToAKey; +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.pce.resource.resource.resource.Node; +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.pce.resource.resource.resource.TerminationPoint; import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev171017.service.path.list.ServicePaths; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.AdministrativeState; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.CapacityUnit; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.ForwardingDirection; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.LayerProtocolName; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.LifecycleState; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.OperationalState; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.PortDirection; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.PortRole; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.Uuid; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.capacity.BandwidthProfileBuilder; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.capacity.TotalSizeBuilder; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.Name; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.global._class.NameBuilder; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.tapi.context.ServiceInterfacePoint; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.tapi.context.ServiceInterfacePointKey; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.CreateConnectivityServiceInput; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.ProtectionRole; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.ServiceType; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPoint; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointBuilder; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPointKey; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connection.end.point.ClientNodeEdgePoint; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connection.end.point.ClientNodeEdgePointBuilder; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectivityService; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectivityServiceBuilder; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.service.Connection; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.service.ConnectionBuilder; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.service.ConnectionKey; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.service.EndPoint; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.service.EndPointBuilder; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.service.EndPointKey; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.service.end.point.CapacityBuilder; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.service.end.point.ServiceInterfacePointBuilder; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.create.connectivity.service.input.ConnectivityConstraint; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.OwnedNodeEdgePoint; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.edge.point.MappedServiceInterfacePointKey; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.AdministrativeState; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.CAPACITYUNITGBPS; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.Context; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.Direction; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.ForwardingDirection; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.LayerProtocolName; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.LifecycleState; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.OperationalState; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.PortRole; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.Uuid; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.capacity.TotalSizeBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.global._class.Name; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.global._class.NameBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.global._class.NameKey; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.tapi.context.ServiceInterfacePoint; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.tapi.context.ServiceInterfacePointKey; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.CreateConnectivityServiceInput; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.ProtectionRole; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.ServiceType; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.cep.list.ConnectionEndPoint; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.cep.list.ConnectionEndPointBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connection.ConnectionEndPointKey; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connection.LowerConnection; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connection.LowerConnectionBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connection.LowerConnectionKey; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connection.end.point.ClientNodeEdgePoint; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connection.end.point.ClientNodeEdgePointBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connection.end.point.ParentNodeEdgePoint; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connection.end.point.ParentNodeEdgePointBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.ConnectivityService; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.ConnectivityServiceBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.service.Connection; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.service.ConnectionBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.service.ConnectionKey; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.service.ConnectivityConstraint; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.service.ConnectivityConstraintBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.service.EndPoint; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.service.EndPointBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.service.EndPointKey; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.service.end.point.CapacityBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.service.end.point.ServiceInterfacePointBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.PHOTONICLAYERQUALIFIERMC; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.PHOTONICLAYERQUALIFIEROTSiMC; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.context.TopologyContext; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.OwnedNodeEdgePoint; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.OwnedNodeEdgePointBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.OwnedNodeEdgePointKey; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.edge.point.MappedServiceInterfacePointKey; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.edge.point.SupportedCepLayerProtocolQualifierInstances; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.edge.point.SupportedCepLayerProtocolQualifierInstancesBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.NodeKey; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.context.Topology; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.context.TopologyKey; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.opendaylight.yangtools.yang.common.Decimal64; import org.opendaylight.yangtools.yang.common.Uint16; import org.opendaylight.yangtools.yang.common.Uint32; import org.opendaylight.yangtools.yang.common.Uint64; +import org.opendaylight.yangtools.yang.common.Uint8; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public final class ConnectivityUtils { - private static final String LGX_PORT_NAME = "Some lgx-port-name"; - private static final String PORT_TYPE = "some port type"; - private static final String LGX_DEVICE_NAME = "Some lgx-device-name"; - private static final String PORT_RACK_VALUE = "000000.00"; - private static final String DSR = "DSR"; - private static final String ODU = "ODU"; - private static final String E_ODU = "eODU"; - private static final String I_ODU = "iODU"; - private static final String OTSI = "OTSi"; - private static final String E_OTSI = "eOTSi"; - private static final String I_OTSI = "iOTSi"; - private static final String PHTNC_MEDIA = "PHOTONIC_MEDIA"; - private static final String MC = "MEDIA_CHANNEL"; - private static final String OTSI_MC = "OTSi_MEDIA_CHANNEL"; - private static final String TP = "TerminationPoint"; - private static final String NODE = "Node"; - private final Uuid tapiTopoUuid = new Uuid(UUID.nameUUIDFromBytes(TopologyUtils.T0_FULL_MULTILAYER - .getBytes(Charset.forName("UTF-8"))).toString()); + private final Uuid tapiTopoUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER + .getBytes(StandardCharsets.UTF_8)).toString()); private static final Logger LOG = LoggerFactory.getLogger(ConnectivityUtils.class); private final ServiceDataStoreOperations serviceDataStoreOperations; private final TapiContext tapiContext; private Map sipMap; - private final Map + private final 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> connectionFullMap; // this variable is for complete connection objects - private Map> networkMap = new HashMap<>(); + private final NetworkTransactionService networkTransactionService; + private Connection topConnRdmRdm; + private Connection topConnXpdrXpdrPhtn; + private Connection topConnXpdrXpdrOdu; // TODO -> handle cases for which node id is ROADM-A1 and not ROADMA01 or XPDR-A1 and not XPDRA01 public ConnectivityUtils(ServiceDataStoreOperations serviceDataStoreOperations, - Map sipMap, TapiContext tapiContext) { + Map sipMap, TapiContext tapiContext, + NetworkTransactionService networkTransactionService) { this.serviceDataStoreOperations = serviceDataStoreOperations; this.tapiContext = tapiContext; this.sipMap = sipMap; this.connectionFullMap = new HashMap<>(); + this.networkTransactionService = networkTransactionService; + this.topConnRdmRdm = null; + this.topConnXpdrXpdrPhtn = null; + this.topConnXpdrXpdrOdu = null; } public static ServiceCreateInput buildServiceCreateInput(GenericServiceEndpoint sepA, GenericServiceEndpoint sepZ) { @@ -162,36 +188,36 @@ public final class ConnectivityUtils { .setOpticType(OpticTypes.Gray) .setServiceFormat(ServiceFormat.Ethernet) .setServiceRate(Uint32.valueOf(100)) - .setTxDirection(new TxDirectionBuilder() + .setTxDirection(Map.of(new TxDirectionKey(Uint8.ZERO), new TxDirectionBuilder() .setPort(new PortBuilder() .setPortDeviceName(txPortDeviceName) .setPortName(txPortName) - .setPortRack(PORT_RACK_VALUE) + .setPortRack(TapiStringConstants.PORT_RACK_VALUE) .setPortShelf("00") - .setPortType(PORT_TYPE) + .setPortType(TapiStringConstants.PORT_TYPE) .build()) .setLgx(new LgxBuilder() - .setLgxDeviceName(LGX_DEVICE_NAME) - .setLgxPortName(LGX_PORT_NAME) - .setLgxPortRack(PORT_RACK_VALUE) + .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME) + .setLgxPortName(TapiStringConstants.LGX_PORT_NAME) + .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE) .setLgxPortShelf("00") .build()) - .build()) - .setRxDirection(new RxDirectionBuilder() + .build())) + .setRxDirection(Map.of(new RxDirectionKey(Uint8.ZERO), new RxDirectionBuilder() .setPort(new PortBuilder() .setPortDeviceName(rxPortDeviceName) .setPortName(rxPortName) - .setPortRack(PORT_RACK_VALUE) + .setPortRack(TapiStringConstants.PORT_RACK_VALUE) .setPortShelf("00") - .setPortType(PORT_TYPE) + .setPortType(TapiStringConstants.PORT_TYPE) .build()) .setLgx(new LgxBuilder() - .setLgxDeviceName(LGX_DEVICE_NAME) - .setLgxPortName(LGX_PORT_NAME) - .setLgxPortRack(PORT_RACK_VALUE) + .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME) + .setLgxPortName(TapiStringConstants.LGX_PORT_NAME) + .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE) .setLgxPortShelf("00") .build()) - .build()) + .build())) .build(); } @@ -201,36 +227,36 @@ public final class ConnectivityUtils { .setOpticType(OpticTypes.Gray) .setServiceFormat(ServiceFormat.Ethernet) .setServiceRate(Uint32.valueOf(100)) - .setTxDirection(new TxDirectionBuilder() + .setTxDirection(Map.of(new TxDirectionKey(Uint8.ZERO), new TxDirectionBuilder() .setPort(new PortBuilder() .setPortDeviceName(txPortDeviceName) .setPortName(txPortName) - .setPortRack(PORT_RACK_VALUE) + .setPortRack(TapiStringConstants.PORT_RACK_VALUE) .setPortShelf("00") - .setPortType(PORT_TYPE) + .setPortType(TapiStringConstants.PORT_TYPE) .build()) .setLgx(new LgxBuilder() - .setLgxDeviceName(LGX_DEVICE_NAME) - .setLgxPortName(LGX_PORT_NAME) - .setLgxPortRack(PORT_RACK_VALUE) + .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME) + .setLgxPortName(TapiStringConstants.LGX_PORT_NAME) + .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE) .setLgxPortShelf("00") .build()) - .build()) - .setRxDirection(new RxDirectionBuilder() + .build())) + .setRxDirection(Map.of(new RxDirectionKey(Uint8.ZERO), new RxDirectionBuilder() .setPort(new PortBuilder() .setPortDeviceName(rxPortDeviceName) .setPortName(rxPortName) - .setPortRack(PORT_RACK_VALUE) + .setPortRack(TapiStringConstants.PORT_RACK_VALUE) .setPortShelf("00") - .setPortType(PORT_TYPE) + .setPortType(TapiStringConstants.PORT_TYPE) .build()) .setLgx(new LgxBuilder() - .setLgxDeviceName(LGX_DEVICE_NAME) - .setLgxPortName(LGX_PORT_NAME) - .setLgxPortRack(PORT_RACK_VALUE) + .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME) + .setLgxPortName(TapiStringConstants.LGX_PORT_NAME) + .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE) .setLgxPortShelf("00") .build()) - .build()) + .build())) .build(); } @@ -267,14 +293,14 @@ public final class ConnectivityUtils { LOG.error("No service path found for service {}", service.getServiceName()); return null; } - ServicePaths servicePaths = optServicePaths.get(); + ServicePaths servicePaths = optServicePaths.orElseThrow(); PathDescription pathDescription = servicePaths.getPathDescription(); LOG.info("Path description of service = {}", pathDescription); - org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.ServiceAEnd serviceAEnd + org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service.ServiceAEnd serviceAEnd = service.getServiceAEnd(); // Endpoint creation EndPoint endPoint1 = mapServiceAEndPoint(serviceAEnd, pathDescription); - org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.ServiceZEnd serviceZEnd + org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service.ServiceZEnd serviceZEnd = service.getServiceZEnd(); EndPoint endPoint2 = mapServiceZEndPoint(serviceZEnd, pathDescription); Map endPointMap = new HashMap<>(); @@ -287,23 +313,26 @@ public final class ConnectivityUtils { // Connection creation Map connMap = createConnectionsFromService(serviceAEnd, serviceZEnd, pathDescription); + LOG.debug("connectionMap for service {} = {} ", name.toString(), connMap.toString()); + ConnectivityConstraint conConstr = + new ConnectivityConstraintBuilder().setServiceType(ServiceType.POINTTOPOINTCONNECTIVITY).build(); // TODO: full connectivity service?? With constraints and the rest of fields... return new ConnectivityServiceBuilder() .setAdministrativeState(AdministrativeState.UNLOCKED) .setOperationalState(OperationalState.ENABLED) .setLifecycleState(LifecycleState.INSTALLED) - .setUuid(new Uuid(UUID.nameUUIDFromBytes(service.getServiceName().getBytes(Charset.forName("UTF-8"))) + .setUuid(new Uuid(UUID.nameUUIDFromBytes(service.getServiceName().getBytes(StandardCharsets.UTF_8)) .toString())) - .setServiceLayer(mapServiceLayer(serviceAEnd.getServiceFormat())) - .setServiceType(ServiceType.POINTTOPOINTCONNECTIVITY) - .setConnectivityDirection(ForwardingDirection.BIDIRECTIONAL) + .setLayerProtocolName(mapServiceLayer(serviceAEnd.getServiceFormat(), endPoint1, endPoint2)) + .setConnectivityConstraint(conConstr) + .setDirection(ForwardingDirection.BIDIRECTIONAL) .setName(Map.of(name.key(), name)) .setConnection(connMap) .setEndPoint(endPointMap) .build(); } - private LayerProtocolName mapServiceLayer(ServiceFormat serviceFormat) { + private LayerProtocolName mapServiceLayer(ServiceFormat serviceFormat, EndPoint endPoint1, EndPoint endPoint2) { switch (serviceFormat) { case OC: case OTU: @@ -311,6 +340,12 @@ public final class ConnectivityUtils { 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()); @@ -318,12 +353,25 @@ public final class ConnectivityUtils { 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 createConnectionsFromService( - org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.ServiceAEnd - serviceAEnd, - org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.ServiceZEnd - serviceZEnd, - PathDescription pathDescription) { + org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service.ServiceAEnd + serviceAEnd, + org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service.ServiceZEnd + serviceZEnd, + PathDescription pathDescription) { Map connectionServMap = new HashMap<>(); // build lists with ROADM nodes, XPDR/MUX/SWITCH nodes, ROADM DEG TTPs, ROADM SRG TTPs, XPDR CLIENT TTPs // and XPDR NETWORK TTPs (if any). From the path description. This will help to build the uuid of the CEPs @@ -336,10 +384,10 @@ public final class ConnectivityUtils { List rdmNodelist = new ArrayList<>(); List xpdrNodelist = new ArrayList<>(); for (AToZ elem:pathDescription.getAToZDirection().getAToZ().values().stream() - .sorted(Comparator.comparing(AToZ::getId)).collect(Collectors.toList())) { + .sorted((Comparator.comparing(atoz -> Integer.valueOf(atoz.getId())))).collect(Collectors.toList())) { resourceType = elem.getResource().getResource().implementedInterface().getSimpleName(); switch (resourceType) { - case TP: + case TapiStringConstants.TP: TerminationPoint tp = (TerminationPoint) elem.getResource().getResource(); String tpID = tp.getTpId(); String tpNode; @@ -370,7 +418,7 @@ public final class ConnectivityUtils { } } break; - case NODE: + case TapiStringConstants.NODE: Node node = (Node) elem.getResource().getResource(); String nodeId = node.getNodeId(); if (nodeId.contains("XPDR") || nodeId.contains("SPDR") || nodeId.contains("MXPDR")) { @@ -411,7 +459,12 @@ public final class ConnectivityUtils { // create corresponding CEPs and Connections. Connections should be added to the corresponding context // CEPs must be included in the topology context as an augmentation for each ONEP!! ServiceFormat serviceFormat = serviceAEnd.getServiceFormat(); // should be equal to serviceZEnd - // TODO -> better mechanism to map services??? + // TODO -> Maybe we dont need to create the connections and ceps if the previous service doesnt exist?? + // As mentioned above, for 100GbE service creation there are ROADMs in the path description. + // What are the configurations needed here? No OTU, ODU... what kind of cross connections is needed? + // this needs to be changed + // TODO: OpenROADM getNodeType from the NamesList to verify what needs to be created + OpenroadmNodeType openroadmNodeType = getOpenRoadmNodeType(xpdrNodelist); switch (serviceFormat) { case OC: // Identify number of ROADMs @@ -433,64 +486,166 @@ public final class ConnectivityUtils { // - XC Connection OTSi betwwen iOTSi y eOTSi of xpdr // - Top connection OTSi between network ports of xpdrs in the Photonic media layer -> i_OTSi connectionServMap.putAll(createXpdrCepsAndConnectionsPht(xpdrNetworkTplist, xpdrNodelist)); + this.topConnRdmRdm = null; break; case ODU: - // Check if OC and OTU are created - if (!rdmNodelist.isEmpty()) { - connectionServMap.putAll(createRoadmCepsAndConnections(rdmAddDropTplist, rdmDegTplist, rdmNodelist, - edgeRoadm1, edgeRoadm2)); - connectionServMap.putAll(createXpdrCepsAndConnectionsPht(xpdrNetworkTplist, xpdrNodelist)); - } + // TODO: verify if this is correct // - XC Connection OTSi betwwen iODU and eODU of xpdr // - Top connection in the ODU layer, between xpdr eODU ports (?) - connectionServMap.putAll(createXpdrCepsAndConnectionsOdu(xpdrNetworkTplist, xpdrNodelist)); + if (openroadmNodeType.equals(OpenroadmNodeType.MUXPDR)) { + connectionServMap.putAll(createXpdrCepsAndConnectionsOdu(xpdrNetworkTplist, xpdrNodelist)); + this.topConnXpdrXpdrPhtn = null; + } break; case Ethernet: // Check if OC, OTU and ODU are created - if (!rdmNodelist.isEmpty()) { + if (openroadmNodeType.equals(OpenroadmNodeType.TPDR)) { + LOG.info("WDM ETH service"); connectionServMap.putAll(createRoadmCepsAndConnections(rdmAddDropTplist, rdmDegTplist, rdmNodelist, edgeRoadm1, edgeRoadm2)); connectionServMap.putAll(createXpdrCepsAndConnectionsPht(xpdrNetworkTplist, xpdrNodelist)); - connectionServMap.putAll(createXpdrCepsAndConnectionsOdu(xpdrNetworkTplist, xpdrNodelist)); + this.topConnRdmRdm = null; + xpdrClientTplist = getAssociatedClientsPort(xpdrNetworkTplist); + LOG.info("Associated client ports = {}", xpdrClientTplist); + connectionServMap.putAll(createXpdrCepsAndConnectionsEth(xpdrClientTplist, xpdrNodelist, + connectionServMap)); + this.topConnXpdrXpdrPhtn = null; + } + if (openroadmNodeType.equals(OpenroadmNodeType.SWITCH)) { + // TODO: We create both ODU and DSR because there is no ODU service creation for the switch + // - XC Connection OTSi between iODU and eODU of xpdr + // - Top connection in the ODU layer, between xpdr eODU ports (?) + connectionServMap.putAll(createXpdrCepsAndConnectionsDsr(xpdrClientTplist, xpdrNetworkTplist, + xpdrNodelist)); + this.topConnXpdrXpdrPhtn = null; + } + if (openroadmNodeType.equals(OpenroadmNodeType.MUXPDR)) { + // TODO: OTN service but mux has 3 steps at rendering. Verify that things exist + connectionServMap.putAll(createXpdrCepsAndConnectionsDsr(xpdrClientTplist, xpdrNetworkTplist, + xpdrNodelist)); + this.topConnXpdrXpdrOdu = null; } - // Top connection in the DSR layer, between client ports of the xpdrs - connectionServMap.putAll(createXpdrCepsAndConnectionsDsr(xpdrClientTplist, xpdrNodelist)); break; default: LOG.error("Service type format not supported"); } + LOG.debug("CONNSERVERMAP = {}", connectionServMap.toString()); return connectionServMap; } + private Map createXpdrCepsAndConnectionsEth(List xpdrClientTplist, + List xpdrNodelist, + Map 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 xcMap = new HashMap<>(); + for (Connection lowConn: lowerConn.values()) { + LowerConnection conn = new LowerConnectionBuilder().setConnectionUuid(lowConn.getConnectionUuid()).build(); + xcMap.put(conn.key(), conn); + } + Map connServMap = new HashMap<>(); + Map 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; + } + private Map createXpdrCepsAndConnectionsDsr(List xpdrClientTplist, + List xpdrNetworkTplist, List xpdrNodelist) { Map connServMap = new HashMap<>(); - Map cepMap = new HashMap<>(); - - // Create 1 cep per Xpdr in the CLIENT and a top connection DSR between the CLIENT xpdrs + Map cepMapDsr = new HashMap<>(); + Map cepMapOdu = new HashMap<>(); + // TODO: when upgrading the models to 2.1.3, get the connection inclusion because those connections will + // be added to the lower connection of a top connection + Map xcMap = new HashMap<>(); + + // Create 1 cep per Xpdr in the CLIENT, 1 cep per Xpdr eODU, 1 XC between eODU and iODE, + // 1 top connection between eODU and a 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().get(); - - ConnectionEndPoint netCep1 = createCepXpdr(spcXpdrClient, DSR, DSR, LayerProtocolName.DSR); - putXpdrCepInTopologyContext(xpdr, spcXpdrClient, DSR, DSR, netCep1); + String spcXpdrClient = xpdrClientTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst() + .orElseThrow(); + ConnectionEndPoint clientCep1 = createCepXpdr(spcXpdrClient, TapiStringConstants.DSR, + TapiStringConstants.XPDR, LayerProtocolName.DSR); + putXpdrCepInTopologyContext(xpdr, spcXpdrClient, TapiStringConstants.DSR, TapiStringConstants.XPDR, + clientCep1); + + ConnectionEndPoint clientCep2 = createCepXpdr(spcXpdrClient, TapiStringConstants.E_ODU, + TapiStringConstants.XPDR, LayerProtocolName.ODU); + putXpdrCepInTopologyContext(xpdr, spcXpdrClient, TapiStringConstants.E_ODU, TapiStringConstants.XPDR, + clientCep2); + + String spcXpdrNetwork = getAssociatedNetworkPort(spcXpdrClient, xpdrNetworkTplist); + ConnectionEndPoint netCep3 = getAssociatediODUCep(spcXpdrNetwork); + + cepMapDsr.put(clientCep1.key(), clientCep1); + cepMapOdu.put(clientCep2.key(), clientCep2); + // Create x connection between I_ODU and E_ODU within xpdr + org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection + connection = createXCBetweenCeps(clientCep2, netCep3, spcXpdrClient, spcXpdrNetwork, + TapiStringConstants.ODU, LayerProtocolName.ODU); + this.connectionFullMap.put(connection.key(), connection); - cepMap.put(netCep1.key(), netCep1); + // Create X connection that will be added to the service object + LowerConnection conn = new LowerConnectionBuilder().setConnectionUuid(connection.getUuid()).build(); + xcMap.put(conn.key(), conn); } // DSR top connection between edge xpdr CLIENT DSR String spcXpdr1 = xpdrClientTplist.stream().filter(adp -> adp.contains(xpdrNodelist - .get(0))).findFirst().get(); + .get(0))).findFirst().orElseThrow(); String spcXpdr2 = xpdrClientTplist.stream().filter(adp -> adp.contains(xpdrNodelist - .get(xpdrNodelist.size() - 1))).findFirst().get(); - org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection - connection = createTopConnection(spcXpdr1, spcXpdr2, cepMap, DSR, LayerProtocolName.DSR); - this.connectionFullMap.put(connection.key(), connection); + .get(xpdrNodelist.size() - 1))).findFirst().orElseThrow(); + + org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection + connectionOdu = createTopConnection(spcXpdr1, spcXpdr2, cepMapOdu, TapiStringConstants.E_ODU, + LayerProtocolName.ODU, xcMap, this.topConnXpdrXpdrOdu); + this.connectionFullMap.put(connectionOdu.key(), connectionOdu); // ODU top connection that will be added to the service object - Connection conn = new ConnectionBuilder().setConnectionUuid(connection.getUuid()).build(); + Connection conn = new ConnectionBuilder().setConnectionUuid(connectionOdu.getUuid()).build(); connServMap.put(conn.key(), conn); + LowerConnection lowerConn = new LowerConnectionBuilder().setConnectionUuid(connectionOdu.getUuid()).build(); + xcMap.put(lowerConn.key(), lowerConn); + + 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; } @@ -498,97 +653,93 @@ public final class ConnectivityUtils { private Map createXpdrCepsAndConnectionsOdu(List xpdrNetworkTplist, List xpdrNodelist) { Map connServMap = new HashMap<>(); - Map cepMap = new HashMap<>(); - // Create 1 cep per Xpdr in the I_ODU and E_ODU, X connection between iODU and eODU and a top + // TODO: when upgrading the models to 2.1.3, get the connection inclusion because those connections will + // be added to the lower connection of a top connection + Map xcMap = new HashMap<>(); + + // Create 1 cep per Xpdr in the I_ODU and a top // connection iODU between the xpdrs for (String xpdr:xpdrNodelist) { LOG.info("Creating ceps and xc for xpdr {}", xpdr); - String spcXpdrNetwork = xpdrNetworkTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst().get(); - - ConnectionEndPoint netCep1 = createCepXpdr(spcXpdrNetwork, E_ODU, DSR, LayerProtocolName.ODU); - putXpdrCepInTopologyContext(xpdr, spcXpdrNetwork, E_ODU, DSR, netCep1); - ConnectionEndPoint netCep2 = createCepXpdr(spcXpdrNetwork, I_ODU, DSR, LayerProtocolName.ODU); - putXpdrCepInTopologyContext(xpdr, spcXpdrNetwork, I_ODU, DSR, netCep2); + String spcXpdrNetwork = xpdrNetworkTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst() + .orElseThrow(); + ConnectionEndPoint netCep1 = createCepXpdr(spcXpdrNetwork, TapiStringConstants.I_ODU, + TapiStringConstants.XPDR, LayerProtocolName.ODU); + putXpdrCepInTopologyContext(xpdr, spcXpdrNetwork, TapiStringConstants.I_ODU, TapiStringConstants.XPDR, + netCep1); cepMap.put(netCep1.key(), netCep1); - cepMap.put(netCep2.key(), netCep2); - - // Create x connection between I_ODU and E_ODU within xpdr - org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection - connection = createXCBetweenCeps(netCep1, netCep2, spcXpdrNetwork, spcXpdrNetwork, ODU, - LayerProtocolName.ODU); - this.connectionFullMap.put(connection.key(), connection); - - // Create X connection that will be added to the service object - Connection conn = new ConnectionBuilder().setConnectionUuid(connection.getUuid()).build(); - connServMap.put(conn.key(), conn); } - // ODU top connection between edge xpdr e_ODU + // ODU top connection between edge xpdr i_ODU String spcXpdr1 = xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist - .get(0))).findFirst().get(); + .get(0))).findFirst().orElseThrow(); String spcXpdr2 = xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist - .get(xpdrNodelist.size() - 1))).findFirst().get(); - org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection - connection = createTopConnection(spcXpdr1, spcXpdr2, cepMap, E_ODU, LayerProtocolName.ODU); + .get(xpdrNodelist.size() - 1))).findFirst().orElseThrow(); + org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection + connection = createTopConnection(spcXpdr1, spcXpdr2, cepMap, TapiStringConstants.I_ODU, + LayerProtocolName.ODU, xcMap, this.topConnXpdrXpdrPhtn); this.connectionFullMap.put(connection.key(), connection); // ODU top connection that will be added to the service object Connection conn = new ConnectionBuilder().setConnectionUuid(connection.getUuid()).build(); connServMap.put(conn.key(), conn); + this.topConnXpdrXpdrOdu = conn; return connServMap; } private Map createXpdrCepsAndConnectionsPht(List xpdrNetworkTplist, List xpdrNodelist) { - Map connServMap = new HashMap<>(); - Map cepMap = new HashMap<>(); + // TODO: when upgrading the models to 2.1.3, get the connection inclusion because those connections will + // be added to the lower connection of a top connection + Map cepMap = new HashMap<>(); // create ceps and x connections within xpdr for (String xpdr:xpdrNodelist) { LOG.info("Creating ceps and xc for xpdr {}", xpdr); - String spcXpdrNetwork = xpdrNetworkTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst().get(); + String spcXpdrNetwork = xpdrNetworkTplist.stream().filter(netp -> netp.contains(xpdr)).findFirst() + .orElseThrow(); // There should be 1 network tp per xpdr - // TODO photonic media model should be updated to have the corresponding CEPs. I will just create - // 3 different MC CEPs giving different IDs to show that they are different - // Create 3 CEPs for each xpdr otsi node and the corresponding cross connection matchin the NEPs - ConnectionEndPoint netCep1 = createCepXpdr(spcXpdrNetwork, PHTNC_MEDIA, OTSI, - LayerProtocolName.PHOTONICMEDIA); - putXpdrCepInTopologyContext(xpdr, spcXpdrNetwork, PHTNC_MEDIA, OTSI, netCep1); - ConnectionEndPoint netCep2 = createCepXpdr(spcXpdrNetwork, E_OTSI, OTSI, LayerProtocolName.PHOTONICMEDIA); - putXpdrCepInTopologyContext(xpdr, spcXpdrNetwork, E_OTSI, OTSI, netCep2); - ConnectionEndPoint netCep3 = createCepXpdr(spcXpdrNetwork, I_OTSI, OTSI, LayerProtocolName.PHOTONICMEDIA); - putXpdrCepInTopologyContext(xpdr, spcXpdrNetwork, I_OTSI, OTSI, netCep3); + // Just create 2 different CEPs (1 OTS + 1 OTSI_MC) + ConnectionEndPoint netCep1 = createCepXpdr(spcXpdrNetwork, TapiStringConstants.PHTNC_MEDIA_OTS, + TapiStringConstants.XPDR, LayerProtocolName.PHOTONICMEDIA); + putXpdrCepInTopologyContext(xpdr, spcXpdrNetwork, TapiStringConstants.PHTNC_MEDIA_OTS, + TapiStringConstants.XPDR, netCep1); + ConnectionEndPoint netCep2 = createCepXpdr(spcXpdrNetwork, TapiStringConstants.OTSI_MC, + TapiStringConstants.XPDR, LayerProtocolName.PHOTONICMEDIA); + putXpdrCepInTopologyContext(xpdr, spcXpdrNetwork, TapiStringConstants.OTSI_MC, TapiStringConstants.XPDR, + netCep2); +// ConnectionEndPoint netCep3 = createCepXpdr(spcXpdrNetwork, TapiStringConstants.I_OTSI, +// TapiStringConstants.XPDR, LayerProtocolName.PHOTONICMEDIA); +// putXpdrCepInTopologyContext(xpdr, spcXpdrNetwork, TapiStringConstants.I_OTSI, TapiStringConstants.OTSI, +// netCep3); + cepMap.put(netCep1.key(), netCep1); cepMap.put(netCep2.key(), netCep2); - cepMap.put(netCep3.key(), netCep3); +// cepMap.put(netCep3.key(), netCep3); - // Create x connection between I_OTSi and E_OTSi within xpdr - org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection - connection = createXCBetweenCeps(netCep2, netCep3, spcXpdrNetwork, spcXpdrNetwork, OTSI, - LayerProtocolName.PHOTONICMEDIA); - this.connectionFullMap.put(connection.key(), connection); - - // Create X connection that will be added to the service object - Connection conn = new ConnectionBuilder().setConnectionUuid(connection.getUuid()).build(); - connServMap.put(conn.key(), conn); } - // OTSi top connection between edge I_OTSI Xpdr + + // OTSi top connection between edge OTSI_MC Xpdr + Map xcMap = new HashMap<>(); String spcXpdr1 = xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist - .get(0))).findFirst().get(); + .get(0))).findFirst().orElseThrow(); String spcXpdr2 = xpdrNetworkTplist.stream().filter(adp -> adp.contains(xpdrNodelist - .get(xpdrNodelist.size() - 1))).findFirst().get(); - org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection - connection = createTopConnection(spcXpdr1, spcXpdr2, cepMap, I_OTSI, LayerProtocolName.PHOTONICMEDIA); + .get(xpdrNodelist.size() - 1))).findFirst().orElseThrow(); + org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection + connection = createTopConnection(spcXpdr1, spcXpdr2, cepMap, TapiStringConstants.OTSI_MC, + LayerProtocolName.PHOTONICMEDIA, xcMap, this.topConnRdmRdm); this.connectionFullMap.put(connection.key(), connection); - // OTSi top connection that will be added to the service object + // OTSi top connection that will be added to the service object + Map connServMap = new HashMap<>(); Connection conn = new ConnectionBuilder().setConnectionUuid(connection.getUuid()).build(); connServMap.put(conn.key(), conn); - + this.topConnXpdrXpdrPhtn = conn; return connServMap; } @@ -598,150 +749,204 @@ public final class ConnectivityUtils { List rdmNodelist, String edgeRoadm1, String edgeRoadm2) { // TODO: will need to check if things exist already or not - Map connServMap = new HashMap<>(); - Map cepMap = new HashMap<>(); // create ceps and x connections within roadm + Map xcLowerMap = new HashMap<>(); for (String roadm : rdmNodelist) { LOG.info("Creating ceps and xc for roadm {}", roadm); - String spcRdmAD = rdmAddDropTplist.stream().filter(adp -> adp.contains(roadm)).findFirst().get(); - LOG.info("AD port of ROADm {} = {}", roadm, spcRdmAD); - // There should be only 1 AD and 1 DEG per roadm - // TODO photonic media model should be updated to have the corresponding CEPs. I will just create - // 3 different MC CEPs giving different IDs to show that they are different - // Create 3 CEPs for each AD and DEG and the corresponding cross connections, matching the NEPs - // created in the topology creation - // add CEPs to the topology to the corresponding ONEP - ConnectionEndPoint adCep1 = createCepRoadm(spcRdmAD, PHTNC_MEDIA); - putRdmCepInTopologyContext(roadm, spcRdmAD, PHTNC_MEDIA, adCep1); - ConnectionEndPoint adCep2 = createCepRoadm(spcRdmAD, MC); - putRdmCepInTopologyContext(roadm, spcRdmAD, MC, adCep2); - ConnectionEndPoint adCep3 = createCepRoadm(spcRdmAD, OTSI_MC); - putRdmCepInTopologyContext(roadm, spcRdmAD, OTSI_MC, adCep3); - cepMap.put(adCep1.key(), adCep1); - cepMap.put(adCep2.key(), adCep2); - cepMap.put(adCep3.key(), adCep3); - - String spcRdmDEG = rdmDegTplist.stream().filter(adp -> adp.contains(roadm)).findFirst().get(); - LOG.info("Degree port of ROADm {} = {}", roadm, spcRdmDEG); - - ConnectionEndPoint degCep1 = createCepRoadm(spcRdmDEG, PHTNC_MEDIA); - putRdmCepInTopologyContext(roadm, spcRdmDEG, PHTNC_MEDIA, degCep1); - ConnectionEndPoint degCep2 = createCepRoadm(spcRdmDEG, MC); - putRdmCepInTopologyContext(roadm, spcRdmDEG, MC, degCep2); - ConnectionEndPoint degCep3 = createCepRoadm(spcRdmDEG, OTSI_MC); - putRdmCepInTopologyContext(roadm, spcRdmDEG, OTSI_MC, degCep3); - cepMap.put(degCep1.key(), degCep1); - cepMap.put(degCep2.key(), degCep2); - cepMap.put(degCep3.key(), degCep3); - - LOG.info("Going to create cross connections for ROADM {}", roadm); - // Create X connections between MC and OTSi_MC for full map - org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection - connection1 = createXCBetweenCeps(adCep2, degCep2, spcRdmAD, spcRdmDEG, MC, - LayerProtocolName.PHOTONICMEDIA); - LOG.info("Cross connection 1 created = {}", connection1); - org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection - connection2 = createXCBetweenCeps(adCep3, degCep3, spcRdmAD, spcRdmDEG, OTSI_MC, - LayerProtocolName.PHOTONICMEDIA); - LOG.info("Cross connection 2 created = {}", connection2); - this.connectionFullMap.put(connection1.key(), connection1); - this.connectionFullMap.put(connection2.key(), connection2); - - // Create X connections that will be added to the service object - Connection conn1 = new ConnectionBuilder().setConnectionUuid(connection1.getUuid()).build(); - Connection conn2 = new ConnectionBuilder().setConnectionUuid(connection2.getUuid()).build(); - connServMap.put(conn1.key(), conn1); - connServMap.put(conn2.key(), conn2); - } - LOG.info("Going to create top connections betwee roadms"); - // create top connections between roadms: MC connections between AD MC CEPs of roadms - for (int i = 0; i < rdmNodelist.size(); i++) { - if (rdmNodelist.size() <= (i + 1)) { - LOG.info("Reached last roadm. No more MC connections"); - break; + if (roadm.equals(edgeRoadm1) || roadm.equals(edgeRoadm2)) { + LOG.info("EDGE ROADM, cross connections needed between SRG and DEG"); + String spcRdmAD = rdmAddDropTplist.stream().filter(adp -> adp.contains(roadm)).findFirst() + .orElseThrow(); + LOG.info("AD port of ROADm {} = {}", roadm, spcRdmAD); + // There should be only 1 AD and 1 DEG per roadm + // TODO photonic media model should be updated to have the corresponding CEPs. I will just create + // 3 different MC CEPs giving different IDs to show that they are different + // Create 3 CEPs for each AD and DEG and the corresponding cross connections, matching the NEPs + // created in the topology creation + // add CEPs to the topology to the corresponding ONEP + ConnectionEndPoint adCep1 = createCepRoadm(spcRdmAD, TapiStringConstants.PHTNC_MEDIA_OTS); + putRdmCepInTopologyContext(roadm, spcRdmAD, TapiStringConstants.PHTNC_MEDIA_OTS, adCep1); + ConnectionEndPoint adCep2 = createCepRoadm(spcRdmAD, TapiStringConstants.MC); + putRdmCepInTopologyContext(roadm, spcRdmAD, TapiStringConstants.MC, adCep2); + ConnectionEndPoint adCep3 = createCepRoadm(spcRdmAD, TapiStringConstants.OTSI_MC); + putRdmCepInTopologyContext(roadm, spcRdmAD, TapiStringConstants.OTSI_MC, adCep3); + cepMap.put(adCep1.key(), adCep1); + cepMap.put(adCep2.key(), adCep2); + cepMap.put(adCep3.key(), adCep3); + + String spcRdmDEG = rdmDegTplist.stream().filter(adp -> adp.contains(roadm)).findFirst().orElseThrow(); + LOG.info("Degree port of ROADm {} = {}", roadm, spcRdmDEG); + + ConnectionEndPoint degCep0 = createCepRoadm(spcRdmDEG, TapiStringConstants.PHTNC_MEDIA_OTS); + putRdmCepInTopologyContext(roadm, spcRdmDEG, TapiStringConstants.PHTNC_MEDIA_OTS, degCep0); + ConnectionEndPoint degCep1 = createCepRoadm(spcRdmDEG, TapiStringConstants.PHTNC_MEDIA_OMS); + putRdmCepInTopologyContext(roadm, spcRdmDEG, TapiStringConstants.PHTNC_MEDIA_OMS, degCep1); + ConnectionEndPoint degCep2 = createCepRoadm(spcRdmDEG, TapiStringConstants.MC); + putRdmCepInTopologyContext(roadm, spcRdmDEG, TapiStringConstants.MC, degCep2); + ConnectionEndPoint degCep3 = createCepRoadm(spcRdmDEG, TapiStringConstants.OTSI_MC); + putRdmCepInTopologyContext(roadm, spcRdmDEG, TapiStringConstants.OTSI_MC, degCep3); + cepMap.put(degCep0.key(), degCep0); + cepMap.put(degCep1.key(), degCep1); + cepMap.put(degCep2.key(), degCep2); + cepMap.put(degCep3.key(), degCep3); + + LOG.info("Going to create cross connections for ROADM {}", roadm); + // Create X connections between MC and OTSi_MC for full map + org.opendaylight.yang.gen.v1.urn + .onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection connection1 + = createXCBetweenCeps(adCep2, degCep2, spcRdmAD, spcRdmDEG, TapiStringConstants.MC, + LayerProtocolName.PHOTONICMEDIA); + LOG.info("Cross connection 1 created = {}", connection1.toString()); + org.opendaylight.yang.gen.v1.urn + .onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection connection2 + = createXCBetweenCeps(adCep3, degCep3, spcRdmAD, spcRdmDEG, TapiStringConstants.OTSI_MC, + LayerProtocolName.PHOTONICMEDIA); + LOG.info("Cross connection 2 created = {}", connection2.toString()); + this.connectionFullMap.put(connection1.key(), connection1); + this.connectionFullMap.put(connection2.key(), connection2); + + // Create X connections that will be added to the service object + LowerConnection conn1 = new LowerConnectionBuilder().setConnectionUuid(connection1.getUuid()).build(); + LowerConnection conn2 = new LowerConnectionBuilder().setConnectionUuid(connection2.getUuid()).build(); + + xcLowerMap.put(conn1.key(), conn1); + xcLowerMap.put(conn2.key(), conn2); + } else { + LOG.info("MIDDLE ROADM, cross connections needed between DEG and DEG"); + String spcRdmDEG1 = rdmDegTplist.stream().filter(adp -> adp.contains(roadm)).findFirst().orElseThrow(); + LOG.info("Degree 1 port of ROADm {} = {}", roadm, spcRdmDEG1); + + ConnectionEndPoint deg1Cep0 = createCepRoadm(spcRdmDEG1, TapiStringConstants.PHTNC_MEDIA_OTS); + putRdmCepInTopologyContext(roadm, spcRdmDEG1, TapiStringConstants.PHTNC_MEDIA_OTS, deg1Cep0); + ConnectionEndPoint deg1Cep1 = createCepRoadm(spcRdmDEG1, TapiStringConstants.PHTNC_MEDIA_OMS); + putRdmCepInTopologyContext(roadm, spcRdmDEG1, TapiStringConstants.PHTNC_MEDIA_OMS, deg1Cep1); + ConnectionEndPoint deg1Cep2 = createCepRoadm(spcRdmDEG1, TapiStringConstants.MC); + putRdmCepInTopologyContext(roadm, spcRdmDEG1, TapiStringConstants.MC, deg1Cep2); + ConnectionEndPoint deg1Cep3 = createCepRoadm(spcRdmDEG1, TapiStringConstants.OTSI_MC); + putRdmCepInTopologyContext(roadm, spcRdmDEG1, TapiStringConstants.OTSI_MC, deg1Cep3); + cepMap.put(deg1Cep0.key(), deg1Cep0); + cepMap.put(deg1Cep1.key(), deg1Cep1); + cepMap.put(deg1Cep2.key(), deg1Cep2); + cepMap.put(deg1Cep3.key(), deg1Cep3); + + String spcRdmDEG2 = rdmDegTplist.stream().filter(adp -> adp.contains(roadm)).skip(1).findFirst() + .orElseThrow(); + LOG.info("Degree 2 port of ROADm {} = {}", roadm, spcRdmDEG2); + + ConnectionEndPoint deg2Cep0 = createCepRoadm(spcRdmDEG2, TapiStringConstants.PHTNC_MEDIA_OTS); + putRdmCepInTopologyContext(roadm, spcRdmDEG2, TapiStringConstants.PHTNC_MEDIA_OTS, deg2Cep0); + ConnectionEndPoint deg2Cep1 = createCepRoadm(spcRdmDEG2, TapiStringConstants.PHTNC_MEDIA_OMS); + putRdmCepInTopologyContext(roadm, spcRdmDEG2, TapiStringConstants.PHTNC_MEDIA_OMS, deg2Cep1); + ConnectionEndPoint deg2Cep2 = createCepRoadm(spcRdmDEG2, TapiStringConstants.MC); + putRdmCepInTopologyContext(roadm, spcRdmDEG2, TapiStringConstants.MC, deg2Cep2); + ConnectionEndPoint deg2Cep3 = createCepRoadm(spcRdmDEG2, TapiStringConstants.OTSI_MC); + putRdmCepInTopologyContext(roadm, spcRdmDEG2, TapiStringConstants.OTSI_MC, deg2Cep3); + cepMap.put(deg2Cep0.key(), deg2Cep0); + cepMap.put(deg2Cep1.key(), deg2Cep1); + cepMap.put(deg2Cep2.key(), deg2Cep2); + cepMap.put(deg2Cep3.key(), deg2Cep3); + + LOG.info("Going to create cross connections for ROADM {}", roadm); + // Create X connections between MC and OTSi_MC for full map + org.opendaylight.yang.gen.v1.urn + .onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection connection1 + = createXCBetweenCeps(deg1Cep2, deg2Cep2, spcRdmDEG1, spcRdmDEG2, + TapiStringConstants.MC, LayerProtocolName.PHOTONICMEDIA); + LOG.info("Cross connection 1 created = {}", connection1.toString()); + org.opendaylight.yang.gen.v1.urn + .onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection connection2 + = createXCBetweenCeps(deg1Cep3, deg2Cep3, spcRdmDEG1, spcRdmDEG2, + TapiStringConstants.OTSI_MC, LayerProtocolName.PHOTONICMEDIA); + LOG.info("Cross connection 2 created = {}", connection2.toString()); + this.connectionFullMap.put(connection1.key(), connection1); + this.connectionFullMap.put(connection2.key(), connection2); + + // Create X connections that will be added to the service object + LowerConnection conn1 = new LowerConnectionBuilder().setConnectionUuid(connection1.getUuid()).build(); + LowerConnection conn2 = new LowerConnectionBuilder().setConnectionUuid(connection2.getUuid()).build(); + + xcLowerMap.put(conn1.key(), conn1); + xcLowerMap.put(conn2.key(), conn2); } - // Current roadm with roadm i + 1 --> MC - String roadm1 = rdmNodelist.get(i); - String spcRdmAD1 = rdmAddDropTplist.stream().filter(adp -> adp.contains(roadm1)).findFirst().get(); - String roadm2 = rdmNodelist.get(i + 1); - String spcRdmAD2 = rdmAddDropTplist.stream().filter(adp -> adp.contains(roadm2)).findFirst().get(); - LOG.info("Creating top connection from {} to {} between tps: {}-{}", roadm1, roadm2, spcRdmAD1, spcRdmAD2); - - // Create top connections between MC for full map - org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection - connection = createTopConnection(spcRdmAD1, spcRdmAD2, cepMap, MC, LayerProtocolName.PHOTONICMEDIA); - this.connectionFullMap.put(connection.key(), connection); - LOG.info("Top connection created = {}", connection); - - // Create top connections that will be added to the service object - Connection conn = new ConnectionBuilder().setConnectionUuid(connection.getUuid()).build(); - connServMap.put(conn.key(), conn); } - - // OTSiMC top connection between edge roadms - LOG.info("Going to created top connection between OTSiMC"); - String spcRdmAD1 = rdmAddDropTplist.stream().filter(adp -> adp.contains(edgeRoadm1)).findFirst().get(); - String spcRdmAD2 = rdmAddDropTplist.stream().filter(adp -> adp.contains(edgeRoadm2)).findFirst().get(); - org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection - connection = createTopConnection(spcRdmAD1, spcRdmAD2, cepMap, OTSI_MC, - LayerProtocolName.PHOTONICMEDIA); + LOG.info("Going to create top connections between roadms"); + String spcRdmAD1 = rdmAddDropTplist.stream().filter(adp -> adp.contains(edgeRoadm1)).findFirst().orElseThrow(); + String spcRdmAD2 = rdmAddDropTplist.stream().filter(adp -> adp.contains(edgeRoadm2)).findFirst().orElseThrow(); + // MC top connection between edge roadms + LOG.info("Going to created top connection between MC"); + org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection + connection = createTopConnection(spcRdmAD1, spcRdmAD2, cepMap, TapiStringConstants.MC, + LayerProtocolName.PHOTONICMEDIA, xcLowerMap, null); this.connectionFullMap.put(connection.key(), connection); - LOG.info("Top connection created = {}", connection); + LOG.info("Top connection created = {}", connection.toString()); + Map connServMap = new HashMap<>(); // OTSiMC top connections that will be added to the service object Connection conn = new ConnectionBuilder().setConnectionUuid(connection.getUuid()).build(); connServMap.put(conn.key(), conn); + LowerConnection conn1 = new LowerConnectionBuilder().setConnectionUuid(connection.getUuid()).build(); + Map topLowerMap = new HashMap<>(); + topLowerMap.put(conn1.key(), conn1); + + // OTSiMC top connection between edge roadms + LOG.info("Going to created top connection between OTSiMC"); + org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection + connection1 = createTopConnection(spcRdmAD1, spcRdmAD2, cepMap, TapiStringConstants.OTSI_MC, + LayerProtocolName.PHOTONICMEDIA, topLowerMap, null); + this.connectionFullMap.put(connection1.key(), connection1); + LOG.info("Top connection created = {}", connection1.toString()); + + // OTSiMC top connections that will be added to the service object + Connection conn2 = new ConnectionBuilder().setConnectionUuid(connection1.getUuid()).build(); + connServMap.put(conn2.key(), conn2); + this.topConnRdmRdm = conn2; return connServMap; } - private org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection + private org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection createTopConnection(String tp1, String tp2, Map cepMap, String qual, LayerProtocolName topPortocol) { + .onf.otcc.yang.tapi.connectivity.rev221121.cep.list.ConnectionEndPointKey, + ConnectionEndPoint> cepMap, String qual, LayerProtocolName topPortocol, + Map xcMap, Connection additionalLowerConn) { // find cep for each AD MC of roadm 1 and 2 LOG.info("Top connection name = {}", String.join("+", "TOP", tp1, tp2, qual)); - org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.ConnectionEndPoint adCep1 = + org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.ConnectionEndPoint adCep1 = cepMap.get(new org.opendaylight.yang.gen.v1.urn - .onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointKey( + .onf.otcc.yang.tapi.connectivity.rev221121.cep.list.ConnectionEndPointKey( new Uuid(UUID.nameUUIDFromBytes((String.join("+", "CEP", tp1.split("\\+")[0], - qual, tp1.split("\\+")[1])).getBytes(Charset.forName("UTF-8"))) + qual, tp1.split("\\+")[1])).getBytes(StandardCharsets.UTF_8)) .toString()))); LOG.info("ADCEP1 = {}", adCep1); org.opendaylight.yang.gen.v1.urn - .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPoint cep1 = + .onf.otcc.yang.tapi.connectivity.rev221121.connection.ConnectionEndPoint cep1 = new org.opendaylight.yang.gen.v1.urn - .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPointBuilder() - .setNodeEdgePointUuid(adCep1.getClientNodeEdgePoint() - .values().stream().findFirst().get().getNodeEdgePointUuid()) - .setTopologyUuid(adCep1.getClientNodeEdgePoint() - .values().stream().findFirst().get().getTopologyUuid()) - .setNodeUuid(adCep1.getClientNodeEdgePoint() - .values().stream().findFirst().get().getNodeUuid()) + .onf.otcc.yang.tapi.connectivity.rev221121.connection.ConnectionEndPointBuilder() + .setNodeEdgePointUuid(adCep1.getParentNodeEdgePoint().getNodeEdgePointUuid()) + .setNodeUuid(adCep1.getParentNodeEdgePoint().getNodeUuid()) + .setTopologyUuid(adCep1.getParentNodeEdgePoint().getTopologyUuid()) .setConnectionEndPointUuid(adCep1.getUuid()) .build(); - org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.ConnectionEndPoint adCep2 = + org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.ConnectionEndPoint adCep2 = cepMap.get(new org.opendaylight.yang.gen.v1.urn - .onf.otcc.yang.tapi.connectivity.rev181210.cep.list.ConnectionEndPointKey( + .onf.otcc.yang.tapi.connectivity.rev221121.cep.list.ConnectionEndPointKey( new Uuid(UUID.nameUUIDFromBytes((String.join("+", "CEP", tp2.split("\\+")[0], - qual, tp2.split("\\+")[1])).getBytes(Charset.forName("UTF-8"))) + qual, tp2.split("\\+")[1])).getBytes(StandardCharsets.UTF_8)) .toString()))); LOG.info("ADCEP2 = {}", adCep2); org.opendaylight.yang.gen.v1.urn - .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPoint cep2 = + .onf.otcc.yang.tapi.connectivity.rev221121.connection.ConnectionEndPoint cep2 = new org.opendaylight.yang.gen.v1.urn - .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPointBuilder() - .setNodeEdgePointUuid(adCep2.getClientNodeEdgePoint() - .values().stream().findFirst().get().getNodeEdgePointUuid()) - .setTopologyUuid(adCep2.getClientNodeEdgePoint() - .values().stream().findFirst().get().getTopologyUuid()) - .setNodeUuid(adCep2.getClientNodeEdgePoint() - .values().stream().findFirst().get().getNodeUuid()) + .onf.otcc.yang.tapi.connectivity.rev221121.connection.ConnectionEndPointBuilder() + .setNodeEdgePointUuid(adCep2.getParentNodeEdgePoint().getNodeEdgePointUuid()) + .setNodeUuid(adCep2.getParentNodeEdgePoint().getNodeUuid()) + .setTopologyUuid(adCep2.getParentNodeEdgePoint().getTopologyUuid()) .setConnectionEndPointUuid(adCep1.getUuid()) .build(); Map ceps = new HashMap<>(); + .onf.otcc.yang.tapi.connectivity.rev221121.connection.ConnectionEndPoint> ceps = new HashMap<>(); ceps.put(cep1.key(), cep1); ceps.put(cep2.key(), cep2); Name connName = new NameBuilder() @@ -749,52 +954,51 @@ public final class ConnectivityUtils { .setValue(String.join("+", "TOP", tp1, tp2, qual)) .build(); // TODO: lower connection, supported link....... + if (additionalLowerConn != null) { + xcMap.putIfAbsent(new LowerConnectionKey(additionalLowerConn.getConnectionUuid()), + new LowerConnectionBuilder().setConnectionUuid(additionalLowerConn.getConnectionUuid()).build()); + } return new org.opendaylight.yang.gen.v1.urn - .onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectionBuilder() + .onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.ConnectionBuilder() .setUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", "TOP", tp1, tp2, qual)) - .getBytes(Charset.forName("UTF-8"))).toString())) + .getBytes(StandardCharsets.UTF_8)).toString())) .setName(Map.of(connName.key(), connName)) .setConnectionEndPoint(ceps) .setOperationalState(OperationalState.ENABLED) .setLayerProtocolName(topPortocol) .setLifecycleState(LifecycleState.INSTALLED) .setDirection(ForwardingDirection.BIDIRECTIONAL) + .setLowerConnection(xcMap) .build(); } - private org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.Connection + private org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection createXCBetweenCeps(ConnectionEndPoint cep1, ConnectionEndPoint cep2, String tp1, String tp2, String qual, LayerProtocolName xcProtocol) { LOG.info("Creation cross connection between: {} and {}", tp1, tp2); LOG.info("Cross connection name = {}", String.join("+", "XC", tp1, tp2, qual)); - LOG.info("CEP1 = {}", cep1.getClientNodeEdgePoint()); - LOG.info("CEP2 = {}", cep2.getClientNodeEdgePoint()); + LOG.debug("Parent NEP of CEP1 = {}", cep1.getParentNodeEdgePoint().toString()); + LOG.debug("Parent NEP CEP2 = {}", cep2.getParentNodeEdgePoint().toString()); org.opendaylight.yang.gen.v1.urn - .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPoint cepServ1 = + .onf.otcc.yang.tapi.connectivity.rev221121.connection.ConnectionEndPoint cepServ1 = new org.opendaylight.yang.gen.v1.urn - .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPointBuilder() - .setNodeEdgePointUuid(cep1.getClientNodeEdgePoint() - .values().stream().findFirst().get().getNodeEdgePointUuid()) - .setTopologyUuid(cep1.getClientNodeEdgePoint() - .values().stream().findFirst().get().getTopologyUuid()) - .setNodeUuid(cep1.getClientNodeEdgePoint() - .values().stream().findFirst().get().getNodeUuid()) - .setConnectionEndPointUuid(cep1.getUuid()) - .build(); + .onf.otcc.yang.tapi.connectivity.rev221121.connection.ConnectionEndPointBuilder() + .setNodeEdgePointUuid(cep1.getParentNodeEdgePoint().getNodeEdgePointUuid()) + .setNodeUuid(cep1.getParentNodeEdgePoint().getNodeUuid()) + .setTopologyUuid(cep1.getParentNodeEdgePoint().getTopologyUuid()) + .setConnectionEndPointUuid(cep1.getUuid()) + .build(); org.opendaylight.yang.gen.v1.urn - .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPoint cepServ2 = + .onf.otcc.yang.tapi.connectivity.rev221121.connection.ConnectionEndPoint cepServ2 = new org.opendaylight.yang.gen.v1.urn - .onf.otcc.yang.tapi.connectivity.rev181210.connection.ConnectionEndPointBuilder() - .setNodeEdgePointUuid(cep2.getClientNodeEdgePoint() - .values().stream().findFirst().get().getNodeEdgePointUuid()) - .setTopologyUuid(cep2.getClientNodeEdgePoint() - .values().stream().findFirst().get().getTopologyUuid()) - .setNodeUuid(cep2.getClientNodeEdgePoint() - .values().stream().findFirst().get().getNodeUuid()) - .setConnectionEndPointUuid(cep2.getUuid()) - .build(); + .onf.otcc.yang.tapi.connectivity.rev221121.connection.ConnectionEndPointBuilder() + .setNodeEdgePointUuid(cep2.getParentNodeEdgePoint().getNodeEdgePointUuid()) + .setNodeUuid(cep2.getParentNodeEdgePoint().getNodeUuid()) + .setTopologyUuid(cep2.getParentNodeEdgePoint().getTopologyUuid()) + .setConnectionEndPointUuid(cep2.getUuid()) + .build(); Map ceps = new HashMap<>(); + .onf.otcc.yang.tapi.connectivity.rev221121.connection.ConnectionEndPoint> ceps = new HashMap<>(); ceps.put(cepServ1.key(), cepServ1); ceps.put(cepServ2.key(), cepServ2); Name connName = new NameBuilder() @@ -803,9 +1007,9 @@ public final class ConnectivityUtils { .build(); // TODO: lower connection, supported link....... return new org.opendaylight.yang.gen.v1.urn - .onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectionBuilder() + .onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.ConnectionBuilder() .setUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", "XC", tp1, tp2, qual)) - .getBytes(Charset.forName("UTF-8"))).toString())) + .getBytes(StandardCharsets.UTF_8)).toString())) .setName(Map.of(connName.key(), connName)) .setConnectionEndPoint(ceps) .setOperationalState(OperationalState.ENABLED) @@ -822,29 +1026,65 @@ public final class ConnectivityUtils { .setValue(String.join("+", id.split("\\+")[0], qualifier, id.split("\\+")[1])) .build(); + ParentNodeEdgePoint pnep = new ParentNodeEdgePointBuilder() + .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", id.split("\\+")[0], + qualifier, id.split("\\+")[1])).getBytes(StandardCharsets.UTF_8)) + .toString())) + .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+",id.split("\\+")[0], + TapiStringConstants.PHTNC_MEDIA)).getBytes(StandardCharsets.UTF_8)) + .toString())) + .setTopologyUuid(new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER + .getBytes(StandardCharsets.UTF_8)).toString())) + .build(); + String clientQualifier = ""; + switch (qualifier) { + case TapiStringConstants.PHTNC_MEDIA_OTS: + clientQualifier = TapiStringConstants.PHTNC_MEDIA_OMS; + break; + case TapiStringConstants.PHTNC_MEDIA_OMS: + clientQualifier = TapiStringConstants.MC; + OwnedNodeEdgePoint onepMC = createRoadmNep(id.split("\\+")[0], id.split("\\+")[1], + false, OperationalState.ENABLED, AdministrativeState.UNLOCKED, clientQualifier); + putRdmNepInTopologyContext(id.split("\\+")[0], id.split("\\+")[1], TapiStringConstants.MC, onepMC); + break; + case TapiStringConstants.MC: + clientQualifier = TapiStringConstants.OTSI_MC; + OwnedNodeEdgePoint onepOTSiMC = createRoadmNep(id.split("\\+")[0], id.split("\\+")[1], + false, OperationalState.ENABLED, AdministrativeState.UNLOCKED, clientQualifier); + putRdmNepInTopologyContext(id.split("\\+")[0], id.split("\\+")[1], + TapiStringConstants.OTSI_MC, onepOTSiMC); + break; + default: + LOG.debug("not currently handling client NEP for OTSiMC CEP {}", + String.join("+", id.split("\\+")[0], qualifier, id.split("\\+")[1])); + break; + } ClientNodeEdgePoint cnep = new ClientNodeEdgePointBuilder() .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", id.split("\\+")[0], - qualifier, id.split("\\+")[1])).getBytes(Charset.forName("UTF-8"))) + clientQualifier, id.split("\\+")[1])).getBytes(StandardCharsets.UTF_8)) .toString())) .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+",id.split("\\+")[0], - qualifier)).getBytes(Charset.forName("UTF-8"))) + TapiStringConstants.PHTNC_MEDIA)).getBytes(StandardCharsets.UTF_8)) .toString())) - .setTopologyUuid(new Uuid(UUID.nameUUIDFromBytes(TopologyUtils.T0_FULL_MULTILAYER - .getBytes(Charset.forName("UTF-8"))).toString())) + .setTopologyUuid(new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER + .getBytes(StandardCharsets.UTF_8)).toString())) .build(); // TODO: add augmentation with the corresponding cep-spec (i.e. MC, OTSiMC...) // TODO: add parent ONEP?? ConnectionEndPointBuilder cepBldr = new ConnectionEndPointBuilder() .setUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", "CEP", id.split("\\+")[0], - qualifier, id.split("\\+")[1])).getBytes(Charset.forName("UTF-8"))) + qualifier, id.split("\\+")[1])).getBytes(StandardCharsets.UTF_8)) .toString())) - .setClientNodeEdgePoint(Map.of(cnep.key(), cnep)) + .setParentNodeEdgePoint(pnep) .setName(Map.of(cepName.key(), cepName)) .setConnectionPortRole(PortRole.SYMMETRIC) - .setConnectionPortDirection(PortDirection.BIDIRECTIONAL) + .setDirection(Direction.BIDIRECTIONAL) .setOperationalState(OperationalState.ENABLED) .setLifecycleState(LifecycleState.INSTALLED) .setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA); + if (!(TapiStringConstants.OTSI_MC.equals(qualifier))) { + cepBldr.setClientNodeEdgePoint(Map.of(cnep.key(), cnep)); + } return cepBldr.build(); } @@ -855,35 +1095,67 @@ public final class ConnectivityUtils { .setValue(String.join("+", id.split("\\+")[0], qualifier, id.split("\\+")[1])) .build(); + ParentNodeEdgePoint pnep = new ParentNodeEdgePointBuilder() + .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", id.split("\\+")[0], + qualifier, id.split("\\+")[1])).getBytes(StandardCharsets.UTF_8)) + .toString())) + .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+",id.split("\\+")[0], + TapiStringConstants.XPDR)).getBytes(StandardCharsets.UTF_8)) + .toString())) + .setTopologyUuid(new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER + .getBytes(StandardCharsets.UTF_8)).toString())) + .build(); + String clientQualifier = ""; + String clientNodeLayer = TapiStringConstants.PHTNC_MEDIA; + switch (qualifier) { + case TapiStringConstants.PHTNC_MEDIA_OTS: + clientQualifier = TapiStringConstants.OTSI_MC; + break; + case TapiStringConstants.OTSI_MC: + clientQualifier = TapiStringConstants.E_ODU; + clientNodeLayer = TapiStringConstants.ODU; + break; + case TapiStringConstants.E_ODU: + clientQualifier = TapiStringConstants.DSR; + clientNodeLayer = TapiStringConstants.DSR; + break; + default : + LOG.debug("no client CEP for DSR NEP {}", + String.join("+", id.split("\\+")[0], qualifier, id.split("\\+")[1])); + break; + } ClientNodeEdgePoint cnep = new ClientNodeEdgePointBuilder() .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", id.split("\\+")[0], - qualifier, id.split("\\+")[1])).getBytes(Charset.forName("UTF-8"))) + clientQualifier, id.split("\\+")[1])).getBytes(StandardCharsets.UTF_8)) .toString())) .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+",id.split("\\+")[0], - nodeLayer)).getBytes(Charset.forName("UTF-8"))) + TapiStringConstants.XPDR)).getBytes(StandardCharsets.UTF_8)) .toString())) - .setTopologyUuid(new Uuid(UUID.nameUUIDFromBytes(TopologyUtils.T0_FULL_MULTILAYER - .getBytes(Charset.forName("UTF-8"))).toString())) + .setTopologyUuid(new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER + .getBytes(StandardCharsets.UTF_8)).toString())) .build(); // TODO: add augmentation with the corresponding cep-spec (i.e. MC, OTSiMC...) // TODO: add parent ONEP?? ConnectionEndPointBuilder cepBldr = new ConnectionEndPointBuilder() .setUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", "CEP", id.split("\\+")[0], - qualifier, id.split("\\+")[1])).getBytes(Charset.forName("UTF-8"))) + qualifier, id.split("\\+")[1])).getBytes(StandardCharsets.UTF_8)) .toString())) - .setClientNodeEdgePoint(Map.of(cnep.key(), cnep)) + .setParentNodeEdgePoint(pnep) .setName(Map.of(cepName.key(), cepName)) .setConnectionPortRole(PortRole.SYMMETRIC) - .setConnectionPortDirection(PortDirection.BIDIRECTIONAL) + .setDirection(Direction.BIDIRECTIONAL) .setOperationalState(OperationalState.ENABLED) .setLifecycleState(LifecycleState.INSTALLED) .setLayerProtocolName(cepProtocol); + if (!(TapiStringConstants.DSR.equals(qualifier))) { + cepBldr.setClientNodeEdgePoint(Map.of(cnep.key(), cnep)); + } return cepBldr.build(); } private EndPoint mapServiceZEndPoint( - org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.ServiceZEnd - serviceZEnd, PathDescription pathDescription) { + org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service.ServiceZEnd + serviceZEnd, PathDescription pathDescription) { EndPointBuilder endPointBuilder = new EndPointBuilder(); // 1. Service Format: ODU, OTU, ETH ServiceFormat serviceFormat = serviceZEnd.getServiceFormat(); @@ -907,12 +1179,13 @@ public final class ConnectivityUtils { default: LOG.error("Service Format not supported"); } - org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.local._class.Name name = - new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.local._class.NameBuilder() + org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.local._class.Name name = + new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.local._class.NameBuilder() .setValueName("OpenROADM info") .setValue(String.join("-", serviceZEnd.getClli(), - serviceZEnd.getTxDirection().getPort().getPortDeviceName(), - serviceZEnd.getTxDirection().getPort().getPortName())) + serviceZEnd.getTxDirection().values().stream().findFirst().orElseThrow().getPort() + .getPortDeviceName(), + serviceZEnd.getTxDirection().values().stream().findFirst().orElseThrow().getPort().getPortName())) .build(); return endPointBuilder .setServiceInterfacePoint(new ServiceInterfacePointBuilder() @@ -920,26 +1193,27 @@ public final class ConnectivityUtils { .build()) .setName(Map.of(name.key(), name)) .setAdministrativeState(AdministrativeState.UNLOCKED) - .setDirection(PortDirection.BIDIRECTIONAL) + .setDirection(Direction.BIDIRECTIONAL) .setLifecycleState(LifecycleState.INSTALLED) .setOperationalState(OperationalState.ENABLED) .setLayerProtocolName(layerProtocols) .setCapacity(new CapacityBuilder() .setTotalSize(new TotalSizeBuilder() - .setValue(Uint64.valueOf(serviceZEnd.getServiceRate())) - .setUnit(CapacityUnit.GBPS) + .setValue(Decimal64.valueOf(BigDecimal.valueOf(serviceZEnd.getServiceRate().doubleValue()))) + .setUnit(CAPACITYUNITGBPS.VALUE) .build()) - .setBandwidthProfile(new BandwidthProfileBuilder().build()) // TODO: implement bandwidth profile +// .setBandwidthProfile(new BandwidthProfileBuilder().build()) .build()) .setProtectionRole(ProtectionRole.WORK) .setRole(PortRole.SYMMETRIC) - .setLocalId(serviceNodeId) + .setLocalId(serviceZEnd.getTxDirection().values().stream().findFirst().orElseThrow() + .getPort().getPortDeviceName()) .build(); } private EndPoint mapServiceAEndPoint( - org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.ServiceAEnd - serviceAEnd, PathDescription pathDescription) { + org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service.ServiceAEnd + serviceAEnd, PathDescription pathDescription) { EndPointBuilder endPointBuilder = new EndPointBuilder(); // 1. Service Format: ODU, OTU, ETH ServiceFormat serviceFormat = serviceAEnd.getServiceFormat(); @@ -963,12 +1237,13 @@ public final class ConnectivityUtils { default: LOG.error("Service Format not supported"); } - org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.local._class.Name name = - new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.local._class.NameBuilder() + org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.local._class.Name name = + new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.local._class.NameBuilder() .setValueName("OpenROADM info") .setValue(String.join("-", serviceAEnd.getClli(), - serviceAEnd.getTxDirection().getPort().getPortDeviceName(), - serviceAEnd.getTxDirection().getPort().getPortName())) + serviceAEnd.getTxDirection().values().stream().findFirst().orElseThrow().getPort() + .getPortDeviceName(), + serviceAEnd.getTxDirection().values().stream().findFirst().orElseThrow().getPort().getPortName())) .build(); return endPointBuilder .setServiceInterfacePoint(new ServiceInterfacePointBuilder() @@ -976,20 +1251,21 @@ public final class ConnectivityUtils { .build()) .setName(Map.of(name.key(), name)) .setAdministrativeState(AdministrativeState.UNLOCKED) - .setDirection(PortDirection.BIDIRECTIONAL) + .setDirection(Direction.BIDIRECTIONAL) .setLifecycleState(LifecycleState.INSTALLED) .setOperationalState(OperationalState.ENABLED) .setLayerProtocolName(layerProtocols) .setCapacity(new CapacityBuilder() .setTotalSize(new TotalSizeBuilder() - .setValue(Uint64.valueOf(serviceAEnd.getServiceRate())) - .setUnit(CapacityUnit.GBPS) + .setValue(Decimal64.valueOf(BigDecimal.valueOf(serviceAEnd.getServiceRate().doubleValue()))) + .setUnit(CAPACITYUNITGBPS.VALUE) .build()) - .setBandwidthProfile(new BandwidthProfileBuilder().build()) // TODO: implement bandwidth profile +// .setBandwidthProfile(new BandwidthProfileBuilder().build()) // TODO: implement bandwidth profile .build()) .setProtectionRole(ProtectionRole.WORK) .setRole(PortRole.SYMMETRIC) - .setLocalId(serviceNodeId) + .setLocalId(serviceAEnd.getTxDirection().values().stream().findFirst().orElseThrow().getPort() + .getPortDeviceName()) .build(); } @@ -998,12 +1274,13 @@ public final class ConnectivityUtils { if (serviceNodeId.contains("ROADM")) { // Service from ROADM to ROADM // AddDrop-AddDrop ports --> MC layer SIPs - ZToA firstElement = mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("0")).findFirst().get(); + ZToA firstElement = mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("0")).findFirst() + .orElseThrow(); TerminationPoint tp = (TerminationPoint) firstElement.getResource().getResource(); Uuid sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP", - tp.getTpNodeId(), MC, tp.getTpId())).getBytes(Charset.forName("UTF-8"))) + tp.getTpNodeId(), TapiStringConstants.MC, tp.getTpId())).getBytes(StandardCharsets.UTF_8)) .toString()); - LOG.info("SIP name = {}", String.join("+", tp.getTpNodeId(), MC, tp.getTpId())); + LOG.info("SIP name = {}", String.join("+", tp.getTpNodeId(), TapiStringConstants.MC, tp.getTpId())); for (ServiceInterfacePoint sip:this.sipMap.values()) { if (!sip.getUuid().equals(sipUuid)) { LOG.info("SIP {} doesn match sipname {}", sip.getUuid().getValue(), sipUuid.getValue()); @@ -1019,31 +1296,35 @@ public final class ConnectivityUtils { Uuid sipUuid; switch (serviceFormat) { case ODU: - firstElement = mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("2")).findFirst().get(); + firstElement = mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("2")).findFirst() + .orElseThrow(); tp = (TerminationPoint) firstElement.getResource().getResource(); // Network-Network ports --> iODU layer SIPs TODO --> updated to E_ODU - sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP", - tp.getTpNodeId(), E_ODU, tp.getTpId())).getBytes(Charset.forName("UTF-8"))) - .toString()); - LOG.info("SIP name = {}", String.join("+", tp.getTpNodeId(), E_ODU, tp.getTpId())); + sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP", tp.getTpNodeId(), + TapiStringConstants.I_ODU, tp.getTpId())).getBytes(StandardCharsets.UTF_8)).toString()); + LOG.info("SIP name = {}", String.join("+", tp.getTpNodeId(), TapiStringConstants.I_ODU, + tp.getTpId())); break; case OTU: - firstElement = mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("2")).findFirst().get(); + firstElement = mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("2")).findFirst() + .orElseThrow(); tp = (TerminationPoint) firstElement.getResource().getResource(); // Network-Network ports --> iOTSi layer SIPs - sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP", - tp.getTpNodeId(), I_OTSI, tp.getTpId())).getBytes(Charset.forName("UTF-8"))) - .toString()); - LOG.info("SIP name = {}", String.join("+", tp.getTpNodeId(), I_OTSI, tp.getTpId())); + sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP", tp.getTpNodeId(), + TapiStringConstants.I_OTSI, tp.getTpId())).getBytes(StandardCharsets.UTF_8)).toString()); + LOG.info("SIP name = {}", String.join("+", tp.getTpNodeId(), TapiStringConstants.I_OTSI, + tp.getTpId())); break; case Ethernet: - firstElement = mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("0")).findFirst().get(); + LOG.info("Elements ZA = {}", mapztoa.values().toString()); + firstElement = mapztoa.values().stream().filter(ztoa -> ztoa.getId().equals("0")).findFirst() + .orElseThrow(); tp = (TerminationPoint) firstElement.getResource().getResource(); // Client-client ports --> DSR layer SIPs - sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP", - tp.getTpNodeId(), DSR, tp.getTpId())).getBytes(Charset.forName("UTF-8"))) - .toString()); - LOG.info("SIP name = {}", String.join("+", tp.getTpNodeId(), DSR, tp.getTpId())); + sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP", tp.getTpNodeId(), + TapiStringConstants.DSR, tp.getTpId())).getBytes(StandardCharsets.UTF_8)).toString()); + LOG.info("SIP name = {}", String.join("+", tp.getTpNodeId(), TapiStringConstants.DSR, + tp.getTpId())); break; default: sipUuid = null; @@ -1068,13 +1349,15 @@ public final class ConnectivityUtils { if (serviceNodeId.contains("ROADM")) { // Service from ROADM to ROADM // AddDrop-AddDrop ports --> MC layer SIPs - AToZ firstElement = mapatoz.values().stream().filter(atoz -> atoz.getId().equals("0")).findFirst().get(); + AToZ firstElement = mapatoz.values().stream().filter(atoz -> atoz.getId().equals("0")).findFirst() + .orElseThrow(); LOG.info("First element of service path = {}", firstElement.getResource().getResource()); TerminationPoint tp = (TerminationPoint) firstElement.getResource().getResource(); Uuid sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP", - tp.getTpNodeId(), MC, tp.getTpId())).getBytes(Charset.forName("UTF-8"))) + tp.getTpNodeId(), TapiStringConstants.MC, tp.getTpId())).getBytes(StandardCharsets.UTF_8)) .toString()); - LOG.info("ROADM SIP name = {}", String.join("+", tp.getTpNodeId(), MC, tp.getTpId())); + LOG.info("ROADM SIP name = {}", String.join("+", tp.getTpNodeId(), TapiStringConstants.MC, + tp.getTpId())); for (ServiceInterfacePoint sip:this.sipMap.values()) { if (!sip.getUuid().equals(sipUuid)) { LOG.info("SIP {} doesn match sipname {}", sip.getUuid().getValue(), sipUuid.getValue()); @@ -1090,31 +1373,35 @@ public final class ConnectivityUtils { Uuid sipUuid; switch (serviceFormat) { case ODU: - firstElement = mapatoz.values().stream().filter(atoz -> atoz.getId().equals("2")).findFirst().get(); + firstElement = mapatoz.values().stream().filter(atoz -> atoz.getId().equals("2")).findFirst() + .orElseThrow(); tp = (TerminationPoint) firstElement.getResource().getResource(); // Network-Network ports --> iODU layer SIPs. TODO -> updated to eODU - sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP", - tp.getTpNodeId(), E_ODU, tp.getTpId())).getBytes(Charset.forName("UTF-8"))) - .toString()); - LOG.info("ODU XPDR SIP name = {}", String.join("+", tp.getTpNodeId(), E_ODU, tp.getTpId())); + sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP", tp.getTpNodeId(), + TapiStringConstants.I_ODU, tp.getTpId())).getBytes(StandardCharsets.UTF_8)).toString()); + LOG.info("ODU XPDR SIP name = {}", String.join("+", tp.getTpNodeId(), + TapiStringConstants.I_ODU, tp.getTpId())); break; case OTU: - firstElement = mapatoz.values().stream().filter(atoz -> atoz.getId().equals("2")).findFirst().get(); + firstElement = mapatoz.values().stream().filter(atoz -> atoz.getId().equals("2")).findFirst() + .orElseThrow(); tp = (TerminationPoint) firstElement.getResource().getResource(); // Network-Network ports --> iOTSi layer SIPs - sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP", - tp.getTpNodeId(), I_OTSI, tp.getTpId())).getBytes(Charset.forName("UTF-8"))) - .toString()); - LOG.info("OTU XPDR SIP name = {}", String.join("+", tp.getTpNodeId(), I_OTSI, tp.getTpId())); + sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP", tp.getTpNodeId(), + TapiStringConstants.I_OTSI, tp.getTpId())).getBytes(StandardCharsets.UTF_8)).toString()); + LOG.info("OTU XPDR SIP name = {}", String.join("+", tp.getTpNodeId(), + TapiStringConstants.I_OTSI, tp.getTpId())); break; case Ethernet: - firstElement = mapatoz.values().stream().filter(atoz -> atoz.getId().equals("0")).findFirst().get(); + LOG.info("Elements AZ = {}", mapatoz.values().toString()); + firstElement = mapatoz.values().stream().filter(atoz -> atoz.getId().equals("0")).findFirst() + .orElseThrow(); tp = (TerminationPoint) firstElement.getResource().getResource(); // Client-client ports --> DSR layer SIPs - sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP", - tp.getTpNodeId(), DSR, tp.getTpId())).getBytes(Charset.forName("UTF-8"))) - .toString()); - LOG.info("DSR XPDR SIP name = {}", String.join("+", tp.getTpNodeId(), DSR, tp.getTpId())); + sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP", tp.getTpNodeId(), + TapiStringConstants.DSR, tp.getTpId())).getBytes(StandardCharsets.UTF_8)).toString()); + LOG.info("DSR XPDR SIP name = {}", String.join("+", tp.getTpNodeId(), + TapiStringConstants.DSR, tp.getTpId())); break; default: sipUuid = null; @@ -1134,63 +1421,111 @@ public final class ConnectivityUtils { private void putRdmCepInTopologyContext(String node, String spcRdmAD, String qual, ConnectionEndPoint cep) { LOG.info("NEP id before Merge = {}", String.join("+", node, qual, spcRdmAD.split("\\+")[1])); - LOG.info("Node of NEP id before Merge = {}", String.join("+", node, PHTNC_MEDIA)); + LOG.info("Node of NEP id before Merge = {}", String.join("+", node, TapiStringConstants.PHTNC_MEDIA)); // Give uuids so that it is easier to look for things: topology uuid, node uuid, nep uuid, cep - Uuid topoUuid = new Uuid(UUID.nameUUIDFromBytes(TopologyUtils.T0_FULL_MULTILAYER - .getBytes(Charset.forName("UTF-8"))).toString()); - Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes(String.join("+", node, PHTNC_MEDIA) - .getBytes(Charset.forName("UTF-8"))).toString()); + Uuid topoUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER + .getBytes(StandardCharsets.UTF_8)).toString()); + Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes(String.join("+", node, TapiStringConstants.PHTNC_MEDIA) + .getBytes(StandardCharsets.UTF_8)).toString()); Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(String.join("+", node, qual, spcRdmAD.split("\\+")[1]) - .getBytes(Charset.forName("UTF-8"))).toString()); + .getBytes(StandardCharsets.UTF_8)).toString()); this.tapiContext.updateTopologyWithCep(topoUuid, nodeUuid, nepUuid, cep); } private void putXpdrCepInTopologyContext(String node, String spcXpdrNet, String qual, String nodeLayer, ConnectionEndPoint cep) { // Give uuids so that it is easier to look for things: topology uuid, node uuid, nep uuid, cep - Uuid topoUuid = new Uuid(UUID.nameUUIDFromBytes(TopologyUtils.T0_FULL_MULTILAYER - .getBytes(Charset.forName("UTF-8"))).toString()); + Uuid topoUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER + .getBytes(StandardCharsets.UTF_8)).toString()); Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes(String.join("+", node, nodeLayer) - .getBytes(Charset.forName("UTF-8"))).toString()); + .getBytes(StandardCharsets.UTF_8)).toString()); Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(String.join("+", node, qual, spcXpdrNet.split("\\+")[1]) - .getBytes(Charset.forName("UTF-8"))).toString()); + .getBytes(StandardCharsets.UTF_8)).toString()); this.tapiContext.updateTopologyWithCep(topoUuid, nodeUuid, nepUuid, cep); } + + private void putRdmNepInTopologyContext(String orNodeId, String orTpId, String qual, OwnedNodeEdgePoint onep) { + LOG.info("NEP id before Merge = {}", String.join("+", orNodeId, qual, orTpId)); + LOG.info("Node of NEP id before Merge = {}", String.join("+", orNodeId, TapiStringConstants.PHTNC_MEDIA)); + // Give uuids so that it is easier to look for things: topology uuid, node uuid, nep uuid, cep + Uuid topoUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER + .getBytes(Charset.forName("UTF-8"))).toString()); + Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes(String.join("+", orNodeId, TapiStringConstants.PHTNC_MEDIA) + .getBytes(Charset.forName("UTF-8"))).toString()); + Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(String.join("+", orNodeId, qual, orTpId) + .getBytes(Charset.forName("UTF-8"))).toString()); + updateTopologyWithNep(topoUuid, nodeUuid, nepUuid, onep); + } + + 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 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 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 + .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; } private String getIdBasedOnModelVersion(String nodeid) { - return nodeid.matches("[A-Z]{5}-[A-Z0-9]{2}-.*") ? String.join("-", nodeid.split("-")[0], nodeid.split("-")[1]) - : nodeid.split("-")[0]; + return nodeid.matches("[A-Z]{5}-[A-Z0-9]{2}-.*") ? String.join("-", nodeid.split("-")[0], + nodeid.split("-")[1]) : nodeid.split("-")[0]; } public ServiceCreateInput createORServiceInput(CreateConnectivityServiceInput input, Uuid serviceUuid) { // TODO: not taking into account all the constraints. Only using EndPoints and Connectivity Constraint. Map + .onf.otcc.yang.tapi.connectivity.rev221121.create.connectivity.service.input.EndPoint> endPointMap = input.getEndPoint(); - ConnectivityConstraint constraint = input.getConnectivityConstraint(); ConnectionType connType = null; ServiceFormat serviceFormat = null; - String nodeAid = String.join("+", endPointMap.values().stream().findFirst().get().getLocalId(), DSR); - String nodeZid = String.join("+", endPointMap.values().stream().skip(1).findFirst().get().getLocalId(), DSR); - LOG.debug("Node a = {}", nodeAid); - LOG.debug("Node z = {}", nodeZid); - switch (constraint.getServiceLayer().getIntValue()) { + 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"); + LOG.info("DSR, need to create OTU and ODU"); connType = ConnectionType.Service; serviceFormat = ServiceFormat.Ethernet; break; @@ -1198,29 +1533,20 @@ public final class ConnectivityUtils { LOG.info("PHOTONIC"); connType = getConnectionTypePhtnc(endPointMap.values()); serviceFormat = getServiceFormatPhtnc(endPointMap.values()); - if (serviceFormat.equals(ServiceFormat.OC)) { - nodeAid = String.join("+", endPointMap.values().stream().findFirst().get().getLocalId(), - PHTNC_MEDIA); - nodeZid = String.join("+", endPointMap.values().stream().skip(1).findFirst().get().getLocalId(), - PHTNC_MEDIA); - } else { - nodeAid = String.join("+", endPointMap.values().stream().findFirst().get().getLocalId(), OTSI); - nodeZid = String.join("+", endPointMap.values().stream().skip(1).findFirst().get().getLocalId(), - OTSI); - } LOG.debug("Node a photonic = {}", nodeAid); LOG.debug("Node z photonic = {}", nodeZid); break; default: - LOG.info("Service type {} not supported", constraint.getServiceLayer().getName()); + LOG.info("Service type {} not supported", input.getLayerProtocolName().getName()); } // Requested Capacity for connectivity service - Uint64 capacity = input.getConnectivityConstraint().getRequestedCapacity().getTotalSize().getValue(); + 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().get(), - serviceFormat, nodeAid, capacity); - ServiceZEnd serviceZEnd = tapiEndPointToServiceZPoint(endPointMap.values().stream().skip(1).findFirst().get(), - serviceFormat, nodeZid, capacity); + 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; @@ -1245,15 +1571,15 @@ public final class ConnectivityUtils { private ServiceZEnd tapiEndPointToServiceZPoint( org.opendaylight.yang.gen.v1.urn - .onf.otcc.yang.tapi.connectivity.rev181210.create.connectivity.service.input.EndPoint endPoint, - ServiceFormat serviceFormat, String nodeZid, Uint64 capacity) { + .onf.otcc.yang.tapi.connectivity.rev221121.create.connectivity.service.input.EndPoint endPoint, + ServiceFormat serviceFormat, String nodeZid, Uint64 capacity, LayerProtocolName serviceLayer) { // TODO -> change way this is being created. The name includes only SPDR-SA1-XPDR1. // Not the rest which is needed in the txPortDeviceName. // It could be obtained from the SIP which has the NEP and includes all the OR name. Uuid sipUuid = endPoint.getServiceInterfacePoint().getServiceInterfacePointUuid(); // Todo -> need to find the NEP associated to that SIP - Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes(nodeZid.getBytes(Charset.forName("UTF-8"))).toString()); - org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node node = + Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes(nodeZid.getBytes(StandardCharsets.UTF_8)).toString()); + org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node node = this.tapiContext.getTapiNode(this.tapiTopoUuid, nodeUuid); if (node == null) { LOG.error("Node not found in datastore"); @@ -1275,28 +1601,23 @@ public final class ConnectivityUtils { LOG.error("Nep not found in datastore"); return null; } - String nodeName = endPoint.getName().values().stream().findFirst().get().getValue(); + String nodeName = ""; + for (Map.Entry entry: + endPoint.getName().entrySet()) { + if (!("Node Type").equals(entry.getValue().getValueName())) { + nodeName = entry.getValue().getValue(); + } + } +// String nodeName = endPoint.getName().values().stream().findFirst().orElseThrow().getValue(); String nodeid = String.join("-", nodeName.split("-")[0], nodeName.split("-")[1]); - String nepName = nep.getName().values().stream().findFirst().get().getValue(); + String nepName = nep.getName().values().stream().findFirst().orElseThrow().getValue(); String txPortDeviceName = nepName.split("\\+")[0]; String txPortName = nepName.split("\\+")[2]; String rxPortDeviceName = txPortDeviceName; String rxPortName = txPortName; LOG.debug("Node z id = {}, txportDeviceName = {}, txPortName = {}", nodeid, txPortDeviceName, txPortName); LOG.debug("Node z id = {}, rxportDeviceName = {}, rxPortName = {}", nodeid, rxPortDeviceName, rxPortName); - if (serviceFormat.equals(ServiceFormat.ODU)) { - // TODO --> populate network map - populateNetworkMap(nodeid, txPortName); - } - if (serviceFormat.equals(ServiceFormat.Ethernet)) { - // TODO --> choose from network Map un network port which hasnt been used yet by another service. - // Set boolean to true and update txportName and so on - String updTxName = findFreeConfiguredNetworkPort(nodeid); - if (updTxName != null) { - txPortName = updTxName; - rxPortName = txPortName; - } - } // TODO --> get clli from datastore? String clli = "NodeSC"; LOG.info("Node z id = {}, txportDeviceName = {}, txPortName = {}", nodeid, txPortDeviceName, txPortName); @@ -1307,63 +1628,72 @@ public final class ConnectivityUtils { .setOpticType(OpticTypes.Gray) .setServiceFormat(serviceFormat) .setServiceRate(Uint32.valueOf(capacity)) - .setSubrateEthSla(new SubrateEthSlaBuilder().setSubrateEthSla( - new org.opendaylight.yang.gen.v1.http - .org.openroadm.common.service.types.rev190531.subrate.eth.sla.SubrateEthSlaBuilder() + .setEthernetAttributes(new EthernetAttributesBuilder().setSubrateEthSla(new SubrateEthSlaBuilder() .setCommittedBurstSize(Uint16.valueOf(64)) .setCommittedInfoRate(Uint32.valueOf(100000)) .build()) .build()) - .setTxDirection(new TxDirectionBuilder() + .setTxDirection(Map.of(new TxDirectionKey(Uint8.ZERO), new TxDirectionBuilder() .setPort(new PortBuilder() .setPortDeviceName(txPortDeviceName) .setPortName(txPortName) - .setPortRack(PORT_RACK_VALUE) + .setPortRack(TapiStringConstants.PORT_RACK_VALUE) .setPortShelf("00") - .setPortType(PORT_TYPE) + .setPortType(TapiStringConstants.PORT_TYPE) .build()) .setLgx(new LgxBuilder() - .setLgxDeviceName(LGX_DEVICE_NAME) - .setLgxPortName(LGX_PORT_NAME) - .setLgxPortRack(PORT_RACK_VALUE) + .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME) + .setLgxPortName(TapiStringConstants.LGX_PORT_NAME) + .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE) .setLgxPortShelf("00") .build()) - .build()) - .setRxDirection(new RxDirectionBuilder() + .setIndex(Uint8.ZERO) + .build())) + .setRxDirection(Map.of(new RxDirectionKey(Uint8.ZERO), new RxDirectionBuilder() .setPort(new PortBuilder() .setPortDeviceName(rxPortDeviceName) .setPortName(rxPortName) - .setPortRack(PORT_RACK_VALUE) + .setPortRack(TapiStringConstants.PORT_RACK_VALUE) .setPortShelf("00") - .setPortType(PORT_TYPE) + .setPortType(TapiStringConstants.PORT_TYPE) .build()) .setLgx(new LgxBuilder() - .setLgxDeviceName(LGX_DEVICE_NAME) - .setLgxPortName(LGX_PORT_NAME) - .setLgxPortRack(PORT_RACK_VALUE) + .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME) + .setLgxPortName(TapiStringConstants.LGX_PORT_NAME) + .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE) .setLgxPortShelf("00") .build()) - .build()); + .setIndex(Uint8.ZERO) + .build())); if (serviceFormat.equals(ServiceFormat.ODU)) { - serviceZEndBuilder.setOduServiceRate(ODU4.class); + serviceZEndBuilder.setOduServiceRate(ODU4.VALUE); } if (serviceFormat.equals(ServiceFormat.OTU)) { - serviceZEndBuilder.setOtuServiceRate(OTU4.class); + serviceZEndBuilder.setOtuServiceRate(OTU4.VALUE); + } + if (!serviceLayer.equals(LayerProtocolName.ETH)) { + serviceZEndBuilder + .setEthernetAttributes(new EthernetAttributesBuilder().setSubrateEthSla(new SubrateEthSlaBuilder() + .setCommittedBurstSize(Uint16.valueOf(64)) + .setCommittedInfoRate(Uint32.valueOf(100000)) + .build()) + .build()); } return serviceZEndBuilder.build(); } private ServiceAEnd tapiEndPointToServiceAPoint( org.opendaylight.yang.gen.v1.urn - .onf.otcc.yang.tapi.connectivity.rev181210.create.connectivity.service.input.EndPoint endPoint, - ServiceFormat serviceFormat, String nodeAid, Uint64 capacity) { + .onf.otcc.yang.tapi.connectivity.rev221121.create.connectivity.service.input.EndPoint endPoint, + ServiceFormat serviceFormat, String nodeAid, Uint64 capacity, LayerProtocolName serviceLayer) { // TODO -> change way this is being created. The name includes only SPDR-SA1-XPDR1. // Not the rest which is needed in the txPortDeviceName. // It could be obtained from the SIP which has the NEP and includes all the OR name. Uuid sipUuid = endPoint.getServiceInterfacePoint().getServiceInterfacePointUuid(); // Todo -> need to find the NEP associated to that SIP - Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes(nodeAid.getBytes(Charset.forName("UTF-8"))).toString()); - org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node node = + Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes(nodeAid.getBytes(StandardCharsets.UTF_8)).toString()); + LOG.info("NodeA {} Uuid is {}", nodeAid, nodeUuid); + org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node node = this.tapiContext.getTapiNode(this.tapiTopoUuid, nodeUuid); if (node == null) { LOG.error("Node not found in datastore"); @@ -1385,28 +1715,23 @@ public final class ConnectivityUtils { LOG.error("Nep not found in datastore"); return null; } - String nodeName = endPoint.getName().values().stream().findFirst().get().getValue(); + String nodeName = ""; + for (Map.Entry entry: + endPoint.getName().entrySet()) { + if (!("Node Type").equals(entry.getValue().getValueName())) { + nodeName = entry.getValue().getValue(); + } + } +// String nodeName = endPoint.getName().values().stream().findFirst().orElseThrow().getValue(); String nodeid = String.join("-", nodeName.split("-")[0], nodeName.split("-")[1]); - String nepName = nep.getName().values().stream().findFirst().get().getValue(); + String nepName = nep.getName().values().stream().findFirst().orElseThrow().getValue(); String txPortDeviceName = nepName.split("\\+")[0]; String txPortName = nepName.split("\\+")[2]; String rxPortDeviceName = txPortDeviceName; String rxPortName = txPortName; LOG.debug("Node a id = {}, txportDeviceName = {}, txPortName = {}", nodeid, txPortDeviceName, txPortName); LOG.debug("Node a id = {}, rxportDeviceName = {}, rxPortName = {}", nodeid, rxPortDeviceName, rxPortName); - if (serviceFormat.equals(ServiceFormat.ODU)) { - // TODO --> populate network map - populateNetworkMap(nodeid, txPortName); - } - if (serviceFormat.equals(ServiceFormat.Ethernet)) { - // TODO --> choose from network Map un network port which hasnt been used yet by another service. - // Set boolean to true and update txportName and so on - String updTxName = findFreeConfiguredNetworkPort(nodeid); - if (updTxName != null) { - txPortName = updTxName; - rxPortName = txPortName; - } - } // TODO --> get clli from datastore? String clli = "NodeSA"; LOG.info("Node a id = {}, txportDeviceName = {}, txPortName = {}", nodeid, txPortDeviceName, txPortName); @@ -1417,78 +1742,63 @@ public final class ConnectivityUtils { .setOpticType(OpticTypes.Gray) .setServiceFormat(serviceFormat) .setServiceRate(Uint32.valueOf(capacity)) - .setSubrateEthSla(new SubrateEthSlaBuilder().setSubrateEthSla( - new org.opendaylight.yang.gen.v1.http - .org.openroadm.common.service.types.rev190531.subrate.eth.sla.SubrateEthSlaBuilder() - .setCommittedBurstSize(Uint16.valueOf(64)) - .setCommittedInfoRate(Uint32.valueOf(100000)) - .build()) + .setEthernetAttributes(new EthernetAttributesBuilder().setSubrateEthSla( + new org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.subrate.eth + .sla.SubrateEthSlaBuilder() + .setCommittedBurstSize(Uint16.valueOf(64)) + .setCommittedInfoRate(Uint32.valueOf(100000)) + .build()) .build()) - .setTxDirection(new TxDirectionBuilder() + .setTxDirection(Map.of(new TxDirectionKey(Uint8.ZERO), new TxDirectionBuilder() .setPort(new PortBuilder() .setPortDeviceName(txPortDeviceName) .setPortName(txPortName) - .setPortRack(PORT_RACK_VALUE) + .setPortRack(TapiStringConstants.PORT_RACK_VALUE) .setPortShelf("00") - .setPortType(PORT_TYPE) + .setPortType(TapiStringConstants.PORT_TYPE) .build()) .setLgx(new LgxBuilder() - .setLgxDeviceName(LGX_DEVICE_NAME) - .setLgxPortName(LGX_PORT_NAME) - .setLgxPortRack(PORT_RACK_VALUE) + .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME) + .setLgxPortName(TapiStringConstants.LGX_PORT_NAME) + .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE) .setLgxPortShelf("00") .build()) - .build()) - .setRxDirection(new RxDirectionBuilder() + .setIndex(Uint8.ZERO) + .build())) + .setRxDirection(Map.of(new RxDirectionKey(Uint8.ZERO), new RxDirectionBuilder() .setPort(new PortBuilder() .setPortDeviceName(rxPortDeviceName) .setPortName(rxPortName) - .setPortRack(PORT_RACK_VALUE) + .setPortRack(TapiStringConstants.PORT_RACK_VALUE) .setPortShelf("00") - .setPortType(PORT_TYPE) + .setPortType(TapiStringConstants.PORT_TYPE) .build()) .setLgx(new LgxBuilder() - .setLgxDeviceName(LGX_DEVICE_NAME) - .setLgxPortName(LGX_PORT_NAME) - .setLgxPortRack(PORT_RACK_VALUE) + .setLgxDeviceName(TapiStringConstants.LGX_DEVICE_NAME) + .setLgxPortName(TapiStringConstants.LGX_PORT_NAME) + .setLgxPortRack(TapiStringConstants.PORT_RACK_VALUE) .setLgxPortShelf("00") .build()) - .build()); + .setIndex(Uint8.ZERO) + .build())); if (serviceFormat.equals(ServiceFormat.ODU)) { - serviceAEndBuilder.setOduServiceRate(ODU4.class); + serviceAEndBuilder.setOduServiceRate(ODU4.VALUE); + } else if (serviceFormat.equals(ServiceFormat.OTU)) { + serviceAEndBuilder.setOtuServiceRate(OTU4.VALUE); } - if (serviceFormat.equals(ServiceFormat.OTU)) { - serviceAEndBuilder.setOtuServiceRate(OTU4.class); + if (!serviceLayer.equals(LayerProtocolName.ETH)) { + serviceAEndBuilder + .setEthernetAttributes(new EthernetAttributesBuilder().setSubrateEthSla(new SubrateEthSlaBuilder() + .setCommittedBurstSize(Uint16.valueOf(64)) + .setCommittedInfoRate(Uint32.valueOf(100000)) + .build()) + .build()); } return serviceAEndBuilder.build(); } - private String findFreeConfiguredNetworkPort(String nodeid) { - if (!this.networkMap.containsKey(nodeid)) { - return null; - } - Map netMap = this.networkMap.get(nodeid); - for (Map.Entry entry : netMap.entrySet()) { - if (!entry.getValue()) { - this.networkMap.get(nodeid).put(entry.getKey(), true); - return entry.getKey(); - } - } - return null; - } - - private void populateNetworkMap(String nodeid, String txPortName) { - Map netMap = new HashMap<>(); - netMap.put(txPortName, false); - if (!this.networkMap.containsKey(nodeid)) { - this.networkMap.put(nodeid, netMap); - } else if (!this.networkMap.get(nodeid).containsKey(txPortName)) { - this.networkMap.get(nodeid).putAll(netMap); - } - } - private ConnectionType getConnectionTypePhtnc(Collection endPoints) { + .onf.otcc.yang.tapi.connectivity.rev221121.create.connectivity.service.input.EndPoint> endPoints) { if (endPoints.stream().anyMatch(ep -> ep.getName().values().stream() .anyMatch(name -> name.getValue().contains("ROADM")))) { // EndPoints are ROADMs @@ -1499,7 +1809,7 @@ public final class ConnectivityUtils { } private ServiceFormat getServiceFormatPhtnc(Collection endPoints) { + .onf.otcc.yang.tapi.connectivity.rev221121.create.connectivity.service.input.EndPoint> endPoints) { if (endPoints.stream().anyMatch(ep -> ep.getName().values().stream() .anyMatch(name -> name.getValue().contains("ROADM")))) { // EndPoints are ROADMs @@ -1508,4 +1818,130 @@ public final class ConnectivityUtils { // EndPoints ar not ROADMs -> XPDR, MUXPDR, SWTICHPDR return ServiceFormat.OTU; } + + private ConnectionEndPoint getAssociatediODUCep(String spcXpdrNetwork) { + Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", spcXpdrNetwork.split("\\+")[0], + TapiStringConstants.XPDR).getBytes(StandardCharsets.UTF_8))).toString()); + Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", spcXpdrNetwork.split("\\+")[0], + TapiStringConstants.I_ODU, spcXpdrNetwork.split("\\+")[1]).getBytes(StandardCharsets.UTF_8))) + .toString()); + Uuid cepUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "CEP", + spcXpdrNetwork.split("\\+")[0], TapiStringConstants.I_ODU, spcXpdrNetwork.split("\\+")[1])) + .getBytes(StandardCharsets.UTF_8)).toString()); + return this.tapiContext.getTapiCEP(this.tapiTopoUuid, nodeUuid, nepUuid, cepUuid); + } + + private String getAssociatedNetworkPort(String spcXpdrClient, List xpdrNetworkTplist) { + for (String networkPort:xpdrNetworkTplist) { + if (networkPort.split("\\+")[0].equals(spcXpdrClient.split("\\+")[0])) { + return networkPort; + } + } + return null; + } + + private List getAssociatedClientsPort(List xpdrNetworkTplist) { + List clientPortList = new ArrayList<>(); + for (String networkPort:xpdrNetworkTplist) { + String nodeId = String.join("-", networkPort.split("\\+")[0].split("-")[0], + networkPort.split("\\+")[0].split("-")[1]); + String tpId = networkPort.split("\\+")[1]; + InstanceIdentifier mapIID = InstanceIdentifier.builder(Network.class) + .child(Nodes.class, new NodesKey(nodeId)) + .child(Mapping.class, new MappingKey(tpId)).build(); + try { + Optional optMapping = this.networkTransactionService.read(LogicalDatastoreType.CONFIGURATION, + mapIID).get(); + if (!optMapping.isPresent()) { + LOG.error("Couldnt find mapping for port {} of node {}", tpId, nodeId); + } + Mapping mapping = optMapping.orElseThrow(); + LOG.info("Mapping for node+port {}+{} = {}", nodeId, tpId, mapping); + String key = String.join("+", String.join("-", nodeId, tpId.split("\\-")[0]), + mapping.getConnectionMapLcp()); + LOG.info("Key to be added to list = {}", key); + if (!clientPortList.contains(key)) { + clientPortList.add(key); + } + } catch (InterruptedException | ExecutionException e) { + LOG.error("Couldnt read mapping from datastore", e); + return null; + } + + } + return clientPortList; + } + + private OpenroadmNodeType getOpenRoadmNodeType(List xpdrNodelist) { + List openroadmNodeTypeList = new ArrayList<>(); + for (String xpdrNode:xpdrNodelist) { + Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+",xpdrNode, TapiStringConstants.XPDR)) + .getBytes(StandardCharsets.UTF_8)).toString()); + InstanceIdentifier nodeIID = InstanceIdentifier.builder( + Context.class).augmentation(org.opendaylight.yang.gen.v1.urn + .onf.otcc.yang.tapi.topology.rev221121.Context1.class).child(TopologyContext.class) + .child(Topology.class, new TopologyKey(this.tapiTopoUuid)) + .child(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node.class, + new NodeKey(nodeUuid)).build(); + try { + Optional optNode + = this.networkTransactionService.read(LogicalDatastoreType.OPERATIONAL, nodeIID).get(); + if (optNode.isEmpty()) { + return null; + } + OpenroadmNodeType openroadmNodeType = OpenroadmNodeType.forName(optNode.orElseThrow().getName().get( + new NameKey("Node Type")).getValue()); + if (!openroadmNodeTypeList.contains(openroadmNodeType)) { + openroadmNodeTypeList.add(openroadmNodeType); + } + } catch (InterruptedException | ExecutionException e) { + LOG.error("Couldnt read node in topology", e); + return null; + } + } + // TODO for now check that there is only one type, otherwise error + if (openroadmNodeTypeList.size() != 1) { + LOG.error("More than one xpdr type. List = {}", openroadmNodeTypeList); + return null; + } + return openroadmNodeTypeList.get(0); + } + + private OwnedNodeEdgePoint createRoadmNep(String orNodeId, String tpId, + boolean withSip, OperationalState operState, AdministrativeState adminState, String nepPhotonicSublayer) { + + //TODO : complete implementation with SIP + Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", orNodeId, nepPhotonicSublayer, + tpId)).getBytes(StandardCharsets.UTF_8)).toString()); + Name nepName = new NameBuilder() + .setValueName(TapiStringConstants.PHTNC_MEDIA + "NodeEdgePoint") + .setValue(String.join("+", orNodeId, nepPhotonicSublayer, tpId)) + .build(); + List sclpqiList = new ArrayList<>(); + if (TapiStringConstants.MC.equals(nepPhotonicSublayer)) { + sclpqiList.add(new SupportedCepLayerProtocolQualifierInstancesBuilder() + .setLayerProtocolQualifier(PHOTONICLAYERQUALIFIERMC.VALUE) + .setNumberOfCepInstances(Uint64.valueOf(1)) + .build()); + } else { + sclpqiList.add(new SupportedCepLayerProtocolQualifierInstancesBuilder() + .setLayerProtocolQualifier(PHOTONICLAYERQUALIFIEROTSiMC.VALUE) + .setNumberOfCepInstances(Uint64.valueOf(1)) + .build()); + } + OwnedNodeEdgePoint onep = new OwnedNodeEdgePointBuilder() + .setUuid(nepUuid) + .setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA) + .setName(Map.of(nepName.key(), nepName)) + .setSupportedCepLayerProtocolQualifierInstances(sclpqiList) + .setDirection(Direction.BIDIRECTIONAL) + .setLinkPortRole(PortRole.SYMMETRIC) + .setAdministrativeState(adminState).setOperationalState(operState) + .setLifecycleState(LifecycleState.INSTALLED) + .build(); + + return onep; + } + }