lightyServices.getRpcProviderService(), lightyServices.getNotificationService(),
serviceDataStoreOperations, pceListenerImpl, rendererListenerImpl, networkModelListenerImpl,
servicehandler);
- tapiProvider = initTapi(lightyServices, servicehandler);
- if (activateNbiNotification) {
+
+ tapiProvider = initTapi(lightyServices, servicehandler, networkTransaction);
+ if(activateNbiNotification) {
LOG.info("Creating nbi-notifications beans ...");
nbiNotificationsProvider = new NbiNotificationsProvider(
publisherTopicList, null, null, lightyServices.getRpcProviderService(),
* @param rendererServiceOperations RendererServiceOperations
* @return TapiProvider instance
*/
- private TapiProvider initTapi(LightyServices lightyServices, OrgOpenroadmServiceService servicehandler) {
+ private TapiProvider initTapi(LightyServices lightyServices, OrgOpenroadmServiceService servicehandler,
+ NetworkTransactionService networkTransaction) {
return new TapiProvider(lightyServices.getBindingDataBroker(), lightyServices.getRpcProviderService(),
- servicehandler, new TapiListener());
+ servicehandler, new TapiListener(), networkTransaction);
}
/**
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.transportpce.tapi.impl;
+package org.opendaylight.transportpce.tapi.connectivity;
import com.google.common.util.concurrent.ListenableFuture;
import java.util.HashMap;
/**
* Top level service interface providing main TAPI Connectivity services.
*/
-public class TapiImpl implements TapiConnectivityService {
+public class TapiConnectivityImpl implements TapiConnectivityService {
- private static final Logger LOG = LoggerFactory.getLogger(TapiImpl.class);
+ private static final Logger LOG = LoggerFactory.getLogger(TapiConnectivityImpl.class);
private OrgOpenroadmServiceService serviceHandler;
- public TapiImpl(OrgOpenroadmServiceService serviceHandler) {
+ public TapiConnectivityImpl(OrgOpenroadmServiceService serviceHandler) {
LOG.info("inside TapiImpl constructor");
this.serviceHandler = serviceHandler;
}
import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
import org.opendaylight.mdsal.binding.api.RpcProviderService;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.transportpce.common.network.NetworkTransactionService;
+import org.opendaylight.transportpce.tapi.connectivity.TapiConnectivityImpl;
import org.opendaylight.transportpce.tapi.topology.TapiTopologyImpl;
+import org.opendaylight.transportpce.tapi.utils.TapiContext;
import org.opendaylight.transportpce.tapi.utils.TapiListener;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.OrgOpenroadmServiceService;
import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.TapiConnectivityService;
private ObjectRegistration<TapiConnectivityService> rpcRegistration;
private final OrgOpenroadmServiceService serviceHandler;
private final TapiListener tapiListener;
+ private final NetworkTransactionService networkTransactionService;
public TapiProvider(DataBroker dataBroker, RpcProviderService rpcProviderService,
- OrgOpenroadmServiceService serviceHandler, TapiListener tapiListener) {
+ OrgOpenroadmServiceService serviceHandler, TapiListener tapiListener,
+ NetworkTransactionService networkTransactionService) {
this.dataBroker = dataBroker;
this.rpcProviderService = rpcProviderService;
this.serviceHandler = serviceHandler;
this.tapiListener = tapiListener;
+ this.networkTransactionService = networkTransactionService;
}
/**
*/
public void init() {
LOG.info("TapiProvider Session Initiated");
- TapiImpl tapi = new TapiImpl(this.serviceHandler);
+ TapiContext tapiContext = new TapiContext(this.networkTransactionService);
+ LOG.info("Empty TAPI context created: {}", tapiContext.getTapiContext());
+ TapiConnectivityImpl tapi = new TapiConnectivityImpl(this.serviceHandler);
TapiTopologyImpl topo = new TapiTopologyImpl(this.dataBroker);
rpcRegistration = rpcProviderService.registerRpcImplementation(TapiConnectivityService.class, tapi);
rpcProviderService.registerRpcImplementation(TapiTopologyService.class, topo);
--- /dev/null
+/*
+ * Copyright © 2021 Nokia, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.transportpce.tapi.utils;
+
+import java.nio.charset.Charset;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
+import java.util.UUID;
+import java.util.concurrent.ExecutionException;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.transportpce.common.network.NetworkTransactionService;
+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.Uuid;
+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.connectivity.rev181210.Context1;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.Context1Builder;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev181210.context.ConnectivityContextBuilder;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.context.TopologyContextBuilder;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.context.NwTopologyServiceBuilder;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class TapiContext {
+
+ private static final Logger LOG = LoggerFactory.getLogger(TapiContext.class);
+ public static final String TAPI_CONTEXT = "T-API context";
+ private final NetworkTransactionService networkTransactionService;
+
+ public TapiContext(NetworkTransactionService networkTransactionService) {
+ this.networkTransactionService = networkTransactionService;
+ createTapiContext();
+ }
+
+ private void createTapiContext() {
+ try {
+ // Augmenting tapi context to include topology and connectivity contexts
+ Name contextName = new NameBuilder().setValue(TAPI_CONTEXT).setValueName("TAPI Context Name").build();
+
+ Context1 connectivityContext =
+ new Context1Builder()
+ .setConnectivityContext(
+ new ConnectivityContextBuilder()
+ .setConnection(new HashMap<>())
+ .setConnectivityService(new HashMap<>())
+ .build())
+ .build();
+
+ Name nwTopoServiceName =
+ new NameBuilder()
+ .setValue("Network Topo Service")
+ .setValueName("Network Topo Service Name")
+ .build();
+
+ org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.Context1 topologyContext
+ = new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.Context1Builder()
+ .setTopologyContext(new TopologyContextBuilder()
+ .setNwTopologyService(new NwTopologyServiceBuilder()
+ .setTopology(new HashMap<>())
+ .setUuid(
+ new Uuid(
+ UUID.nameUUIDFromBytes("Network Topo Service".getBytes(Charset.forName("UTF-8")))
+ .toString()))
+ .setName(Map.of(nwTopoServiceName.key(), nwTopoServiceName))
+ .build())
+ .setTopology(new HashMap<>())
+ .build())
+ .build();
+
+ ContextBuilder contextBuilder = new ContextBuilder()
+ .setName(Map.of(contextName.key(), contextName))
+ .setUuid(
+ new Uuid(UUID.nameUUIDFromBytes(TAPI_CONTEXT.getBytes(Charset.forName("UTF-8"))).toString()))
+ .setServiceInterfacePoint(new HashMap<>())
+ .addAugmentation(connectivityContext)
+ .addAugmentation(topologyContext);
+
+ // todo: add notification context
+ InstanceIdentifier<Context> contextIID = InstanceIdentifier.builder(Context.class).build();
+ // put in datastore
+ this.networkTransactionService.put(LogicalDatastoreType.OPERATIONAL, contextIID, contextBuilder.build());
+ this.networkTransactionService.commit().get();
+ LOG.info("TAPI context created successfully.");
+ } catch (InterruptedException | ExecutionException e) {
+ LOG.error("Failed to create TAPI context", e);
+ }
+ }
+
+ public Context getTapiContext() {
+ // TODO: verify this is correct. Should we identify the context IID with the context UUID??
+ // There is no Identifiable in Context model
+ InstanceIdentifier<Context> contextIID = InstanceIdentifier.builder(Context.class).build();
+ try {
+ Optional<Context> optionalContext = this.networkTransactionService.read(LogicalDatastoreType.OPERATIONAL,
+ contextIID).get();
+ if (!optionalContext.isPresent()) {
+ LOG.error("Tapi context is not present in datastore");
+ return null;
+ }
+ return optionalContext.get();
+ } catch (InterruptedException | ExecutionException e) {
+ LOG.error("Couldnt read tapi context from datastore", e);
+ return null;
+ }
+ }
+
+ public void deleteTapiContext() {
+
+ }
+
+}
<reference id="serviceHandlerService"
interface="org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.OrgOpenroadmServiceService" />
+ <reference id="networkTransactionImpl"
+ interface="org.opendaylight.transportpce.common.network.NetworkTransactionService" />
+
<bean id="tapiListener"
class="org.opendaylight.transportpce.tapi.utils.TapiListener">
</bean>
<argument ref="rpcProviderService" />
<argument ref="serviceHandlerService" />
<argument ref="tapiListener" />
+ <argument ref="networkTransactionImpl" />
</bean>
</blueprint>