diff options
author | Ravi Pendurty <ravi.pendurty@highstreet-technologies.com> | 2021-07-30 15:14:17 +0530 |
---|---|---|
committer | KAPIL SINGAL <ks220y@att.com> | 2021-07-30 18:05:09 +0000 |
commit | df5869629e4ffd6cb0b1ccb81c1fe17cdd73f851 (patch) | |
tree | b6633de7ba8efc028053e5b0a3f710b7d8fe34ab /sdnr/wt | |
parent | 0c8d2c3d7dfd79a25107480af718d3d76cd45f39 (diff) |
devicemanager-core refactoring and support for TLS mountpoints using data-provider interface
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>
Diffstat (limited to 'sdnr/wt')
35 files changed, 568 insertions, 181 deletions
diff --git a/sdnr/wt/common-yang/rfc7317-ietf-system/pom.xml b/sdnr/wt/common-yang/rfc7317-ietf-system/pom.xml index 10a70d91c..bad26467e 100755 --- a/sdnr/wt/common-yang/rfc7317-ietf-system/pom.xml +++ b/sdnr/wt/common-yang/rfc7317-ietf-system/pom.xml @@ -42,12 +42,12 @@ <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> diff --git a/sdnr/wt/data-provider/model/pom.xml b/sdnr/wt/data-provider/model/pom.xml index 15eeccef7..6a193a423 100644 --- a/sdnr/wt/data-provider/model/pom.xml +++ b/sdnr/wt/data-provider/model/pom.xml @@ -56,17 +56,17 @@ <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> </dependency> diff --git a/sdnr/wt/data-provider/model/src/main/yang/data-provider@2020-11-10.yang b/sdnr/wt/data-provider/model/src/main/yang/data-provider@2020-11-10.yang index 31c7fd875..be2c638e2 100644 --- a/sdnr/wt/data-provider/model/src/main/yang/data-provider@2020-11-10.yang +++ b/sdnr/wt/data-provider/model/src/main/yang/data-provider@2020-11-10.yang @@ -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"; + } + } + } } diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataProviderServiceImpl.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataProviderServiceImpl.java index ad712847f..2bf67fde9 100644 --- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataProviderServiceImpl.java +++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataProviderServiceImpl.java @@ -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 index 000000000..610f5476c --- /dev/null +++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestGetTlsKeys.java @@ -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 + + } + } +} diff --git a/sdnr/wt/devicemanager-core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/AaiService.java b/sdnr/wt/devicemanager-core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/AaiService.java index eca19a8c0..53c5c1444 100644 --- a/sdnr/wt/devicemanager-core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/AaiService.java +++ b/sdnr/wt/devicemanager-core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/AaiService.java @@ -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); } diff --git a/sdnr/wt/devicemanager-core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/EventHandlingService.java b/sdnr/wt/devicemanager-core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/EventHandlingService.java index 5cb9b9f21..e59401cc7 100644 --- a/sdnr/wt/devicemanager-core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/EventHandlingService.java +++ b/sdnr/wt/devicemanager-core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/EventHandlingService.java @@ -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 diff --git a/sdnr/wt/devicemanager-core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/FaultService.java b/sdnr/wt/devicemanager-core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/FaultService.java index f414b4b15..5598bd1e8 100644 --- a/sdnr/wt/devicemanager-core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/FaultService.java +++ b/sdnr/wt/devicemanager-core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/FaultService.java @@ -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); diff --git a/sdnr/wt/devicemanager-core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/MaintenanceService.java b/sdnr/wt/devicemanager-core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/MaintenanceService.java index 8a2ffd880..544ba5fbf 100644 --- a/sdnr/wt/devicemanager-core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/MaintenanceService.java +++ b/sdnr/wt/devicemanager-core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/MaintenanceService.java @@ -17,28 +17,30 @@ */ 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); } diff --git a/sdnr/wt/devicemanager-core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/NotificationService.java b/sdnr/wt/devicemanager-core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/NotificationService.java index b249c5008..c766faaac 100644 --- a/sdnr/wt/devicemanager-core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/NotificationService.java +++ b/sdnr/wt/devicemanager-core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/NotificationService.java @@ -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); - - - } diff --git a/sdnr/wt/devicemanager-core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/PerformanceManager.java b/sdnr/wt/devicemanager-core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/PerformanceManager.java index 3f93108a3..d3cd88226 100644 --- a/sdnr/wt/devicemanager-core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/PerformanceManager.java +++ b/sdnr/wt/devicemanager-core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/service/PerformanceManager.java @@ -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); } diff --git a/sdnr/wt/devicemanager-core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/types/InternalConnectionStatus.java b/sdnr/wt/devicemanager-core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/types/InternalConnectionStatus.java index 303cd8214..29450ed31 100644 --- a/sdnr/wt/devicemanager-core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/types/InternalConnectionStatus.java +++ b/sdnr/wt/devicemanager-core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/types/InternalConnectionStatus.java @@ -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; diff --git a/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/aaiconnector/impl/AaiProviderClient.java b/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/aaiconnector/impl/AaiProviderClient.java index 193b96a44..acd18336e 100644 --- a/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/aaiconnector/impl/AaiProviderClient.java +++ b/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/aaiconnector/impl/AaiProviderClient.java @@ -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()); } } diff --git a/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/DcaeForwarderImpl.java b/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/DcaeForwarderImpl.java index 8e091bef5..e5dc1d0eb 100644 --- a/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/DcaeForwarderImpl.java +++ b/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/DcaeForwarderImpl.java @@ -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) { diff --git a/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/DcaeForwarderInternal.java b/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/DcaeForwarderInternal.java index d86e0b451..d4e601679 100644 --- a/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/DcaeForwarderInternal.java +++ b/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/DcaeForwarderInternal.java @@ -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); } diff --git a/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/DcaeMessages.java b/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/DcaeMessages.java index de62af08e..065faf3ff 100644 --- a/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/DcaeMessages.java +++ b/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/DcaeMessages.java @@ -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" diff --git a/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/DcaeProviderClient.java b/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/DcaeProviderClient.java index 7ceafcb46..8416d366e 100644 --- a/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/DcaeProviderClient.java +++ b/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/DcaeProviderClient.java @@ -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 diff --git a/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/DcaeProviderWorker.java b/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/DcaeProviderWorker.java index 1ef50c3e9..f407b7811 100644 --- a/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/DcaeProviderWorker.java +++ b/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/dcaeconnector/impl/DcaeProviderWorker.java @@ -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 diff --git a/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/eventdatahandler/DeviceManagerDatabaseNotificationService.java b/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/eventdatahandler/DeviceManagerDatabaseNotificationService.java index dc57626ff..94694cd90 100644 --- a/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/eventdatahandler/DeviceManagerDatabaseNotificationService.java +++ b/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/eventdatahandler/DeviceManagerDatabaseNotificationService.java @@ -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"); diff --git a/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/eventdatahandler/ODLEventListenerHandler.java b/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/eventdatahandler/ODLEventListenerHandler.java index 66fcc05c3..037f09778 100644 --- a/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/eventdatahandler/ODLEventListenerHandler.java +++ b/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/eventdatahandler/ODLEventListenerHandler.java @@ -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); } diff --git a/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/eventdatahandler/RpcPushNotificationsHandler.java b/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/eventdatahandler/RpcPushNotificationsHandler.java index 273231a9b..90e07e666 100644 --- a/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/eventdatahandler/RpcPushNotificationsHandler.java +++ b/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/eventdatahandler/RpcPushNotificationsHandler.java @@ -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()); } diff --git a/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/housekeeping/ResyncNetworkElementHouskeepingService.java b/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/housekeeping/ResyncNetworkElementHouskeepingService.java index fe166c92d..50b0215d6 100644 --- a/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/housekeeping/ResyncNetworkElementHouskeepingService.java +++ b/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/housekeeping/ResyncNetworkElementHouskeepingService.java @@ -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; diff --git a/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerImpl.java b/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerImpl.java index ed452cb7e..361356217 100644 --- a/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerImpl.java +++ b/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerImpl.java @@ -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, diff --git a/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerNetconfConnectHandler.java b/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerNetconfConnectHandler.java index bb61a82b4..4b4d1eded 100644 --- a/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerNetconfConnectHandler.java +++ b/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerNetconfConnectHandler.java @@ -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); } } diff --git a/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerNetconfNotConnectHandler.java b/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerNetconfNotConnectHandler.java index df833018d..f9bbe1abf 100644 --- a/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerNetconfNotConnectHandler.java +++ b/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerNetconfNotConnectHandler.java @@ -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 } } diff --git a/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/ProviderClient.java b/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/ProviderClient.java index 82519e48b..7258e8d84 100644 --- a/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/ProviderClient.java +++ b/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/ProviderClient.java @@ -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 @@ -18,25 +18,26 @@ 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); } diff --git a/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/util/NetworkElementConnectionEntitiyUtil.java b/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/util/NetworkElementConnectionEntitiyUtil.java index 5b8105a07..4369af019 100644 --- a/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/util/NetworkElementConnectionEntitiyUtil.java +++ b/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/util/NetworkElementConnectionEntitiyUtil.java @@ -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(); } } diff --git a/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/maintenance/impl/MaintenanceServiceImpl.java b/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/maintenance/impl/MaintenanceServiceImpl.java index 7dad49e01..6351f3958 100644 --- a/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/maintenance/impl/MaintenanceServiceImpl.java +++ b/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/maintenance/impl/MaintenanceServiceImpl.java @@ -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; } diff --git a/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/performancemanager/impl/PerformanceManagerImpl.java b/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/performancemanager/impl/PerformanceManagerImpl.java index 22098675b..3ccaa7550 100644 --- a/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/performancemanager/impl/PerformanceManagerImpl.java +++ b/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/performancemanager/impl/PerformanceManagerImpl.java @@ -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()); } } diff --git a/sdnr/wt/devicemanager-core/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestAai.java b/sdnr/wt/devicemanager-core/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestAai.java index cc49ea9bf..02d381ff2 100644 --- a/sdnr/wt/devicemanager-core/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestAai.java +++ b/sdnr/wt/devicemanager-core/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestAai.java @@ -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(); diff --git a/sdnr/wt/devicemanager-core/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDcae.java b/sdnr/wt/devicemanager-core/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDcae.java index ff01f9a2b..a403fe4a6 100644 --- a/sdnr/wt/devicemanager-core/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDcae.java +++ b/sdnr/wt/devicemanager-core/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDcae.java @@ -21,7 +21,10 @@ 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); diff --git a/sdnr/wt/devicemanager-onap/onf12/feature/pom.xml b/sdnr/wt/devicemanager-onap/onf12/feature/pom.xml index 41604dacb..de83dc9bf 100644 --- a/sdnr/wt/devicemanager-onap/onf12/feature/pom.xml +++ b/sdnr/wt/devicemanager-onap/onf12/feature/pom.xml @@ -41,6 +41,11 @@ <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> diff --git a/sdnr/wt/devicemanager-onap/onf12/installer/pom.xml b/sdnr/wt/devicemanager-onap/onf12/installer/pom.xml index 7107e184d..f347d7363 100755 --- a/sdnr/wt/devicemanager-onap/onf12/installer/pom.xml +++ b/sdnr/wt/devicemanager-onap/onf12/installer/pom.xml @@ -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> diff --git a/sdnr/wt/devicemanager-onap/onf12/provider/pom.xml b/sdnr/wt/devicemanager-onap/onf12/provider/pom.xml index cce5bdbaf..94c836cfa 100644 --- a/sdnr/wt/devicemanager-onap/onf12/provider/pom.xml +++ b/sdnr/wt/devicemanager-onap/onf12/provider/pom.xml @@ -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> diff --git a/sdnr/wt/devicemanager-onap/onf12/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/ONFCoreNetworkElement12Basic.java b/sdnr/wt/devicemanager-onap/onf12/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/ONFCoreNetworkElement12Basic.java index a7a09fccb..9bd1ddb93 100644 --- a/sdnr/wt/devicemanager-onap/onf12/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/ONFCoreNetworkElement12Basic.java +++ b/sdnr/wt/devicemanager-onap/onf12/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/ONFCoreNetworkElement12Basic.java @@ -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()); } |