package org.opendaylight.transportpce.servicehandler.listeners;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+import java.util.List;
+import java.util.Map;
import org.opendaylight.mdsal.binding.api.NotificationPublishService;
import org.opendaylight.transportpce.common.OperationResult;
import org.opendaylight.transportpce.common.StringConstants;
import org.opendaylight.transportpce.servicehandler.ServiceInput;
import org.opendaylight.transportpce.servicehandler.service.PCEServiceWrapper;
import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210618.RendererRpcResultSp;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210618.TransportpceRendererListener;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210618.renderer.rpc.result.sp.Link;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.RendererRpcResultSp;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.TransportpceRendererListener;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.renderer.rpc.result.sp.Link;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev201125.ServiceRpcResultSh;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev201125.ServiceRpcResultShBuilder;
import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.ServiceNotificationTypes;
import org.opendaylight.yang.gen.v1.http.org.openroadm.equipment.states.types.rev191129.AdminStates;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.list.Services;
import org.opendaylight.yang.gen.v1.http.transportpce.topology.rev210511.OtnLinkType;
-import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.PublishNotificationService;
-import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.PublishNotificationServiceBuilder;
-import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.notification.service.ServiceAEndBuilder;
-import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.notification.service.ServiceZEndBuilder;
-import org.opendaylight.yangtools.yang.common.Uint32;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.PublishNotificationProcessService;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.PublishNotificationProcessServiceBuilder;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.notification.process.service.ServiceAEndBuilder;
+import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.notification.process.service.ServiceZEndBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
*/
public class RendererListenerImpl implements TransportpceRendererListener {
- private static final String TOPIC = "RendererListener";
+ private static final String PUBLISHER = "RendererListener";
private static final Logger LOG = LoggerFactory.getLogger(RendererListenerImpl.class);
private RendererRpcResultSp serviceRpcResultSp;
private ServiceDataStoreOperations serviceDataStoreOperations;
private void onServiceDeleteResult(RendererRpcResultSp notification) {
switch (serviceRpcResultSp.getStatus()) {
case Successful:
- String serviceType = notification.getServiceType();
- switch (serviceType) {
- case StringConstants.SERVICE_TYPE_1GE:
- case StringConstants.SERVICE_TYPE_10GE:
- case StringConstants.SERVICE_TYPE_100GE_M:
- Short tribPort = Short.valueOf(notification.getAToZDirection().getMinTribSlot().getValue()
- .split("\\.")[0]);
- Short minTribSlot = Short.valueOf(notification.getAToZDirection().getMinTribSlot().getValue()
- .split("\\.")[1]);
- Short maxTribSlot = Short.valueOf(notification.getAToZDirection().getMaxTribSlot().getValue()
- .split("\\.")[1]);
- updateOtnTopology(notification.getLink(), true, notification.getServiceType(),
- notification.getAToZDirection().getRate(), tribPort, minTribSlot, maxTribSlot);
- break;
- case StringConstants.SERVICE_TYPE_OTU4:
- case StringConstants.SERVICE_TYPE_OTUC4:
- case StringConstants.SERVICE_TYPE_ODU4:
- case StringConstants.SERVICE_TYPE_ODUC4:
- updateOtnTopology(notification.getLink(), true, notification.getServiceType(), null, null,
- null, null);
- break;
- default:
- break;
- }
+ updateOtnTopology(notification, true);
break;
case Failed:
LOG.error("Renderer service delete failed !");
Services service = serviceDataStoreOperations.getService(input.getServiceName()).get();
- sendNbiNotification(new PublishNotificationServiceBuilder()
+ sendNbiNotification(new PublishNotificationProcessServiceBuilder()
.setServiceName(service.getServiceName())
.setServiceAEnd(new ServiceAEndBuilder(service.getServiceAEnd()).build())
.setServiceZEnd(new ServiceZEndBuilder(service.getServiceZEnd()).build())
.setResponseFailed("Renderer service delete failed !")
.setMessage("ServiceDelete request failed ...")
.setOperationalState(service.getOperationalState())
- .setTopic(TOPIC)
+ .setPublisherName(PUBLISHER)
.build());
return;
case Pending:
LOG.debug("serviceDataStoreOperations is null");
return;
}
- String serviceType = notification.getServiceType();
- switch (serviceType) {
- case StringConstants.SERVICE_TYPE_1GE:
- case StringConstants.SERVICE_TYPE_10GE:
- case StringConstants.SERVICE_TYPE_100GE_M:
- Short tribPort = Short.valueOf(notification.getAToZDirection().getMinTribSlot().getValue()
- .split("\\.")[0]);
- Short minTribSlot = Short.valueOf(notification.getAToZDirection().getMinTribSlot().getValue()
- .split("\\.")[1]);
- Short maxTribSlot = Short.valueOf(notification.getAToZDirection().getMaxTribSlot().getValue()
- .split("\\.")[1]);
- updateOtnTopology(notification.getLink(), false, notification.getServiceType(),
- notification.getAToZDirection().getRate(), tribPort, minTribSlot, maxTribSlot);
- break;
- case StringConstants.SERVICE_TYPE_OTU4:
- case StringConstants.SERVICE_TYPE_OTUC4:
- case StringConstants.SERVICE_TYPE_ODU4:
- case StringConstants.SERVICE_TYPE_ODUC4:
- updateOtnTopology(notification.getLink(), false, notification.getServiceType(), null, null, null, null);
- break;
- default:
- break;
- }
- PublishNotificationServiceBuilder nbiNotificationBuilder = new PublishNotificationServiceBuilder()
+
+ updateOtnTopology(notification, false);
+
+ PublishNotificationProcessServiceBuilder nbiNotificationBuilder = new PublishNotificationProcessServiceBuilder()
.setServiceName(input.getServiceName())
.setServiceAEnd(new ServiceAEndBuilder(input.getServiceAEnd()).build())
.setServiceZEnd(new ServiceZEndBuilder(input.getServiceZEnd()).build())
.setCommonId(input.getCommonId()).setConnectionType(input.getConnectionType())
- .setTopic(TOPIC);
+ .setPublisherName(PUBLISHER);
OperationResult operationResult;
String serviceTemp = "";
if (tempService) {
private void onFailedServiceImplementation(String serviceName) {
LOG.error("Renderer implementation failed !");
Services service = serviceDataStoreOperations.getService(input.getServiceName()).get();
- sendNbiNotification(new PublishNotificationServiceBuilder()
+ sendNbiNotification(new PublishNotificationProcessServiceBuilder()
.setServiceName(service.getServiceName())
.setServiceAEnd(new ServiceAEndBuilder(service.getServiceAEnd()).build())
.setServiceZEnd(new ServiceZEndBuilder(service.getServiceZEnd()).build())
.setResponseFailed("Renderer implementation failed !")
.setMessage("ServiceCreate request failed ...")
.setOperationalState(service.getOperationalState())
- .setTopic(TOPIC)
+ .setPublisherName(PUBLISHER)
.build());
OperationResult deleteServicePathOperationResult =
this.serviceDataStoreOperations.deleteServicePath(serviceName);
value = "ES_COMPARING_STRINGS_WITH_EQ",
justification = "false positives, not strings but real object references comparisons")
private Boolean compareServiceRpcResultSp(RendererRpcResultSp notification) {
- if (serviceRpcResultSp == null) {
- return false;
- }
- if (serviceRpcResultSp.getNotificationType() != notification.getNotificationType()) {
- return false;
- }
- if (serviceRpcResultSp.getServiceName() != notification.getServiceName()) {
- return false;
- }
- if (serviceRpcResultSp.getStatus() != notification.getStatus()) {
- return false;
- }
- if (serviceRpcResultSp.getStatusMessage() != notification.getStatusMessage()) {
+ if (serviceRpcResultSp == null
+ || serviceRpcResultSp.getNotificationType() != notification.getNotificationType()
+ || serviceRpcResultSp.getServiceName() != notification.getServiceName()
+ || serviceRpcResultSp.getStatus() != notification.getStatus()
+ || serviceRpcResultSp.getStatusMessage() != notification.getStatusMessage()) {
return false;
}
return true;
* Send notification to NBI notification in order to publish message.
* @param service PublishNotificationService
*/
- private void sendNbiNotification(PublishNotificationService service) {
+ private void sendNbiNotification(PublishNotificationProcessService service) {
try {
notificationPublishService.putNotification(service);
} catch (InterruptedException e) {
}
}
- private void updateOtnTopology(Link link, boolean isDeletion, String serviceType, Uint32 rate, Short portNb,
- Short minSlotNb, Short maxSlotNb) {
- if (link == null) {
+
+ private void updateOtnTopology(RendererRpcResultSp notification, boolean isDeletion) {
+ Link link = notification.getLink();
+ List<String> supportedLinkIds = notification.getLinkId();
+ if (link == null && supportedLinkIds == null) {
return;
}
- OtnLinkType otnLinkType;
- switch (serviceType) {
- case StringConstants.SERVICE_TYPE_OTU4:
- otnLinkType = OtnLinkType.OTU4;
- break;
- case StringConstants.SERVICE_TYPE_OTUC4:
- otnLinkType = OtnLinkType.OTUC4;
- break;
- case StringConstants.SERVICE_TYPE_ODU4:
- otnLinkType = OtnLinkType.ODTU4;
- break;
- case StringConstants.SERVICE_TYPE_ODUC4:
- otnLinkType = OtnLinkType.ODUC4;
- break;
- default:
- otnLinkType = null;
- LOG.warn("No otn-link-type corresponds to service-type {}", serviceType);
- break;
- }
+
+ String serviceType = notification.getServiceType();
switch (serviceType) {
case StringConstants.SERVICE_TYPE_OTU4:
case StringConstants.SERVICE_TYPE_OTUC4:
case StringConstants.SERVICE_TYPE_ODU4:
case StringConstants.SERVICE_TYPE_ODUC4:
+ Map<String, OtnLinkType> otnLinkTypeMap = Map.of(
+ StringConstants.SERVICE_TYPE_OTU4, OtnLinkType.OTU4,
+ StringConstants.SERVICE_TYPE_OTUC4, OtnLinkType.OTUC4,
+ StringConstants.SERVICE_TYPE_ODU4, OtnLinkType.ODTU4,
+ StringConstants.SERVICE_TYPE_ODUC4, OtnLinkType.ODUC4);
if (isDeletion) {
LOG.info("updating otn-topology removing links");
this.networkModelService.deleteOtnLinks(link.getATermination().getNodeId(),
link.getATermination().getTpId(), link.getZTermination().getNodeId(),
- link.getZTermination().getTpId(), otnLinkType);
+ link.getZTermination().getTpId(), otnLinkTypeMap.get(serviceType));
} else {
LOG.info("updating otn-topology adding links");
this.networkModelService.createOtnLinks(link.getATermination().getNodeId(),
link.getATermination().getTpId(), link.getZTermination().getNodeId(),
- link.getZTermination().getTpId(), otnLinkType);
+ link.getZTermination().getTpId(), otnLinkTypeMap.get(serviceType));
}
break;
case StringConstants.SERVICE_TYPE_1GE:
case StringConstants.SERVICE_TYPE_10GE:
case StringConstants.SERVICE_TYPE_100GE_M:
+ Short tribPort = Short.valueOf(notification.getAToZDirection().getMinTribSlot().getValue()
+ .split("\\.")[0]);
+ Short minTribSlot = Short.valueOf(notification.getAToZDirection().getMinTribSlot().getValue()
+ .split("\\.")[1]);
+ Short maxTribSlot = Short.valueOf(notification.getAToZDirection().getMaxTribSlot().getValue()
+ .split("\\.")[1]);
LOG.info("updating otn-topology node tps -tps and tpn pools");
- this.networkModelService.updateOtnLinks(link, rate, portNb, minSlotNb, maxSlotNb, isDeletion);
+ this.networkModelService.updateOtnLinks(link, notification.getAToZDirection().getRate(),
+ tribPort, minTribSlot, maxTribSlot, isDeletion);
+ break;
+ case StringConstants.SERVICE_TYPE_100GE_S:
+ this.networkModelService.updateOtnLinks(link, supportedLinkIds, isDeletion);
break;
default:
+ LOG.warn("service-type {} not managed yet", serviceType);
break;
}
}