X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=tapi%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Ftransportpce%2Ftapi%2Ftopology%2FTapiNetworkModelServiceImpl.java;h=8706dc301dc4fea8194387c18ee171fce8a4a2d0;hb=652c9098f8d97e6f5a723a7c55929f9351bffb5b;hp=5de39efb1e95ddf32b75ac41e191428408f1fa74;hpb=4fc7683a8eefbd3121f6c90c1444394b91973e8a;p=transportpce.git diff --git a/tapi/src/main/java/org/opendaylight/transportpce/tapi/topology/TapiNetworkModelServiceImpl.java b/tapi/src/main/java/org/opendaylight/transportpce/tapi/topology/TapiNetworkModelServiceImpl.java index 5de39efb1..8706dc301 100644 --- a/tapi/src/main/java/org/opendaylight/transportpce/tapi/topology/TapiNetworkModelServiceImpl.java +++ b/tapi/src/main/java/org/opendaylight/transportpce/tapi/topology/TapiNetworkModelServiceImpl.java @@ -8,159 +8,179 @@ package org.opendaylight.transportpce.tapi.topology; import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; +import java.util.Collections; import java.util.Comparator; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Optional; +import java.util.Set; import java.util.UUID; import java.util.concurrent.ExecutionException; import java.util.stream.Collectors; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.mdsal.common.api.LogicalDatastoreType; +import org.opendaylight.transportpce.common.NetworkUtils; +import org.opendaylight.transportpce.common.device.DeviceTransactionManager; +import org.opendaylight.transportpce.common.fixedflex.GridConstant; import org.opendaylight.transportpce.common.network.NetworkTransactionService; import org.opendaylight.transportpce.tapi.R2RTapiLinkDiscovery; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210426.mapping.Mapping; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210426.network.Nodes; +import org.opendaylight.transportpce.tapi.TapiStringConstants; +import org.opendaylight.transportpce.tapi.utils.TapiLink; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev231221.mapping.Mapping; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev231221.network.Nodes; +import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.TerminationPoint1; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev181019.NodeTypes; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.types.rev191129.XpdrNodeTypes; import org.opendaylight.yang.gen.v1.http.org.openroadm.equipment.states.types.rev191129.AdminStates; -import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev200327.xpdr.odu.switching.pools.OduSwitchingPools; -import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev200327.xpdr.odu.switching.pools.OduSwitchingPoolsBuilder; -import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev200327.xpdr.odu.switching.pools.odu.switching.pools.NonBlockingList; -import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev200327.xpdr.odu.switching.pools.odu.switching.pools.NonBlockingListBuilder; -import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev200327.xpdr.odu.switching.pools.odu.switching.pools.NonBlockingListKey; -import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev200529.OpenroadmNodeType; -import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev200529.xpdr.tp.supported.interfaces.SupportedInterfaceCapability; -import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev200529.xpdr.tp.supported.interfaces.SupportedInterfaceCapabilityBuilder; -import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev200529.xpdr.tp.supported.interfaces.SupportedInterfaceCapabilityKey; -import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.If100GE; -import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.If100GEODU4; -import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.If10GE; -import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.If10GEODU2; -import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.If10GEODU2e; -import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.If1GE; -import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.If1GEODU0; -import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.IfOCH; -import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.IfOCHOTU4ODU4; -import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.SupportedIfCapability; +import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev230526.xpdr.odu.switching.pools.OduSwitchingPools; +import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev230526.xpdr.odu.switching.pools.OduSwitchingPoolsBuilder; +import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev230526.xpdr.odu.switching.pools.odu.switching.pools.NonBlockingList; +import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev230526.xpdr.odu.switching.pools.odu.switching.pools.NonBlockingListBuilder; +import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev230526.xpdr.odu.switching.pools.odu.switching.pools.NonBlockingListKey; +import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev230526.OpenroadmNodeType; +import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev230526.OpenroadmTpType; +import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev230526.xpdr.tp.supported.interfaces.SupportedInterfaceCapability; +import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev230526.xpdr.tp.supported.interfaces.SupportedInterfaceCapabilityBuilder; +import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev230526.xpdr.tp.supported.interfaces.SupportedInterfaceCapabilityKey; +import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev230526.SupportedIfCapability; import org.opendaylight.yang.gen.v1.http.org.openroadm.switching.pool.types.rev191129.SwitchingPoolTypes; +import org.opendaylight.yang.gen.v1.http.org.openroadm.xponder.rev230526.xpdr.mode.attributes.supported.operational.modes.OperationalModeKey; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.NetworkId; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.Networks; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.NodeId; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.Network; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.NetworkKey; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.TpId; -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.Context; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.ContextBuilder; -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.LAYERPROTOCOLQUALIFIER; -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.TerminationDirection; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.TerminationState; -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.TotalSizeBuilder; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.capacity.pac.AvailableCapacityBuilder; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.capacity.pac.TotalPotentialCapacityBuilder; -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.global._class.NameKey; -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.ServiceInterfacePointBuilder; -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.connectivity.context.Connection; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectionBuilder; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.connectivity.context.ConnectionKey; -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.context.ConnectivityServiceKey; -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.EndPointKey; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.context.ConnectivityContext; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.dsr.rev181210.DIGITALSIGNALTYPE100GigE; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.dsr.rev181210.DIGITALSIGNALTYPE10GigELAN; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.odu.rev181210.ODUTYPEODU2; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.odu.rev181210.ODUTYPEODU2E; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.odu.rev181210.ODUTYPEODU4; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev181210.PHOTONICLAYERQUALIFIEROMS; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev181210.PHOTONICLAYERQUALIFIEROTSi; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.Context1; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.ForwardingRule; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.ProtectionType; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.RestorationPolicy; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.RuleType; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.context.TopologyContext; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.link.NodeEdgePoint; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.link.NodeEdgePointBuilder; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.link.NodeEdgePointKey; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.link.ResilienceTypeBuilder; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.NodeRuleGroup; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.NodeRuleGroupBuilder; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.NodeRuleGroupKey; -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.OwnedNodeEdgePointBuilder; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.OwnedNodeEdgePointKey; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.edge.point.MappedServiceInterfacePoint; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.edge.point.MappedServiceInterfacePointBuilder; -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.topology.rev181210.node.rule.group.Rule; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.RuleBuilder; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.RuleKey; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.risk.parameter.pac.RiskCharacteristic; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.risk.parameter.pac.RiskCharacteristicBuilder; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Link; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.LinkBuilder; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.LinkKey; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.NodeBuilder; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.NodeKey; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.context.Topology; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.context.TopologyBuilder; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.context.TopologyKey; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.transfer.cost.pac.CostCharacteristic; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.transfer.cost.pac.CostCharacteristicBuilder; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.transfer.timing.pac.LatencyCharacteristic; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.transfer.timing.pac.LatencyCharacteristicBuilder; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.validation.pac.ValidationMechanism; -import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.validation.pac.ValidationMechanismBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.node.TerminationPoint; +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.Context; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.ContextBuilder; +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.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.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.ServiceInterfacePointBuilder; +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.OwnedNodeEdgePoint1; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.OwnedNodeEdgePoint1Builder; +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.cep.list.ConnectionEndPointKey; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.Connection; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.ConnectionBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.connectivity.context.ConnectionKey; +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.context.ConnectivityServiceKey; +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.EndPointKey; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.context.ConnectivityContext; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.context.topology.context.topology.node.owned.node.edge.point.CepList; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.context.topology.context.topology.node.owned.node.edge.point.CepListBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev221121.NOTIFICATIONTYPEATTRIBUTEVALUECHANGE; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev221121.NotificationBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev221121.notification.ChangedAttributes; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev221121.notification.ChangedAttributesBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev221121.notification.ChangedAttributesKey; +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.PHOTONICLAYERQUALIFIEROMS; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.PHOTONICLAYERQUALIFIEROTS; +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.photonic.media.rev221121.context.topology.context.topology.node.owned.node.edge.point.PhotonicMediaNodeEdgePointSpec; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.Context1; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.FORWARDINGRULEMAYFORWARDACROSSGROUP; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.NodeEdgePointRef; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.RuleType; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.TOPOLOGYOBJECTTYPENODEEDGEPOINT; +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.InterRuleGroup; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.InterRuleGroupKey; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.NodeRuleGroup; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.NodeRuleGroupBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.NodeRuleGroupKey; +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.RiskParameterPac; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.RiskParameterPacBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.edge.point.MappedServiceInterfacePoint; +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.node.rule.group.NodeEdgePoint; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.NodeEdgePointBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.NodeEdgePointKey; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.Rule; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.RuleBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.RuleKey; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.risk.parameter.pac.RiskCharacteristic; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.risk.parameter.pac.RiskCharacteristicBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Link; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.LinkBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.LinkKey; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.NodeBuilder; +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.TopologyBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.context.TopologyKey; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.transfer.cost.pac.CostCharacteristic; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.transfer.cost.pac.CostCharacteristicBuilder; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.transfer.timing.pac.LatencyCharacteristic; +import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.transfer.timing.pac.LatencyCharacteristicBuilder; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.opendaylight.yangtools.yang.binding.Notification; import org.opendaylight.yangtools.yang.common.Uint16; import org.opendaylight.yangtools.yang.common.Uint32; import org.opendaylight.yangtools.yang.common.Uint64; +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Reference; import org.slf4j.Logger; import org.slf4j.LoggerFactory; + +@Component public class TapiNetworkModelServiceImpl implements TapiNetworkModelService { private static final Logger LOG = LoggerFactory.getLogger(TapiNetworkModelServiceImpl.class); - private static final String DSR = "DSR"; - private static final String I_ODU = "iODU"; - private static final String E_ODU = "eODU"; - 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 CLIENT = "-CLIENT"; - private static final String NETWORK = "-NETWORK"; - private static final String XPDR = "-XPDR"; - 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 final NetworkTransactionService networkTransactionService; - private Map sipMap; private final R2RTapiLinkDiscovery linkDiscovery; - - public TapiNetworkModelServiceImpl(final R2RTapiLinkDiscovery linkDiscovery, - NetworkTransactionService networkTransactionService) { + private final TapiLink tapiLink; + private final ConvertORToTapiTopology tapiFactory; + private String topologicalMode; + private final ConvertORTopoToTapiFullTopo tapiFullFactory; + private final NotificationPublishService notificationPublishService; + private Map sipMap = new HashMap<>(); + + @Activate + public TapiNetworkModelServiceImpl(@Reference NetworkTransactionService networkTransactionService, + @Reference DeviceTransactionManager deviceTransactionManager, + @Reference TapiLink tapiLink, + @Reference final NotificationPublishService notificationPublishService) { this.networkTransactionService = networkTransactionService; - this.sipMap = new HashMap<>(); - this.linkDiscovery = linkDiscovery; + this.linkDiscovery = new R2RTapiLinkDiscovery(networkTransactionService, deviceTransactionManager, tapiLink); + this.notificationPublishService = notificationPublishService; + this.tapiFactory = new ConvertORToTapiTopology(tapiTopoUuid); + this.tapiLink = tapiLink; + this.tapiFullFactory = new ConvertORTopoToTapiFullTopo(tapiTopoUuid, tapiLink); + this.topologicalMode = tapiFullFactory.getTopologicalMode(); } @Override @@ -199,25 +219,52 @@ public class TapiNetworkModelServiceImpl implements TapiNetworkModelService { } // Transform LCPs into ONEP Map onepMap = - new HashMap<>(transformDegToOnep(orNodeId, mapDeg)); - onepMap.putAll(transformSrgToOnep(orNodeId, mapSrg)); - - // create tapi Node - org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node roadmNode = - createRoadmTapiNode(orNodeId, onepMap); - mergeNodeinTopology(Map.of(roadmNode.key(), roadmNode)); - mergeSipsinContext(this.sipMap); - // TODO add states corresponding to device config -> based on mapping. - // This should be possible after Gilles work is merged - - // rdm to rdm link creation if neighbour roadm is mounted - LOG.info("checking if neighbor roadm exists"); - Map rdm2rdmLinks = this.linkDiscovery.readLLDP(new NodeId(orNodeId), orNodeVersion, - this.tapiTopoUuid); - if (!rdm2rdmLinks.isEmpty()) { - mergeLinkinTopology(rdm2rdmLinks); + new HashMap<>(transformSrgToOnep(orNodeId, mapSrg)); + LOG.debug("CreateTapiNode NetworkModelServiceImpl, TopologicalMode = {}", topologicalMode); + LOG.debug("TAPINETWORKMODELSERVICEIMPL call transformSRGtoONEP (OrNodeId {} ", orNodeId); + LOG.debug("TAPINETWORKMODELSERVICEIMPL SRG OTSNode of retrieved OnepMap {} ", + onepMap.entrySet().stream().filter(e -> e.getValue() + .getSupportedCepLayerProtocolQualifierInstances() + .contains(new SupportedCepLayerProtocolQualifierInstancesBuilder() + .setNumberOfCepInstances(Uint64.valueOf(1)) + .setLayerProtocolQualifier(PHOTONICLAYERQUALIFIEROTS.VALUE) + .build())) + .collect(Collectors.toList())); + if (topologicalMode.equals("Full")) { + onepMap.putAll(transformDegToOnep(orNodeId, mapDeg)); + LOG.debug("TAPINETWORKMODELSERVICEIMPL DEG+SRG OTSNode of retrieved OnepMap {} ", + onepMap.entrySet().stream().filter(e -> e.getValue() + .getSupportedCepLayerProtocolQualifierInstances() + .contains(new SupportedCepLayerProtocolQualifierInstancesBuilder() + .setNumberOfCepInstances(Uint64.valueOf(1)) + .setLayerProtocolQualifier(PHOTONICLAYERQUALIFIEROTS.VALUE) + .build())) + .collect(Collectors.toList())); + LOG.debug("TAPINETWORKMODELSERVICEIMPL DEG+SRG complete retrieved OnepMap {} ", onepMap); + // create tapi Node + Node roadmNode = createRoadmTapiNode(orNodeId, onepMap); + mergeNodeinTopology(Map.of(roadmNode.key(), roadmNode)); + mergeSipsinContext(this.sipMap); + // TODO add states corresponding to device config -> based on mapping. + // This should be possible after Gilles work is merged + + // rdm to rdm link creation if neighbour roadm is mounted + LOG.info("checking if neighbor roadm exists"); + Map rdm2rdmLinks = this.linkDiscovery.readLLDP(new NodeId(orNodeId), orNodeVersion, + this.tapiTopoUuid); + if (!rdm2rdmLinks.isEmpty()) { + mergeLinkinTopology(rdm2rdmLinks); + } + } else { + // create tapi Node + Node roadmNode = createRoadmTapiNode("ROADMINFRA", onepMap); + mergeNodeinTopology(Map.of(roadmNode.key(), roadmNode)); + mergeSipsinContext(this.sipMap); + // TODO add states corresponding to device config -> based on mapping. + // This should be possible after Gilles work is merged } + LOG.info("TAPI node for or node {} successfully merged", orNodeId); } else if (NodeTypes.Xpdr.getIntValue() == node.getNodeInfo().getNodeType().getIntValue()) { List networkMappings = node.nonnullMapping().values() .stream().filter(k -> k.getLogicalConnectionPoint() @@ -225,74 +272,227 @@ public class TapiNetworkModelServiceImpl implements TapiNetworkModelService { Map xpdrMap = new HashMap<>(); for (Mapping mapping : networkMappings) { Integer xpdrNb = Integer.parseInt(mapping.getLogicalConnectionPoint().split("XPDR")[1].split("-")[0]); - String nodeId = node.getNodeId() + XPDR + xpdrNb; + String nodeId = node.getNodeId() + TapiStringConstants.XXPDR + xpdrNb; if (!xpdrMap.containsKey(xpdrNb)) { List xpdrNetMaps = node.nonnullMapping().values() - .stream().filter(k -> k.getLogicalConnectionPoint() - .contains("XPDR" + xpdrNb + NETWORK)).collect(Collectors.toList()); + .stream().filter(k -> k.getLogicalConnectionPoint() + .contains("XPDR" + xpdrNb + TapiStringConstants.NETWORK)).collect(Collectors.toList()); List xpdrClMaps = node.nonnullMapping().values() - .stream().filter(k -> k.getLogicalConnectionPoint() - .contains("XPDR" + xpdrNb + CLIENT)).collect(Collectors.toList()); + .stream().filter(k -> k.getLogicalConnectionPoint() + .contains("XPDR" + xpdrNb + TapiStringConstants.CLIENT)).collect(Collectors.toList()); xpdrMap.put(xpdrNb, node.getNodeId()); // create switching pool OduSwitchingPools oorOduSwitchingPool = createSwitchPoolForXpdr( - mapping.getXponderType().getIntValue(), xpdrClMaps, xpdrNetMaps, xpdrNb); + mapping.getXpdrType().getIntValue(), xpdrClMaps, xpdrNetMaps, xpdrNb); // node transformation Map nodeMap = new HashMap<>(transformXpdrToTapiNode( - nodeId, xpdrClMaps, xpdrNetMaps, mapping.getXponderType(), oorOduSwitchingPool, - mapping.getSupportedInterfaceCapability())); - + nodeId, xpdrClMaps, xpdrNetMaps, mapping.getXpdrType(), oorOduSwitchingPool)); // add nodes and sips to tapi context mergeNodeinTopology(nodeMap); mergeSipsinContext(this.sipMap); } } + LOG.info("TAPI node for or node {} successfully merged", orNodeId); } // Device not managed yet } + @Override + public void updateTapiTopology(String nodeId, Mapping mapping) { + List uuids = getChangedNodeUuids(nodeId, mapping); + + List changedOneps = updateNeps(mapping, uuids); + updateLinks(changedOneps, mapping); + sendNotification(changedOneps, mapping); + + LOG.info("Updated TAPI topology successfully."); + } + + @SuppressWarnings("rawtypes") + private void sendNotification(List changedOneps, Mapping mapping) { + Notification notification = new NotificationBuilder() + .setNotificationType(NOTIFICATIONTYPEATTRIBUTEVALUECHANGE.VALUE) +// .setTargetObjectType(ObjectType.NODEEDGEPOINT) + //TODO: Change this : modification in Models 2.4 does not provide for Object type Node EdgePoint + .setTargetObjectType(TOPOLOGYOBJECTTYPENODEEDGEPOINT.VALUE) + .setChangedAttributes(getChangedAttributes(changedOneps, mapping)) + .setUuid(tapiTopoUuid) + .build(); + try { + notificationPublishService.putNotification(notification); + } catch (InterruptedException e) { + LOG.error("Could not send notification"); + } + } + + private Map getChangedAttributes(List changedOneps, + Mapping mapping) { + Map changedAttributes = new HashMap<>(); + for (Uuid nep : changedOneps) { + changedAttributes.put(new ChangedAttributesKey(nep.getValue()), + new ChangedAttributesBuilder().setValueName(nep.getValue()) + .setOldValue(mapping.getPortOperState().equals("InService") ? "OutOfService" : "InService") + .setNewValue(mapping.getPortOperState()) + .build()); + } + return changedAttributes; + } + + private void updateLinks(List changedOneps, Mapping mapping) { + try { + InstanceIdentifier topoIID = InstanceIdentifier.builder(Context.class) + .augmentation(Context1.class).child(TopologyContext.class) + .child(Topology.class, new TopologyKey(tapiTopoUuid)) + .build(); + Optional optTopology = this.networkTransactionService + .read(LogicalDatastoreType.OPERATIONAL, topoIID).get(); + if (optTopology.isEmpty()) { + LOG.error("Could not update TAPI links"); + return; + } + int nbAffectedLinks = 0; + LOG.info("UUIDofAffectedONEPS = {} ", changedOneps.toString()); + for (Link link : optTopology.orElseThrow().nonnullLink().values()) { + List linkNeps = Objects.requireNonNull(link.getNodeEdgePoint()).values().stream() + .map(NodeEdgePointRef::getNodeEdgePointUuid).collect(Collectors.toList()); + LOG.info("LinkEndPointsUUID = {} for link Name {}", linkNeps.toString(), link.getName().toString()); + if (!Collections.disjoint(changedOneps, linkNeps)) { + InstanceIdentifier linkIID = InstanceIdentifier.builder(Context.class) + .augmentation(Context1.class).child(TopologyContext.class) + .child(Topology.class, new TopologyKey(tapiTopoUuid)) + .child(Link.class, new LinkKey(link.getUuid())).build(); + Link linkblr = new LinkBuilder().setUuid(link.getUuid()) + .setAdministrativeState(transformAdminState(mapping.getPortAdminState())) + .setOperationalState(transformOperState(mapping.getPortOperState())).build(); + this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, linkIID, linkblr); + nbAffectedLinks++ ; + } + } + LOG.info("AffectedLinksNb = {} ", nbAffectedLinks); + this.networkTransactionService.commit().get(); + } catch (InterruptedException | ExecutionException e) { + LOG.error("Could not update TAPI links"); + } + } + + private List updateNeps(Mapping mapping, List uuids) { + List changedOneps = new ArrayList<>(); + for (Uuid nodeUuid : uuids) { + try { + InstanceIdentifier nodeIID = InstanceIdentifier.builder(Context.class) + .augmentation(Context1.class).child(TopologyContext.class) + .child(Topology.class, new TopologyKey(tapiTopoUuid)).child(Node.class, new NodeKey(nodeUuid)) + .build(); + Optional optionalNode = this.networkTransactionService.read( + LogicalDatastoreType.OPERATIONAL, nodeIID).get(); + if (optionalNode.isPresent()) { + Node node = optionalNode.orElseThrow(); + List oneps = node.getOwnedNodeEdgePoint().values().stream() + .filter(onep -> ((Name) onep.getName().values().toArray()[0]).getValue() + .contains(mapping.getLogicalConnectionPoint())).collect(Collectors.toList()); + for (OwnedNodeEdgePoint onep : oneps) { + changedOneps.add(onep.getUuid()); + updateSips(mapping, onep); + CepList cepList = getUpdatedCeps(mapping, onep); + InstanceIdentifier onepIID = InstanceIdentifier.builder(Context.class) + .augmentation(Context1.class).child(TopologyContext.class) + .child(Topology.class, new TopologyKey(tapiTopoUuid)) + .child(Node.class, new NodeKey(nodeUuid)) + .child(OwnedNodeEdgePoint.class, new OwnedNodeEdgePointKey(onep.getUuid())) + .build(); + OwnedNodeEdgePoint onepblr = new OwnedNodeEdgePointBuilder().setUuid(onep.getUuid()) + .addAugmentation(new OwnedNodeEdgePoint1Builder().setCepList(cepList).build()) + .setAdministrativeState(transformAdminState(mapping.getPortAdminState())) + .setOperationalState(transformOperState(mapping.getPortOperState())).build(); + this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, onepIID, onepblr); + LOG.info("UpdatedNEP {} of UUID {} to ADMIN {} OPER {}", + onep.getName().toString(), onep.getUuid(), + transformAdminState(mapping.getPortAdminState()), + transformOperState(mapping.getPortOperState())); + } + this.networkTransactionService.commit().get(); + } + } catch (InterruptedException | ExecutionException e) { + LOG.error("Could not update TAPI NEP"); + } + } + return changedOneps; + } + + private CepList getUpdatedCeps(Mapping mapping, OwnedNodeEdgePoint onep) { + OwnedNodeEdgePoint1 onep1 = onep.augmentation(OwnedNodeEdgePoint1.class); + Map cepMap = new HashMap<>(); + if (onep1 != null && onep1.getCepList() != null && onep1.getCepList().getConnectionEndPoint() != null) { + for (Map.Entry entry : onep1.getCepList().getConnectionEndPoint() + .entrySet()) { + ConnectionEndPoint cep = new ConnectionEndPointBuilder(entry.getValue()) + .setOperationalState(transformOperState(mapping.getPortOperState())).build(); + cepMap.put(entry.getKey(), cep); + } + } + return new CepListBuilder().setConnectionEndPoint(cepMap).build(); + } + + private List getChangedNodeUuids(String nodeId, Mapping mapping) { + List uuids = new ArrayList<>(); + if (nodeId.contains("ROADM")) { + uuids.add(new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId, TapiStringConstants.PHTNC_MEDIA)) + .getBytes(StandardCharsets.UTF_8)).toString())); + } else if (nodeId.contains("PDR")) { + LOG.debug("ANALYSING change in {}", nodeId); + int xpdrNb = Integer.parseInt(mapping.getLogicalConnectionPoint().split("XPDR")[1].split("-")[0]); + String xpdrNodeId = nodeId + TapiStringConstants.XXPDR + xpdrNb; + uuids.add(new Uuid(UUID.nameUUIDFromBytes((String.join("+", xpdrNodeId, TapiStringConstants.XPDR)) + .getBytes(StandardCharsets.UTF_8)).toString())); + } else { + LOG.error("Updating this device is currently not supported"); + return uuids; + } + return uuids; + } + + private void updateSips(Mapping mapping, OwnedNodeEdgePoint onep) { + if (onep.getMappedServiceInterfacePoint() == null + || onep.getMappedServiceInterfacePoint().size() == 0) { + return; + } + for (MappedServiceInterfacePoint msip : onep.getMappedServiceInterfacePoint().values()) { + InstanceIdentifier sipIID = InstanceIdentifier + .builder(Context.class) + .child(ServiceInterfacePoint.class, + new ServiceInterfacePointKey(msip.getServiceInterfacePointUuid())) + .build(); + ServiceInterfacePoint sipblr = new ServiceInterfacePointBuilder() + .setUuid(msip.getServiceInterfacePointUuid()) + .setAdministrativeState(transformAdminState(mapping.getPortAdminState())) + .setOperationalState(transformOperState(mapping.getPortOperState())).build(); + this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, sipIID, sipblr); + } + + } + private Map transformXpdrToTapiNode(String nodeId, List xpdrClMaps, List xpdrNetMaps, XpdrNodeTypes xponderType, - OduSwitchingPools oorOduSwitchingPool, - List> - supportedInterfaceCapability) { + OduSwitchingPools oorOduSwitchingPool) { Map nodeMap = new HashMap<>(); LOG.info("creation of a DSR/ODU node for {}", nodeId); - Uuid nodeUuidDsr = new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId, DSR)) - .getBytes(Charset.forName("UTF-8"))).toString()); + Uuid nodeUuidDsr = new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId, TapiStringConstants.XPDR)) + .getBytes(StandardCharsets.UTF_8)).toString()); Name nameDsr = new NameBuilder().setValueName("dsr/odu node name").setValue( - String.join("+", nodeId, DSR)).build(); - List dsrLayerProtocols = Arrays.asList(LayerProtocolName.DSR, - LayerProtocolName.ODU); - org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology - .Node dsrNode = createTapiXpdrNode(Map.of(nameDsr.key(), nameDsr), dsrLayerProtocols, - nodeId, nodeUuidDsr, xpdrClMaps, xpdrNetMaps, xponderType, oorOduSwitchingPool, - supportedInterfaceCapability); - - nodeMap.put(dsrNode.key(), dsrNode); - - // node creation [otsi] - LOG.info("creation of an OTSi node for {}", nodeId); - Uuid nodeUuidOtsi = new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId, OTSI)) - .getBytes(Charset.forName("UTF-8"))).toString()); + String.join("+", nodeId, TapiStringConstants.XPDR)).build(); Name nameOtsi = new NameBuilder().setValueName("otsi node name").setValue( - String.join("+", nodeId, OTSI)).build(); - List otsiLayerProtocols = Arrays.asList(LayerProtocolName.PHOTONICMEDIA); - org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology - .Node otsiNode = createTapiXpdrNode(Map.of(nameOtsi.key(), nameOtsi), otsiLayerProtocols, - nodeId, nodeUuidOtsi, xpdrClMaps, xpdrNetMaps, xponderType, null, - supportedInterfaceCapability); - - nodeMap.put(otsiNode.key(), otsiNode); - - // transitional link cration between network nep of DSR/ODU node and iNep of otsi node - LOG.info("creation of transitional links between DSR/ODU and OTSi nodes"); - Map linkMap = createTapiTransitionalLinks(nodeId, xpdrNetMaps, nodeUuidDsr, - nodeUuidOtsi); - mergeLinkinTopology(linkMap); + String.join("+", nodeId, TapiStringConstants.XPDR)).build(); + Name nameNodeType = new NameBuilder().setValueName("Node Type") + .setValue(getNodeType(xponderType)).build(); + Set dsrLayerProtocols = Set.of(LayerProtocolName.DSR, LayerProtocolName.ODU, + LayerProtocolName.DIGITALOTN, LayerProtocolName.PHOTONICMEDIA); + Node dsrNode = createTapiXpdrNode(Map.of(nameDsr.key(), nameDsr, nameOtsi.key(), nameOtsi, nameNodeType.key(), + nameNodeType), dsrLayerProtocols, nodeId, nodeUuidDsr, xpdrClMaps, xpdrNetMaps, xponderType, + oorOduSwitchingPool); + nodeMap.put(dsrNode.key(), dsrNode); return nodeMap; } @@ -302,7 +502,7 @@ public class TapiNetworkModelServiceImpl implements TapiNetworkModelService { switch (xpdrType) { case 1: // Tpdr - return createTpdrSwitchPool(); + return createTpdrSwitchPool(xpdrNetMaps); case 2: // Mux return createMuxSwitchPool(xpdrClMaps, xpdrNetMaps, xpdrNb); @@ -316,41 +516,79 @@ public class TapiNetworkModelServiceImpl implements TapiNetworkModelService { } private Map transformSrgToOnep(String orNodeId, - Map> mapSrg) { - Map onepMap = new HashMap<>(); + Map> mapSrg) { + LOG.debug("CREATENEP transformSrgToOnep, ListOfMapping {}, of NodeId {} ", mapSrg, orNodeId); + Map tpMap = new HashMap<>(); + //List tpList = new ArrayList<>(); for (Map.Entry> entry : mapSrg.entrySet()) { // For each srg node. Loop through the LCPs and create neps and sips for PP for (Mapping m:entry.getValue()) { - if (!m.getLogicalConnectionPoint().contains("PP")) { - LOG.info("LCP {} is not an external TP of SRG node", m.getLogicalConnectionPoint()); + String tpId = m.getLogicalConnectionPoint(); + String overlayNodeId = String.join("-", orNodeId, tpId.split("\\-")[0]); + if (!tpId.contains("PP")) { + LOG.info("LCP {} is not an external TP of SRG node", tpId); continue; } - Map srgNeps = - createRoadmNeps(orNodeId, m.getLogicalConnectionPoint(), true, - transformOperState(m.getPortOperState()), transformAdminState(m.getPortAdminState())); - onepMap.putAll(srgNeps); + int counter = 50; + do { + counter--; + try { + Thread.sleep(1); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + LOG.debug("Waiting until PP is backported in Topology, Exception raised", e); + } + } while (getNetworkTerminationPoint1FromDatastore(overlayNodeId, tpId) == null && counter != 0); + if (getNetworkTerminationPoint1FromDatastore(overlayNodeId, tpId) != null) { + //tpList.add(getNetworkTerminationPointFromDatastore(overlayNodeId, tpId)); + tpMap.put(tpId, getNetworkTerminationPoint1FromDatastore(overlayNodeId, tpId)); + LOG.debug("LCP {} is not empty for augmentation TP1", tpId); + } else { + LOG.error("CREATENEP transformSrgToOnep, No Tp1 found in topology for LCP {}, of NodeId {} ", + tpId, overlayNodeId); + } + if (getNetworkTerminationPoint11FromDatastore(overlayNodeId, tpId) != null) { + LOG.info("LCP {} is not empty for augmentation TP11", tpId); + } else { + LOG.error("CREATENEP transformSrgToOnep, No Tp11 found in topology for LCP {}, of NodeId {} ", + tpId, overlayNodeId); + } } } - return onepMap; + LOG.debug("TransformSRGToONep for tps {}, of NodeId {} ", + tpMap.entrySet().stream().map(tp -> tp.getKey()).collect(Collectors.toList()).toString(), orNodeId); + return populateNepsForRdmNode(orNodeId, tpMap, false, TapiStringConstants.PHTNC_MEDIA_OTS); } private Map transformDegToOnep(String orNodeId, - Map> mapDeg) { - Map onepMap = new HashMap<>(); + Map> mapDeg) { + LOG.debug("CREATENEP transformDegToOnep, ListOfMapping {}, of NodeId {} ", + mapDeg.toString(), orNodeId); + Map degOnepMap = new HashMap<>(); + Map tpMap = new HashMap<>(); + //List tpList = new ArrayList<>(); for (Map.Entry> entry : mapDeg.entrySet()) { // For each degree node. Loop through the LCPs and create neps and sips for TTP for (Mapping m:entry.getValue()) { - if (!m.getLogicalConnectionPoint().contains("TTP")) { - LOG.info("LCP {} is not an external TP of DEGREE node", m.getLogicalConnectionPoint()); + String tpId = m.getLogicalConnectionPoint(); + String overlayNodeId = String.join("-", orNodeId, tpId.split("\\-")[0]); + if (!tpId.contains("TTP")) { + LOG.info("LCP {} is not an external TP of DEGREE node", tpId); continue; } - Map degNeps = - createRoadmNeps(orNodeId, m.getLogicalConnectionPoint(), false, - transformOperState(m.getPortOperState()), transformAdminState(m.getPortAdminState())); - onepMap.putAll(degNeps); + if (getNetworkTerminationPoint1FromDatastore(overlayNodeId, tpId) != null) { + //tpList.add(getNetworkTerminationPointFromDatastore(overlayNodeId, tpId)); + tpMap.put(tpId, getNetworkTerminationPoint1FromDatastore(overlayNodeId, tpId)); + LOG.info("LCP {} is not empty for augmentation TP1", tpId); + } else { + LOG.error("CREATENEP transformDegToOnep, No Tp found in topology for LCP {}, of NodeId {} ", + tpId, overlayNodeId); + } } } - return onepMap; + degOnepMap.putAll(populateNepsForRdmNode(orNodeId, tpMap, false, TapiStringConstants.PHTNC_MEDIA_OTS)); + degOnepMap.putAll(populateNepsForRdmNode(orNodeId, tpMap, false, TapiStringConstants.PHTNC_MEDIA_OMS)); + return degOnepMap; } private List getRoadmNodelist(List mappingList) { @@ -384,7 +622,7 @@ public class TapiNetworkModelServiceImpl implements TapiNetworkModelService { LOG.error("No topology object present. Error deleting node {}", nodeId); return; } - topology = optTopology.get(); + topology = optTopology.orElseThrow(); } catch (InterruptedException | ExecutionException e) { LOG.error("Couldnt read tapi topology from datastore", e); } @@ -397,10 +635,15 @@ public class TapiNetworkModelServiceImpl implements TapiNetworkModelService { return; } if (nodeId.contains("ROADM")) { - // Node is in photonic media layer and UUID can be built from nodeId + PHTN_MEDIA - Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId, PHTNC_MEDIA)) - .getBytes(Charset.forName("UTF-8"))).toString()); - deleteNodeFromTopo(nodeUuid); + if (topologicalMode.equals("Full")) { + // Node is in photonic media layer and UUID can be built from nodeId + PHTN_MEDIA + Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId, + TapiStringConstants.PHTNC_MEDIA)).getBytes(StandardCharsets.UTF_8)).toString()); + deleteNodeFromTopo(nodeUuid); + } else { + LOG.info("Abstracted Topo Mode in TAPI topology Datastore for OR topology representation. Node" + + " {} is not represented in the abstraction and will not be deleted", nodeId); + } } if (nodeId.contains("XPDR") || nodeId.contains("SPDR") || nodeId.contains("MXPDR")) { // Node is either XPDR, MXPDR or SPDR. Retrieve nodes from topology and check names @@ -430,7 +673,7 @@ public class TapiNetworkModelServiceImpl implements TapiNetworkModelService { LOG.error("No context object present in datastore."); return; } - context = optContext.get(); + context = optContext.orElseThrow(); } catch (InterruptedException | ExecutionException e) { LOG.error("Couldnt read tapi context from datastore", e); } @@ -450,49 +693,52 @@ public class TapiNetworkModelServiceImpl implements TapiNetworkModelService { } } - private Node createTapiXpdrNode(Map nameMap, List layerProtocols, + private Node createTapiXpdrNode(Map nameMap, Set layerProtocols, String nodeId, Uuid nodeUuid, List xpdrClMaps, List xpdrNetMaps, - XpdrNodeTypes xponderType, OduSwitchingPools oorOduSwitchingPool, - List> supportedInterfaceCapability) { - Map onepl = new HashMap<>(); - Map nodeRuleGroupList = new HashMap<>(); + XpdrNodeTypes xponderType, OduSwitchingPools oorOduSwitchingPool) { + Map ruleList = new HashMap<>(); + Set ruleTypes = new HashSet<>(); + ruleTypes.add(RuleType.FORWARDING); Rule rule = new RuleBuilder() .setLocalId("forward") - .setForwardingRule(ForwardingRule.MAYFORWARDACROSSGROUP) - .setRuleType(RuleType.FORWARDING) + .setForwardingRule(FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE) + .setRuleType(ruleTypes) .build(); ruleList.put(rule.key(), rule); - if (layerProtocols.contains(LayerProtocolName.DSR)) { - // neps for dsr/odu layer - Map dsroduNeps = - createXpdrDsrOduNeps(nodeId, xpdrClMaps, xpdrNetMaps, xponderType, supportedInterfaceCapability); - onepl.putAll(dsroduNeps); - nodeRuleGroupList = createNodeRuleGroupForDsrNode(nodeId, oorOduSwitchingPool, ruleList, onepl); - } else if (layerProtocols.contains(LayerProtocolName.PHOTONICMEDIA)) { - // neps for photonic layer - Map phtmdNeps = - createXpdrPhtnMdNeps(nodeId, xpdrNetMaps, supportedInterfaceCapability); - onepl.putAll(phtmdNeps); - nodeRuleGroupList = createNodeRuleGroupForOtsiNode(nodeId, xpdrNetMaps, ruleList); - } else { + if (!(layerProtocols.contains(LayerProtocolName.DSR) + && layerProtocols.contains(LayerProtocolName.PHOTONICMEDIA))) { LOG.error("Undefined LayerProtocolName for {} node {}", nameMap.get(nameMap.keySet().iterator().next()) - .getValueName(), nameMap.get(nameMap.keySet().iterator().next()).getValue()); + .getValueName(), nameMap.get(nameMap.keySet().iterator().next()).getValue()); } + Map onepl = new HashMap<>(); + onepl.putAll(createXpdrDsrOduNeps(nodeId, xpdrClMaps, xpdrNetMaps, xponderType)); + Map nodeRuleGroupList = createNodeRuleGroupForDsrNode( + nodeId, oorOduSwitchingPool, ruleList, onepl); + onepl.putAll(createXpdrPhtnMdNeps(nodeId, xpdrNetMaps)); + LOG.debug("TapiNetworkModelServiceImpl line 721, total NEP map = {}", onepl.toString()); + // Empty random creation of mandatory fields for avoiding errors.... CostCharacteristic costCharacteristic = new CostCharacteristicBuilder() .setCostAlgorithm("Restricted Shortest Path - RSP") .setCostName("HOP_COUNT") - .setCostValue("12345678") + .setCostValue(TapiStringConstants.COST_HOP_VALUE) .build(); LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder() - .setFixedLatencyCharacteristic("12345678") - .setQueingLatencyCharacteristic("12345678") - .setJitterCharacteristic("12345678") - .setWanderCharacteristic("12345678") + .setFixedLatencyCharacteristic(TapiStringConstants.FIXED_LATENCY_VALUE) + .setQueuingLatencyCharacteristic(TapiStringConstants.QUEING_LATENCY_VALUE) + .setJitterCharacteristic(TapiStringConstants.JITTER_VALUE) + .setWanderCharacteristic(TapiStringConstants.WANDER_VALUE) .setTrafficPropertyName("FIXED_LATENCY") .build(); - return new NodeBuilder() + RiskCharacteristic riskCharacteristic = new RiskCharacteristicBuilder() + .setRiskCharacteristicName("risk characteristic") + .setRiskIdentifierList(Set.of("risk identifier1", "risk identifier2")) + .build(); + RiskParameterPac riskParamPac = new RiskParameterPacBuilder() + .setRiskCharacteristic(Map.of(riskCharacteristic.key(), riskCharacteristic)) + .build(); + Node builtNode = new NodeBuilder() .setUuid(nodeUuid) .setName(nameMap) .setLayerProtocolName(layerProtocols) @@ -509,80 +755,97 @@ public class TapiNetworkModelServiceImpl implements TapiNetworkModelService { .setDeliveryOrderCharacteristic("delivery order") .setUnavailableTimeCharacteristic("unavailable time") .setServerIntegrityProcessCharacteristic("server integrity process") + .setRiskParameterPac(riskParamPac) .build(); + List pmnepspecList = new ArrayList<>(); + for (Map.Entry entry : + builtNode.getOwnedNodeEdgePoint().entrySet()) { + if (!entry.getValue().getSupportedCepLayerProtocolQualifierInstances().stream() + .filter(sclpqi -> sclpqi.getLayerProtocolQualifier().equals(PHOTONICLAYERQUALIFIEROTS.VALUE)) + .collect(Collectors.toList()).isEmpty() + && entry.getValue().augmentationOrElseThrow(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang + .tapi.photonic.media.rev221121.OwnedNodeEdgePoint1.class) != null + && entry.getValue().augmentationOrElseThrow(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi + .photonic.media.rev221121.OwnedNodeEdgePoint1.class).getPhotonicMediaNodeEdgePointSpec() + != null) { + pmnepspecList.add(entry.getValue().augmentationOrElseThrow(org.opendaylight.yang.gen.v1.urn.onf.otcc + .yang.tapi.photonic.media.rev221121.OwnedNodeEdgePoint1.class).getPhotonicMediaNodeEdgePointSpec()); + } + } + LOG.debug("TapiNetworkModelServiceImpl line 775, List of non empty PMNEPSEC is = {}", pmnepspecList); + return builtNode; } private Map createXpdrPhtnMdNeps(String nodeId, - List xpdrNetMaps, List> supportedInterfaceCapability) { + List xpdrNetMaps) { Map onepl = new HashMap<>(); - // iNep creation on otsi node - for (int i = 0; i < xpdrNetMaps.size(); i++) { - Uuid nepUuid1 = new Uuid(UUID.nameUUIDFromBytes( - (String.join("+", nodeId, I_OTSI, xpdrNetMaps.get(i).getLogicalConnectionPoint())) - .getBytes(Charset.forName("UTF-8"))) - .toString()); - Name onedName = new NameBuilder() - .setValueName("iNodeEdgePoint") - .setValue(String.join("+", nodeId, I_OTSI, xpdrNetMaps.get(i).getLogicalConnectionPoint())) - .build(); - - OwnedNodeEdgePoint onep = createNep(nepUuid1, xpdrNetMaps.get(i).getLogicalConnectionPoint(), - Map.of(onedName.key(), onedName), LayerProtocolName.PHOTONICMEDIA, LayerProtocolName.PHOTONICMEDIA, - true, String.join("+", nodeId, I_OTSI), supportedInterfaceCapability, - transformOperState(xpdrNetMaps.get(i).getPortOperState()), - transformAdminState(xpdrNetMaps.get(i).getPortAdminState())); - onepl.put(onep.key(), onep); - } // eNep creation on otsi node for (int i = 0; i < xpdrNetMaps.size(); i++) { Uuid nepUuid2 = new Uuid(UUID.nameUUIDFromBytes( - (String.join("+", nodeId, E_OTSI, xpdrNetMaps.get(i).getLogicalConnectionPoint())) - .getBytes(Charset.forName("UTF-8"))).toString()); + (String.join("+", nodeId, TapiStringConstants.PHTNC_MEDIA_OTS, + xpdrNetMaps.get(i).getLogicalConnectionPoint())).getBytes(StandardCharsets.UTF_8)).toString()); Name onedName = new NameBuilder() - .setValueName("eNodeEdgePoint") - .setValue(String.join("+", nodeId, E_OTSI, xpdrNetMaps.get(i).getLogicalConnectionPoint())) - .build(); + .setValueName("eNodeEdgePoint") + .setValue(String.join("+", nodeId, TapiStringConstants.PHTNC_MEDIA_OTS, + xpdrNetMaps.get(i).getLogicalConnectionPoint())) + .build(); + + List newSupIfCapList = + new ArrayList<>(xpdrNetMaps.get(i).getSupportedInterfaceCapability()); + List opModeList = new ArrayList<>(); + if (xpdrNetMaps.get(i).getSupportedOperationalMode() != null) { + opModeList.addAll(xpdrNetMaps.get(i).getSupportedOperationalMode()); + } - OwnedNodeEdgePoint onep = createNep(nepUuid2, xpdrNetMaps.get(i).getLogicalConnectionPoint(), - Map.of(onedName.key(), onedName), LayerProtocolName.PHOTONICMEDIA, LayerProtocolName.PHOTONICMEDIA, - false, String.join("+", nodeId, E_OTSI), supportedInterfaceCapability, - transformOperState(xpdrNetMaps.get(i).getPortOperState()), - transformAdminState(xpdrNetMaps.get(i).getPortAdminState())); + OwnedNodeEdgePoint onep = createNep(nodeId, nepUuid2, xpdrNetMaps.get(i).getLogicalConnectionPoint(), + Map.of(onedName.key(), onedName), LayerProtocolName.PHOTONICMEDIA, LayerProtocolName.PHOTONICMEDIA, + true, String.join("+", nodeId, TapiStringConstants.PHTNC_MEDIA_OTS), newSupIfCapList, opModeList, + transformOperState(xpdrNetMaps.get(i).getPortOperState()), + transformAdminState(xpdrNetMaps.get(i).getPortAdminState())); onepl.put(onep.key(), onep); } - // Photonic Media Nep creation on otsi node + // OTSi_MC Nep creation on otsi node for (int i = 0; i < xpdrNetMaps.size(); i++) { Uuid nepUuid3 = new Uuid(UUID.nameUUIDFromBytes( - (String.join("+", nodeId, PHTNC_MEDIA, xpdrNetMaps.get(i).getLogicalConnectionPoint())) - .getBytes(Charset.forName("UTF-8"))).toString()); + (String.join("+", nodeId, TapiStringConstants.OTSI_MC, + xpdrNetMaps.get(i).getLogicalConnectionPoint())).getBytes(StandardCharsets.UTF_8)).toString()); Name onedName = new NameBuilder() - .setValueName("PhotMedNodeEdgePoint") - .setValue(String.join("+", nodeId, PHTNC_MEDIA, xpdrNetMaps.get(i).getLogicalConnectionPoint())) - .build(); + .setValueName("PhotMedNodeEdgePoint") + .setValue(String.join("+", nodeId, TapiStringConstants.OTSI_MC, + xpdrNetMaps.get(i).getLogicalConnectionPoint())) + .build(); + + List newSupIfCapList = + new ArrayList<>(xpdrNetMaps.get(i).getSupportedInterfaceCapability()); + List opModeList = new ArrayList<>(); + if (xpdrNetMaps.get(i).getSupportedOperationalMode() != null) { + opModeList.addAll(xpdrNetMaps.get(i).getSupportedOperationalMode()); + } - OwnedNodeEdgePoint onep = createNep(nepUuid3, xpdrNetMaps.get(i).getLogicalConnectionPoint(), - Map.of(onedName.key(), onedName), LayerProtocolName.PHOTONICMEDIA, LayerProtocolName.PHOTONICMEDIA, - false, String.join("+", nodeId, PHTNC_MEDIA), supportedInterfaceCapability, - transformOperState(xpdrNetMaps.get(i).getPortOperState()), - transformAdminState(xpdrNetMaps.get(i).getPortAdminState())); + OwnedNodeEdgePoint onep = createNep(nodeId, nepUuid3, xpdrNetMaps.get(i).getLogicalConnectionPoint(), + Map.of(onedName.key(), onedName), LayerProtocolName.PHOTONICMEDIA, LayerProtocolName.PHOTONICMEDIA, + false, String.join("+", nodeId, TapiStringConstants.OTSI_MC), newSupIfCapList, opModeList, + transformOperState(xpdrNetMaps.get(i).getPortOperState()), + transformAdminState(xpdrNetMaps.get(i).getPortAdminState())); onepl.put(onep.key(), onep); } return onepl; } private Map createXpdrDsrOduNeps(String nodeId, List xpdrClMaps, - List xpdrNetMaps, XpdrNodeTypes xponderType, - List> supportedInterfaceCapability) { + List xpdrNetMaps, + XpdrNodeTypes xponderType) { Map onepl = new HashMap<>(); // client nep creation on DSR node for (int i = 0; i < xpdrClMaps.size(); i++) { - LOG.info("Client NEP = {}", String.join("+", nodeId, DSR, xpdrClMaps.get(i).getLogicalConnectionPoint())); + LOG.info("Client NEP = {}", String.join("+", nodeId, TapiStringConstants.DSR, + xpdrClMaps.get(i).getLogicalConnectionPoint())); Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes( - (String.join("+", nodeId, DSR, xpdrClMaps.get(i).getLogicalConnectionPoint())) - .getBytes(Charset.forName("UTF-8"))).toString()); - NameBuilder nameBldr = new NameBuilder().setValue( - String.join("+", nodeId, DSR, xpdrClMaps.get(i).getLogicalConnectionPoint())); + (String.join("+", nodeId, TapiStringConstants.DSR, + xpdrClMaps.get(i).getLogicalConnectionPoint())).getBytes(StandardCharsets.UTF_8)).toString()); + NameBuilder nameBldr = new NameBuilder().setValue(String.join("+", nodeId, + TapiStringConstants.DSR, xpdrClMaps.get(i).getLogicalConnectionPoint())); Name name; if (OpenroadmNodeType.TPDR.getName().equalsIgnoreCase(xponderType.getName())) { name = nameBldr.setValueName("100G-tpdr").build(); @@ -590,49 +853,61 @@ public class TapiNetworkModelServiceImpl implements TapiNetworkModelService { name = nameBldr.setValueName("NodeEdgePoint_C").build(); } - OwnedNodeEdgePoint onep = createNep(nepUuid, xpdrClMaps.get(i).getLogicalConnectionPoint(), - Map.of(name.key(), name), LayerProtocolName.DSR, LayerProtocolName.DSR, true, - String.join("+", nodeId, DSR), supportedInterfaceCapability, - transformOperState(xpdrClMaps.get(i).getPortOperState()), - transformAdminState(xpdrClMaps.get(i).getPortAdminState())); + List newSupIfCapList = + new ArrayList<>(xpdrClMaps.get(i).getSupportedInterfaceCapability()); + + OwnedNodeEdgePoint onep = createNep(nodeId, nepUuid, xpdrClMaps.get(i).getLogicalConnectionPoint(), + Map.of(name.key(), name), LayerProtocolName.DSR, LayerProtocolName.DSR, true, + String.join("+", nodeId, TapiStringConstants.DSR), newSupIfCapList, null, + transformOperState(xpdrClMaps.get(i).getPortOperState()), + transformAdminState(xpdrClMaps.get(i).getPortAdminState())); onepl.put(onep.key(), onep); } // network nep creation on I_ODU node for (int i = 0; i < xpdrNetMaps.size(); i++) { - LOG.info("iODU NEP = {}", String.join("+", nodeId, I_ODU, xpdrNetMaps.get(i).getLogicalConnectionPoint())); + LOG.info("iODU NEP = {}", String.join("+", nodeId, TapiStringConstants.I_ODU, + xpdrNetMaps.get(i).getLogicalConnectionPoint())); Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes( - (String.join("+", nodeId, I_ODU, xpdrNetMaps.get(i).getLogicalConnectionPoint())) - .getBytes(Charset.forName("UTF-8"))).toString()); + (String.join("+", nodeId, TapiStringConstants.I_ODU, + xpdrNetMaps.get(i).getLogicalConnectionPoint())).getBytes(StandardCharsets.UTF_8)).toString()); Name onedName = new NameBuilder() - .setValueName("iNodeEdgePoint_N") - .setValue(String.join("+", nodeId, I_ODU, xpdrNetMaps.get(i).getLogicalConnectionPoint())) - .build(); + .setValueName("iNodeEdgePoint_N") + .setValue(String.join("+", nodeId, TapiStringConstants.I_ODU, + xpdrNetMaps.get(i).getLogicalConnectionPoint())) + .build(); - OwnedNodeEdgePoint onep = createNep(nepUuid, xpdrNetMaps.get(i).getLogicalConnectionPoint(), - Map.of(onedName.key(), onedName), - LayerProtocolName.ODU, LayerProtocolName.DSR, false, - String.join("+", nodeId, I_ODU), supportedInterfaceCapability, - transformOperState(xpdrNetMaps.get(i).getPortOperState()), - transformAdminState(xpdrNetMaps.get(i).getPortAdminState())); + List newSupIfCapList = + new ArrayList<>(xpdrNetMaps.get(i).getSupportedInterfaceCapability()); + OwnedNodeEdgePoint onep = createNep(nodeId, nepUuid, xpdrNetMaps.get(i).getLogicalConnectionPoint(), + Map.of(onedName.key(), onedName), + LayerProtocolName.ODU, LayerProtocolName.DSR, true, + String.join("+", nodeId, TapiStringConstants.I_ODU), newSupIfCapList, null, + transformOperState(xpdrNetMaps.get(i).getPortOperState()), + transformAdminState(xpdrNetMaps.get(i).getPortAdminState())); onepl.put(onep.key(), onep); } // network nep creation on E_ODU node - for (int i = 0; i < xpdrNetMaps.size(); i++) { - LOG.info("eODU NEP = {}", String.join("+", nodeId, E_ODU, xpdrNetMaps.get(i).getLogicalConnectionPoint())); + for (int i = 0; i < xpdrClMaps.size(); i++) { + LOG.info("eODU NEP = {}", String.join("+", nodeId, TapiStringConstants.E_ODU, + xpdrClMaps.get(i).getLogicalConnectionPoint())); Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes( - (String.join("+", nodeId, E_ODU, xpdrNetMaps.get(i).getLogicalConnectionPoint())) - .getBytes(Charset.forName("UTF-8"))).toString()); + (String.join("+", nodeId, TapiStringConstants.E_ODU, + xpdrClMaps.get(i).getLogicalConnectionPoint())).getBytes(StandardCharsets.UTF_8)).toString()); Name onedName = new NameBuilder() - .setValueName("eNodeEdgePoint_N") - .setValue(String.join("+", nodeId, E_ODU, xpdrNetMaps.get(i).getLogicalConnectionPoint())) - .build(); + .setValueName("eNodeEdgePoint_N") + .setValue(String.join("+", nodeId, TapiStringConstants.E_ODU, + xpdrClMaps.get(i).getLogicalConnectionPoint())) + .build(); + + List newSupIfCapList = + new ArrayList<>(xpdrClMaps.get(i).getSupportedInterfaceCapability()); - OwnedNodeEdgePoint onep = createNep(nepUuid, xpdrNetMaps.get(i).getLogicalConnectionPoint(), - Map.of(onedName.key(), onedName), - LayerProtocolName.ODU, LayerProtocolName.DSR, true, - String.join("+", nodeId, E_ODU), supportedInterfaceCapability, - transformOperState(xpdrNetMaps.get(i).getPortOperState()), - transformAdminState(xpdrNetMaps.get(i).getPortAdminState())); + OwnedNodeEdgePoint onep = createNep(nodeId, nepUuid, xpdrClMaps.get(i).getLogicalConnectionPoint(), + Map.of(onedName.key(), onedName), + LayerProtocolName.ODU, LayerProtocolName.DSR, true, + String.join("+", nodeId, TapiStringConstants.E_ODU), newSupIfCapList, null, + transformOperState(xpdrClMaps.get(i).getPortOperState()), + transformAdminState(xpdrClMaps.get(i).getPortAdminState())); onepl.put(onep.key(), onep); } return onepl; @@ -645,179 +920,124 @@ public class TapiNetworkModelServiceImpl implements TapiNetworkModelService { private AdministrativeState transformAdminState(String adminString) { AdminStates adminState = org.opendaylight.transportpce.networkmodel.util.TopologyUtils - .setNetworkAdminState(adminString); + .setNetworkAdminState(adminString); return adminState.equals(AdminStates.InService) ? AdministrativeState.UNLOCKED : AdministrativeState.LOCKED; } - private OwnedNodeEdgePoint createNep(Uuid nepUuid, String tpid, Map nepNames, - LayerProtocolName nepProtocol, LayerProtocolName nodeProtocol, boolean withSip, - String keyword, - List> supportedInterfaceCapability, - OperationalState operState, AdministrativeState adminState) { + private OwnedNodeEdgePoint createNep(String nodeId, Uuid nepUuid, String tpid, Map nepNames, + LayerProtocolName nepProtocol, LayerProtocolName nodeProtocol, boolean withSip, String keyword, + List sicList, List opModeList, + OperationalState operState, AdministrativeState adminState) { + List sicListTemp = new ArrayList<>(); + List keyedOpModeList = new ArrayList<>(); + for (SupportedIfCapability supInterCapa : sicList) { + SupportedInterfaceCapability supIfCapa = new SupportedInterfaceCapabilityBuilder() + .withKey(new SupportedInterfaceCapabilityKey(supInterCapa)) + .setIfCapType(supInterCapa) + .build(); + sicListTemp.add(supIfCapa); + } + Collection sicColl = sicListTemp; OwnedNodeEdgePointBuilder onepBldr = new OwnedNodeEdgePointBuilder() .setUuid(nepUuid) .setLayerProtocolName(nepProtocol) .setName(nepNames); if (withSip) { - onepBldr.setMappedServiceInterfacePoint(createMSIP(1, nepProtocol, tpid, keyword, - supportedInterfaceCapability, operState, adminState)); + onepBldr.setMappedServiceInterfacePoint(this.tapiFactory.createMSIP(1, nepProtocol, tpid, keyword, + sicColl, operState, adminState)); + this.sipMap.putAll(tapiFactory.getTapiSips()); } LOG.debug("Node layer {}", nodeProtocol.getName()); - onepBldr.setSupportedCepLayerProtocolQualifier(createSupportedLayerProtocolQualifier( - supportedInterfaceCapability, nodeProtocol)); - onepBldr.setLinkPortDirection(PortDirection.BIDIRECTIONAL).setLinkPortRole(PortRole.SYMMETRIC) + onepBldr.setSupportedCepLayerProtocolQualifierInstances( + this.tapiFactory.createSupportedCepLayerProtocolQualifier(sicColl, nepProtocol)); + onepBldr.setDirection(Direction.BIDIRECTIONAL).setLinkPortRole(PortRole.SYMMETRIC) .setAdministrativeState(adminState).setOperationalState(operState) - .setLifecycleState(LifecycleState.INSTALLED).setTerminationDirection(TerminationDirection.BIDIRECTIONAL) - .setTerminationState(TerminationState.TERMINATEDBIDIRECTIONAL); + .setLifecycleState(LifecycleState.INSTALLED); + if (keyword.contains(TapiStringConstants.OTSI_MC) || keyword.contains(TapiStringConstants.PHTNC_MEDIA_OTS)) { + if (opModeList == null || opModeList.isEmpty()) { + for (SupportedInterfaceCapability sic : sicColl) { + String ifCapType = sic.getIfCapType().toString().split("\\{")[0]; + if (("IfOCHOTUCnODUCn").equals(ifCapType) || ("IfOCHOTUCnODUCnUniregen").equals(ifCapType) + || ("IfOCHOTUCnODUCnRegen").equals(ifCapType)) { + keyedOpModeList.add(new OperationalModeKey("400G")); + LOG.warn(TopologyUtils.NOOPMODEDECLARED + "400G rate available", tpid); + break; + } + } + keyedOpModeList.add(new OperationalModeKey("100G")); + LOG.warn(TopologyUtils.NOOPMODEDECLARED + "100G rate available", tpid); + } else { + for (String opMode : opModeList) { + keyedOpModeList.add(new OperationalModeKey(opMode)); + } + } + Map freqWidthMap = new HashMap<>(); + if (getNetworkTerminationPointFromDatastore(nodeId, tpid) != null) { + freqWidthMap = tapiFactory.getXpdrUsedWavelength(getNetworkTerminationPointFromDatastore(nodeId, tpid)); + } else { + LOG.error("CREATENEP, No Tp found in topology for LCP {}, of NodeId {} ", tpid, nodeId); + } + onepBldr = tapiFactory.addPayloadStructureAndPhotSpecToOnep(nodeId, freqWidthMap, keyedOpModeList, + sicColl, onepBldr, keyword); + LOG.debug("TapiNetworkServiceImpl line982, onep = {}", onepBldr.build()); + } return onepBldr.build(); } - private Map createRoadmNeps(String orNodeId, String tpId, - boolean withSip, OperationalState operState, - AdministrativeState adminState) { - Map onepMap = new HashMap<>(); - // PHOTONIC MEDIA nep - Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", orNodeId, PHTNC_MEDIA, tpId)) - .getBytes(Charset.forName("UTF-8"))) - .toString()); - Name nepName = new NameBuilder() - .setValueName("NodeEdgePoint name") - .setValue(String.join("+", orNodeId, PHTNC_MEDIA, tpId)) - .build(); - OwnedNodeEdgePointBuilder onepBldr = new OwnedNodeEdgePointBuilder() - .setUuid(nepUuid) - .setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA) - .setName(Map.of(nepName.key(), nepName)) - .setSupportedCepLayerProtocolQualifier(List.of(PHOTONICLAYERQUALIFIEROMS.class)) - .setLinkPortDirection(PortDirection.BIDIRECTIONAL).setLinkPortRole(PortRole.SYMMETRIC) - .setAdministrativeState(adminState).setOperationalState(operState) - .setLifecycleState(LifecycleState.INSTALLED).setTerminationDirection(TerminationDirection.BIDIRECTIONAL) - .setTerminationState(TerminationState.TERMINATEDBIDIRECTIONAL); - OwnedNodeEdgePoint onep = onepBldr.build(); - onepMap.put(onep.key(), onep); - - // MC nep - Uuid nepUuid1 = new Uuid(UUID.nameUUIDFromBytes((String.join("+", orNodeId, MC, tpId)) - .getBytes(Charset.forName("UTF-8"))) - .toString()); - Name nepName1 = new NameBuilder() - .setValueName("NodeEdgePoint name") - .setValue(String.join("+", orNodeId, MC, tpId)) + private Node createRoadmTapiNode(String orNodeId, Map onepMap) { + // UUID and Node Names + Uuid nodeUuid; + Name nodeNames; + if (orNodeId.equals("ROADMINFRA")) { + nodeUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.RDM_INFRA + .getBytes(Charset.forName("UTF-8"))).toString()); + nodeNames = new NameBuilder().setValueName("roadm node name").setValue(TapiStringConstants.RDM_INFRA) .build(); - OwnedNodeEdgePointBuilder onepBldr1 = new OwnedNodeEdgePointBuilder() - .setUuid(nepUuid1) - .setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA) - .setName(Map.of(nepName1.key(), nepName1)) - .setSupportedCepLayerProtocolQualifier(List.of(PHOTONICLAYERQUALIFIEROMS.class)) - .setLinkPortDirection(PortDirection.BIDIRECTIONAL).setLinkPortRole(PortRole.SYMMETRIC) - .setAdministrativeState(adminState).setOperationalState(operState) - .setLifecycleState(LifecycleState.INSTALLED).setTerminationDirection(TerminationDirection.BIDIRECTIONAL) - .setTerminationState(TerminationState.TERMINATEDBIDIRECTIONAL); - if (withSip) { - onepBldr1.setMappedServiceInterfacePoint(createMSIP(1, LayerProtocolName.PHOTONICMEDIA, - tpId, String.join("+", orNodeId, MC), null, operState, adminState)); - } - OwnedNodeEdgePoint onep1 = onepBldr1.build(); - onepMap.put(onep1.key(), onep1); - - // OTSiMC nep - Uuid nepUuid2 = new Uuid(UUID.nameUUIDFromBytes((String.join("+", orNodeId, OTSI_MC, tpId)) - .getBytes(Charset.forName("UTF-8"))) - .toString()); - Name nepName2 = new NameBuilder() - .setValueName("NodeEdgePoint name") - .setValue(String.join("+", orNodeId, OTSI_MC, tpId)) - .build(); - OwnedNodeEdgePointBuilder onepBldr2 = new OwnedNodeEdgePointBuilder() - .setUuid(nepUuid2) - .setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA) - .setName(Map.of(nepName2.key(), nepName2)) - .setSupportedCepLayerProtocolQualifier(List.of(PHOTONICLAYERQUALIFIEROMS.class)) - .setLinkPortDirection(PortDirection.BIDIRECTIONAL).setLinkPortRole(PortRole.SYMMETRIC) - .setAdministrativeState(adminState).setOperationalState(operState) - .setLifecycleState(LifecycleState.INSTALLED).setTerminationDirection(TerminationDirection.BIDIRECTIONAL) - .setTerminationState(TerminationState.TERMINATEDBIDIRECTIONAL); - OwnedNodeEdgePoint onep2 = onepBldr2.build(); - onepMap.put(onep2.key(), onep2); - return onepMap; - } - - private Map - createMSIP(int nb, LayerProtocolName layerProtocol, String tpid, String nodeid, - List> supportedInterfaceCapability, - OperationalState operState, AdministrativeState adminState) { - Map msipl = new HashMap<>(); - for (int i = 0; i < nb; i++) { - Uuid sipUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", "SIP", nodeid, - tpid)).getBytes(Charset.forName("UTF-8"))).toString()); - MappedServiceInterfacePoint msip = new MappedServiceInterfacePointBuilder() - .setServiceInterfacePointUuid(sipUuid).build(); - org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.tapi.context.ServiceInterfacePoint sip - = createSIP(sipUuid, layerProtocol, tpid, nodeid, supportedInterfaceCapability, - operState, adminState); - this.sipMap.put(sip.key(), sip); - LOG.info("SIP created {}", sip.getUuid()); - // this.tapiSips.put(sip.key(), sip); - msipl.put(msip.key(), msip); + } else { + nodeUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", orNodeId, + TapiStringConstants.PHTNC_MEDIA)).getBytes(StandardCharsets.UTF_8)).toString()); + nodeNames = new NameBuilder().setValueName("roadm node name") + .setValue(String.join("+", orNodeId, TapiStringConstants.PHTNC_MEDIA)).build(); } - return msipl; - } - - private ServiceInterfacePoint createSIP(Uuid sipUuid, LayerProtocolName layerProtocol, String tpid, String nodeid, - List> supportedInterfaceCapability, - OperationalState operState, AdministrativeState adminState) { - // TODO: what value should be set in total capacity and available capacity - LOG.info("SIP name = {}", String.join("+", nodeid, tpid)); - Name sipName = new NameBuilder() - .setValueName("SIP name") - .setValue(String.join("+", nodeid, tpid)) - .build(); - return new ServiceInterfacePointBuilder() - .setUuid(sipUuid) - .setName(Map.of(sipName.key(), sipName)) - .setLayerProtocolName(layerProtocol) - .setAdministrativeState(adminState) - .setOperationalState(operState) - .setLifecycleState(LifecycleState.INSTALLED) - .setAvailableCapacity(new AvailableCapacityBuilder().build()) - .setTotalPotentialCapacity(new TotalPotentialCapacityBuilder().build()) - .setSupportedLayerProtocolQualifier(createSupportedLayerProtocolQualifier(supportedInterfaceCapability, - layerProtocol)) - .build(); - } - - private org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.Node - createRoadmTapiNode(String orNodeId, Map oneplist) { - // UUID - Uuid nodeUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", orNodeId, - PHTNC_MEDIA)).getBytes(Charset.forName("UTF-8"))).toString()); - // Names - Name nodeNames = new NameBuilder().setValueName("roadm node name") - .setValue(String.join("+", orNodeId, PHTNC_MEDIA)).build(); + Name nameNodeType = new NameBuilder().setValueName("Node Type") + .setValue(OpenroadmNodeType.ROADM.getName()).build(); // Protocol Layer - List layerProtocols = Arrays.asList(LayerProtocolName.PHOTONICMEDIA); + Set layerProtocols = Set.of(LayerProtocolName.PHOTONICMEDIA); // Empty random creation of mandatory fields for avoiding errors.... CostCharacteristic costCharacteristic = new CostCharacteristicBuilder() .setCostAlgorithm("Restricted Shortest Path - RSP") .setCostName("HOP_COUNT") - .setCostValue("12345678") + .setCostValue(TapiStringConstants.COST_HOP_VALUE) .build(); LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder() - .setFixedLatencyCharacteristic("12345678") - .setQueingLatencyCharacteristic("12345678") - .setJitterCharacteristic("12345678") - .setWanderCharacteristic("12345678") + .setFixedLatencyCharacteristic(TapiStringConstants.COST_HOP_VALUE) + .setQueuingLatencyCharacteristic(TapiStringConstants.QUEING_LATENCY_VALUE) + .setJitterCharacteristic(TapiStringConstants.JITTER_VALUE) + .setWanderCharacteristic(TapiStringConstants.WANDER_VALUE) .setTrafficPropertyName("FIXED_LATENCY") .build(); + RiskCharacteristic riskCharacteristic = new RiskCharacteristicBuilder() + .setRiskCharacteristicName("risk characteristic") + .setRiskIdentifierList(Set.of("risk identifier1", "risk identifier2")) + .build(); + RiskParameterPac riskParamPac = new RiskParameterPacBuilder() + .setRiskCharacteristic(Map.of(riskCharacteristic.key(), riskCharacteristic)) + .build(); + Map nodeRuleGroupMap + = tapiFactory.createAllNodeRuleGroupForRdmNode(topologicalMode, nodeUuid, orNodeId, onepMap.values()); + Map interRuleGroupMap + = tapiFactory.createInterRuleGroupForRdmNode(topologicalMode, nodeUuid, orNodeId, + nodeRuleGroupMap.entrySet().stream().map(e -> e.getKey()).collect(Collectors.toList())); return new NodeBuilder() .setUuid(nodeUuid) - .setName(Map.of(nodeNames.key(), nodeNames)) + .setName(Map.of(nodeNames.key(), nodeNames, nameNodeType.key(), nameNodeType)) .setLayerProtocolName(layerProtocols) .setAdministrativeState(AdministrativeState.UNLOCKED) .setOperationalState(OperationalState.ENABLED) .setLifecycleState(LifecycleState.INSTALLED) - .setOwnedNodeEdgePoint(oneplist) - .setNodeRuleGroup(createNodeRuleGroupForRdmNode(nodeUuid, oneplist.values())) + .setOwnedNodeEdgePoint(onepMap) + .setNodeRuleGroup(nodeRuleGroupMap) + .setInterRuleGroup(interRuleGroupMap) .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic)) .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic)) .setErrorCharacteristic("error") @@ -826,175 +1046,74 @@ public class TapiNetworkModelServiceImpl implements TapiNetworkModelService { .setDeliveryOrderCharacteristic("delivery order") .setUnavailableTimeCharacteristic("unavailable time") .setServerIntegrityProcessCharacteristic("server integrity process") + .setRiskParameterPac(riskParamPac) .build(); } - private Map createNodeRuleGroupForRdmNode(Uuid nodeUuid, - Collection onepl) { - Map - nepMap = new HashMap<>(); - for (OwnedNodeEdgePoint onep : onepl) { - org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePoint - nep = new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group - .NodeEdgePointBuilder() - .setTopologyUuid(tapiTopoUuid) - .setNodeUuid(nodeUuid) - .setNodeEdgePointUuid(onep.key().getUuid()) - .build(); - nepMap.put(nep.key(), nep); - } - Map nodeRuleGroupMap = new HashMap<>(); - Map ruleList = new HashMap<>(); - Rule rule = new RuleBuilder() - .setLocalId("forward") - .setForwardingRule(ForwardingRule.MAYFORWARDACROSSGROUP) - .setRuleType(RuleType.FORWARDING) - .build(); - ruleList.put(rule.key(), rule); - NodeRuleGroup nodeRuleGroup = new NodeRuleGroupBuilder() - .setUuid(new Uuid(UUID.nameUUIDFromBytes(("rdm infra node rule group") - .getBytes(Charset.forName("UTF-8"))).toString())) - .setRule(ruleList) - .setNodeEdgePoint(nepMap) - .build(); - nodeRuleGroupMap.put(nodeRuleGroup.key(), nodeRuleGroup); - return nodeRuleGroupMap; - } - - private Map createTapiTransitionalLinks(String nodeId, List xpdrNetMaps, Uuid nodeUuidDsr, - Uuid nodeUuidOtsi) { - Map linkMap = new HashMap<>(); - for (Mapping mapping : xpdrNetMaps) { - Map nepList = new HashMap<>(); - String sourceKey = String.join("+", nodeId, I_ODU, mapping.getLogicalConnectionPoint()); - Uuid sourceUuidTp = new Uuid(UUID.nameUUIDFromBytes( - (String.join("+", nodeId, I_ODU, mapping.getLogicalConnectionPoint())) - .getBytes(Charset.forName("UTF-8"))).toString()); - String destKey = String.join("+", nodeId, I_OTSI, mapping.getLogicalConnectionPoint()); - Uuid destUuidTp = new Uuid(UUID.nameUUIDFromBytes( - (String.join("+", nodeId, I_OTSI, mapping.getLogicalConnectionPoint())) - .getBytes(Charset.forName("UTF-8"))).toString()); - NodeEdgePoint sourceNep = new NodeEdgePointBuilder() - .setTopologyUuid(this.tapiTopoUuid) - .setNodeUuid(nodeUuidDsr) - .setNodeEdgePointUuid(sourceUuidTp) - .build(); - nepList.put(sourceNep.key(), sourceNep); - NodeEdgePoint destNep = new NodeEdgePointBuilder() - .setTopologyUuid(this.tapiTopoUuid) - .setNodeUuid(nodeUuidOtsi) - .setNodeEdgePointUuid(destUuidTp) - .build(); - nepList.put(destNep.key(), destNep); - Name linkName = new NameBuilder().setValueName("transitional link name") - .setValue(String.join("--",nodeId, sourceKey, destKey)) - .build(); - CostCharacteristic costCharacteristic = new CostCharacteristicBuilder() - .setCostAlgorithm("Restricted Shortest Path - RSP") - .setCostName("HOP_COUNT") - .setCostValue("12345678") - .build(); - LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder() - .setFixedLatencyCharacteristic("12345678") - .setQueingLatencyCharacteristic("12345678") - .setJitterCharacteristic("12345678") - .setWanderCharacteristic("12345678") - .setTrafficPropertyName("FIXED_LATENCY") - .build(); - RiskCharacteristic riskCharacteristic = new RiskCharacteristicBuilder() - .setRiskCharacteristicName("risk characteristic") - .setRiskIdentifierList(List.of("risk identifier1", "risk identifier2")) - .build(); - ValidationMechanism validationMechanism = new ValidationMechanismBuilder() - .setValidationMechanism("validation mechanism") - .setValidationRobustness("validation robustness") - .setLayerProtocolAdjacencyValidated("layer protocol adjacency") - .build(); - Link transiLink = new LinkBuilder() - .setUuid(new Uuid( - UUID.nameUUIDFromBytes((String.join("--", nodeId, sourceKey, destKey)) - .getBytes(Charset.forName("UTF-8"))) - .toString())) - .setName(Map.of(linkName.key(), linkName)) - .setTransitionedLayerProtocolName(Arrays.asList(LayerProtocolName.ODU.getName(), - LayerProtocolName.PHOTONICMEDIA.getName())) - .setNodeEdgePoint(nepList) - .setLayerProtocolName(Arrays.asList(LayerProtocolName.PHOTONICMEDIA, LayerProtocolName.ODU)) - .setDirection(ForwardingDirection.BIDIRECTIONAL) - .setAvailableCapacity(new AvailableCapacityBuilder().setTotalSize( - new TotalSizeBuilder().setUnit(CapacityUnit.GBPS).setValue(Uint64.valueOf(100)).build()) - .build()) - .setResilienceType(new ResilienceTypeBuilder().setProtectionType(ProtectionType.NOPROTECTON) - .setRestorationPolicy(RestorationPolicy.NA) - .build()) - .setAdministrativeState(transformAdminState(mapping.getPortAdminState())) - .setOperationalState(transformOperState(mapping.getPortOperState())) - .setLifecycleState(LifecycleState.INSTALLED) - .setTotalPotentialCapacity(new TotalPotentialCapacityBuilder().setTotalSize( - new TotalSizeBuilder().setUnit(CapacityUnit.GBPS).setValue(Uint64.valueOf(100)).build()) - .build()) - .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic)) - .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic)) - .setRiskCharacteristic(Map.of(riskCharacteristic.key(), riskCharacteristic)) - .setErrorCharacteristic("error") - .setLossCharacteristic("loss") - .setRepeatDeliveryCharacteristic("repeat delivery") - .setDeliveryOrderCharacteristic("delivery order") - .setUnavailableTimeCharacteristic("unavailable time") - .setServerIntegrityProcessCharacteristic("server integrity process") - .setValidationMechanism(Map.of(validationMechanism.key(), validationMechanism)) + private OduSwitchingPools createTpdrSwitchPool(List xpdrNetMaps) { + Map nblMap = new HashMap<>(); + int count = 1; + for (int i = 1; i <= xpdrNetMaps.size(); i++) { + LOG.info("XPDr net LCP = {}", xpdrNetMaps.get(i - 1).getLogicalConnectionPoint()); + LOG.info("XPDr net associated LCP = {}", xpdrNetMaps.get(i - 1).getConnectionMapLcp()); + TpId tpid1 = new TpId(xpdrNetMaps.get(i - 1).getLogicalConnectionPoint()); + TpId tpid2 = new TpId(xpdrNetMaps.get(i - 1).getConnectionMapLcp()); + Set tpList = new HashSet<>(); + tpList.add(tpid1); + tpList.add(tpid2); + NonBlockingList nbl = new NonBlockingListBuilder() + .setNblNumber(Uint16.valueOf(count)) + .setTpList(tpList) .build(); - linkMap.put(transiLink.key(), transiLink); + nblMap.put(nbl.key(), nbl); + count++; } - // return a map of links and then we can do merge the corresponding link map into the topology context - return linkMap; - } - - private OduSwitchingPools createTpdrSwitchPool() { - return new OduSwitchingPoolsBuilder().build(); + return new OduSwitchingPoolsBuilder() + .setNonBlockingList(nblMap) + .setSwitchingPoolNumber(Uint16.valueOf(1)) + .build(); } private OduSwitchingPools createSwtchSwitchPool(List xpdrClMaps, List xpdrNetMaps, Integer xpdrNb) { - List tpl = new ArrayList<>(); + Set tpl = new HashSet<>(); TpId tpId = null; for (int i = 1; i <= xpdrClMaps.size(); i++) { - tpId = new TpId("XPDR" + xpdrNb + CLIENT + i); + tpId = new TpId("XPDR" + xpdrNb + TapiStringConstants.CLIENT + i); tpl.add(tpId); } for (int i = 1; i <= xpdrNetMaps.size(); i++) { - tpId = new TpId("XPDR" + xpdrNb + NETWORK + i); + tpId = new TpId("XPDR" + xpdrNb + TapiStringConstants.NETWORK + i); tpl.add(tpId); } Map nbMap = new HashMap<>(); NonBlockingList nbl = new NonBlockingListBuilder() - .setNblNumber(Uint16.valueOf(1)) - .setTpList(tpl) - .build(); + .setNblNumber(Uint16.valueOf(1)) + .setTpList(tpl) + .build(); nbMap.put(nbl.key(),nbl); return new OduSwitchingPoolsBuilder() - .setSwitchingPoolNumber(Uint16.valueOf(1)) - .setSwitchingPoolType(SwitchingPoolTypes.NonBlocking) - .setNonBlockingList(nbMap) - .build(); + .setSwitchingPoolNumber(Uint16.valueOf(1)) + .setSwitchingPoolType(SwitchingPoolTypes.NonBlocking) + .setNonBlockingList(nbMap) + .build(); } private OduSwitchingPools createMuxSwitchPool(List xpdrClMaps, List xpdrNetMaps, Integer xpdrNb) { Map nbMap = new HashMap<>(); for (int i = 1; i <= xpdrClMaps.size(); i++) { - List tpList = new ArrayList<>(); - TpId tpId = new TpId("XPDR" + xpdrNb + CLIENT + i); + Set tpList = new HashSet<>(); + TpId tpId = new TpId("XPDR" + xpdrNb + TapiStringConstants.CLIENT + i); tpList.add(tpId); tpId = new TpId("XPDR" + xpdrNb + "-NETWORK1"); tpList.add(tpId); NonBlockingList nbl = new NonBlockingListBuilder() - .setNblNumber(Uint16.valueOf(i)) - .setTpList(tpList) - .setAvailableInterconnectBandwidth(Uint32.valueOf(xpdrNetMaps.size() * 10L)) - .setInterconnectBandwidthUnit(Uint32.valueOf(1000000000)) - .build(); + .setNblNumber(Uint16.valueOf(i)) + .setTpList(tpList) + .setAvailableInterconnectBandwidth(Uint32.valueOf(xpdrNetMaps.size() * 10L)) + .setInterconnectBandwidthUnit(Uint32.valueOf(1000000000)) + .build(); nbMap.put(nbl.key(),nbl); } return new OduSwitchingPoolsBuilder() @@ -1004,134 +1123,67 @@ public class TapiNetworkModelServiceImpl implements TapiNetworkModelService { .build(); } - private Map createNodeRuleGroupForOtsiNode(String nodeId, - List xpdrNetMaps, - Map ruleList) { - Map nodeRuleGroupMap = new HashMap<>(); - // create NodeRuleGroup - int count = 1; - for (Mapping tpMapping : xpdrNetMaps) { - Map - nepList = new HashMap<>(); - org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group - .NodeEdgePoint inep = new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210 - .node.rule.group.NodeEdgePointBuilder() - .setTopologyUuid(tapiTopoUuid) - .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes( - (String.join("+", nodeId, OTSI)).getBytes(Charset.forName("UTF-8"))) - .toString())) - .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes( - (String.join("+", nodeId, I_OTSI, tpMapping.getLogicalConnectionPoint())) - .getBytes(Charset.forName("UTF-8"))).toString())) - .build(); - org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group - .NodeEdgePoint enep = new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210 - .node.rule.group.NodeEdgePointBuilder() - .setTopologyUuid(tapiTopoUuid) - .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes( - (String.join("+", nodeId, OTSI)).getBytes(Charset.forName("UTF-8"))) - .toString())) - .setNodeEdgePointUuid(new Uuid(UUID.nameUUIDFromBytes( - (String.join("+", nodeId, E_OTSI, tpMapping.getLogicalConnectionPoint())) - .getBytes(Charset.forName("UTF-8"))).toString())) - .build(); - nepList.put(inep.key(), inep); - nepList.put(enep.key(), enep); - // Empty random creation of mandatory fields for avoiding errors.... - CostCharacteristic costCharacteristic = new CostCharacteristicBuilder() - .setCostAlgorithm("Restricted Shortest Path - RSP") - .setCostName("HOP_COUNT") - .setCostValue("12345678") - .build(); - LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder() - .setFixedLatencyCharacteristic("12345678") - .setQueingLatencyCharacteristic("12345678") - .setJitterCharacteristic("12345678") - .setWanderCharacteristic("12345678") - .setTrafficPropertyName("FIXED_LATENCY") - .build(); - RiskCharacteristic riskCharacteristic = new RiskCharacteristicBuilder() - .setRiskCharacteristicName("risk characteristic") - .setRiskIdentifierList(List.of("risk identifier1", "risk identifier2")) - .build(); - NodeRuleGroup nodeRuleGroup = new NodeRuleGroupBuilder() - .setUuid(new Uuid( - UUID.nameUUIDFromBytes(("otsi node rule group " + count).getBytes(Charset.forName("UTF-8"))) - .toString())) - .setRule(ruleList) - .setNodeEdgePoint(nepList) - .setRiskCharacteristic(Map.of(riskCharacteristic.key(), riskCharacteristic)) - .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic)) - .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic)) - .build(); - nodeRuleGroupMap.put(nodeRuleGroup.key(), nodeRuleGroup); - count++; - } - return nodeRuleGroupMap; - } - private Map createNodeRuleGroupForDsrNode(String nodeId, - OduSwitchingPools oorOduSwitchingPool, - Map ruleList, - Map onepl) { + OduSwitchingPools oorOduSwitchingPool, Map ruleList, + Map onepl) { // create NodeRuleGroup if (oorOduSwitchingPool == null) { - LOG.info("TPDR node --> no switching pool"); + LOG.info("No switching pool created for node = {}", nodeId); return new HashMap<>(); } - LOG.info("ONEPL = {}", onepl.values()); + LOG.debug("ONEPL = {}", onepl.values()); Map nodeRuleGroupMap = new HashMap<>(); int count = 1; for (NonBlockingList nbl : oorOduSwitchingPool.nonnullNonBlockingList().values()) { LOG.info("Non blocking list = {}", nbl); - Map - nepList = new HashMap<>(); + Map nepList = new HashMap<>(); for (TpId tp : nbl.getTpList()) { - LOG.info("EDOU TP = {}", String.join("+", nodeId, E_ODU, tp.getValue())); - LOG.info("DSR TP = {}", String.join("+", nodeId, DSR, tp.getValue())); - Uuid tpUuid = new Uuid(UUID.nameUUIDFromBytes( - (String.join("+", nodeId, E_ODU, tp.getValue())).getBytes(Charset.forName("UTF-8"))) - .toString()); - Uuid tp1Uuid = new Uuid(UUID.nameUUIDFromBytes( - (String.join("+", nodeId, DSR, tp.getValue())).getBytes(Charset.forName("UTF-8"))) - .toString()); + LOG.info("EDOU TP = {}", String.join("+", nodeId, TapiStringConstants.E_ODU, tp.getValue())); + LOG.info("DSR TP = {}", String.join("+", nodeId, TapiStringConstants.DSR, tp.getValue())); + Uuid tpUuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId, + TapiStringConstants.E_ODU, tp.getValue())).getBytes(StandardCharsets.UTF_8)).toString()); + Uuid tp1Uuid = new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId, + TapiStringConstants.DSR, tp.getValue())).getBytes(StandardCharsets.UTF_8)).toString()); if (onepl.containsKey(new OwnedNodeEdgePointKey(tpUuid)) - || onepl.containsKey(new OwnedNodeEdgePointKey(tp1Uuid))) { - org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group.NodeEdgePoint - nep = new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.node.rule.group - .NodeEdgePointBuilder() - .setTopologyUuid(tapiTopoUuid) - .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes( - (String.join("+", nodeId, DSR)).getBytes(Charset.forName("UTF-8"))) - .toString())) - .setNodeEdgePointUuid((tp.getValue().contains("CLIENT")) ? tp1Uuid : tpUuid) - .build(); - nepList.put(nep.key(), nep); + && onepl.containsKey(new OwnedNodeEdgePointKey(tp1Uuid))) { + NodeEdgePoint nep1 = new NodeEdgePointBuilder() + .setTopologyUuid(this.tapiTopoUuid) + .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes( + (String.join("+", nodeId,TapiStringConstants. DSR)) + .getBytes(StandardCharsets.UTF_8)).toString())) + .setNodeEdgePointUuid(tp1Uuid) + .build(); + NodeEdgePoint nep2 = new NodeEdgePointBuilder() + .setTopologyUuid(this.tapiTopoUuid) + .setNodeUuid(new Uuid(UUID.nameUUIDFromBytes( + (String.join("+", nodeId,TapiStringConstants. DSR)) + .getBytes(StandardCharsets.UTF_8)).toString())) + .setNodeEdgePointUuid(tpUuid) + .build(); + nepList.put(nep1.key(), nep1); + nepList.put(nep2.key(), nep2); } } // Empty random creation of mandatory fields for avoiding errors.... CostCharacteristic costCharacteristic = new CostCharacteristicBuilder() .setCostAlgorithm("Restricted Shortest Path - RSP") .setCostName("HOP_COUNT") - .setCostValue("12345678") + .setCostValue(TapiStringConstants.COST_HOP_VALUE) .build(); LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder() - .setFixedLatencyCharacteristic("12345678") - .setQueingLatencyCharacteristic("12345678") - .setJitterCharacteristic("12345678") - .setWanderCharacteristic("12345678") + .setFixedLatencyCharacteristic(TapiStringConstants.FIXED_LATENCY_VALUE) + .setQueuingLatencyCharacteristic(TapiStringConstants.QUEING_LATENCY_VALUE) + .setJitterCharacteristic(TapiStringConstants.JITTER_VALUE) + .setWanderCharacteristic(TapiStringConstants.WANDER_VALUE) .setTrafficPropertyName("FIXED_LATENCY") .build(); RiskCharacteristic riskCharacteristic = new RiskCharacteristicBuilder() .setRiskCharacteristicName("risk characteristic") - .setRiskIdentifierList(List.of("risk identifier1", "risk identifier2")) + .setRiskIdentifierList(Set.of("risk identifier1", "risk identifier2")) .build(); NodeRuleGroup nodeRuleGroup = new NodeRuleGroupBuilder() .setUuid(new Uuid( - UUID.nameUUIDFromBytes(("dsr node rule group " + count).getBytes(Charset.forName("UTF-8"))) + UUID.nameUUIDFromBytes(("dsr node rule group " + count).getBytes(StandardCharsets.UTF_8)) .toString())) .setRule(ruleList) .setNodeEdgePoint(nepList) @@ -1145,93 +1197,19 @@ public class TapiNetworkModelServiceImpl implements TapiNetworkModelService { return nodeRuleGroupMap; } - private List> createSupportedLayerProtocolQualifier( - List> sicList, LayerProtocolName lpn) { - if (sicList == null) { - return List.of(PHOTONICLAYERQUALIFIEROMS.class); - } - Map supIfMap = new HashMap<>(); - LOG.info("SIC list = {}", sicList); - for (Class supInterCapa : sicList) { - SupportedInterfaceCapability supIfCapa = new SupportedInterfaceCapabilityBuilder() - .withKey(new SupportedInterfaceCapabilityKey(convertSupIfCapa(supInterCapa))) - .setIfCapType(convertSupIfCapa(supInterCapa)) - .build(); - supIfMap.put(supIfCapa.key(), supIfCapa); - } - List> sclpqList = new ArrayList<>(); - for (SupportedInterfaceCapability sic : supIfMap.values()) { - switch (lpn.getName()) { - case "DSR": - case "ODU": - switch (sic.getIfCapType().getSimpleName()) { - case "If10GEODU2e": - sclpqList.add(ODUTYPEODU2E.class); - sclpqList.add(DIGITALSIGNALTYPE10GigELAN.class); - break; - case "If10GEODU2": - sclpqList.add(ODUTYPEODU2.class); - sclpqList.add(DIGITALSIGNALTYPE10GigELAN.class); - break; - case "If10GE": - sclpqList.add(DIGITALSIGNALTYPE10GigELAN.class); - break; - case "If100GEODU4": - sclpqList.add(DIGITALSIGNALTYPE100GigE.class); - sclpqList.add(ODUTYPEODU4.class); - break; - case "If100GE": - sclpqList.add(DIGITALSIGNALTYPE100GigE.class); - break; - case "IfOCHOTU4ODU4": - case "IfOCH": - sclpqList.add(ODUTYPEODU4.class); - break; - default: - LOG.error("IfCapability type not managed"); - break; - } - break; - case "PHOTONIC_MEDIA": - if (sic.getIfCapType().getSimpleName().equals("IfOCHOTU4ODU4") - || sic.getIfCapType().getSimpleName().equals("IfOCH")) { - sclpqList.add(PHOTONICLAYERQUALIFIEROTSi.class); - sclpqList.add(PHOTONICLAYERQUALIFIEROMS.class); - } - break; - default: - LOG.error("Layer Protocol Name is unknown {}", lpn.getName()); - break; - } - } - return sclpqList; - } - - private static Class convertSupIfCapa(Class ifCapType) { - LOG.info("Interface Capability type = {}", ifCapType.getSimpleName()); - switch (ifCapType.getSimpleName()) { - case "If100GEODU4": - return If100GEODU4.class; - case "IfOCHOTU4ODU4": - return IfOCHOTU4ODU4.class; - case "If1GEODU0": - return If1GEODU0.class; - case "If10GEODU2e": - return If10GEODU2e.class; - case "If10GEODU2": - return If10GEODU2.class; - case "If100GE": - return If100GE.class; - case "If10GE": - return If10GE.class; - case "If1GE": - return If1GE.class; - case "IfOCH": - return IfOCH.class; + private String getNodeType(XpdrNodeTypes xponderType) { + switch (xponderType.getIntValue()) { + case 1: + return OpenroadmNodeType.TPDR.getName(); + case 2: + return OpenroadmNodeType.MUXPDR.getName(); + case 3: + return OpenroadmNodeType.SWITCH.getName(); default: - return null; + LOG.info("XpdrType {} not supported", xponderType); + break; } + return null; } private void mergeNodeinTopology(Map nodeMap) { @@ -1239,12 +1217,11 @@ public class TapiNetworkModelServiceImpl implements TapiNetworkModelService { // TODO: verify this is correct. Should we identify the context IID with the context UUID?? LOG.info("Creating tapi node in TAPI topology context"); InstanceIdentifier topoIID = InstanceIdentifier.builder(Context.class) - .augmentation(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.Context1.class) - .child(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.context.TopologyContext.class) - .child(Topology.class, new TopologyKey(tapiTopoUuid)) + .augmentation(Context1.class).child(TopologyContext.class) + .child(Topology.class, new TopologyKey(this.tapiTopoUuid)) .build(); - Topology topology = new TopologyBuilder().setUuid(tapiTopoUuid).setNode(nodeMap).build(); + Topology topology = new TopologyBuilder().setUuid(this.tapiTopoUuid).setNode(nodeMap).build(); // merge in datastore this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, topoIID, @@ -1254,7 +1231,7 @@ public class TapiNetworkModelServiceImpl implements TapiNetworkModelService { } catch (InterruptedException | ExecutionException e) { LOG.error("Error populating TAPI topology: ", e); } - LOG.info("Roadm Node added succesfully."); + LOG.info("Node added succesfully."); } private void mergeLinkinTopology(Map linkMap) { @@ -1262,13 +1239,11 @@ public class TapiNetworkModelServiceImpl implements TapiNetworkModelService { // TODO: verify this is correct. Should we identify the context IID with the context UUID?? LOG.info("Creating tapi node in TAPI topology context"); InstanceIdentifier topoIID = InstanceIdentifier.builder(Context.class) - .augmentation(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.Context1.class) - .child(org.opendaylight.yang.gen.v1.urn - .onf.otcc.yang.tapi.topology.rev181210.context.TopologyContext.class) - .child(Topology.class, new TopologyKey(tapiTopoUuid)) - .build(); + .augmentation(Context1.class).child(TopologyContext.class) + .child(Topology.class, new TopologyKey(this.tapiTopoUuid)) + .build(); - Topology topology = new TopologyBuilder().setUuid(tapiTopoUuid).setLink(linkMap).build(); + Topology topology = new TopologyBuilder().setUuid(this.tapiTopoUuid).setLink(linkMap).build(); // merge in datastore this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, topoIID, @@ -1303,7 +1278,7 @@ public class TapiNetworkModelServiceImpl implements TapiNetworkModelService { try { InstanceIdentifier linkIID = InstanceIdentifier.builder(Context.class) .augmentation(Context1.class).child(TopologyContext.class).child(Topology.class, - new TopologyKey(tapiTopoUuid)).child(Link.class, new LinkKey(linkUuid)).build(); + new TopologyKey(this.tapiTopoUuid)).child(Link.class, new LinkKey(linkUuid)).build(); this.networkTransactionService.delete(LogicalDatastoreType.OPERATIONAL, linkIID); this.networkTransactionService.commit().get(); LOG.info("TAPI link deleted successfully."); @@ -1317,7 +1292,7 @@ public class TapiNetworkModelServiceImpl implements TapiNetworkModelService { try { InstanceIdentifier nodeIDD = InstanceIdentifier.builder(Context.class) .augmentation(Context1.class).child(TopologyContext.class).child(Topology.class, - new TopologyKey(tapiTopoUuid)).child(Node.class, new NodeKey(nodeUuid)).build(); + new TopologyKey(this.tapiTopoUuid)).child(Node.class, new NodeKey(nodeUuid)).build(); this.networkTransactionService.delete(LogicalDatastoreType.OPERATIONAL, nodeIDD); this.networkTransactionService.commit().get(); LOG.info("TAPI Node deleted successfully."); @@ -1342,9 +1317,9 @@ public class TapiNetworkModelServiceImpl implements TapiNetworkModelService { private void updateConnectivityServicesState(Uuid sipUuid, String nodeId) { // TODO: check if this IID is correct InstanceIdentifier connectivitycontextIID = InstanceIdentifier.builder(Context.class) - .augmentation(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.Context1.class) - .child(ConnectivityContext.class) - .build(); + .augmentation(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.Context1.class) + .child(ConnectivityContext.class) + .build(); ConnectivityContext connContext = null; try { Optional optConnContext = @@ -1354,7 +1329,7 @@ public class TapiNetworkModelServiceImpl implements TapiNetworkModelService { LOG.error("Couldnt retrieve connectivity context from datastore"); return; } - connContext = optConnContext.get(); + connContext = optConnContext.orElseThrow(); } catch (InterruptedException | ExecutionException e) { LOG.error("Couldnt read connectivity context from datastore", e); } @@ -1398,7 +1373,7 @@ public class TapiNetworkModelServiceImpl implements TapiNetworkModelService { private void updateConnection(Connection updConn) { // TODO: check if this IID is correct InstanceIdentifier connectionIID = InstanceIdentifier.builder(Context.class) - .augmentation(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.Context1.class) + .augmentation(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.Context1.class) .child(ConnectivityContext.class).child(Connection.class, new ConnectionKey(updConn.getUuid())).build(); this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, connectionIID, updConn); @@ -1412,7 +1387,7 @@ public class TapiNetworkModelServiceImpl implements TapiNetworkModelService { private void updateConnectivityService(ConnectivityService updService) { // TODO: check if this IID is correct InstanceIdentifier connectivityserviceIID = InstanceIdentifier.builder(Context.class) - .augmentation(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.Context1.class) + .augmentation(org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.Context1.class) .child(ConnectivityContext.class).child(ConnectivityService.class, new ConnectivityServiceKey(updService.getUuid())).build(); this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, connectivityserviceIID, updService); @@ -1423,4 +1398,223 @@ public class TapiNetworkModelServiceImpl implements TapiNetworkModelService { } } + private Map populateNepsForRdmNode(String nodeId, + Map tpMap, boolean withSip, String nepPhotonicSublayer) { + // create neps for MC and and Photonic Media OTS/OMS + Map onepMap = new HashMap<>(); + for (Map.Entry entry : tpMap.entrySet()) { + // Admin and oper state common for all tps + OpenroadmTpType tpType = entry.getValue().getTpType(); + // PHOTONIC MEDIA nep + LOG.debug("PHOTO NEP = {}", String.join("+", nodeId, nepPhotonicSublayer, + entry.getKey())); + SupportedCepLayerProtocolQualifierInstancesBuilder sclpqiBd = + new SupportedCepLayerProtocolQualifierInstancesBuilder() + .setNumberOfCepInstances(Uint64.valueOf(1)); + switch (nepPhotonicSublayer) { + case TapiStringConstants.PHTNC_MEDIA_OMS: + sclpqiBd.setLayerProtocolQualifier(PHOTONICLAYERQUALIFIEROMS.VALUE); + break; + case TapiStringConstants.PHTNC_MEDIA_OTS: + sclpqiBd.setLayerProtocolQualifier(PHOTONICLAYERQUALIFIEROTS.VALUE); + break; + case TapiStringConstants.MC: + sclpqiBd.setLayerProtocolQualifier(PHOTONICLAYERQUALIFIERMC.VALUE); + break; + case TapiStringConstants.OTSI_MC: + sclpqiBd.setLayerProtocolQualifier(PHOTONICLAYERQUALIFIEROTSiMC.VALUE); + break; + default: + break; + } + + List sclpqiList = new ArrayList<>(List.of(sclpqiBd.build())); + OwnedNodeEdgePointBuilder onepBd = new OwnedNodeEdgePointBuilder(); + if (!nepPhotonicSublayer.equals(TapiStringConstants.MC) + && !nepPhotonicSublayer.equals(TapiStringConstants.OTSI_MC)) { + Map usedFreqMap = new HashMap<>(); + Map availableFreqMap = new HashMap<>(); + switch (tpType) { + // Whatever is the TP and its type we consider that it is handled in a bidirectional way : + // same wavelength(s) used in both direction. + case SRGRXPP: + case SRGTXPP: + case SRGTXRXPP: + usedFreqMap = tapiFactory.getPP11UsedWavelength( + getNetworkTerminationPoint11FromDatastore(nodeId, entry.getKey())); + if (usedFreqMap == null || usedFreqMap.isEmpty()) { + availableFreqMap.put(GridConstant.START_EDGE_FREQUENCY * 1E09, + GridConstant.START_EDGE_FREQUENCY * 1E09 + + GridConstant.GRANULARITY * GridConstant.EFFECTIVE_BITS * 1E06); + } else { + LOG.debug("EnteringLOOPcreateOTSiMC & MC with usedFreqMap non empty {} for Node {}, tp {}", + usedFreqMap.toString(), nodeId, tpMap.toString()); + onepMap.putAll(populateNepsForRdmNode(nodeId, + new HashMap<>(Map.of(entry.getKey(), entry.getValue())), + true, TapiStringConstants.MC)); + onepMap.putAll(populateNepsForRdmNode(nodeId, + new HashMap<>(Map.of(entry.getKey(), entry.getValue())), + true, TapiStringConstants.OTSI_MC)); + } + break; + case DEGREERXTTP: + case DEGREETXTTP: + case DEGREETXRXTTP: + usedFreqMap = tapiFactory.getTTP11UsedFreqMap( + getNetworkTerminationPoint11FromDatastore(nodeId, entry.getKey())); + availableFreqMap = tapiFactory.getTTP11AvailableFreqMap( + getNetworkTerminationPoint11FromDatastore(nodeId, entry.getKey())); + break; + default: + break; + } + LOG.debug("calling add Photonic NEP spec for Roadm"); + onepBd = tapiFactory.addPhotSpecToRoadmOnep(nodeId, usedFreqMap, availableFreqMap, onepBd, + nepPhotonicSublayer); + } + AdminStates admin = entry.getValue().getAdministrativeState(); + State oper = entry.getValue().getOperationalState(); + Name nepName = new NameBuilder() + .setValueName(nepPhotonicSublayer + "NodeEdgePoint") + .setValue(String.join("+", nodeId, nepPhotonicSublayer, + entry.getKey())) + .build(); + OwnedNodeEdgePoint onep = onepBd + .setUuid(new Uuid(UUID.nameUUIDFromBytes((String.join("+", nodeId, + nepPhotonicSublayer, entry.getKey())) + .getBytes(Charset.forName("UTF-8"))).toString())) + .setLayerProtocolName(LayerProtocolName.PHOTONICMEDIA) + .setName(Map.of(nepName.key(), nepName)) + .setSupportedCepLayerProtocolQualifierInstances(sclpqiList) + .setDirection(Direction.BIDIRECTIONAL) + .setLinkPortRole(PortRole.SYMMETRIC) + .setAdministrativeState(this.tapiLink.setTapiAdminState(admin.getName())) + .setOperationalState(this.tapiLink.setTapiOperationalState(oper.getName())) + .setLifecycleState(LifecycleState.INSTALLED) + .build(); + LOG.debug("ROADMNEPPopulation TapiNetworkModelServiceImpl populate NEP {} for Node {}", + onep.getName().entrySet(), nodeId); + onepMap.put(onep.key(), onep); + } + LOG.debug("ROADMNEPPopulation FINISH for Node {}", nodeId); + return onepMap; + } + + /** + * Get a network termination point for nodeId and tpId. + * @param nodeId String + * @param tpId String + * @return network termination point, null otherwise + */ + private TerminationPoint getNetworkTerminationPointFromDatastore(String nodeId, String tpId) { + InstanceIdentifier tpIID = InstanceIdentifier.builder(Networks.class) + .child(Network.class, new NetworkKey(new NetworkId(NetworkUtils.OVERLAY_NETWORK_ID))) + .child( + org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226 + .networks.network.Node.class, + new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226 + .networks.network.NodeKey(new NodeId(nodeId))) + .augmentation(Node1.class) + .child( + org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226 + .networks.network.node.TerminationPoint.class, + new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226 + .networks.network.node.TerminationPointKey(new TpId(tpId))) + .build(); + try { + Optional tpOptional = + networkTransactionService.read(LogicalDatastoreType.CONFIGURATION, tpIID).get(); + if (tpOptional.isEmpty()) { + LOG.error("readMdSal: Error reading tp {} , empty list",tpIID); + return null; + } + LOG.debug("SUCCES getting LCP TP for NodeId {} TpId {} while creating NEP in TapiNetworkModelServiceImpl", + nodeId, tpId); + LOG.debug(" The Tp in Datastore is as follows {}", tpOptional); + return tpOptional.orElseThrow(); + } catch (ExecutionException | InterruptedException e) { + LOG.warn("Exception while getting termination {} for node id {} point from {} topology", + tpId, nodeId, NetworkUtils.OVERLAY_NETWORK_ID, e); + return null; + } + } + + /** + * Get a network termination point with Common TerminationPoint1 augmentation for nodeId and tpId. + * @param nodeId String + * @param tpId String + * @return network termination point, null otherwise + */ + private TerminationPoint1 getNetworkTerminationPoint1FromDatastore(String nodeId, String tpId) { + InstanceIdentifier tpIID = InstanceIdentifier.builder(Networks.class) + .child(Network.class, new NetworkKey(new NetworkId(NetworkUtils.OVERLAY_NETWORK_ID))) + .child( + org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226 + .networks.network.Node.class, + new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226 + .networks.network.NodeKey(new NodeId(nodeId))) + .augmentation(Node1.class) + .child( + org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226 + .networks.network.node.TerminationPoint.class, + new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226 + .networks.network.node.TerminationPointKey(new TpId(tpId))) + .augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526 + .TerminationPoint1.class) + .build(); + try { + Optional tpOptional = + networkTransactionService.read(LogicalDatastoreType.CONFIGURATION, tpIID).get(); + if (tpOptional.isEmpty()) { + LOG.error("readMdSal: Error reading tp {} , empty list",tpIID); + return null; + } + LOG.debug("SUCCES getting LCP TP1 for NodeId {} TpId {} while creating NEP in TapiNetworkModelServiceImpl", + nodeId, tpId); + LOG.debug(" The Tp in Datastore is as follows {}", tpOptional); + return tpOptional.orElseThrow(); + } catch (ExecutionException | InterruptedException e) { + LOG.warn("Exception while getting termination {} for node id {} point from {} topology", + tpId, nodeId, NetworkUtils.OVERLAY_NETWORK_ID, e); + return null; + } + } + + private org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev230526.TerminationPoint1 + getNetworkTerminationPoint11FromDatastore(String nodeId, String tpId) { + InstanceIdentifier + tpIID = InstanceIdentifier.builder(Networks.class) + .child(Network.class, new NetworkKey(new NetworkId(NetworkUtils.OVERLAY_NETWORK_ID))) + .child( + org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226 + .networks.network.Node.class, + new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226 + .networks.network.NodeKey(new NodeId(nodeId))) + .augmentation(Node1.class) + .child( + org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226 + .networks.network.node.TerminationPoint.class, + new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226 + .networks.network.node.TerminationPointKey(new TpId(tpId))) + .augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev230526.TerminationPoint1 + .class) + .build(); + try { + Optional + tpOptional = networkTransactionService.read(LogicalDatastoreType.CONFIGURATION, tpIID).get(); + if (tpOptional.isEmpty()) { + LOG.error("readMdSal: Error reading tp {} , empty list",tpIID); + return null; + } + LOG.debug("SUCCESS getting LCP TP11 for NodeId {} TpId {} while creating NEP in TapiNetworkModelServiceImpl" + + " The Tp in Datastore is as follows {}", + nodeId, tpId, tpOptional.toString()); + return tpOptional.orElseThrow(); + } catch (ExecutionException | InterruptedException e) { + LOG.warn("Exception while getting termination {} for node id {} point from {} topology", + tpId, nodeId, NetworkUtils.OVERLAY_NETWORK_ID, e); + return null; + } + } + }