devicemanager-core refactoring and support for TLS mountpoints using data-provider... 87/122987/2
authorRavi Pendurty <ravi.pendurty@highstreet-technologies.com>
Fri, 30 Jul 2021 09:44:17 +0000 (15:14 +0530)
committerKAPIL SINGAL <ks220y@att.com>
Fri, 30 Jul 2021 18:05:09 +0000 (18:05 +0000)
Use NodeId instead of String for mountpointname and enhance data-provider for creation of TLS mountpoints using REST or from the UI

Issue-ID: CCSDK-3403
Signed-off-by: Ravi Pendurty <ravi.pendurty@highstreet-technologies.com>
Change-Id: Iafb9fe81c2e1d1152beef2b86299edb78a870d85
Signed-off-by: Ravi Pendurty <ravi.pendurty@highstreet-technologies.com>
35 files changed:
sdnr/wt/common-yang/rfc7317-ietf-system/pom.xml
sdnr/wt/data-provider/model/pom.xml
sdnr/wt/data-provider/model/src/main/yang/data-provider@2020-11-10.yang
sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataProviderServiceImpl.java
sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestGetTlsKeys.java [new file with mode: 0644]
sdnr/wt/devicemanager-core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/AaiService.java
sdnr/wt/devicemanager-core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/EventHandlingService.java
sdnr/wt/devicemanager-core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/FaultService.java
sdnr/wt/devicemanager-core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/MaintenanceService.java
sdnr/wt/devicemanager-core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/NotificationService.java
sdnr/wt/devicemanager-core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/PerformanceManager.java
sdnr/wt/devicemanager-core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/types/InternalConnectionStatus.java
sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/aaiconnector/impl/AaiProviderClient.java
sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/DcaeForwarderImpl.java
sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/DcaeForwarderInternal.java
sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/DcaeMessages.java
sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/DcaeProviderClient.java
sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/DcaeProviderWorker.java
sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/eventdatahandler/DeviceManagerDatabaseNotificationService.java
sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/eventdatahandler/ODLEventListenerHandler.java
sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/eventdatahandler/RpcPushNotificationsHandler.java
sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/housekeeping/ResyncNetworkElementHouskeepingService.java
sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerImpl.java
sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerNetconfConnectHandler.java
sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerNetconfNotConnectHandler.java
sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/ProviderClient.java
sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/util/NetworkElementConnectionEntitiyUtil.java
sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/maintenance/impl/MaintenanceServiceImpl.java
sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/performancemanager/impl/PerformanceManagerImpl.java
sdnr/wt/devicemanager-core/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestAai.java
sdnr/wt/devicemanager-core/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDcae.java
sdnr/wt/devicemanager-onap/onf12/feature/pom.xml
sdnr/wt/devicemanager-onap/onf12/installer/pom.xml
sdnr/wt/devicemanager-onap/onf12/provider/pom.xml
sdnr/wt/devicemanager-onap/onf12/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/ONFCoreNetworkElement12Basic.java

index 10a70d9..bad2646 100755 (executable)
 
     <dependencies>
         <dependency>
-            <groupId>org.onap.ccsdk.features.sdnr.wt</groupId>
+            <groupId>${project.groupId}</groupId>
             <artifactId>rfc8341</artifactId>
             <version>${project.version}</version>
         </dependency>
         <dependency>
-            <groupId>org.onap.ccsdk.features.sdnr.wt</groupId>
+            <groupId>${project.groupId}</groupId>
             <artifactId>iana-crypt-hash</artifactId>
             <version>${project.version}</version>
         </dependency>
index 15eecce..6a193a4 100644 (file)
             <groupId>${project.groupId}</groupId>
             <artifactId>openroadm-pm-types</artifactId>
             <version>${project.version}</version>
-        </dependency>
-         <dependency>
-            <groupId>org.opendaylight.netconf</groupId>
-            <artifactId>sal-netconf-connector</artifactId>
-            <scope>provided</scope>
         </dependency>
         <dependency>
             <groupId>${project.groupId}</groupId>
             <artifactId>sdnr-wt-common</artifactId>
             <version>${project.version}</version>
         </dependency>
+        <dependency>
+            <groupId>org.opendaylight.netconf</groupId>
+            <artifactId>sal-netconf-connector</artifactId>
+            <scope>provided</scope>
+        </dependency>
         <dependency>
             <groupId>com.fasterxml.jackson.core</groupId>
             <artifactId>jackson-databind</artifactId>
index 31c7fd8..be2c638 100644 (file)
@@ -195,7 +195,7 @@ module data-provider {
         description
           "implements sth. like o-ran*.yang";
       }
-      enum ORAN {
+      enum O-RAN {
         description
           "implements RAN according to o-ran*.yang";
       }
@@ -1253,6 +1253,11 @@ module data-provider {
       description
         "categorized type of device based on implemented yang specs";
     }
+    leaf device-function {
+      type string;
+      description
+            "specifies the RAN functions supported by the device";
+    }
     leaf is-required {
       type boolean;
       description
@@ -1273,6 +1278,11 @@ module data-provider {
       description
         "TLS key-id in MD-SAL";
     }
+    leaf mount-method {
+      type string;
+      description
+        "netconf-node credential type for mount";
+    }
     description
       "An object class defining the NetConf connection towards a
        NetConf server. ";
@@ -1897,4 +1907,23 @@ module data-provider {
         }
       }
     }
+  rpc read-tls-key-entry {
+      description
+        "Get tls-keys of netconf-keystore";
+      input {
+        uses entity-input;
+      }
+      output {
+        container pagination {
+          uses pagination-output-g;
+          description
+            "The pagination details used by the provider to filter the data.";
+        }
+        leaf-list data {
+          type string;
+          description
+            "The output data as list of tls-keys in netconf-keystore";
+        }
+      }
+    }
 }
index ad71284..2bf67fd 100644 (file)
@@ -95,12 +95,17 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.pro
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadPmdata24hLtpListOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadStatusInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadStatusOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadTlsKeyEntryInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadTlsKeyEntryOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadTlsKeyEntryOutputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.UpdateMaintenanceInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.UpdateMaintenanceOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.UpdateMediatorServerInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.UpdateMediatorServerOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.UpdateNetworkElementConnectionInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.UpdateNetworkElementConnectionOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.tls.key.entry.output.Pagination;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.tls.key.entry.output.PaginationBuilder;
 import org.opendaylight.yangtools.concepts.Builder;
 import org.opendaylight.yangtools.concepts.ObjectRegistration;
 import org.opendaylight.yangtools.yang.binding.DataObject;
@@ -119,6 +124,8 @@ public class DataProviderServiceImpl implements DataProviderService, AutoCloseab
     public static final String CONFIGURATIONFILE = "etc/dataprovider.properties";
     private static final long DATABASE_TIMEOUT_MS = 120 * 1000L;
     private static final @NonNull InstanceIdentifier<Keystore> KEYSTORE_IIF = InstanceIdentifier.create(Keystore.class);
+    private static final Pagination EMPTY_PAGINATION = new PaginationBuilder().setSize(Uint32.valueOf(20))
+            .setTotal(Uint64.valueOf(0)).setPage(Uint64.valueOf(1)).build();
     private static final long DEFAULT_PAGESIZE = 20;
     private static final long DEFAULT_PAGE = 1;
 
@@ -407,6 +414,45 @@ public class DataProviderServiceImpl implements DataProviderService, AutoCloseab
         return result.buildFuture();
     }
 
+    @Override
+    public ListenableFuture<RpcResult<ReadTlsKeyEntryOutput>> readTlsKeyEntry(ReadTlsKeyEntryInput input) {
+        LOG.debug("RPC Request: readTlsKeyEntry with input {}", input);
+        RpcResultBuilder<ReadTlsKeyEntryOutput> result = read(() -> DataProviderServiceImpl.this.readTlsKeys(input));
+        return result.buildFuture();
+    }
+
+    // -- private classes and functions
+
+    private ReadTlsKeyEntryOutputBuilder readTlsKeys(ReadTlsKeyEntryInput input) {
+        Optional<Keystore> result = Optional.empty();
+        try {
+            result = this.dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, KEYSTORE_IIF)
+                    .get();
+        } catch (InterruptedException | ExecutionException e) {
+            LOG.warn("problem reading netconf-keystore: ", e);
+        }
+        ReadTlsKeyEntryOutputBuilder output = new ReadTlsKeyEntryOutputBuilder();
+        if (result.isEmpty()) {
+            return output.setData(Arrays.asList()).setPagination(EMPTY_PAGINATION);
+        }
+        Map<KeyCredentialKey, KeyCredential> keyCredential = result.get().getKeyCredential();
+        if (keyCredential == null) {
+            return output.setData(Arrays.asList()).setPagination(EMPTY_PAGINATION);
+        }
+        long pageNum = input.getPagination() == null ? DEFAULT_PAGE
+                : input.getPagination().getPage() == null ? DEFAULT_PAGE : input.getPagination().getPage().longValue();
+        long size = input.getPagination() == null ? DEFAULT_PAGESIZE
+                : input.getPagination().getSize() == null ? DEFAULT_PAGESIZE
+                        : input.getPagination().getSize().longValue();
+        long from = pageNum > 0 ? (pageNum - 1) * size : 0;
+        output.setData(keyCredential.keySet().stream().skip(from).limit(size).map(e -> e.getKeyId())
+                .collect(Collectors.toList()));
+        output.setPagination(new PaginationBuilder().setPage(Uint64.valueOf(pageNum))
+                .setSize(Uint32.valueOf(output.getData().size())).setTotal(Uint64.valueOf(keyCredential.size()))
+                .build());
+        return output;
+    }
+
     private static String assembleExceptionMessage(Exception e) {
         StringWriter sw = new StringWriter();
         PrintWriter pw = new PrintWriter(sw);
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestGetTlsKeys.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestGetTlsKeys.java
new file mode 100644 (file)
index 0000000..610f547
--- /dev/null
@@ -0,0 +1,201 @@
+/*
+ * ============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.dataprovider.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import com.google.common.util.concurrent.FluentFuture;
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.StandardOpenOption;
+import java.util.Optional;
+import java.util.concurrent.ExecutionException;
+import org.eclipse.jdt.annotation.NonNull;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.http.MsServlet;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.impl.DataProviderServiceImpl;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.test.util.HostInfoForTest;
+import org.onap.ccsdk.features.sdnr.wt.yang.mapper.YangToolsMapper;
+import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.api.ReadTransaction;
+import org.opendaylight.mdsal.binding.api.RpcProviderService;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.keystore.rev171017.Keystore;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadTlsKeyEntryInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadTlsKeyEntryInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadTlsKeyEntryOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.entity.input.Pagination;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.entity.input.PaginationBuilder;
+import org.opendaylight.yangtools.util.concurrent.FluentFutures;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.common.Uint32;
+import org.opendaylight.yangtools.yang.common.Uint64;
+
+public class TestGetTlsKeys {
+
+    private static final int DBPORT = HostInfoForTest.get()[0].port;
+    private static RpcProviderService rpcProviderService = mock(RpcProviderService.class);
+    private static MsServlet msServlet = mock(MsServlet.class);
+    private static DataBroker dataBroker = mock(DataBroker.class);
+    private static DataProviderServiceImpl dataProvider = null;
+
+    @BeforeClass
+    public static void init() {
+        String configContent = "[es]\n" + "esHosts=" + String.format("http://localhost:%d", DBPORT) + "\n"
+                + "esArchiveLifetimeSeconds=2592000\n" + "esCluster=\n" + "esArchiveCheckIntervalSeconds=0\n"
+                + "esNode=elasticsearchnode\n" + "esAuthUsername=${SDNRDBUSERNAME}\n"
+                + "esAuthPassword=${SDNRDBPASSWORD}\n" + "esTrustAllCerts=${SDNRDBTRUSTALLCERTS}\n" + "";
+        try {
+            finish();
+            Files.createDirectories(new File("etc").toPath());
+            Files.write(new File(DataProviderServiceImpl.CONFIGURATIONFILE).toPath(), configContent.getBytes(),
+                    StandardOpenOption.WRITE, StandardOpenOption.CREATE_NEW);
+        } catch (IOException e) {
+            e.printStackTrace();
+            fail(e.getMessage());
+        }
+
+        when(dataBroker.newReadOnlyTransaction())
+                .thenReturn(new ReadHelperTransaction("src/test/resources/tlskeys/keys1.json", Keystore.class));
+        try {
+            dataProvider = new DataProviderServiceImpl(rpcProviderService, msServlet, dataBroker);
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail(e.getMessage());
+        }
+
+    }
+
+    @AfterClass
+    public static void finish() {
+        File f = new File(DataProviderServiceImpl.CONFIGURATIONFILE);
+        if (f.exists()) {
+            f.delete();
+        }
+        File folder = new File("etc");
+        if (folder.exists()) {
+            folder.delete();
+        }
+    }
+
+    @Test
+    public void test() {
+         Pagination pagination = new PaginationBuilder().setPage(Uint64.valueOf(1)).setSize(Uint32.valueOf(20)).build();
+        ReadTlsKeyEntryInput firstPageInput = new ReadTlsKeyEntryInputBuilder().setPagination(pagination).build();
+        RpcResult<ReadTlsKeyEntryOutput> output = null;
+        try {
+            output = dataProvider.readTlsKeyEntry(firstPageInput).get();
+        } catch (InterruptedException | ExecutionException e) {
+            fail(e.getMessage());
+        }
+        ReadTlsKeyEntryOutput result = output.getResult();
+        assertEquals(4,result.getPagination().getTotal().longValue());
+        assertEquals(4, result.getData().size());
+        assertEquals(1, result.getPagination().getPage().longValue());
+        assertEquals(4, result.getPagination().getSize().longValue());
+    }
+    @Test
+    public void test2() {
+         Pagination pagination = new PaginationBuilder().setPage(Uint64.valueOf(1)).setSize(Uint32.valueOf(2)).build();
+        ReadTlsKeyEntryInput firstPageInput = new ReadTlsKeyEntryInputBuilder().setPagination(pagination).build();
+        RpcResult<ReadTlsKeyEntryOutput> output = null;
+        try {
+            output = dataProvider.readTlsKeyEntry(firstPageInput).get();
+        } catch (InterruptedException | ExecutionException e) {
+            fail(e.getMessage());
+        }
+        ReadTlsKeyEntryOutput result = output.getResult();
+        assertEquals(4,result.getPagination().getTotal().longValue());
+        assertEquals(2, result.getData().size());
+        assertEquals(1, result.getPagination().getPage().longValue());
+        assertEquals(2, result.getPagination().getSize().longValue());
+    }
+
+    @Test
+    public void test3() {
+         Pagination pagination = new PaginationBuilder().setPage(Uint64.valueOf(2)).setSize(Uint32.valueOf(3)).build();
+        ReadTlsKeyEntryInput firstPageInput = new ReadTlsKeyEntryInputBuilder().setPagination(pagination).build();
+        RpcResult<ReadTlsKeyEntryOutput> output = null;
+        try {
+            output = dataProvider.readTlsKeyEntry(firstPageInput).get();
+        } catch (InterruptedException | ExecutionException e) {
+            fail(e.getMessage());
+        }
+        ReadTlsKeyEntryOutput result = output.getResult();
+        assertEquals(4,result.getPagination().getTotal().longValue());
+        assertEquals(1, result.getData().size());
+        assertEquals(2, result.getPagination().getPage().longValue());
+        assertEquals(1, result.getPagination().getSize().longValue());
+    }
+
+    private static class ReadHelperTransaction implements ReadTransaction {
+        private final String filename;
+        private final YangToolsMapper mapper;
+        private final Class<?> clazz;
+
+        public ReadHelperTransaction(String filename, Class<?> clazz) {
+            this.filename = filename;
+            this.clazz = clazz;
+            this.mapper = new YangToolsMapper();
+        }
+
+        @Override
+        public @NonNull Object getIdentifier() {
+            // TODO Auto-generated method stub
+            return null;
+        }
+
+        @SuppressWarnings("unchecked")
+        @Override
+        public <T extends DataObject> @NonNull FluentFuture<Optional<T>> read(@NonNull LogicalDatastoreType store,
+                @NonNull InstanceIdentifier<T> path) {
+
+            T result = null;
+            try {
+                result = (T) this.mapper.readValue(new File(filename), this.clazz);
+            } catch (IOException e) {
+                return FluentFutures.immediateFluentFuture(Optional.empty());
+            }
+            return FluentFutures.immediateFluentFuture(Optional.of(result));
+        }
+
+        @Override
+        public @NonNull FluentFuture<Boolean> exists(@NonNull LogicalDatastoreType store,
+                @NonNull InstanceIdentifier<?> path) {
+            // TODO Auto-generated method stub
+            return null;
+        }
+
+        @Override
+        public void close() {
+            // TODO Auto-generated method stub
+
+        }
+    }
+}
index eca19a8..53c5c14 100644 (file)
@@ -17,6 +17,8 @@
  */
 package org.onap.ccsdk.features.sdnr.wt.devicemanager.service;
 
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
+
 /**
  * Forward to Active and Available Inventory
  */
@@ -25,11 +27,11 @@ public interface AaiService extends DeviceManagerService {
     /**
      * @param mountPointNodeName
      */
-    void onDeviceRegistered(String mountPointNodeName);
+    void onDeviceRegistered(NodeId nodeId);
 
     /**
      * @param mountPointNodeName
      */
-    void onDeviceUnregistered(String mountPointNodeName);
+    void onDeviceUnregistered(NodeId nodeId);
 
 }
index 5cb9b9f..e59401c 100644 (file)
@@ -19,6 +19,7 @@ package org.onap.ccsdk.features.sdnr.wt.devicemanager.service;
 
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.NetworkElementDeviceType;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
 
 /**
  * Event Forwarding for central event management by devicemanager
@@ -29,12 +30,12 @@ public interface EventHandlingService {
      * @param mountPointNodeName
      * @param deviceType
      */
-    void connectIndication(String mountPointNodeName, NetworkElementDeviceType deviceType);
+    void connectIndication(NodeId nodeId, NetworkElementDeviceType deviceType);
 
     /**
      * @param mountPointNodeName
      */
-    void deRegistration(String mountPointNodeName);
+    void deRegistration(NodeId nodeId);
 
     /**
      *
@@ -43,13 +44,13 @@ public interface EventHandlingService {
      * @param attributeNewValue
      * @param nNode
      */
-    void updateRegistration(String registrationName, String attribute, String attributeNewValue, NetconfNode nNode);
+    void updateRegistration(NodeId nodeId, String attribute, String attributeNewValue, NetconfNode nNode);
 
     /**
      * @param nodeIdString
      * @param nNode
      */
-    void registration(String nodeIdString, NetconfNode nNode);
+    void registration(NodeId nodeId, NetconfNode nNode);
 
     /**
      * @param objectId
index f414b4b..5598bd1 100644 (file)
@@ -28,9 +28,18 @@ import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.
 public interface FaultService extends DeviceManagerService {
 
     /**
-     * Notify fault information to devicemanager
+     * Forward received fault information to devicemanager. Devicemanager writes abstracted fault information to
+     * database and send abstracted fault information to websocket.
+     * For sending specific notifications to a client, additionally use
+     * {@link org.onap.ccsdk.features.sdnr.wt.websocketmanager.model.WebsocketManagerService}
+     * <ul>
+     * <li>write to database faultcurrent FaultlogEntity namespace: urn:opendaylight:params:xml:ns:yang:data-provider
+     * <li>write to database faultlog
+     * <li>send via websocket as ProblemNotification namespace: urn:opendaylight:params:xml:ns:yang:devicemanager
+     * </ul>
      *
      * @param faultNotification to send
+     *
      */
     void faultNotification(@NonNull FaultlogEntity faultNotification);
 
index 8a2ffd8..544ba5f 100644 (file)
  */
 package org.onap.ccsdk.features.sdnr.wt.devicemanager.service;
 
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
+
 public interface MaintenanceService extends DeviceManagerService {
 
     /**
      * Verify maintenance state of given object according to the filter settings. The object is specified by the
      * criteria provided in the parameters. The data _id (uuid) is equal to the mountpointReference.
-     * 
+     *
      * @param mountpointReference used as reference, to query the data from database.
      * @param objectIdRef first level id in onf core model, delivered by notification objectid
      * @param problem problem name of device, delivered in problem notification
      * @return boolean indication
      */
-    boolean isONFObjectInMaintenance(String mountpointReference, String objectIdRef, String problem);
+    boolean isONFObjectInMaintenance(NodeId nodeId, String objectIdRef, String problem);
 
     /**
      * @param mountPointNodeName
      */
-    void createIfNotExists(String mountPointNodeName);
+    void createIfNotExists(NodeId nodeId);
 
     /**
      * @param mountPointNodeName
      */
-    void deleteIfNotRequired(String mountPointNodeName);
+    void deleteIfNotRequired(NodeId nodeId);
 
 
 }
index b249c50..c766faa 100644 (file)
@@ -24,31 +24,52 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.pro
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
 
 /**
- * Central notification management of devicemanager
+ * Central notification management of devicemanagers.
+ * Notifications are forwarded to ODLUX-Clients and written into database.
+ * Type {@link #EventlogEntity} contains all information.
+ * Basically, all fields have to be provided with meaningful or
+ * unique value.
+ * <ul>
+ * <li>SourceType: Mandatory to choose one of the ENUMS, specified by SDNC software
+ * <li>Host Name: Mountpoint name
+ * <li>Timestamp: From message or created by controller
+ * <li>ObjectId: Unique ID of Object (e.g. device, interface) within namespace device
+ * <li>attributeName: Unique ID within namespace object or message about changed value,
+ *     presented in ODLUX "Message" column.
+ * </ul>
  */
 public interface NotificationService extends DeviceManagerService {
 
-
-    /** Event notification to devicemanager. Can be change, create or remove indication **/
+    /**
+     * Handling of event notification, received by devicemanager.
+     * Can be a change, create or remove indication.
+     *
+     * @param eventNotification is containing all event related information.
+     */
     void eventNotification(@NonNull EventlogEntity eventNotification);
 
-//    void eventNotification(NodeId nodeId, Notification notification, @NonNull QName qname,
-//            @Nullable DateAndTime timeStamp);
-
-    /** create notification for an object **/
+    /**
+     * create notification for an object. Message set to "Create"
+     *
+     * @param nodeId of device
+     * @param counter provided
+     * @param timeStamp provided
+     * @param objectId provided
+     */
     void creationNotification(NodeId nodeId, @Nullable Integer counter, @Nullable DateAndTime timeStamp,
             @Nullable String objectId);
 
-//    void creationNotification(NodeId nodeId, Notification notification, @NonNull QName qname,
-//            @Nullable DateAndTime timeStamp);
-
-    /** delete notification of object **/
+    /**
+     * delete notification of object. Message set to "Deletion"
+     *
+     * @param nodeId of device
+     * @param counter provided
+     * @param timeStamp provided
+     * @param objectId provided
+     */
     void deletionNotification(NodeId nodeId, @Nullable Integer counter, @Nullable DateAndTime timeStamp,
             @Nullable String objectId);
 
-//    void deletionNotification(NodeId nodeId, Notification notification, @NonNull QName qname,
-//            @Nullable DateAndTime timeStamp);
-
     /**
      * change notification of attribute of object
      *
@@ -62,9 +83,4 @@ public interface NotificationService extends DeviceManagerService {
     void changeNotification(NodeId nodeId, @Nullable Integer counter, @Nullable DateAndTime timeStamp,
             @Nullable String objectId, @Nullable String attributeName, @Nullable String newValue);
 
-//    void changeNotification(NodeId nodeId, Notification notification, @NonNull QName qname,
-//            @Nullable DateAndTime timeStamp);
-
-
-
 }
index 3f93108..d3cd882 100644 (file)
@@ -18,6 +18,7 @@
 package org.onap.ccsdk.features.sdnr.wt.devicemanager.service;
 
 import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.NetworkElement;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
 
 /**
  * @author herbert
@@ -29,11 +30,11 @@ public interface PerformanceManager extends DeviceManagerService {
      * @param mountPointNodeName
      * @param ne
      */
-    void registration(String mountPointNodeName, NetworkElement ne);
+    void registration(NodeId nodeId, NetworkElement ne);
 
     /**
      * @param mountPointNodeName
      */
-    void deRegistration(String mountPointNodeName);
+    void deRegistration(NodeId nodeId);
 
 }
index 303cd82..29450ed 100644 (file)
@@ -23,6 +23,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.pro
 
 public class InternalConnectionStatus {
     public static ConnectionLogStatus statusFromNodeStatus(ConnectionStatus nodeStatus) {
+        if(nodeStatus==null) {
+            return ConnectionLogStatus.Undefined;
+        }
         switch (nodeStatus) {
             case Connected:
                 return ConnectionLogStatus.Connected;
index 193b96a..acd1833 100644 (file)
@@ -30,6 +30,7 @@ import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.InventoryProvide
 import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.NetworkElement;
 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.AaiService;
 import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.InventoryInformationDcae;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -59,33 +60,35 @@ public class AaiProviderClient implements AaiService, AutoCloseable {
         return this.config;
     }
 
-    public void onDeviceRegistered(String mountPointName) {
+    @Override
+    public void onDeviceRegistered(NodeId nodeId) {
         if (this.config.isOff()) {
             return;
         }
         NetworkElement ne =
-                this.deviceManager != null ? this.deviceManager.getConnectedNeByMountpoint(mountPointName) : null;
+                this.deviceManager != null ? this.deviceManager.getConnectedNeByMountpoint(nodeId.getValue()) : null;
         Optional<InventoryProvider> oip = ne != null ? ne.getService(InventoryProvider.class) : Optional.empty();
-        this.onDeviceRegistered(mountPointName,
+        this.onDeviceRegistered(nodeId,
                 oip.isPresent() ? oip.get().getInventoryInformation("MWPS") : InventoryInformationDcae.getDefault());
     }
 
-    public void onDeviceRegistered(String mountPointName, InventoryInformationDcae i) {
+    public void onDeviceRegistered(NodeId nodeId, InventoryInformationDcae i) {
         if (this.config.isOff()) {
             return;
         }
-        new Thread(new AaiCreateRequestRunnable(mountPointName, i.getType(), i.getModel(), i.getVendor(),
+        new Thread(new AaiCreateRequestRunnable(nodeId.getValue(), i.getType(), i.getModel(), i.getVendor(),
                 i.getDeviceIpv4(), i.getInterfaceUuidList())).start();
     }
 
-    public void onDeviceUnregistered(String mountPointName) {
+    @Override
+    public void onDeviceUnregistered(NodeId nodeId) {
         if (this.config.isOff()) {
             return;
         }
         if (this.config.doDeleteOnMountPointRemoved()) {
-            new Thread(new AaiDeleteRequestRunnable(mountPointName)).start();
+            new Thread(new AaiDeleteRequestRunnable(nodeId.getValue())).start();
         } else {
-            LOG.debug("prevent deleting device {} by config", mountPointName);
+            LOG.debug("prevent deleting device {} by config", nodeId.getValue());
         }
     }
 
index 8e091be..e5dc1d0 100644 (file)
@@ -24,6 +24,7 @@ import org.onap.ccsdk.features.sdnr.wt.common.HtAssert;
 import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.ProviderClient;
 import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ProblemNotificationXml;
 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.MaintenanceService;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -47,23 +48,23 @@ public class DcaeForwarderImpl implements DcaeForwarderInternal, AutoCloseable {
 
     @Override
     @SuppressWarnings("null")
-    public void sendProblemNotificationUsingMaintenanceFilter(String nodeId, ProblemNotificationXml notificationXml) {
-        if (!this.maintenanceService.isONFObjectInMaintenance(nodeId, notificationXml.getObjectId(),
+    public void sendProblemNotificationUsingMaintenanceFilter(NodeId oWNKEYID, ProblemNotificationXml notificationXml) {
+        if (!this.maintenanceService.isONFObjectInMaintenance(oWNKEYID, notificationXml.getObjectId(),
                 notificationXml.getProblem())) {
             if (dcaeProvider != null) {
-                this.dcaeProvider.sendProblemNotification(nodeId, notificationXml);
+                this.dcaeProvider.sendProblemNotification(oWNKEYID, notificationXml);
             }
             if (this.aotsmClient != null) {
-                this.aotsmClient.sendProblemNotification(nodeId, notificationXml);
+                this.aotsmClient.sendProblemNotification(oWNKEYID, notificationXml);
             }
         } else {
             LOG.debug(
-                    "Notification will not be sent to external services. Device " + nodeId + " is in maintenance mode");
+                    "Notification will not be sent to external services. Device " + oWNKEYID.getValue() + " is in maintenance mode");
         }
     }
 
     @Override
-    public void sendProblemNotification(String nodeId, ProblemNotificationXml notificationXml) {
+    public void sendProblemNotification(NodeId nodeId, ProblemNotificationXml notificationXml) {
         //to prevent push alarms on reconnect
         //=> only pushed alarms are forwared to dcae
         if (dcaeProvider != null) {
index d86e0b4..d4e6016 100644 (file)
@@ -18,6 +18,7 @@
 package org.onap.ccsdk.features.sdnr.wt.devicemanager.dcaeconnector.impl;
 
 import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ProblemNotificationXml;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
 
 /**
  * @author herbert
@@ -29,12 +30,12 @@ public interface DcaeForwarderInternal {
      * @param oWNKEYNAME
      * @param notificationXml
      */
-    void sendProblemNotificationUsingMaintenanceFilter(String oWNKEYNAME, ProblemNotificationXml notificationXml);
+    void sendProblemNotificationUsingMaintenanceFilter(NodeId oWNKEYID, ProblemNotificationXml notificationXml);
 
     /**
      * @param nodeName
      * @param notificationXml
      */
-    void sendProblemNotification(String nodeName, ProblemNotificationXml notificationXml);
+    void sendProblemNotification(NodeId nodeId, ProblemNotificationXml notificationXml);
 
 }
index de62af0..065faf3 100644 (file)
@@ -41,6 +41,7 @@ import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ProblemNotificatio
 import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.InventoryProvider;
 import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.NetworkElement;
 import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.InventoryInformationDcae;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -103,7 +104,7 @@ public class DcaeMessages {
      * @return String with answer
      */
 
-    public String postNotification(String mountPointName, ProblemNotificationXml notification) {
+    public String postNotification(NodeId nodeId, ProblemNotificationXml notification) {
 
         String problemName = notification.getProblem();
         String sequence = notification.getCounter();
@@ -111,7 +112,7 @@ public class DcaeMessages {
         String severity = convert(notification.getSeverity());
         String timeStamp = convert(notification.getTimeStamp());
 
-        String body = assembleEventNotificationFromTemplate(null, timeStamp, sequence, mountPointName, objId,
+        String body = assembleEventNotificationFromTemplate(null, timeStamp, sequence, nodeId, objId,
                 problemName, severity, notification.getTimeStamp()).toString();
 
         return dcaeSender.sendDcaePost(body);
@@ -243,7 +244,7 @@ public class DcaeMessages {
      */
 
     private StringBuffer assembleEventNotificationFromTemplate(StringBuffer sb, String epochTimeMicrosecondsString,
-            String sequence, String mountpointName, String objId, String problemName, String severity,
+            String sequence, NodeId nodeId, String objId, String problemName, String severity,
             String eventTimeValueNetconfFormatString) {
 
         if (sb == null) {
@@ -251,7 +252,7 @@ public class DcaeMessages {
         }
 
         NetworkElement optionalNe =
-                deviceManager != null ? deviceManager.getConnectedNeByMountpoint(mountpointName) : null;
+                deviceManager != null ? deviceManager.getConnectedNeByMountpoint(nodeId.getValue()) : null;
         InventoryInformationDcae neInventory = InventoryInformationDcae.getDefault();
         if (optionalNe != null) {
             Optional<InventoryProvider> inventoryProvider = optionalNe.getService(InventoryProvider.class);
@@ -265,7 +266,7 @@ public class DcaeMessages {
                 + "    \"event\": {\n"
                 + "        \"commonEventHeader\": {\n"
                 + "            \"domain\": \"fault\",\n"
-                + "            \"eventId\": \"" + mountpointName + "_" + objId + "_" + problemName + "\",\n"
+                + "            \"eventId\": \"" + nodeId.getValue() + "_" + objId + "_" + problemName + "\",\n"
                 + "            \"eventName\": \"" + eventNamePrefix + "_" + problemName + "\",\n"
                 + "            \"eventType\": \"" + eventType + "\",\n"
                 + "            \"sequence\": " + sequence + ",\n"
@@ -273,7 +274,7 @@ public class DcaeMessages {
                 + "            \"reportingEntityId\": \"\",\n"
                 + "            \"reportingEntityName\": \"" + entityName + "\",\n"
                 + "            \"sourceId\": \"\",\n"
-                + "            \"sourceName\": \"" + mountpointName + "\",\n"
+                + "            \"sourceName\": \"" + nodeId.getValue() + "\",\n"
                 + "            \"startEpochMicrosec\": " + epochTimeMicrosecondsString + ",\n"
                 + "            \"lastEpochMicrosec\": " + epochTimeMicrosecondsString + ",\n"
                 + "            \"version\": 3.0\n"
index 7ceafcb..8416d36 100644 (file)
@@ -23,6 +23,7 @@ import org.onap.ccsdk.features.sdnr.wt.devicemanager.dcaeconnector.impl.config.D
 import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.DeviceManagerImpl;
 import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.ProviderClient;
 import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ProblemNotificationXml;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -55,16 +56,16 @@ public class DcaeProviderClient implements AutoCloseable, ProviderClient {
     }
 
     @Override
-    public void sendProblemNotification(String mountPointName, ProblemNotificationXml notification) {
+    public void sendProblemNotification(NodeId nodeId, ProblemNotificationXml notification) {
         synchronized (lock) {
-            worker.sendProblemNotification(mountPointName, notification);
+            worker.sendProblemNotification(nodeId, notification);
         }
     }
 
     @Override
-    public void sendProblemNotification(String mountPointName, ProblemNotificationXml notification,
+    public void sendProblemNotification(NodeId nodeId, ProblemNotificationXml notification,
             boolean neDeviceAlarm) {
-        sendProblemNotification(mountPointName, notification);
+        sendProblemNotification(nodeId, notification);
     }
 
     @Override
index 1ef50c3..f407b78 100644 (file)
@@ -21,10 +21,10 @@ import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
-
 import org.onap.ccsdk.features.sdnr.wt.devicemanager.dcaeconnector.impl.config.DcaeConfig;
 import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.DeviceManagerImpl;
 import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ProblemNotificationXml;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -62,8 +62,8 @@ class DcaeProviderWorker implements AutoCloseable {
         LOG.info("Fault task scheduled");
     }
 
-    public void sendProblemNotification(String mountPointName, ProblemNotificationXml notification) {
-        LOG.debug("Notification answer: {}", dcaeMessages.postNotification(mountPointName, notification));
+    public void sendProblemNotification(NodeId nodeId, ProblemNotificationXml notification) {
+        LOG.debug("Notification answer: {}", dcaeMessages.postNotification(nodeId, notification));
     }
 
     @Override
index dc57626..94694cd 100644 (file)
@@ -171,9 +171,9 @@ public class DeviceManagerDatabaseNotificationService implements NotificationSer
     }
 
     private void pushAlarmIfNotInMaintenance(String nodeName, ProblemNotificationXml notificationXml) {
-        if (!this.maintenanceService.isONFObjectInMaintenance(nodeName, notificationXml.getObjectId(),
+        if (!this.maintenanceService.isONFObjectInMaintenance(new NodeId(nodeName), notificationXml.getObjectId(),
                 notificationXml.getProblem())) {
-            this.aotsDcaeForwarder.sendProblemNotification(nodeName, notificationXml);
+            this.aotsDcaeForwarder.sendProblemNotification(new NodeId(nodeName), notificationXml);
         } else {
             LOG.debug("Notification will not be sent to external services. Device " + nodeName
                     + " is in maintenance mode");
index 66fcc05..037f097 100644 (file)
@@ -17,6 +17,8 @@
  */
 package org.onap.ccsdk.features.sdnr.wt.devicemanager.eventdatahandler;
 
+import java.util.Optional;
+import java.util.concurrent.ExecutionException;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.TimeUnit;
@@ -30,9 +32,12 @@ import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.util.NetworkElementCon
 import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ProblemNotificationXml;
 import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.WebSocketServiceClientInternal;
 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.EventHandlingService;
+import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
 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.opendaylight.netconf.node.topology.rev150114.network.topology.topology.topology.types.TopologyNetconf;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ConnectionLogStatus;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Connectionlog;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ConnectionlogBuilder;
@@ -48,7 +53,14 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicema
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.ObjectDeletionNotificationBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.ProblemNotification;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.ProblemNotificationBuilder;
+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.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -78,6 +90,7 @@ public class ODLEventListenerHandler implements EventHandlingService, AutoClosea
     private final WebSocketServiceClientInternal webSocketService;
     private final DataProvider databaseService;
     private final DcaeForwarderInternal aotsDcaeForwarder;
+    private final DataBroker dataBroker;
     private final ExecutorService executor = Executors.newFixedThreadPool(5);
     private int eventNumber;
 
@@ -95,7 +108,7 @@ public class ODLEventListenerHandler implements EventHandlingService, AutoClosea
      * @param dcaeForwarder to deliver problems to external service
      */
     public ODLEventListenerHandler(String ownKeyName, WebSocketServiceClientInternal webSocketService,
-            DataProvider databaseService, DcaeForwarderInternal dcaeForwarder) {
+            DataProvider databaseService, DcaeForwarderInternal dcaeForwarder, DataBroker dataBroker) {
         super();
 
         this.ownKeyName = ownKeyName;
@@ -103,6 +116,7 @@ public class ODLEventListenerHandler implements EventHandlingService, AutoClosea
 
         this.databaseService = databaseService;
         this.aotsDcaeForwarder = dcaeForwarder;
+        this.dataBroker = dataBroker;
 
         this.eventNumber = 0;
     }
@@ -118,24 +132,43 @@ public class ODLEventListenerHandler implements EventHandlingService, AutoClosea
      * @param nNode with mountpoint data
      */
     @Override
-    public void registration(String registrationName, NetconfNode nNode) {
+    public void registration(NodeId nodeId, NetconfNode nNode) {
 
         DateAndTime ts = NETCONFTIME_CONVERTER.getTimeStamp();
         ObjectCreationNotification notification = new ObjectCreationNotificationBuilder()
-                .setObjectIdRef(registrationName).setCounter(popEvntNumber()).setTimeStamp(ts).build();
-        Connectionlog log = new ConnectionlogBuilder().setNodeId(registrationName)
+                .setObjectIdRef(nodeId.getValue()).setCounter(popEvntNumber()).setTimeStamp(ts).build();
+        Connectionlog log = new ConnectionlogBuilder().setNodeId(nodeId.getValue())
                 .setStatus(ConnectionLogStatus.Mounted).setTimestamp(ts).build();
-        NetworkElementConnectionEntity e =
-                NetworkElementConnectionEntitiyUtil.getNetworkConnection(registrationName, nNode);
-        LOG.debug("registration networkelement-connection for {} with status {}", registrationName, e.getStatus());
+
+        NetworkElementConnectionEntity e = NetworkElementConnectionEntitiyUtil.getNetworkConnection(nodeId.getValue(),
+                nNode, getNnodeConfig(nodeId));
+        LOG.debug("registration networkelement-connection for {} with status {}", nodeId.getValue(), e.getStatus());
 
         // Write first to prevent missing entries
-        databaseService.updateNetworkConnection22(e, registrationName);
+        databaseService.updateNetworkConnection22(e, nodeId.getValue());
         databaseService.writeConnectionLog(log);
         webSocketService.sendViaWebsockets(new NodeId(ownKeyName), notification, ObjectCreationNotification.QNAME,
                 NetconfTimeStampImpl.getConverter().getTimeStamp());
     }
 
+    private Optional<NetconfNode> getNnodeConfig(NodeId nodeId) {
+        if (this.dataBroker != null) {
+
+            InstanceIdentifier<NetconfNode> iif = InstanceIdentifier.create(NetworkTopology.class)
+                    .child(Topology.class, new TopologyKey(new TopologyId(TopologyNetconf.QNAME.getLocalName())))
+                    .child(Node.class, new NodeKey(nodeId)).augmentation(NetconfNode.class);
+
+            try {
+                Optional<NetconfNode> onode =
+                        this.dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, iif).get();
+                return onode;
+            } catch (InterruptedException | ExecutionException e) {
+                LOG.warn("problem requesting netconfnode again:", e);
+            }
+        }
+        return Optional.empty();
+    }
+
     /**
      * (Connected) mountpoint state moves to connected
      *
@@ -143,21 +176,22 @@ public class ODLEventListenerHandler implements EventHandlingService, AutoClosea
      * @param deviceType according to assessement
      */
     @Override
-    public void connectIndication(String mountpointNodeName, NetworkElementDeviceType deviceType) {
+    public void connectIndication(NodeId nNodeId, NetworkElementDeviceType deviceType) {
 
         // Write first to prevent missing entries
-        LOG.debug("updating networkelement-connection devicetype for {} with {}", mountpointNodeName, deviceType);
+        LOG.debug("updating networkelement-connection devicetype for {} with {}", nNodeId.getValue(), deviceType);
         NetworkElementConnectionEntity e =
                 NetworkElementConnectionEntitiyUtil.getNetworkConnectionDeviceTpe(deviceType);
         //if updating db entry for ne connection fails retry later on (due elasticsearch max script executions error)
-        if (!databaseService.updateNetworkConnectionDeviceType(e, mountpointNodeName)) {
-            this.updateNeConnectionRetryWithDelay(e, mountpointNodeName);
+        if (!databaseService.updateNetworkConnectionDeviceType(e, nNodeId.getValue())) {
+            this.updateNeConnectionRetryWithDelay(e, nNodeId.getValue());
         }
         DateAndTime ts = NETCONFTIME_CONVERTER.getTimeStamp();
         AttributeValueChangedNotification notification = new AttributeValueChangedNotificationBuilder()
-                .setCounter(popEvntNumber()).setTimeStamp(ts).setObjectIdRef(mountpointNodeName)
+                .setCounter(popEvntNumber()).setTimeStamp(ts).setObjectIdRef(nNodeId.getValue())
                 .setAttributeName("deviceType").setNewValue(deviceType.name()).build();
-        webSocketService.sendViaWebsockets(new NodeId(ownKeyName), notification, AttributeValueChangedNotification.QNAME, ts);
+        webSocketService.sendViaWebsockets(new NodeId(ownKeyName), notification,
+                AttributeValueChangedNotification.QNAME, ts);
     }
 
     /**
@@ -166,11 +200,11 @@ public class ODLEventListenerHandler implements EventHandlingService, AutoClosea
      * @param mountpointNodeName nodeid
      * @param netconfNode node
      */
-    public void onStateChangeIndication(String mountpointNodeName, NetconfNode netconfNode) {
-        LOG.debug("mountpoint state changed indication for {}", mountpointNodeName);
+    public void onStateChangeIndication(NodeId nodeId, NetconfNode netconfNode) {
+        LOG.debug("mountpoint state changed indication for {}", nodeId.getValue());
         ConnectionStatus csts = netconfNode.getConnectionStatus();
-        this.updateRegistration(mountpointNodeName, ConnectionStatus.class.getSimpleName(),
-                csts != null ? csts.getName() : "null", netconfNode);
+        this.updateRegistration(nodeId, ConnectionStatus.class.getSimpleName(), csts != null ? csts.getName() : "null",
+                netconfNode);
 
     }
 
@@ -181,17 +215,18 @@ public class ODLEventListenerHandler implements EventHandlingService, AutoClosea
      */
     @SuppressWarnings("null")
     @Override
-    public void deRegistration(String registrationName) {
+    public void deRegistration(NodeId nodeId) {
 
         DateAndTime ts = NETCONFTIME_CONVERTER.getTimeStamp();
         ObjectDeletionNotification notification = new ObjectDeletionNotificationBuilder().setCounter(popEvntNumber())
-                .setTimeStamp(ts).setObjectIdRef(registrationName).build();
-        Connectionlog log = new ConnectionlogBuilder().setNodeId(registrationName)
+                .setTimeStamp(ts).setObjectIdRef(nodeId.getValue()).build();
+        Connectionlog log = new ConnectionlogBuilder().setNodeId(nodeId.getValue())
                 .setStatus(ConnectionLogStatus.Unmounted).setTimestamp(ts).build();
         // Write first to prevent missing entries
-        databaseService.removeNetworkConnection(registrationName);
+        databaseService.removeNetworkConnection(nodeId.getValue());
         databaseService.writeConnectionLog(log);
-        webSocketService.sendViaWebsockets(new NodeId(registrationName), notification, ObjectDeletionNotification.QNAME, ts);
+        webSocketService.sendViaWebsockets(new NodeId(nodeId.getValue()), notification,
+                ObjectDeletionNotification.QNAME, ts);
 
     }
 
@@ -201,24 +236,24 @@ public class ODLEventListenerHandler implements EventHandlingService, AutoClosea
      * @param registrationName Name of the event that is used as key in the database.
      */
     @Override
-    public void updateRegistration(String registrationName, String attribute, String attributeNewValue,
-            NetconfNode nNode) {
+    public void updateRegistration(NodeId nodeId, String attribute, String attributeNewValue, NetconfNode nNode) {
         DateAndTime ts = NETCONFTIME_CONVERTER.getTimeStamp();
         AttributeValueChangedNotification notification = new AttributeValueChangedNotificationBuilder()
-                .setCounter(popEvntNumber()).setTimeStamp(ts).setObjectIdRef(registrationName)
+                .setCounter(popEvntNumber()).setTimeStamp(ts).setObjectIdRef(nodeId.getValue())
                 .setAttributeName(attribute).setNewValue(attributeNewValue).build();
-        Connectionlog log = new ConnectionlogBuilder().setNodeId(registrationName).setStatus(getStatus(attributeNewValue))
-                .setTimestamp(ts).build();
-        NetworkElementConnectionEntity e =
-                NetworkElementConnectionEntitiyUtil.getNetworkConnection(registrationName, nNode);
-        LOG.debug("updating networkelement-connection for {} with status {}", registrationName, e.getStatus());
+        Connectionlog log = new ConnectionlogBuilder().setNodeId(nodeId.getValue())
+                .setStatus(getStatus(attributeNewValue)).setTimestamp(ts).build();
+        NetworkElementConnectionEntity e = NetworkElementConnectionEntitiyUtil.getNetworkConnection(nodeId.getValue(),
+                nNode, getNnodeConfig(nodeId));
+        LOG.debug("updating networkelement-connection for {} with status {}", nodeId.getValue(), e.getStatus());
 
         //if updating db entry for ne connection fails retry later on (due elasticsearch max script executions error)
-        if (!databaseService.updateNetworkConnection22(e, registrationName)) {
-            this.updateNeConnectionRetryWithDelay(nNode, registrationName);
+        if (!databaseService.updateNetworkConnection22(e, nodeId.getValue())) {
+            this.updateNeConnectionRetryWithDelay(nNode, nodeId.getValue());
         }
         databaseService.writeConnectionLog(log);
-        webSocketService.sendViaWebsockets(new NodeId(ownKeyName), notification, AttributeValueChangedNotification.QNAME, ts);
+        webSocketService.sendViaWebsockets(new NodeId(ownKeyName), notification,
+                AttributeValueChangedNotification.QNAME, ts);
     }
 
 
@@ -271,7 +306,7 @@ public class ODLEventListenerHandler implements EventHandlingService, AutoClosea
         databaseService.writeFaultLog(notificationXml.getFaultlog(SourceType.Controller));
         databaseService.updateFaultCurrent(notificationXml.getFaultcurrent());
 
-        aotsDcaeForwarder.sendProblemNotificationUsingMaintenanceFilter(ownKeyName, notificationXml);
+        aotsDcaeForwarder.sendProblemNotificationUsingMaintenanceFilter(new NodeId(ownKeyName), notificationXml);
 
         webSocketService.sendViaWebsockets(new NodeId(ownKeyName), notification, ProblemNotification.QNAME, ts);
     }
index 273231a..90e07e6 100644 (file)
@@ -102,7 +102,7 @@ public class RpcPushNotificationsHandler implements PushNotifications {
         ProblemNotification notification = new ProblemNotificationBuilder().setProblem(input.getProblem())
                 .setCounter(input.getCounter()).setObjectIdRef(input.getObjectId())
                 .setSeverity(InternalSeverity.toYang(input.getSeverity())).setTimeStamp(input.getTimestamp()).build();
-        aotsDcaeForwarder.sendProblemNotificationUsingMaintenanceFilter(OWNKEYNAME, notificationXml);
+        aotsDcaeForwarder.sendProblemNotificationUsingMaintenanceFilter(new NodeId(OWNKEYNAME), notificationXml);
         webSocketService.sendViaWebsockets(new NodeId(input.getNodeId()!=null?input.getNodeId():OWNKEYNAME), notification, ProblemNotification.QNAME, input.getTimestamp());
     }
 
index fe166c9..50b0215 100644 (file)
@@ -99,7 +99,7 @@ public class ResyncNetworkElementHouskeepingService implements ResyncNetworkElem
             List<String> nodeNamesInput;
 
             // Create list of mountpoints if input is empty, using the content in ES
-            if (nodeNames == null || nodeNames.isEmpty()) {
+            if (nodeNames == null || nodeNames.size() <= 0) {
                 nodeNamesInput = this.databaseClientEvents.getAllNodesWithCurrentAlarms();
             } else {
                 nodeNamesInput = nodeNames;
index ed452cb..3613562 100644 (file)
@@ -218,8 +218,8 @@ public class DeviceManagerImpl implements NetconfNetworkElementService, DeviceMa
 
         RpcPushNotificationsHandler rpcPushNotificationsHandler =
                 new RpcPushNotificationsHandler(webSocketService, dataProvider, aotsDcaeForwarder);
-        this.odlEventListenerHandler =
-                new ODLEventListenerHandler(myDbKeyNameExtended, webSocketService, dataProvider, aotsDcaeForwarder);
+        this.odlEventListenerHandler = new ODLEventListenerHandler(myDbKeyNameExtended, webSocketService, dataProvider,
+                aotsDcaeForwarder, dataBroker);
         this.archiveCleanService = new ArchiveCleanService(iEntityDataProvider.getEsConfig(),
                 clusterSingletonServiceProvider, dataProvider);
         this.housekeepingService = new ConnectionStatusHousekeepingService(config, clusterSingletonServiceProvider,
index bb61a82..4b4d1ed 100644 (file)
@@ -88,13 +88,13 @@ public class DeviceManagerNetconfConnectHandler extends DeviceManagerNetconfNotC
         }
         // update db with connect status
         NetconfNode netconfNode = acessor.getNetconfNode();
-        sendUpdateNotification(mountPointNodeName, netconfNode.getConnectionStatus(), netconfNode);
+        sendUpdateNotification(acessor.getNodeId(), netconfNode.getConnectionStatus(), netconfNode);
 
         for (NetworkElementFactory f : getFactoryList()) {
             Optional<NetworkElement> optionalNe = f.create(acessor, getServiceProvider());
             if (optionalNe.isPresent()) {
                 // sendUpdateNotification(mountPointNodeName, nNode.getConnectionStatus(), nNode);
-                handleNeStartup(mountPointNodeName, optionalNe.get());
+                handleNeStartup(acessor.getNodeId(), optionalNe.get());
                 break; // Use the first provided
             }
         }
@@ -109,7 +109,7 @@ public class DeviceManagerNetconfConnectHandler extends DeviceManagerNetconfNotC
         if (optionalNetconfNode.isPresent()) {
             NetconfNode nNode = optionalNetconfNode.get();
             ConnectionStatus csts = nNode.getConnectionStatus();
-            sendUpdateNotification(mountPointNodeName, csts, nNode);
+            sendUpdateNotification(nNodeId, csts, nNode);
         }
 
         // Handling if mountpoint exist. connected -> connecting/UnableToConnect
@@ -137,7 +137,7 @@ public class DeviceManagerNetconfConnectHandler extends DeviceManagerNetconfNotC
 
     /**
      * Do all tasks necessary to move from mountpoint state connected -> connecting
-     * 
+     *
      * @param mountPointNodeName provided
      */
     private void stopListenerOnNodeForConnectedState(String mountPointNodeName) {
@@ -154,32 +154,32 @@ public class DeviceManagerNetconfConnectHandler extends DeviceManagerNetconfNotC
     }
 
 
-    private void handleNeStartup(String mountPointNodeName, NetworkElement inNe) {
+    private void handleNeStartup(NodeId nodeId, NetworkElement inNe) {
 
-        LOG.info("NE Management for {} with {}", mountPointNodeName, inNe.getClass().getName());
+        LOG.info("NE Management for {} with {}", nodeId.getValue(), inNe.getClass().getName());
         NetworkElement result;
         synchronized (networkelementLock) {
-            result = connectedNetworkElementRepresentations.put(mountPointNodeName, inNe);
+            result = connectedNetworkElementRepresentations.put(nodeId.getValue(), inNe);
         }
         if (result != null) {
             LOG.warn("NE list was not empty as expected, but contained {} ", result.getNodeId());
         } else {
-            LOG.debug("refresh necon entry for {} with type {}", mountPointNodeName, inNe.getDeviceType());
+            LOG.debug("refresh necon entry for {} with type {}", nodeId.getValue(), inNe.getDeviceType());
             if (isOdlEventListenerHandlerEnabled()) {
-                getOdlEventListenerHandler().connectIndication(mountPointNodeName, inNe.getDeviceType());
+                getOdlEventListenerHandler().connectIndication(nodeId, inNe.getDeviceType());
             }
         }
         if (isDeviceMonitorEnabled()) {
-            getDeviceMonitor().deviceConnectMasterIndication(mountPointNodeName, inNe);
+            getDeviceMonitor().deviceConnectMasterIndication(nodeId.getValue(), inNe);
         }
 
         inNe.register();
     }
 
-    private void sendUpdateNotification(String mountPointNodeName, ConnectionStatus csts, NetconfNode nNode) {
-        LOG.info("update ConnectedState for device :: Name : {} ConnectionStatus {}", mountPointNodeName, csts);
+    private void sendUpdateNotification(NodeId nodeId, ConnectionStatus csts, NetconfNode nNode) {
+        LOG.info("update ConnectedState for device :: Name : {} ConnectionStatus {}", nodeId.getValue(), csts);
         if (isOdlEventListenerHandlerEnabled()) {
-            getOdlEventListenerHandler().updateRegistration(mountPointNodeName, ConnectionStatus.class.getSimpleName(),
+            getOdlEventListenerHandler().updateRegistration(nodeId, ConnectionStatus.class.getSimpleName(),
                     csts != null ? csts.getName() : "null", nNode);
         }
     }
index df83301..f9bbe1a 100644 (file)
@@ -75,7 +75,7 @@ public class DeviceManagerNetconfNotConnectHandler implements NetconfNodeStateLi
     public void onCreated(NodeId nNodeId, NetconfNode netconfNode) {
         LOG.info("onCreated {}", nNodeId);
         if (isOdlEventListenerHandlerMaster()) {
-            odlEventListenerHandler.registration(nNodeId.getValue(), netconfNode);
+            odlEventListenerHandler.registration(nNodeId, netconfNode);
         }
         if (deviceMonitorEnabled) {
             deviceMonitor.deviceDisconnectIndication(nNodeId.getValue());
@@ -86,20 +86,19 @@ public class DeviceManagerNetconfNotConnectHandler implements NetconfNodeStateLi
     public void onStateChange(NodeId nNodeId, NetconfNode netconfNode) {
         LOG.info("onStateChange {}", nNodeId);
         if (isOdlEventListenerHandlerMaster()) {
-            odlEventListenerHandler.onStateChangeIndication(nNodeId.getValue(), netconfNode);
+            odlEventListenerHandler.onStateChangeIndication(nNodeId, netconfNode);
         }
     }
 
     @Override
     public void onRemoved(NodeId nNodeId) {
-        String mountPointNodeName = nNodeId.getValue();
         LOG.info("mountpointNodeRemoved {}", nNodeId.getValue());
 
         if (deviceMonitorEnabled) {
-            deviceMonitor.removeMountpointIndication(mountPointNodeName);
+            deviceMonitor.removeMountpointIndication(nNodeId.getValue());
         }
         if (isOdlEventListenerHandlerMaster()) {
-            odlEventListenerHandler.deRegistration(mountPointNodeName); //Additional indication for log
+            odlEventListenerHandler.deRegistration(nNodeId); //Additional indication for log
         }
     }
 
index 82519e4..7258e8d 100644 (file)
@@ -6,9 +6,9 @@
  * =================================================================================================
  * 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
 package org.onap.ccsdk.features.sdnr.wt.devicemanager.impl;
 
 import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ProblemNotificationXml;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
 
 public interface ProviderClient extends AutoCloseable {
 
     /**
      * Send out problem notification, that was created by a device/ or NE
-     * 
+     *
      * @param mountPointName related
      * @param notification xml description
      */
-    public void sendProblemNotification(String mountPointName, ProblemNotificationXml notification);
+    public void sendProblemNotification(NodeId nodeId, ProblemNotificationXml notification);
 
     /**
      * Send out problem notification
-     * 
+     *
      * @param mountPointName related
      * @param notification xml description
      * @param neDeviceAlarm true indicates an NE originated alarm, false an sdncontroller generated alarm
      */
-    public void sendProblemNotification(String mountPointName, ProblemNotificationXml notification,
+    public void sendProblemNotification(NodeId nodeId, ProblemNotificationXml notification,
             boolean neDeviceAlarm);
 
 }
index 5b8105a..4369af0 100644 (file)
@@ -17,6 +17,7 @@
  */
 package org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.util;
 
+import java.util.Optional;
 import javax.annotation.Nonnull;
 import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.InternalConnectionStatus;
 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities;
@@ -24,12 +25,16 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.
 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.topology.rev150114.NetconfNode;
 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.node.credentials.credentials.KeyAuth;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.credentials.LoginPassword;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.credentials.LoginPw;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.credentials.LoginPwUnencrypted;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ConnectionLogStatus;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.NetworkElementConnectionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.NetworkElementConnectionEntity;
 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.data.provider.rev201110.network.element.connection.entity.NodeDetailsBuilder;
+import org.opendaylight.yangtools.yang.common.Uint32;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -58,6 +63,11 @@ public class NetworkElementConnectionEntitiyUtil {
      * @return NetworkElementConnectionEntity specific information
      */
     public static NetworkElementConnectionEntity getNetworkConnection(String nodeId, @Nonnull NetconfNode nNode) {
+        return getNetworkConnection(nodeId, nNode, Optional.empty());
+    }
+
+    public static NetworkElementConnectionEntity getNetworkConnection(String nodeId, @Nonnull NetconfNode nNode,
+            Optional<NetconfNode> configNetconfNode) {
 
         NetworkElementConnectionBuilder eb = new NetworkElementConnectionBuilder();
         // -- basics
@@ -79,15 +89,34 @@ public class NetworkElementConnectionEntitiyUtil {
         Host host = nNode.getHost();
         PortNumber portNumber = nNode.getPort();
         if (host != null && portNumber != null) {
-            eb.setHost(host.stringValue()).setPort(portNumber.getValue().longValue());
+            eb.setHost(host.stringValue()).setPort(Uint32.valueOf(portNumber.getValue()));
         }
 
-        Credentials credentials = nNode.getCredentials();
+        Credentials credentials =
+                configNetconfNode.isPresent() ? configNetconfNode.get().getCredentials() : nNode.getCredentials();
         if (credentials instanceof LoginPassword) {
             LoginPassword loginPassword = (LoginPassword) credentials;
-            eb.setUsername(loginPassword.getUsername()).setPassword(loginPassword.getPassword());
+            eb.setUsername(loginPassword.getUsername()).setPassword(loginPassword.getPassword())
+                    .setMountMethod(LoginPassword.class.getSimpleName());
+        } else if (credentials instanceof LoginPwUnencrypted) {
+            LoginPwUnencrypted loginPassword = (LoginPwUnencrypted) credentials;
+            eb.setUsername(loginPassword.getLoginPasswordUnencrypted().getUsername())
+                    .setPassword(loginPassword.getLoginPasswordUnencrypted().getPassword())
+                    .setMountMethod(LoginPwUnencrypted.class.getSimpleName());
+        } else if (credentials instanceof LoginPw) {
+            LoginPw loginPassword = (LoginPw) credentials;
+            eb.setUsername(loginPassword.getLoginPassword().getUsername())
+                    .setPassword(loginPassword.getLoginPassword().getPassword())
+                    .setMountMethod(LoginPw.class.getSimpleName());
+        } else if (credentials instanceof KeyAuth) {
+            KeyAuth keyAuth = (KeyAuth) credentials;
+            eb.setUsername(keyAuth.getKeyBased().getUsername()).setTlsKey(keyAuth.getKeyBased().getKeyId())
+                    .setMountMethod(KeyAuth.class.getSimpleName());
         }
-        eb.setCoreModelCapability("Unsupported"); // Default value. Specific value (if any) is set in the specific devicemanagers
+        LOG.debug("mount-method: {} ({})", eb.getMountMethod(),
+                credentials == null ? null : credentials.getClass().getName());
+        // Default value. Specific value (if any) is set in the specific devicemanagers
+        eb.setCoreModelCapability("Unsupported");
         return eb.build();
     }
 }
index 7dad49e..6351f39 100644 (file)
@@ -35,6 +35,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicema
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.TestMaintenanceModeInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.TestMaintenanceModeOutputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.show.required.network.element.output.RequiredNetworkElementBuilder;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -54,13 +55,13 @@ public class MaintenanceServiceImpl implements MaintenanceService, MaintenanceRP
     }
 
     @Override
-    public void createIfNotExists(String mountPointNodeName) {
-        database.createIfNotExists(mountPointNodeName);
+    public void createIfNotExists(NodeId nodeId) {
+        database.createIfNotExists(nodeId.getValue());
     }
 
     @Override
-    public void deleteIfNotRequired(String mountPointNodeName) {
-        database.deleteIfNotRequired(mountPointNodeName);
+    public void deleteIfNotRequired(NodeId nodeId) {
+        database.deleteIfNotRequired(nodeId.getValue());
     }
 
     /*-------------------------------------------------
@@ -159,10 +160,10 @@ public class MaintenanceServiceImpl implements MaintenanceService, MaintenanceRP
      */
 
     @Override
-    public boolean isONFObjectInMaintenance(String mountpointReference, String objectIdRef, String problem) {
-        MaintenanceEntity maintenanceMode = database.getMaintenance(mountpointReference);
+    public boolean isONFObjectInMaintenance(NodeId nodeId, String objectIdRef, String problem) {
+        MaintenanceEntity maintenanceMode = database.getMaintenance(nodeId.getValue());
         boolean res = MaintenanceCalculator.isONFObjectInMaintenance(maintenanceMode, objectIdRef, problem);
-        LOG.debug("inMaintenance={} for mountpoint/id/problem:{} {} {} Definition: {}", res, mountpointReference,
+        LOG.debug("inMaintenance={} for mountpoint/id/problem:{} {} {} Definition: {}", res, nodeId.getValue(),
                 objectIdRef, problem, this);
         return res;
     }
index 2209867..3ccaa75 100644 (file)
@@ -23,6 +23,7 @@ import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.NetworkElement;
 import org.onap.ccsdk.features.sdnr.wt.devicemanager.performancemanager.impl.config.PmConfig;
 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.NetconfNetworkElementService;
 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.PerformanceManager;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -65,18 +66,18 @@ public class PerformanceManagerImpl implements PerformanceManager, AutoCloseable
     }
 
     @Override
-    public void registration(String mountPointNodeName, NetworkElement ne) {
-        LOG.debug("Register {}", mountPointNodeName);
+    public void registration(NodeId nodeId, NetworkElement ne) {
+        LOG.debug("Register {}", nodeId.getValue());
         if (task != null) {
-            task.registration(mountPointNodeName, ne);
+            task.registration(nodeId.getValue(), ne);
         }
     }
 
     @Override
-    public void deRegistration(String mountPointNodeName) {
-        LOG.debug("Deregister {}", mountPointNodeName);
+    public void deRegistration(NodeId nodeId) {
+        LOG.debug("Deregister {}", nodeId.getValue());
         if (task != null) {
-            task.deRegistration(mountPointNodeName);
+            task.deRegistration(nodeId.getValue());
         }
     }
 
index cc49ea9..02d381f 100644 (file)
@@ -23,7 +23,6 @@ package org.onap.ccsdk.features.sdnr.wt.devicemanager.test;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
-
 import com.google.common.io.Files;
 import com.sun.net.httpserver.HttpExchange;
 import com.sun.net.httpserver.HttpHandler;
@@ -37,9 +36,7 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
-import org.junit.After;
 import org.junit.AfterClass;
-import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation;
@@ -47,6 +44,7 @@ import org.onap.ccsdk.features.sdnr.wt.common.util.ResourceFileLoader;
 import org.onap.ccsdk.features.sdnr.wt.devicemanager.aaiconnector.impl.AaiProviderClient;
 import org.onap.ccsdk.features.sdnr.wt.devicemanager.aaiconnector.impl.config.AaiConfig;
 import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.InventoryInformationDcae;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
 
 public class TestAai {
 
@@ -113,14 +111,14 @@ public class TestAai {
         ifInfos.add("LP-MWPS-RADIO");
         InventoryInformationDcae ii = new InventoryInformationDcae(type, model, vendor, ipv4, ipv6, ifInfos);
         System.out.println("registering device");
-        provider.onDeviceRegistered(mountPointName, ii);
+        provider.onDeviceRegistered(new NodeId(mountPointName), ii);
         try {
             Thread.sleep(5000);
         } catch (InterruptedException e) {
             e.printStackTrace();
         }
         System.out.println("unregistering device");
-        provider.onDeviceUnregistered(mountPointName);
+        provider.onDeviceUnregistered(new NodeId(mountPointName));
         System.out.println("finished");
         try {
             provider.close();
@@ -148,15 +146,15 @@ public class TestAai {
         ifInfos.add("LP-MWPS-RADIO");
         InventoryInformationDcae ii = new InventoryInformationDcae(type, model, vendor, ipv4, ipv6, ifInfos);
         System.out.println("registering device");
-        provider.onDeviceRegistered(mountPointName);
-        provider.onDeviceRegistered(mountPointName, ii);
+        provider.onDeviceRegistered(new NodeId(mountPointName));
+        provider.onDeviceRegistered(new NodeId(mountPointName), ii);
         try {
             Thread.sleep(5000);
         } catch (InterruptedException e) {
             e.printStackTrace();
         }
         System.out.println("unregistering device");
-        provider.onDeviceUnregistered(mountPointName);
+        provider.onDeviceUnregistered(new NodeId(mountPointName));
         System.out.println("finished");
         try {
             provider.close();
index ff01f9a..a403fe4 100644 (file)
 package org.onap.ccsdk.features.sdnr.wt.devicemanager.test;
 
 import static org.junit.Assert.fail;
-
+import com.google.common.io.Files;
+import com.sun.net.httpserver.HttpExchange;
+import com.sun.net.httpserver.HttpHandler;
+import com.sun.net.httpserver.HttpServer;
 import java.io.File;
 import java.io.IOException;
 import java.io.OutputStream;
@@ -31,7 +34,6 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
-
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -41,10 +43,7 @@ import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.util.InternalDateAndTi
 import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.util.InternalSeverity;
 import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ProblemNotificationXml;
 import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.InventoryInformationDcae;
-import com.google.common.io.Files;
-import com.sun.net.httpserver.HttpExchange;
-import com.sun.net.httpserver.HttpHandler;
-import com.sun.net.httpserver.HttpServer;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
 
 @SuppressWarnings("restriction")
 public class TestDcae {
@@ -93,7 +92,7 @@ public class TestDcae {
         boolean neDeviceAlarm = false;
         ProblemNotificationXml notification = new ProblemNotificationXml(mountPointName, "network-element",
                 "problemName", InternalSeverity.Critical, 123, InternalDateAndTime.getTestpattern());
-        provider.sendProblemNotification(mountPointName, notification, neDeviceAlarm);
+        provider.sendProblemNotification(new NodeId(mountPointName), notification, neDeviceAlarm);
 
         try {
             Thread.sleep(5000);
index 41604da..de83dc9 100644 (file)
     <name>ccsdk-features :: ${project.artifactId}</name>
 
     <dependencies>
+        <!--     <dependency> -->
+        <!--       <groupId>${project.groupId}</groupId> -->
+        <!--       <artifactId>sdnr-wt-devicemanager-onap-onf-model</artifactId> -->
+        <!--       <version>${project.version}</version> -->
+        <!--     </dependency> -->
         <dependency>
             <groupId>${project.groupId}</groupId>
             <artifactId>sdnr-wt-devicemanager-onap-onf12-provider</artifactId>
index 7107e18..f347d73 100755 (executable)
@@ -47,7 +47,7 @@
 
     <dependencies>
         <dependency>
-            <groupId>org.onap.ccsdk.features.sdnr.wt</groupId>
+            <groupId>${project.groupId}</groupId>
             <artifactId>${application.name}-feature</artifactId>
             <version>${project.version}</version>
             <type>xml</type>
@@ -60,7 +60,7 @@
             </exclusions>
         </dependency>
         <dependency>
-            <groupId>org.onap.ccsdk.features.sdnr.wt</groupId>
+            <groupId>${project.groupId}</groupId>
             <artifactId>${application.name}-provider</artifactId>
             <version>${project.version}</version>
         </dependency>
index cce5bdb..94c836c 100644 (file)
@@ -68,7 +68,7 @@
             <scope>provided</scope>
         </dependency>
         <dependency>
-            <groupId>org.onap.ccsdk.features.sdnr.wt</groupId>
+            <groupId>${project.groupId}</groupId>
             <artifactId>sdnr-wt-devicemanager-core-model</artifactId>
             <version>${project.version}</version>
             <scope>provided</scope>
index a7a09fc..9bd1ddb 100644 (file)
@@ -29,11 +29,11 @@ import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.MaintenanceService;
 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.PerformanceManager;
 import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.FaultData;
 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.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.NetworkElementConnectionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.NetworkElementDeviceType;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -66,7 +66,7 @@ public class ONFCoreNetworkElement12Basic extends ONFCoreNetworkElement12Base {
     private final @NonNull DataProvider dataProvider;
 
 
-    private final @NonNull String mountPointNodeName;
+    private final @NonNull NodeId mountPointNodeId;
     private final @NonNull NetconfBindingAccessor acessor;
     private final @NonNull DeviceManagerOnfConfiguration pollAlarmConfig;
 
@@ -84,7 +84,7 @@ public class ONFCoreNetworkElement12Basic extends ONFCoreNetworkElement12Base {
             @NonNull DeviceManagerServiceProvider serviceProvider, DeviceManagerOnfConfiguration configuration) {
 
         super(acessor);
-        this.mountPointNodeName = acessor.getNodeId().getValue();
+        this.mountPointNodeId = acessor.getNodeId();
         this.acessor = acessor;
         this.pollAlarmConfig = configuration;
 
@@ -200,8 +200,10 @@ public class ONFCoreNetworkElement12Basic extends ONFCoreNetworkElement12Base {
         // Setup microwaveEventListener for notification service
         doRegisterEventListener(acessor.getMountpoint());
 
-        // Register netconf stream
-        acessor.registerNotificationsStream(NetconfAccessor.DefaultNotificationsStream);
+               if (acessor.isNotificationsRFC5277Supported()) {
+                       // Register default (NETCONF) stream
+                       acessor.registerNotificationsStream();
+               }
 
         // Set core-model revision value in "core-model-capability" field
         setCoreModel(acessor.getNetconfNode());
@@ -211,17 +213,17 @@ public class ONFCoreNetworkElement12Basic extends ONFCoreNetworkElement12Base {
 
         // create automatic empty maintenance entry into db before reading and listening
         // for problems
-        maintenanceService.createIfNotExists(mountPointNodeName);
+        maintenanceService.createIfNotExists(mountPointNodeId);
 
-        aaiProviderClient.onDeviceRegistered(mountPointNodeName);
+        aaiProviderClient.onDeviceRegistered(mountPointNodeId);
         // -- Register NE to performance manager
-        performanceManager.registration(mountPointNodeName, this);
+        performanceManager.registration(mountPointNodeId, this);
 
         //events will be already pushed by base devmgr (needs more clarification SDNC-1123)
         //eventListenerHandler.registration(mountPointNodeName, acessor.getNetconfNode());
         //LOG.debug("refresh necon entry for {} with type {} not",mountPointNodeName,this.getDeviceType());
         //eventListenerHandler.connectIndication(mountPointNodeName, getDeviceType());
-        LOG.info("Starting Event listener finished. Added Netconf device:{} type:{}", mountPointNodeName,
+        LOG.info("Starting Event listener finished. Added Netconf device:{} type:{}", mountPointNodeId,
                 getDeviceType());
 
     }
@@ -229,9 +231,9 @@ public class ONFCoreNetworkElement12Basic extends ONFCoreNetworkElement12Base {
 
     @Override
     public void deregister() {
-        maintenanceService.deleteIfNotRequired(mountPointNodeName);
-        performanceManager.deRegistration(mountPointNodeName);
-        aaiProviderClient.onDeviceUnregistered(mountPointNodeName);
+        maintenanceService.deleteIfNotRequired(mountPointNodeId);
+        performanceManager.deRegistration(mountPointNodeId);
+        aaiProviderClient.onDeviceUnregistered(mountPointNodeId);
         faultService.removeAllCurrentProblemsOfNode(acessor.getNodeId());
     }