diff options
author | herbert <herbert.eiselt@highstreet-technologies.com> | 2019-12-14 00:36:01 +0100 |
---|---|---|
committer | Herbert Eiselt <herbert.eiselt@highstreet-technologies.com> | 2019-12-16 11:22:50 +0000 |
commit | 2cf702de0b65fe132ec32b6abfffe4c2c976dca0 (patch) | |
tree | 43bdda96e1320969c08de301cd619ae29621386e /sdnr/wt/netconfnode-state-service/model | |
parent | 3309d25d5883ebaa9db9fa10a81ff0779dcfb2a3 (diff) |
Add netconfnode-state-service
v2 add new service to devicemanager
Issue-ID: SDNC-1006
Signed-off-by: herbert <herbert.eiselt@highstreet-technologies.com>
Change-Id: Iaba3d02e0ef6078cba57a33e03c2b2ad7aa0bacd
Signed-off-by: herbert <herbert.eiselt@highstreet-technologies.com>
Diffstat (limited to 'sdnr/wt/netconfnode-state-service/model')
10 files changed, 809 insertions, 0 deletions
diff --git a/sdnr/wt/netconfnode-state-service/model/pom.xml b/sdnr/wt/netconfnode-state-service/model/pom.xml new file mode 100644 index 000000000..b0c9840ac --- /dev/null +++ b/sdnr/wt/netconfnode-state-service/model/pom.xml @@ -0,0 +1,78 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + * ============LICENSE_START======================================================= + * ONAP : CCSDK.sdnr.wt.netconfnode-state-service.model + * ================================================================================ + * Copyright (C) 2018 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========================================================= + +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.onap.ccsdk.features.sdnr.wt</groupId> + <artifactId>sdnr-wt-netconfnode-state-service-model</artifactId> + <version>0.7.0-SNAPSHOT</version> + <name>ccsdk-features-sdnr-wt :: ${project.artifactId}</name> + <packaging>bundle</packaging> + + <parent> + <groupId>org.onap.ccsdk.parent</groupId> + <artifactId>binding-parent</artifactId> + <version>1.5.1-SNAPSHOT</version> + <relativePath/> + </parent> + + <properties> + <maven.javadoc.skip>true</maven.javadoc.skip> + </properties> + + <licenses> + <license> + <name>Apache License, Version 2.0</name> + <url>http://www.apache.org/licenses/LICENSE-2.0</url> + </license> + </licenses> + + <dependencies> + <dependency> + <groupId>org.opendaylight.netconf</groupId> + <artifactId>sal-netconf-connector</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.onap.ccsdk.features.sdnr.wt</groupId> + <artifactId>sdnr-wt-data-provider-model</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> + <build> + <plugins> + <plugin> + <groupId>org.jacoco</groupId> + <artifactId>jacoco-maven-plugin</artifactId> + <configuration> + <excludes> + <exclude>**/gen/**</exclude> + <exclude>**/generated-sources/**</exclude> + <exclude>**/yang-gen-sal/**</exclude> + <exclude>**/pax/**</exclude> + </excludes> + </configuration> + </plugin> + </plugins> + </build> +</project> diff --git a/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/Capabilities.java b/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/Capabilities.java new file mode 100644 index 000000000..ba80d305f --- /dev/null +++ b/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/Capabilities.java @@ -0,0 +1,226 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2019 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========================================================================== + ******************************************************************************/ +/** + * Convert capabilities of netconfnode into internal format. Boron and Carbon are providing + * different versions + */ +package org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.List; +import java.util.Optional; +import javax.annotation.Nullable; +import org.eclipse.jdt.annotation.NonNull; +import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode; +import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.AvailableCapabilities; +import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.UnavailableCapabilities; +import org.opendaylight.yangtools.yang.common.QName; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Wrapper class for capabilites for Boron and later releases. Uses generics because yang model was + * changed from Boron to later version. Interface class: + * org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.available.capabilities.AvailableCapability + */ +public class Capabilities { + + private static final Logger LOG = LoggerFactory.getLogger(Capabilities.class); + + private static final String METHODNAME = "getCapability"; + private final List<String> capabilities = new ArrayList<>(); + private final DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); + + private Capabilities() {} + + @SuppressWarnings("null") + public static Capabilities getAvailableCapabilities(@Nullable NetconfNode nnode) { + LOG.info("GetAvailableCapabilities for node"); + Capabilities capabilities = new Capabilities(); + if (nnode != null) { + AvailableCapabilities availableCapabilites = nnode.getAvailableCapabilities(); + if (availableCapabilites != null) { + capabilities.constructor(availableCapabilites.getAvailableCapability()); + } else { + LOG.debug("empty capabilites"); + } + } else { + LOG.debug("No node provided"); + } + return capabilities; + } + + @SuppressWarnings("null") + public static Capabilities getUnavailableCapabilities(NetconfNode nnode) { + LOG.info("GetAvailableCapabilities for node"); + Capabilities capabilities = new Capabilities(); + if (nnode != null) { + UnavailableCapabilities availableCapabilites = nnode.getUnavailableCapabilities(); + if (availableCapabilites != null) { + capabilities.constructor(availableCapabilites.getUnavailableCapability()); + } else { + LOG.debug("empty capabilites"); + } + } else { + LOG.debug("No node provided"); + } + return capabilities; + } + + + /** + * Does all construction steps + * + * @param pcapabilities with a list of capabilities. <br> + * Type could be <br> + * - Boron: List<code><String></code> <br> + * - Carbon: List<AvailableCapability> + */ + private void constructor(List<@NonNull ?> pcapabilities) { + if (pcapabilities != null) { + Method methodGetCapability; + + for (Object capability : pcapabilities) { + if (capability instanceof String) { // ODL Boron specific + this.capabilities.add((String) capability); + } else { // Carbon specific part .. handled via generics + try { + methodGetCapability = capability.getClass().getDeclaredMethod(METHODNAME); + methodGetCapability.setAccessible(true); + this.capabilities.add(methodGetCapability.invoke(capability).toString()); + } catch (NoSuchMethodException | SecurityException | IllegalAccessException + | IllegalArgumentException | InvocationTargetException e) { + LOG.warn("Capability class with missing interface method {}: {} {} {}", METHODNAME, + e.getMessage(), capability.getClass(), + Arrays.toString(capability.getClass().getInterfaces())); + } + } + } + } + } + + /** + * Get Capabilites + * @return List<String> with capabilites + */ + public List<String> getCapabilities() { + return capabilities; + } + + /** + * Verify if the namespace is supported + * @param qCapability from model + * @return true if namespace is supported + */ + public boolean isSupportingNamespace(QName qCapability) { + + String namespace = qCapability.getNamespace().toString(); + + return isSupportingNamespaceAndRevision(namespace, null); + + } + + /** + * check if the namespace and its revision are supported by the given capabilities + * + * @param qCapability capability from the model + * @return true if supporting the model AND revision<br> + * false if revision not available or both not found. + */ + public boolean isSupportingNamespaceAndRevision(QName qCapability) { + + String namespace = qCapability.getNamespace().toString(); + String revision = getRevisionString(qCapability); + return revision == null ? false : isSupportingNamespaceAndRevision(namespace, revision); + } + + /** + * + * @param namespace requested + * @param revision request or null for any revision + * @return true if existing + */ + private boolean isSupportingNamespaceAndRevision(String namespace, @Nullable String revision) { + LOG.trace("isSupportingNamespaceAndRevision: Model namespace {}?[revision {}]", namespace, revision); + for (String capability : capabilities) { + if (capability.contains(namespace) && (revision == null || capability.contains(revision))) { + LOG.trace("Verify true with: {}", capability); + return true; + } else { + LOG.trace("Verify false with: {}", capability); + } + } + return false; + } + + /** + * Provide revision as String from QName, considering older formats. + * @param qCapability that specifies the revision + * @return String with revisiondate or null + */ + private String getRevisionString(QName qCapability) { + Object revisionObject = qCapability.getRevision(); + String revision = null; + if (revisionObject instanceof Optional) { + if (((Optional<?>) revisionObject).isPresent()) { + revisionObject = ((Optional<?>) revisionObject).get(); + LOG.info("Unwrapp Optional: {}", revisionObject != null ? revisionObject.getClass() : null); + } + } + if (revisionObject == null) { + // Cover null case + } else if (revisionObject instanceof String) { + revision = (String) revisionObject; + } else if (revisionObject instanceof Date) { + revision = formatter.format((Date) revisionObject); + } else { + revision = revisionObject.toString(); + LOG.debug("Revision number type not supported. Use toString().String:{} Class:{} ", revisionObject, + revisionObject.getClass().getName()); + } + return revision; + } + + /** + * Get revision of first entry of related capability + * @param qCapability that specifies the namespace + * @return String with date or + */ + public String getRevisionForNamespace(QName qCapability) { + String namespace = qCapability.getNamespace().toString(); + for (String capability : capabilities) { + if (capability.contains(namespace)) { + return QName.create(capability).getRevision().get().toString(); + } + } + return "Unsupported"; + } + + + @Override + public String toString() { + return "Capabilities [capabilities=" + capabilities + "]"; + } + +} diff --git a/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/INetconfAcessor.java b/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/INetconfAcessor.java new file mode 100644 index 000000000..a186b3c6e --- /dev/null +++ b/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/INetconfAcessor.java @@ -0,0 +1,74 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2019 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.netconfnodestateservice; + +import org.eclipse.jdt.annotation.NonNull; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.MountPoint; +import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; +import org.opendaylight.yangtools.concepts.ListenerRegistration; +import org.opendaylight.yangtools.yang.binding.NotificationListener; + +/** + * Interface handling netconf connection. + */ +public interface INetconfAcessor { + + /** + * @return the nodeId + */ + NodeId getNodeId(); + + /** + * @return NetconfNode of this connection + */ + NetconfNode getNetconfNode(); + + /** + * @return Capabilites + */ + Capabilities getCapabilites(); + + /** + * @return the dataBroker + */ + DataBroker getDataBroker(); + + /** + * @return the MDSAL Mountpoint service + **/ + MountPoint getMountpoint(); + + /** + * @Return TransAction + */ + TransactionUtils getTransactionUtils(); + + + /** + * Register netconf notification listener for related mountpoint + * + * @param <T> specific child class of NotificationListener + * @param listener listener to be called + * @return handler to manager registration + */ + <T extends NotificationListener> ListenerRegistration<NotificationListener> doRegisterNotificationListener( + @NonNull T listener); + +} diff --git a/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/NetconfAccessor.java b/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/NetconfAccessor.java new file mode 100644 index 000000000..c80c7befc --- /dev/null +++ b/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/NetconfAccessor.java @@ -0,0 +1,109 @@ +/** + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2019 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.netconfnodestateservice; + +import java.util.Optional; +import org.eclipse.jdt.annotation.NonNull; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.MountPoint; +import org.opendaylight.mdsal.binding.api.NotificationService; +import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode; +import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNodeConnectionStatus.ConnectionStatus; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; +import org.opendaylight.yangtools.concepts.ListenerRegistration; +import org.opendaylight.yangtools.yang.binding.NotificationListener; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class NetconfAccessor implements INetconfAcessor { + + private static final Logger log = LoggerFactory.getLogger(NetconfAccessor.class); + + private final NodeId nodeId; + private final DataBroker dataBroker; + private final TransactionUtils transactionUtils; + private final MountPoint mountpoint; + private final NetconfNode netconfNode; + private final Capabilities capabilities; + + /** + * @param nodeId of managed netconf node + * @param dataBroker to access node + */ + public NetconfAccessor(NodeId nodeId, NetconfNode netconfNode, DataBroker dataBroker, MountPoint mountpoint, + TransactionUtils transactionUtils) { + super(); + this.nodeId = nodeId; + this.netconfNode = netconfNode; + this.dataBroker = dataBroker; + this.mountpoint = mountpoint; + this.transactionUtils = transactionUtils; + + ConnectionStatus csts = netconfNode != null ? netconfNode.getConnectionStatus() : null; + this.capabilities = Capabilities.getAvailableCapabilities(csts != null ? netconfNode : null); + } + + /** + * @param nodeId with uuid of managed netconf node + * @param dataBroker to access node + */ + public NetconfAccessor(String nodeId, NetconfNode netconfNode, DataBroker dataBroker, MountPoint mountpoint, + TransactionUtils transactionUtils) { + this(new NodeId(nodeId), netconfNode, dataBroker, mountpoint, transactionUtils); + } + + @Override + public NodeId getNodeId() { + return nodeId; + } + + @Override + public DataBroker getDataBroker() { + return dataBroker; + } + @Override + public MountPoint getMountpoint() { + return mountpoint; + } + @Override + public TransactionUtils getTransactionUtils() { + return transactionUtils; + } + @Override + public NetconfNode getNetconfNode() { + return netconfNode; + } + @Override + public Capabilities getCapabilites() { + return capabilities; + } + + @Override + public @NonNull <T extends NotificationListener> ListenerRegistration<NotificationListener> doRegisterNotificationListener(@NonNull T listener) { + log.info("Begin register listener for Mountpoint {}", mountpoint.getIdentifier().toString()); + final Optional<NotificationService> optionalNotificationService = mountpoint + .getService(NotificationService.class); + final NotificationService notificationService = optionalNotificationService.get(); + final ListenerRegistration<NotificationListener> ranListenerRegistration = notificationService + .registerNotificationListener(listener); + log.info("End registration listener for Mountpoint {} Listener: {} Result: {}", + mountpoint.getIdentifier().toString(), optionalNotificationService, ranListenerRegistration); + return ranListenerRegistration; + } + +} diff --git a/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/NetconfNodeConnectListener.java b/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/NetconfNodeConnectListener.java new file mode 100644 index 000000000..942e29f19 --- /dev/null +++ b/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/NetconfNodeConnectListener.java @@ -0,0 +1,50 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2019 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.netconfnodestateservice; + +import java.util.EventListener; + +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; + +/** + * Indicate if device is connected or not. + * A NetconfNode (Mountpoint) is providing the status. + * If this is Master and connected, this function is calles. + */ + +public interface NetconfNodeConnectListener extends EventListener, AutoCloseable { + + /** + * Called if device state changes to "connected" for a netconf master node. + * @param nNodeId name of mount point + * @param netconfNode with related information + * @param netconfNodeDataBroker to access connected netconf device + */ + public void onEnterConnected(NodeId nNodeId, NetconfNode netconfNode, DataBroker netconfNodeDataBroker); + + /** + * Notify of device state change to "not connected" mount point supervision. + * HINT: This callback could be called multiple times also the onEnterConnected state was not called. + * @param nNodeId name of mount point + */ + public void onLeaveConnected(NodeId nNodeId); + +} diff --git a/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/NetconfNodeStateListener.java b/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/NetconfNodeStateListener.java new file mode 100644 index 000000000..253af0598 --- /dev/null +++ b/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/NetconfNodeStateListener.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2019 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.netconfnodestateservice; + +import java.util.EventListener; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; + +/** + * Indicate all state changes of NetconfNode (Mountpoint). Cleans up and + * summarizes the + */ +public interface NetconfNodeStateListener extends EventListener { + + /** + * New NetconfNode has been created + * @param nNodeId of Node + * @param netconfNode object + */ + + void onCreated(NodeId nNodeId, NetconfNode netconfNode); + + /** + * New NetconfNode has been created + * @param nNodeId of node + * @param netconfNode object after change + */ + void onStateChange(NodeId nNodeId, NetconfNode netconfNode); + + /** + * NetconfNode has been removed + * @param nNodeId of related node + */ + void onRemoved(NodeId nNodeId); + +} diff --git a/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/NetconfNodeStateService.java b/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/NetconfNodeStateService.java new file mode 100644 index 000000000..0105c36e8 --- /dev/null +++ b/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/NetconfNodeStateService.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2019 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.netconfnodestateservice; + +import org.eclipse.jdt.annotation.NonNull; +import org.opendaylight.yangtools.concepts.ListenerRegistration; +import org.opendaylight.yangtools.concepts.Registration; + +public interface NetconfNodeStateService extends Registration { + + /** + * Register for indication that Master NetconNode is entering or leaving Connected state. + * @param netconfNodeConnectListener + * @return managing object for listener + */ + @NonNull <L extends NetconfNodeConnectListener> ListenerRegistration<L> registerNetconfNodeConnectListener(@NonNull L netconfNodeConnectListener); + + /** + * Register for all NetconfNode specific state changes + * @param netconfNodeStateListener + * @return managing object for listener + */ + @NonNull <L extends NetconfNodeStateListener> ListenerRegistration<L> registerNetconfNodeStateListener(@NonNull L netconfNodeStateListener); + + /** + * Register for Ves/DmaaP provided messages + * @param netconfNodeStateListener + * @return managing object for listener + */ + @NonNull <L extends VesNotificationListener> ListenerRegistration<L> registerVesNotifications(@NonNull L netconfNodeStateListener); + +} diff --git a/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/TransactionUtils.java b/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/TransactionUtils.java new file mode 100644 index 000000000..da8da5c7f --- /dev/null +++ b/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/TransactionUtils.java @@ -0,0 +1,62 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2019 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.netconfnodestateservice; + +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicReference; +import org.eclipse.jdt.annotation.Nullable; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; +import org.opendaylight.yangtools.yang.binding.DataObject; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; + +/** + * @author herbert + * + */ +public interface TransactionUtils { + + /** + * Deliver the data back or null. Warning + * + * @param <T> SubType of the DataObject to be handled + * @param dataBroker for accessing data + * @param dataStoreType to address datastore + * @param iid id to access data + * @return null or object + */ + @Nullable + <T extends DataObject> T readData(DataBroker dataBroker, LogicalDatastoreType dataStoreType, + InstanceIdentifier<T> iid); + + /** + * Deliver the data back or null + * + * @param <T> SubType of the DataObject to be handled + * @param dataBroker for accessing data + * @param dataStoreType to address datastore + * @param iid id to access data + * @param noErrorIndication (Output) true if data could be read and are available and is not null + * @param statusIndicator (Output) String with status indications during the read. + * @return null or object + */ + @Nullable + <T extends DataObject> T readDataOptionalWithStatus(DataBroker dataBroker, LogicalDatastoreType dataStoreType, + InstanceIdentifier<T> iid, AtomicBoolean noErrorIndication, AtomicReference<String> statusIndicator); + +}
\ No newline at end of file diff --git a/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/VesNotificationListener.java b/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/VesNotificationListener.java new file mode 100644 index 000000000..e7d2481b8 --- /dev/null +++ b/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/VesNotificationListener.java @@ -0,0 +1,45 @@ +/******************************************************************************* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2019 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.netconfnodestateservice; + +import java.util.EventListener; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconfnode.state.rev191011.AttributeChangeNotification; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconfnode.state.rev191011.FaultNotification; + +/** + * Indicate if device is connected or not. + * A NetconfNode (Mountpoint) is providing the status. + * If this is Master and connected, this function is calles. + */ + +public interface VesNotificationListener extends EventListener, AutoCloseable { + + /** + * Called in case of fault notification + * @param faultNotification to handle + */ + public void onNotification(FaultNotification faultNotification); + + /** + * Called in case of attributeChange notification + * @param attributeChangeNotification to handle + */ + public void onNotification(AttributeChangeNotification attributeChangeNotification); + +} diff --git a/sdnr/wt/netconfnode-state-service/model/src/main/yang/netconfnodestateservice.yang b/sdnr/wt/netconfnode-state-service/model/src/main/yang/netconfnodestateservice.yang new file mode 100644 index 000000000..737f858de --- /dev/null +++ b/sdnr/wt/netconfnode-state-service/model/src/main/yang/netconfnodestateservice.yang @@ -0,0 +1,64 @@ +module netconfnode-state { + + yang-version 1; + namespace "urn:opendaylight:params:xml:ns:yang:netconfnode-state"; + prefix "netconfnode-state"; + + import data-provider { prefix "data-provider"; } + + description + "sdnr-wt-netconfnode-state-service Api Module"; + + revision "2019-10-11" { + description + "Initial revision"; + } + + container fault-notification { + description + "Handle fault problem notification of a network-element"; + uses data-provider:object-change-reference; + uses data-provider:fault; + } + container attribute-change-notification { + description + "Handle attribute change notification of a network-element"; + uses data-provider:object-change-reference; + uses data-provider:attribute-change; + } + rpc push-fault-notification { + description + "Forward fault problem notification of a network-element"; + input { + uses data-provider:object-change-reference; + uses data-provider:fault; + } + } + rpc push-attribute-change-notification { + description + "Forward attribute change notification of a network-element"; + input { + uses data-provider:object-change-reference; + uses data-provider:attribute-change; + } + } + + rpc get-status { + description + "Returns status information"; + + output { + list status { + description "Provides a key value list with status information"; + key key; + leaf key { + type string; + } + leaf value { + type string; + } + } + } + } +} + |