summaryrefslogtreecommitdiffstats
path: root/sdnr/wt
diff options
context:
space:
mode:
authorRavi Pendurty <ravi.pendurty@highstreet-technologies.com>2021-04-05 11:04:55 +0200
committerRavi Pendurty <ravi.pendurty@highstreet-technologies.com>2021-04-06 07:16:24 +0200
commit6188c03a3fd1b73da7184c26fdb81f02c8aa8825 (patch)
tree6e5c8c71a0d57ac0f2ec60cf7a60acfab7e83bb4 /sdnr/wt
parent9fb395380431345b7da7a765651185815a9ac91d (diff)
Callhome to VES PNF Registration
Callhome to VES PNF Registration Issue-ID: CCSDK-3160 Signed-off-by: Ravi Pendurty <ravi.pendurty@highstreet-technologies.com> Change-Id: Ic5503ff7bb5bb77af3d5b4ad3ba6b09ccd10d87e Signed-off-by: Ravi Pendurty <ravi.pendurty@highstreet-technologies.com>
Diffstat (limited to 'sdnr/wt')
-rw-r--r--sdnr/wt/devicemanager-adapter-manager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/adaptermanager/test/TestAdapterManagerNetworkElement.java11
-rw-r--r--sdnr/wt/devicemanager-adapter-manager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/adaptermanager/test/TestAdapterManagerNetworkElementFactory.java3
-rw-r--r--sdnr/wt/devicemanager-adapter-manager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/adaptermanager/test/mock/NetconfAccessorMock.java141
-rw-r--r--sdnr/wt/devicemanager-adapter-manager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/adaptermanager/test/mock/TransactionUtilsMock.java47
-rw-r--r--sdnr/wt/devicemanager-oran/provider/pom.xml5
-rw-r--r--sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanNetworkElement.java66
-rw-r--r--sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanRegistrationToVESpnfRegistrationMapper.java87
-rw-r--r--sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanNetworkElementFactory.java9
-rw-r--r--sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanRegistrationToVESpnfRegistration.java248
-rw-r--r--sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/NetconfAccessor.java6
-rw-r--r--sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/NetconfNodeStateServiceImpl.java6
-rw-r--r--sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/NetconfAccessorImpl.java24
-rw-r--r--sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/NetconfAccessorManager.java6
-rw-r--r--sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/TestNetconfAccessorImpl.java51
-rw-r--r--sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/example/TestNetconfHelper.java4
15 files changed, 446 insertions, 268 deletions
diff --git a/sdnr/wt/devicemanager-adapter-manager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/adaptermanager/test/TestAdapterManagerNetworkElement.java b/sdnr/wt/devicemanager-adapter-manager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/adaptermanager/test/TestAdapterManagerNetworkElement.java
index 0fa83c031..203c06134 100644
--- a/sdnr/wt/devicemanager-adapter-manager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/adaptermanager/test/TestAdapterManagerNetworkElement.java
+++ b/sdnr/wt/devicemanager-adapter-manager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/adaptermanager/test/TestAdapterManagerNetworkElement.java
@@ -20,7 +20,6 @@ package org.onap.ccsdk.features.sdnr.wt.devicemanager.adaptermanager.test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
import java.io.IOException;
import java.util.Optional;
@@ -29,18 +28,18 @@ import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.adaptermanager.impl.AdapterManagerNetworkElementFactory;
-import org.onap.ccsdk.features.sdnr.wt.devicemanager.adaptermanager.test.mock.NetconfAccessorMock;
-import org.onap.ccsdk.features.sdnr.wt.devicemanager.adaptermanager.test.mock.TransactionUtilsMock;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.NetworkElement;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider;
import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities;
+import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfBindingAccessor;
+import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.TransactionUtils;
import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.network.topology.simulator.rev191025.SimulatorStatus;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
import org.opendaylight.yangtools.yang.common.QName;
public class TestAdapterManagerNetworkElement {
- static NetconfAccessorMock accessor;
+ static NetconfBindingAccessor accessor;
static DeviceManagerServiceProvider serviceProvider;
static Capabilities capabilities;
QName qCapability;
@@ -49,13 +48,13 @@ public class TestAdapterManagerNetworkElement {
public static void init() throws InterruptedException, IOException {
capabilities = mock(Capabilities.class);
//accessor = mock(NetconfAccessorMock.class);
- accessor = spy(new NetconfAccessorMock(null, null, null, null));
+ accessor = mock(NetconfBindingAccessor.class); //accessor = spy(new NetconfAccessorMock(null, null, null, null));
serviceProvider = mock(DeviceManagerServiceProvider.class);
NodeId nNodeId = new NodeId("nSky");
when(accessor.getCapabilites()).thenReturn(capabilities);
when(accessor.getNodeId()).thenReturn(nNodeId);
- when(accessor.getTransactionUtils()).thenReturn(new TransactionUtilsMock());
+ when(accessor.getTransactionUtils()).thenReturn(mock(TransactionUtils.class));
DataProvider dataProvider = mock(DataProvider.class);
when(serviceProvider.getDataProvider()).thenReturn(dataProvider);
diff --git a/sdnr/wt/devicemanager-adapter-manager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/adaptermanager/test/TestAdapterManagerNetworkElementFactory.java b/sdnr/wt/devicemanager-adapter-manager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/adaptermanager/test/TestAdapterManagerNetworkElementFactory.java
index 228401d6e..ad024e10e 100644
--- a/sdnr/wt/devicemanager-adapter-manager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/adaptermanager/test/TestAdapterManagerNetworkElementFactory.java
+++ b/sdnr/wt/devicemanager-adapter-manager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/adaptermanager/test/TestAdapterManagerNetworkElementFactory.java
@@ -25,7 +25,6 @@ import org.junit.After;
import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.adaptermanager.impl.AdapterManagerNetworkElementFactory;
-import org.onap.ccsdk.features.sdnr.wt.devicemanager.adaptermanager.test.mock.NetconfAccessorMock;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider;
import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities;
import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor;
@@ -42,7 +41,7 @@ public class TestAdapterManagerNetworkElementFactory {
@BeforeClass
public static void init() throws InterruptedException, IOException {
capabilities = mock(Capabilities.class);
- accessor = mock(NetconfAccessorMock.class);
+ accessor = mock(NetconfAccessor.class);
serviceProvider = mock(DeviceManagerServiceProvider.class);
when(accessor.getCapabilites()).thenReturn(capabilities);
diff --git a/sdnr/wt/devicemanager-adapter-manager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/adaptermanager/test/mock/NetconfAccessorMock.java b/sdnr/wt/devicemanager-adapter-manager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/adaptermanager/test/mock/NetconfAccessorMock.java
deleted file mode 100644
index 8a0694087..000000000
--- a/sdnr/wt/devicemanager-adapter-manager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/adaptermanager/test/mock/NetconfAccessorMock.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * ============LICENSE_START========================================================================
- * ONAP : ccsdk feature sdnr wt
- * =================================================================================================
- * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved.
- * =================================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing permissions and limitations under
- * the License.
- * ============LICENSE_END==========================================================================
- */
-package org.onap.ccsdk.features.sdnr.wt.devicemanager.adaptermanager.test.mock;
-
-import com.google.common.util.concurrent.ListenableFuture;
-import java.util.List;
-import java.util.Optional;
-
-import org.eclipse.jdt.annotation.NonNull;
-import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities;
-import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor;
-import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfBindingAccessor;
-import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfDomAccessor;
-import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfNotifications;
-import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.TransactionUtils;
-import org.opendaylight.mdsal.binding.api.DataBroker;
-import org.opendaylight.mdsal.binding.api.MountPoint;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714.CreateSubscriptionOutput;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.netconf.streams.Stream;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.binding.NotificationListener;
-import org.opendaylight.yangtools.yang.common.RpcResult;
-
-/**
- */
-public class NetconfAccessorMock implements NetconfBindingAccessor, NetconfNotifications {
-
- private final NodeId nNodeId;
- private final NetconfNode netconfNode;
- private final MountPoint mountpoint;
- private final DataBroker netconfNodeDataBroker;
-
- public NetconfAccessorMock(NodeId nNodeId, NetconfNode netconfNode, MountPoint mountpoint,
- DataBroker netconfNodeDataBroker) {
- this.nNodeId = nNodeId;
- this.netconfNode = netconfNode;
- this.mountpoint = mountpoint;
- this.netconfNodeDataBroker = netconfNodeDataBroker;
- }
-
- @Override
- public NodeId getNodeId() {
- return nNodeId;
- }
-
- @Override
- public NetconfNode getNetconfNode() {
- return netconfNode;
- }
-
- @Override
- public Capabilities getCapabilites() {
- return null;
- }
-
- @Override
- public DataBroker getDataBroker() {
- return netconfNodeDataBroker;
- }
-
- @Override
- public MountPoint getMountpoint() {
- return mountpoint;
- }
-
- @Override
- public TransactionUtils getTransactionUtils() {
- return null;
- }
-
- @Override
- public <T extends NotificationListener> ListenerRegistration<NotificationListener> doRegisterNotificationListener(
- @NonNull T listener) {
- return null;
- }
-
- @Override
- public ListenableFuture<RpcResult<CreateSubscriptionOutput>> registerNotificationsStream(String streamName) {
- return null;
- }
-
- @Override
- public void registerNotificationsStream(List<Stream> streamList) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public boolean isNCNotificationsSupported() {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public List<Stream> getNotificationStreams() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Optional<NetconfBindingAccessor> getNetconfBindingAccessor() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Optional<NetconfDomAccessor> getNetconfDomAccessor() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Optional<NetconfNotifications> getNotificationAccessor() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public boolean isNotificationsSupported() {
- // TODO Auto-generated method stub
- return false;
- }
-
-}
diff --git a/sdnr/wt/devicemanager-adapter-manager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/adaptermanager/test/mock/TransactionUtilsMock.java b/sdnr/wt/devicemanager-adapter-manager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/adaptermanager/test/mock/TransactionUtilsMock.java
deleted file mode 100644
index e3aa0ae43..000000000
--- a/sdnr/wt/devicemanager-adapter-manager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/adaptermanager/test/mock/TransactionUtilsMock.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * ============LICENSE_START========================================================================
- * ONAP : ccsdk feature sdnr wt
- * =================================================================================================
- * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved.
- * =================================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing permissions and limitations under
- * the License.
- * ============LICENSE_END==========================================================================
- */
-package org.onap.ccsdk.features.sdnr.wt.devicemanager.adaptermanager.test.mock;
-
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicReference;
-
-import org.eclipse.jdt.annotation.Nullable;
-import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.TransactionUtils;
-import org.opendaylight.mdsal.binding.api.DataBroker;
-import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-public class TransactionUtilsMock implements TransactionUtils {
-
- @Override
- public <T extends DataObject> @Nullable T readData(DataBroker dataBroker, LogicalDatastoreType dataStoreType,
- InstanceIdentifier<T> iid) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public <T extends DataObject> @Nullable T readDataOptionalWithStatus(DataBroker dataBroker,
- LogicalDatastoreType dataStoreType, InstanceIdentifier<T> iid, AtomicBoolean noErrorIndication,
- AtomicReference<String> statusIndicator) {
- // TODO Auto-generated method stub
- return null;
- }
-
-}
diff --git a/sdnr/wt/devicemanager-oran/provider/pom.xml b/sdnr/wt/devicemanager-oran/provider/pom.xml
index 3b8583dad..e6ae4bfc2 100644
--- a/sdnr/wt/devicemanager-oran/provider/pom.xml
+++ b/sdnr/wt/devicemanager-oran/provider/pom.xml
@@ -91,6 +91,11 @@
<scope>provided</scope>
</dependency>
<dependency>
+ <groupId>org.opendaylight.netconf</groupId>
+ <artifactId>callhome-model</artifactId>
+ <!-- <scope>provided</scope> -->
+ </dependency>
+ <dependency>
<groupId>org.opendaylight.mdsal</groupId>
<artifactId>mdsal-singleton-common-api</artifactId>
<scope>provided</scope>
diff --git a/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanNetworkElement.java b/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanNetworkElement.java
index 47ea3eadd..df81f60bf 100644
--- a/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanNetworkElement.java
+++ b/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanNetworkElement.java
@@ -41,6 +41,9 @@ import org.opendaylight.yang.gen.v1.urn.onap.system.rev201026.System1;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Guicutthrough;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Inventory;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.NetworkElementDeviceType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev161109.NetconfCallhomeServer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev161109.netconf.callhome.server.AllowedDevices;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev161109.netconf.callhome.server.allowed.devices.Device;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
@@ -64,7 +67,9 @@ public class ORanNetworkElement implements NetworkElement {
private ListenerRegistration<NotificationListener> oRanFaultListenerRegistrationResult;
private @NonNull final ORanFaultNotificationListener oRanFaultListener;
private final NotificationProxyParser notificationProxyParser;
+ private @NonNull ORanRegistrationToVESpnfRegistrationMapper mapper;
private Collection<Component> componentList;
+ private static int sequenceNo = 0;
ORanNetworkElement(NetconfBindingAccessor netconfAccess, DataProvider databaseService,
VESCollectorService vesCollectorService) {
@@ -89,7 +94,7 @@ public class ORanNetworkElement implements NetworkElement {
componentList = YangHelper.getCollection(hardware.nonnullComponent());
List<Inventory> inventoryList =
ORanToInternalDataModel.getInventoryList(netconfAccessor.getNodeId(), componentList);
- inventoryList.forEach(databaseService::writeInventory);
+ inventoryList.forEach(databaseService::writeInventory);
}
Optional<Guicutthrough> oGuicutthrough = ORanToInternalDataModel.getGuicutthrough(getOnapSystemData());
@@ -106,6 +111,8 @@ public class ORanNetworkElement implements NetworkElement {
@Override
public void register() {
initialReadFromNetworkElement();
+ // Publish the mountpoint to VES if enabled
+ publishMountpointToVES();
// Register call back class for receiving notifications
Optional<NetconfNotifications> oNotifications = netconfAccessor.getNotificationAccessor();
if (oNotifications.isPresent()) {
@@ -176,5 +183,60 @@ public class ORanNetworkElement implements NetworkElement {
log.debug("Result of Hardware = {}", res);
return res;
}
-
+
+ private void publishMountpointToVES() {
+ log.debug("In publishMountpointToVES()");
+
+ /**
+ * 1. Check if this device is in the list of allowed-devices.
+ * 2. If device exists in allowed-devices, then create VES pnfRegistration event and publish to VES
+ */
+ if (inAllowedDevices(netconfAccessor.getNodeId().getValue())) {
+ if (vesCollectorService.getConfig().isVESCollectorEnabled()) {
+
+ for (Component component : ORanToInternalDataModel.getRootComponents(componentList)) {
+ //Just get one component. At the moment we don't care which one. Also since there is only one management address, we assume there will be only one chassis.
+ //If the device supports subtended configuration then it is assumed that the Chassis containing the management interface will be the root component and there will be only one root.
+ this.mapper = new ORanRegistrationToVESpnfRegistrationMapper(netconfAccessor,
+ vesCollectorService, component);
+ VESCommonEventHeaderPOJO header =
+ mapper.mapCommonEventHeader(sequenceNo++);
+ VESPNFRegistrationFieldsPOJO body = mapper.mapPNFRegistrationFields();
+ try {
+ vesCollectorService.publishVESMessage(vesCollectorService.generateVESEvent(header, body));
+ } catch (JsonProcessingException e) {
+ log.warn("Error while serializing VES Event to String ", e);
+ e.printStackTrace();
+ }
+
+ }
+ }
+
+ }
+
+ }
+
+ private boolean inAllowedDevices(String mountpointName) {
+ final InstanceIdentifier<AllowedDevices> ALL_DEVICES =
+ InstanceIdentifier.create(NetconfCallhomeServer.class).child(AllowedDevices.class);
+
+ AllowedDevices allowedDevices;
+ allowedDevices = netconfAccessor.getTransactionUtils().readData(
+ netconfAccessor.getControllerBindingDataBroker(), LogicalDatastoreType.CONFIGURATION, ALL_DEVICES);
+
+ if (allowedDevices != null) {
+ Collection<Device> deviceList = YangHelper.getCollection(allowedDevices.nonnullDevice());
+ for (Device device : deviceList) {
+ log.info("Device in allowed-devices is - {}", device.getUniqueId());
+ if (device.getUniqueId().equals(netconfAccessor.getNodeId().getValue())) {
+ log.info("Mountpoint is part of allowed-devices list");
+ return true;
+ }
+ }
+ }
+
+ log.info("Mountpoint {} is not part of allowed-devices list", mountpointName);
+ return false;
+ }
+
}
diff --git a/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanRegistrationToVESpnfRegistrationMapper.java b/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanRegistrationToVESpnfRegistrationMapper.java
new file mode 100644
index 000000000..81605e450
--- /dev/null
+++ b/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanRegistrationToVESpnfRegistrationMapper.java
@@ -0,0 +1,87 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP : ccsdk features
+ * ================================================================================
+ * Copyright (C) 2021 highstreet technologies GmbH Intellectual Property.
+ * All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl;
+
+import java.time.Instant;
+import org.eclipse.jdt.annotation.NonNull;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.VESCollectorService;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESCommonEventHeaderPOJO;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESPNFRegistrationFieldsPOJO;
+import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.hardware.rev180313.hardware.Component;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ORanRegistrationToVESpnfRegistrationMapper {
+
+ private static final Logger LOG = LoggerFactory.getLogger(ORanFaultToVESFaultMapper.class);
+ //CommonEventHeader fields
+ private static final String VES_EVENT_DOMAIN = "pnfRegistration";
+ private static final String VES_EVENTTYPE = "NetConf Callhome Registration";
+ private static final String VES_EVENT_PRIORITY = "Normal";
+
+ private final VESCollectorService vesProvider;
+ private final @NonNull Component component;
+ private final NetconfAccessor netconfAccessor;
+
+ public ORanRegistrationToVESpnfRegistrationMapper(NetconfAccessor netconfAccessor,
+ VESCollectorService vesCollectorService, Component component) {
+ this.netconfAccessor = netconfAccessor;
+ this.vesProvider = vesCollectorService;
+ this.component = component;
+ }
+
+ public VESCommonEventHeaderPOJO mapCommonEventHeader(int sequenceNo) {
+ VESCommonEventHeaderPOJO vesCEH = new VESCommonEventHeaderPOJO();
+ vesCEH.setDomain(VES_EVENT_DOMAIN);
+ vesCEH.setEventId(netconfAccessor.getNodeId().getValue());
+ vesCEH.setEventName(netconfAccessor.getNodeId().getValue());
+ vesCEH.setEventType(VES_EVENTTYPE);
+ vesCEH.setPriority(VES_EVENT_PRIORITY);
+
+ vesCEH.setStartEpochMicrosec(Instant.now().toEpochMilli() * 1000);
+ vesCEH.setLastEpochMicrosec(Instant.now().toEpochMilli() * 1000);
+ vesCEH.setNfVendorName(component.getMfgName());
+ vesCEH.setReportingEntityName(vesProvider.getConfig().getReportingEntityName());
+ vesCEH.setSequence(sequenceNo);
+ vesCEH.setSourceId(component.getUuid().toString());
+ vesCEH.setSourceName(netconfAccessor.getNodeId().getValue());
+
+ return vesCEH;
+ }
+
+ public VESPNFRegistrationFieldsPOJO mapPNFRegistrationFields() {
+ VESPNFRegistrationFieldsPOJO vesPnfFields = new VESPNFRegistrationFieldsPOJO();
+ vesPnfFields.setModelNumber(component.getModelName());
+ vesPnfFields.setOamV4IpAddress(netconfAccessor.getNetconfNode().getHost().getIpAddress().toString());
+ //vesPnfFields.setOamV6IpAddress(oamV6IpAddress); // Check if IP address in V6 format and then include it. Same with v4 address also
+ vesPnfFields.setSerialNumber(component.getSerialNum());
+ vesPnfFields.setVendorName(component.getMfgName());
+ vesPnfFields.setSoftwareVersion(component.getSoftwareRev());
+ vesPnfFields.setUnitType(component.getAlias());
+ vesPnfFields.setUnitFamily(component.getXmlClass().toString());
+ vesPnfFields.setManufactureDate(component.getMfgDate().toString());
+ //vesPnfFields.setLastServiceDate(component.getLastChange());
+
+ return vesPnfFields;
+ }
+}
diff --git a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanNetworkElementFactory.java b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanNetworkElementFactory.java
index 05a2f9334..0da5ec1f4 100644
--- a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanNetworkElementFactory.java
+++ b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanNetworkElementFactory.java
@@ -22,7 +22,6 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.io.IOException;
import java.util.Optional;
-
import org.junit.After;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -43,27 +42,23 @@ public class TestORanNetworkElementFactory {
private static DeviceManagerServiceProvider serviceProvider;
private static Capabilities capabilities;
private static VESCollectorService vesCollectorService;
- private static NetconfBindingAccessor bindingCommunicator;
@BeforeClass
public static void init() throws InterruptedException, IOException {
- bindingCommunicator = mock(NetconfBindingAccessor.class);
- vesCollectorService = mock(VESCollectorService.class);
+ NetconfBindingAccessor bindingCommunicator = mock(NetconfBindingAccessor.class);
NodeId nodeId = new NodeId(NODEIDSTRING);
when(bindingCommunicator.getTransactionUtils()).thenReturn(mock(TransactionUtils.class));
when(bindingCommunicator.getNodeId()).thenReturn(nodeId);
-
capabilities = mock(Capabilities.class);
accessor = mock(NetconfBindingAccessor.class);
serviceProvider = mock(DeviceManagerServiceProvider.class);
+ vesCollectorService = mock(VESCollectorService.class);
when(accessor.getCapabilites()).thenReturn(capabilities);
when(accessor.getNetconfBindingAccessor()).thenReturn(Optional.of(bindingCommunicator));
when(serviceProvider.getDataProvider()).thenReturn(null);
when(serviceProvider.getVESCollectorService()).thenReturn(vesCollectorService);
-
-
}
@Test
diff --git a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanRegistrationToVESpnfRegistration.java b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanRegistrationToVESpnfRegistration.java
new file mode 100644
index 000000000..781d333fe
--- /dev/null
+++ b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanRegistrationToVESpnfRegistration.java
@@ -0,0 +1,248 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP : ccsdk features
+ * ================================================================================
+ * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property.
+ * All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.test;
+
+import static org.mockito.Mockito.when;
+import java.math.BigDecimal;
+import org.eclipse.jdt.annotation.Nullable;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl.ORanRegistrationToVESpnfRegistrationMapper;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.VESCollectorCfgService;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.VESCollectorService;
+import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.hardware.rev180313.hardware.Component;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Host;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.optional.rev190614.netconf.node.augmented.optional.fields.IgnoreMissingSchemaSources;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.parameters.NonModuleCapabilities;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.parameters.OdlHelloMessageCapabilities;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.parameters.Protocol;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.parameters.YangModuleCapabilities;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.AvailableCapabilities;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.ClusteredConnectionStatus;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.PassThrough;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.UnavailableCapabilities;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.Credentials;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.schema.storage.YangLibrary;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
+import org.opendaylight.yangtools.yang.common.Uint16;
+import org.opendaylight.yangtools.yang.common.Uint32;
+
+@RunWith(MockitoJUnitRunner.class)
+public class TestORanRegistrationToVESpnfRegistration {
+
+ @Mock
+ NetconfAccessor netconfAccessor;
+ @Mock
+ VESCollectorService vesCollectorService;
+ @Mock
+ VESCollectorCfgService vesCfgService;
+
+ private final int SEQUENCE_NO = 10;
+
+ @Test
+ public void test() {
+ String dateTimeString = "2020-02-05T12:30:45.283Z";
+ String name = "Slot-0";
+
+ when(netconfAccessor.getNodeId()).thenReturn(new NodeId("nSky"));
+ when(netconfAccessor.getNetconfNode()).thenReturn(new TestNetconfNode());
+ when(vesCollectorService.getConfig()).thenReturn(vesCfgService);
+ when(vesCfgService.getReportingEntityName()).thenReturn("SDN-R");
+ Component testComponent = ComponentHelper.get(name, dateTimeString);
+
+ ORanRegistrationToVESpnfRegistrationMapper mapper = new ORanRegistrationToVESpnfRegistrationMapper(netconfAccessor, vesCollectorService, testComponent);
+ mapper.mapCommonEventHeader(SEQUENCE_NO);
+ mapper.mapPNFRegistrationFields();
+ }
+
+ public class TestNetconfNode implements NetconfNode {
+
+ @Override
+ public @Nullable Credentials getCredentials() {
+ return null;
+ }
+
+ @Override
+ public @Nullable Host getHost() {
+ return new Host(new IpAddress(new Ipv4Address("10.10.10.10")));
+ }
+
+ @Override
+ public @Nullable PortNumber getPort() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public @Nullable Boolean isTcpOnly() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public @Nullable Protocol getProtocol() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public @Nullable Boolean isSchemaless() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public @Nullable YangModuleCapabilities getYangModuleCapabilities() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public @Nullable NonModuleCapabilities getNonModuleCapabilities() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public @Nullable Boolean isReconnectOnChangedSchema() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public @Nullable Uint32 getConnectionTimeoutMillis() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public @Nullable Uint32 getDefaultRequestTimeoutMillis() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public @Nullable Uint32 getMaxConnectionAttempts() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public @Nullable Uint16 getBetweenAttemptsTimeoutMillis() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public @Nullable BigDecimal getSleepFactor() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public @Nullable Uint32 getKeepaliveDelay() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public @Nullable Uint16 getConcurrentRpcLimit() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public @Nullable Uint16 getActorResponseWaitTime() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public @Nullable OdlHelloMessageCapabilities getOdlHelloMessageCapabilities() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public @Nullable ConnectionStatus getConnectionStatus() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public @Nullable ClusteredConnectionStatus getClusteredConnectionStatus() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public @Nullable String getConnectedMessage() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public @Nullable AvailableCapabilities getAvailableCapabilities() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public @Nullable UnavailableCapabilities getUnavailableCapabilities() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public @Nullable PassThrough getPassThrough() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public @Nullable String getSchemaCacheDirectory() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public @Nullable YangLibrary getYangLibrary() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public @Nullable IgnoreMissingSchemaSources getIgnoreMissingSchemaSources() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ }
+
+}
diff --git a/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/NetconfAccessor.java b/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/NetconfAccessor.java
index f24503957..fa544e19a 100644
--- a/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/NetconfAccessor.java
+++ b/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/NetconfAccessor.java
@@ -18,6 +18,7 @@
package org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice;
import java.util.Optional;
+import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
@@ -29,6 +30,11 @@ public interface NetconfAccessor {
static String DefaultNotificationsStream = "NETCONF";
/**
+ * @return the Controller DataBroker
+ */
+ DataBroker getControllerBindingDataBroker();
+
+ /**
* @return the nodeId
*/
NodeId getNodeId();
diff --git a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/NetconfNodeStateServiceImpl.java b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/NetconfNodeStateServiceImpl.java
index 92ce34b16..d3752cdc4 100644
--- a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/NetconfNodeStateServiceImpl.java
+++ b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/NetconfNodeStateServiceImpl.java
@@ -221,7 +221,7 @@ public class NetconfNodeStateServiceImpl
LOG.info("Session Initiated start {}", APPLICATION_NAME);
this.domContext = new DomContext(this.yangParserFactory, this.bindingNormalizedNodeSerializer);
this.netconfCommunicatorManager = new NetconfCommunicatorManager(mountPointService, domMountPointService, domContext);
- this.accessorManager = new NetconfAccessorManager(netconfCommunicatorManager, domContext);
+ this.accessorManager = new NetconfAccessorManager(netconfCommunicatorManager, domContext, this);
// Start RPC Service
this.rpcApiService = new NetconfnodeStateServiceRpcApiImpl(rpcProviderRegistry, vesNotificationListenerList);
// Get configuration
@@ -266,6 +266,10 @@ public class NetconfNodeStateServiceImpl
return Objects.requireNonNull(domContext, "Initialization not completed for domContext" );
}
+ public DataBroker getDataBroker() {
+ return dataBroker;
+ }
+
public NetconfnodeStateServiceRpcApiImpl getNetconfnodeStateServiceRpcApiImpl() {
return Objects.requireNonNull(rpcApiService, "Initialization not completed for rpcApiService" );
}
diff --git a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/NetconfAccessorImpl.java b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/NetconfAccessorImpl.java
index 189845831..8eba4e7ef 100644
--- a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/NetconfAccessorImpl.java
+++ b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/NetconfAccessorImpl.java
@@ -23,7 +23,9 @@ import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities;
import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor;
import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfBindingAccessor;
import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfDomAccessor;
+import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.NetconfNodeStateServiceImpl;
import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.access.dom.DomContext;
+import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNodeConnectionStatus.ConnectionStatus;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
@@ -40,7 +42,7 @@ public class NetconfAccessorImpl implements NetconfAccessor {
private final Capabilities capabilities;
private final NetconfCommunicatorManager netconfCommunicatorManager;
private final DomContext domContext;
-
+ private final NetconfNodeStateServiceImpl netconfNodeStateService;
/**
* Contains all data to access and manage netconf device
*
@@ -52,13 +54,14 @@ public class NetconfAccessorImpl implements NetconfAccessor {
* @param dataBroker to access node
* @param mountpoint of netconfNode
*/
- public NetconfAccessorImpl(NodeId nodeId, NetconfNode netconfNode,
- NetconfCommunicatorManager netconfCommunicatorManager, DomContext domContext) {
+ public NetconfAccessorImpl(NodeId nodeId, NetconfNode netconfNode,
+ NetconfCommunicatorManager netconfCommunicatorManager, DomContext domContext, NetconfNodeStateServiceImpl netconfNodeStateService) {
super();
this.nodeId = Objects.requireNonNull(nodeId);
this.netconfNode = Objects.requireNonNull(netconfNode);
this.netconfCommunicatorManager = Objects.requireNonNull(netconfCommunicatorManager);
this.domContext = Objects.requireNonNull(domContext);
+ this.netconfNodeStateService = Objects.requireNonNull(netconfNodeStateService);
ConnectionStatus csts = netconfNode != null ? netconfNode.getConnectionStatus() : null;
if (csts == null) {
@@ -71,21 +74,13 @@ public class NetconfAccessorImpl implements NetconfAccessor {
this.capabilities = tmp;
}
- /**
- * @param nodeId with uuid of managed netconf node
- * @param dataBroker to access node
- */
- public NetconfAccessorImpl(String nodeId, NetconfNode netconfNode,
- NetconfCommunicatorManager netconfCommunicatorManager, DomContext domContext) {
- this(new NodeId(nodeId), netconfNode, netconfCommunicatorManager, domContext);
- }
-
public NetconfAccessorImpl(NetconfAccessorImpl accessor) {
this.nodeId = accessor.getNodeId();
this.netconfNode = accessor.getNetconfNode();
this.capabilities = accessor.getCapabilites();
this.netconfCommunicatorManager = accessor.netconfCommunicatorManager;
this.domContext = accessor.domContext;
+ this.netconfNodeStateService = accessor.netconfNodeStateService;
}
@Override
@@ -113,4 +108,9 @@ public class NetconfAccessorImpl implements NetconfAccessor {
return netconfCommunicatorManager.getNetconfDomAccessor(this);
}
+ @Override
+ public DataBroker getControllerBindingDataBroker() {
+ return netconfNodeStateService.getDataBroker();
+ }
+
}
diff --git a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/NetconfAccessorManager.java b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/NetconfAccessorManager.java
index 280193402..6c3704421 100644
--- a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/NetconfAccessorManager.java
+++ b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/access/NetconfAccessorManager.java
@@ -45,15 +45,17 @@ public class NetconfAccessorManager {
private final ConcurrentHashMap<NodeId, NetconfAccessor> accessorList;
private final NetconfCommunicatorManager netconfCommunicatorManager;
private final DomContext domContext;
+ private final NetconfNodeStateServiceImpl netconfNodeStateService;
- public NetconfAccessorManager(NetconfCommunicatorManager netconfCommunicatorManager, DomContext domContext) {
+ public NetconfAccessorManager(NetconfCommunicatorManager netconfCommunicatorManager, DomContext domContext, NetconfNodeStateServiceImpl netconfNodeStateService) {
this.netconfCommunicatorManager = Objects.requireNonNull(netconfCommunicatorManager);
this.domContext = Objects.requireNonNull(domContext);
this.accessorList = new ConcurrentHashMap<>();
+ this.netconfNodeStateService = Objects.requireNonNull(netconfNodeStateService);
}
public NetconfAccessor getAccessor(NodeId nNodeId, NetconfNode netconfNode) {
- NetconfAccessor res = new NetconfAccessorImpl(nNodeId, netconfNode, netconfCommunicatorManager, domContext);
+ NetconfAccessor res = new NetconfAccessorImpl(nNodeId, netconfNode, netconfCommunicatorManager, domContext, netconfNodeStateService);
NetconfAccessor previouse = accessorList.put(nNodeId, res);
if (Objects.nonNull(previouse)) {
LOG.warn("Accessor with name already available. Replaced with new one.");
diff --git a/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/TestNetconfAccessorImpl.java b/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/TestNetconfAccessorImpl.java
index 1ec9cde2c..dd61db0d1 100644
--- a/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/TestNetconfAccessorImpl.java
+++ b/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/TestNetconfAccessorImpl.java
@@ -23,37 +23,28 @@ package org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.test;
import static org.junit.Assert.assertEquals;
import java.util.Arrays;
-import java.util.Collection;
import java.util.Optional;
import org.junit.Assert;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Mockito;
import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfNotifications;
+import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.NetconfNodeStateServiceImpl;
import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.access.NetconfAccessorImpl;
import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.access.NetconfCommunicatorManager;
import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.access.binding.NetconfBindingNotificationsImpl;
import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.access.dom.DomContext;
-import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.access.dom.NetconfDomAccessorImpl;
import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.test.example.TestNetconfHelper;
import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.mdsal.binding.api.MountPoint;
import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
-import org.opendaylight.mdsal.dom.api.DOMDataBroker;
-import org.opendaylight.mdsal.dom.api.DOMMountPoint;
-import org.opendaylight.mdsal.dom.api.DOMNotificationListener;
-import org.opendaylight.mdsal.dom.api.DOMNotificationService;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714.CreateSubscriptionInput;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714.NotificationsService;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714.StreamNameType;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.netconf.streams.Stream;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.netconf.streams.StreamBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.model.api.SchemaPath;
public class TestNetconfAccessorImpl extends Mockito {
@@ -67,8 +58,9 @@ public class TestNetconfAccessorImpl extends Mockito {
NetconfNode testNode = TestNetconfHelper.getTestNode(nodeId, capabilityStringForNetworkElement)
.augmentation(NetconfNode.class);
- NetconfAccessorImpl netconfAccessor =
- new NetconfAccessorImpl(nodeId, testNode, netconfCommunicatorManager, domContext);
+ NetconfNodeStateServiceImpl netconfNodeStateService = mock(NetconfNodeStateServiceImpl.class);
+ NetconfAccessorImpl netconfAccessor = new NetconfAccessorImpl(nodeId, testNode, netconfCommunicatorManager,
+ domContext, netconfNodeStateService);
Assert.assertNotNull(netconfAccessor);
@@ -138,39 +130,4 @@ public class TestNetconfAccessorImpl extends Mockito {
}
- @Test
- public void testNetconfDomNotification() {
-
- NetconfAccessorImpl netconfAccessor = TestNetconfHelper.getNetconfAcessorImpl();
- DOMDataBroker domDataBroker = mock(DOMDataBroker.class);
- DOMMountPoint domMountPoint = mock(DOMMountPoint.class);
- DOMNotificationService domNotificationService = mock(DOMNotificationService.class);
-
- YangInstanceIdentifier mountpointPath = YangInstanceIdentifier.builder()
- .node(NetworkTopology.QNAME)
- .build();
- when(domMountPoint.getIdentifier()).thenReturn(mountpointPath);
- when(domMountPoint.getService(DOMNotificationService.class)).thenReturn(Optional.of(domNotificationService));
-
- DomContext domContext = mock(DomContext.class);
-
- NetconfDomAccessorImpl netconfDomAccessor =
- new NetconfDomAccessorImpl(netconfAccessor, domDataBroker, domMountPoint, domContext);
-
- Collection<SchemaPath> types = Arrays.asList(SchemaPath.create(false, NetworkTopology.QNAME));
-
- DOMNotificationListener listener = (notification) -> System.out.println("Notification: "+notification);
- ListenerRegistration<DOMNotificationListener> res =
- netconfDomAccessor.doRegisterNotificationListener(listener, types);
-
- //Capture parameters and assert them
- ArgumentCaptor<DOMNotificationListener> captor1 = ArgumentCaptor.forClass(DOMNotificationListener.class);
- @SuppressWarnings("unchecked")
- ArgumentCaptor<Collection<SchemaPath>> captor2 = ArgumentCaptor.forClass(Collection.class);
- verify(domNotificationService).registerNotificationListener(captor1.capture(), captor2.capture());
-
- assertEquals("Listener", listener, captor1.getValue());
- assertEquals("SchemaPath", types, captor2.getValue());
- }
-
}
diff --git a/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/example/TestNetconfHelper.java b/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/example/TestNetconfHelper.java
index ac466579f..2b6c77ce0 100644
--- a/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/example/TestNetconfHelper.java
+++ b/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/example/TestNetconfHelper.java
@@ -23,6 +23,7 @@ package org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.test.example;
import java.util.Arrays;
import org.mockito.Mockito;
+import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.NetconfNodeStateServiceImpl;
import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.access.NetconfAccessorImpl;
import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.access.NetconfCommunicatorManager;
import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.access.dom.DomContext;
@@ -71,8 +72,9 @@ public class TestNetconfHelper extends Mockito {
NetconfNode testNode = TestNetconfHelper.getTestNode(nodeId, capabilityStringForNetworkElement)
.augmentation(NetconfNode.class);
+ NetconfNodeStateServiceImpl netconfNodeStateService = mock(NetconfNodeStateServiceImpl.class);
NetconfAccessorImpl netconfAccessor =
- new NetconfAccessorImpl(nodeId, testNode, netconfCommunicatorManager, domContext);
+ new NetconfAccessorImpl(nodeId, testNode, netconfCommunicatorManager, domContext, netconfNodeStateService);
return netconfAccessor;
}
}