import org.opendaylight.transportpce.common.network.NetworkTransactionService;
import org.opendaylight.transportpce.tapi.TapiStringConstants;
import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State;
-import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.PublishTapiNotificationService;
-import org.opendaylight.yang.gen.v1.nbi.notifications.rev211013.PublishTapiNotificationServiceBuilder;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev230726.PublishTapiNotificationService;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev230726.PublishTapiNotificationServiceBuilder;
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.Context;
import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.DateAndTime;
import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.context.TopologyKey;
import org.opendaylight.yangtools.yang.binding.EnumTypeObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+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 TapiNetworkModelListenerImpl implements TapiNotificationListener {
private static final Logger LOG = LoggerFactory.getLogger(TapiNetworkModelListenerImpl.class);
private final NetworkTransactionService networkTransactionService;
+ private final NotificationPublishService notificationPublishService;
private final List<ConnectivityService> connectivityServiceChanges = new ArrayList<>();
private final Uuid tapiTopoUuid = new Uuid(UUID.nameUUIDFromBytes(TapiStringConstants.T0_FULL_MULTILAYER
.getBytes(StandardCharsets.UTF_8)).toString());
private final List<LayerProtocolName> orderedServiceLayerList;
- private final NotificationPublishService notificationPublishService;
- public TapiNetworkModelListenerImpl(NetworkTransactionService networkTransactionService,
- NotificationPublishService notificationPublishService) {
+ @Activate
+ public TapiNetworkModelListenerImpl(@Reference NetworkTransactionService networkTransactionService,
+ @Reference NotificationPublishService notificationPublishService) {
this.networkTransactionService = networkTransactionService;
+ this.notificationPublishService = notificationPublishService;
this.orderedServiceLayerList = List.of(LayerProtocolName.PHOTONICMEDIA, LayerProtocolName.ODU,
LayerProtocolName.DSR, LayerProtocolName.ETH);
- this.notificationPublishService = notificationPublishService;
+ LOG.debug("TapiNetworkModelListenerImpl instantiated");
}
@Override
LOG.error("Could not update TAPI connectivity services");
return;
}
- ConnectivityContext connContext = optConnContext.get();
+ ConnectivityContext connContext = optConnContext.orElseThrow();
Map<Uuid, EnumTypeObject[]> states = new HashMap<>();
if (connContext.getConnectivityService() == null) {
return;
LOG.error("Could not get state for a TAPI connection");
continue;
}
- LOG.info("State of connection {} of connectivity service {} = {}", optConn.get().getUuid().getValue(),
- connService.getUuid().getValue(), optConn.get().getOperationalState().getName());
- if (optConn.get().getOperationalState() == OperationalState.DISABLED) {
+ LOG.info("State of connection {} of connectivity service {} = {}", optConn.orElseThrow().getUuid()
+ .getValue(), connService.getUuid().getValue(), optConn.orElseThrow().getOperationalState().getName());
+ if (optConn.orElseThrow().getOperationalState() == OperationalState.DISABLED) {
adminState = AdministrativeState.LOCKED;
operState = OperationalState.DISABLED;
}
LOG.error(TapiStringConstants.TAPI_CONNECTION_UPDATE_ERROR);
return;
}
- if (optConnContext.get().getConnectivityService() == null) {
+ if (optConnContext.orElseThrow().getConnectivityService() == null) {
LOG.info("No TAPI connectivity service to update");
return;
}
// TODO: order services from lower layer to upper layer
Map<ConnectivityServiceKey, ConnectivityService> connServMap
- = optConnContext.get().getConnectivityService();
+ = optConnContext.orElseThrow().getConnectivityService();
if (connServMap == null) {
LOG.info("No connections to update");
return;
LOG.error(TapiStringConstants.TAPI_CONNECTION_READ_ERROR);
continue;
}
- Connection newConn = optConn.get();
+ Connection newConn = optConn.orElseThrow();
// Check LowerConnection states and if any of the lower connection is disabled then we can put
// the connection out of service. And based on the connection previous state we decide
// the update necessary
LOG.error(TapiStringConstants.TAPI_CONNECTION_READ_ERROR);
continue;
}
- Connection newConn = optConn.get(); // Current state of connection
+ Connection newConn = optConn.orElseThrow(); // Current state of connection
if (newConn.getLowerConnection() != null) {
// TODO: we can receive disable here because the lower connection haven been yet looped through and
// therefore it is disabled but it has to be changed to enable before returning disable.
InstanceIdentifier<OwnedNodeEdgePoint> onepIID = InstanceIdentifier.builder(Context.class)
.augmentation(Context1.class).child(TopologyContext.class)
.child(Topology.class, new TopologyKey(tapiTopoUuid))
- .child(Node.class, new NodeKey(ocep.get().getNodeUuid()))
+ .child(Node.class, new NodeKey(ocep.orElseThrow().getNodeUuid()))
.child(OwnedNodeEdgePoint.class, new OwnedNodeEdgePointKey(connectionNep))
.build();
Optional<OwnedNodeEdgePoint> onep =
this.networkTransactionService.read(LogicalDatastoreType.OPERATIONAL, onepIID).get();
- if (onep.isEmpty() || onep.get().augmentation(OwnedNodeEdgePoint1.class) == null
- || onep.get().augmentation(OwnedNodeEdgePoint1.class).getCepList() == null) {
+ if (onep.isEmpty() || onep.orElseThrow().augmentation(OwnedNodeEdgePoint1.class) == null
+ || onep.orElseThrow().augmentation(OwnedNodeEdgePoint1.class).getCepList() == null) {
continue;
}
- if (onep.get().getOperationalState() == OperationalState.DISABLED
- && !changedOneps.contains(onep.get().getUuid())) {
+ if (onep.orElseThrow().getOperationalState() == OperationalState.DISABLED
+ && !changedOneps.contains(onep.orElseThrow().getUuid())) {
return OperationalState.DISABLED;
}
}
LOG.error(TapiStringConstants.TAPI_CONNECTION_READ_ERROR);
continue;
}
- Connection newConn = optConn.get(); // Current state of connection
+ Connection newConn = optConn.orElseThrow(); // Current state of connection
// updated connection state if it contains a nep that has changed
if (newConn.getOperationalState().equals(OperationalState.DISABLED)) {
LOG.info("LowerConnection state is disable");
LOG.error("Could not update TAPI connectivity service");
continue;
}
- ConnectivityService newConnService = optNewConnService.get();
+ ConnectivityService newConnService = optNewConnService.orElseThrow();
if (supportedConnService.getServiceLevel() != null
&& supportedConnService.getServiceLevel().equals(supportingConnService.getValue())
&& newConnService.getAdministrativeState() != AdministrativeState.LOCKED