Set coremodel for ONF Devicemanagers
Set coremodel for ONF Devicemanagers
Issue-ID: SDNC-1383
Signed-off-by: Ravi Pendurty <ravi.pendurty@highstreet-technologies.com>
Change-Id: Ia6015dbf16ec7ded8066a2e68d1cb53d130670c3
Signed-off-by: Ravi Pendurty <ravi.pendurty@highstreet-technologies.com>
diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/ONFCoreNetworkElement12Basic.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/ONFCoreNetworkElement12Basic.java
index 19be028..93d31c5 100644
--- a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/ONFCoreNetworkElement12Basic.java
+++ b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/ONFCoreNetworkElement12Basic.java
@@ -18,6 +18,7 @@
package org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.ne;
import org.eclipse.jdt.annotation.NonNull;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.impl.DeviceManagerOnfConfiguration;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.AaiService;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider;
@@ -27,8 +28,12 @@
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.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.rev190801.NetworkElementConnectionBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.NetworkElementDeviceType;
+import org.opendaylight.yangtools.yang.common.QName;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -57,6 +62,7 @@
private final @NonNull AaiService aaiProviderClient;
private final @NonNull PerformanceManager performanceManager;
private final @NonNull EventHandlingService eventListenerHandler;
+ private final @NonNull DataProvider dataProvider;
private final @NonNull String mountPointNodeName;
@@ -69,7 +75,7 @@
/**
* Basic element for netconf device with ONF Core model V1.2
- *
+ *
* @param acessor to manage device connection
* @param serviceProvider to get devicemanager services
*/
@@ -87,6 +93,7 @@
this.aaiProviderClient = serviceProvider.getAaiService();
this.performanceManager = serviceProvider.getPerformanceManagerService();
this.eventListenerHandler = serviceProvider.getEventHandlingService();
+ this.dataProvider = serviceProvider.getDataProvider();
}
@@ -162,6 +169,25 @@
}
/**
+ * @param nNode
+ * set core-model-capability
+ */
+ public void setCoreModel(@NonNull NetconfNode nNode) {
+ NetworkElementConnectionBuilder eb = new NetworkElementConnectionBuilder();
+
+ String namespaceRevision;
+ QName QNAME_COREMODEL = QName.create("urn:onf:params:xml:ns:yang:core-model", "2017-03-20", "core-model").intern();
+
+ Capabilities availableCapabilities = Capabilities.getAvailableCapabilities(nNode);
+ namespaceRevision = availableCapabilities.getRevisionForNamespace(QNAME_COREMODEL);
+ if (Capabilities.isNamespaceSupported(namespaceRevision)) {
+ eb.setCoreModelCapability(namespaceRevision);
+ } else {
+ eb.setCoreModelCapability("Unsupported");
+ }
+ dataProvider.updateNetworkConnection22(eb.build(), acessor.getNodeId().getValue());
+ }
+ /**
* Remove all entries from list
*/
@Override
@@ -178,6 +204,9 @@
// Register netconf stream
acessor.registerNotificationsStream(NetconfAccessor.DefaultNotificationsStream);
+ // Set core-model revision value in "core-model-capability" field
+ setCoreModel(acessor.getNetconfNode());
+
// -- Read data from NE
initialReadFromNetworkElement();
@@ -204,6 +233,7 @@
maintenanceService.deleteIfNotRequired(mountPointNodeName);
performanceManager.deRegistration(mountPointNodeName);
aaiProviderClient.onDeviceUnregistered(mountPointNodeName);
+ faultService.removeAllCurrentProblemsOfNode(acessor.getNodeId());
}
@Override
diff --git a/sdnr/wt/devicemanager-onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/Onf14NetworkElement.java b/sdnr/wt/devicemanager-onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/Onf14NetworkElement.java
index 92840fb..816aa50 100644
--- a/sdnr/wt/devicemanager-onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/Onf14NetworkElement.java
+++ b/sdnr/wt/devicemanager-onf14/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf14/impl/Onf14NetworkElement.java
@@ -28,6 +28,7 @@
import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.FaultService;
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.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.yang.gen.v1.urn.onf.yang.air._interface._2._0.rev200121.LAYERPROTOCOLNAMETYPEAIRLAYER;
@@ -51,11 +52,14 @@
import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.equipment.ContainedHolder;
import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.logical.termination.point.LayerProtocol;
import org.opendaylight.yang.gen.v1.urn.onf.yang.core.model._1._4.rev191127.logical.termination.point.LayerProtocolKey;
+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.rev190801.NetworkElementConnectionBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.NetworkElementDeviceType;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.NotificationListener;
+import org.opendaylight.yangtools.yang.common.QName;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -125,8 +129,31 @@
}
}
+ /**
+ * @param nNode
+ * set core-model-capability
+ */
+ public void setCoreModel(@NonNull NetconfNode nNode) {
+ NetworkElementConnectionBuilder eb = new NetworkElementConnectionBuilder();
+ log.info("In setCoreModel for Onf14NetworkElement");
+ String namespaceRevision;
+ QName QNAME_COREMODEL14 = QName.create("urn:onf:yang:core-model-1-4", "2019-11-27", "core-model-1-4").intern();
+
+ Capabilities availableCapabilities = Capabilities.getAvailableCapabilities(nNode);
+ namespaceRevision = availableCapabilities.getRevisionForNamespace(QNAME_COREMODEL14);
+ log.info("In setCoreModel for Onf14NetworkElement- namespaceRevision = "+namespaceRevision);
+ if (Capabilities.isNamespaceSupported(namespaceRevision)) {
+ eb.setCoreModelCapability(namespaceRevision);
+ } else {
+ eb.setCoreModelCapability("Unsupported");
+ }
+ databaseService.updateNetworkConnection22(eb.build(), netconfAccessor.getNodeId().getValue());
+ }
+
@Override
public void register() {
+ // Set core-model revision value in "core-model-capability" field
+ setCoreModel(netconfAccessor.getNetconfNode());
initialReadFromNetworkElement();
// Register netconf stream
airInterfaceNotificationListenerHandler =
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/util/NetworkElementConnectionEntitiyUtil.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/util/NetworkElementConnectionEntitiyUtil.java
index 789930c..23c79f7 100644
--- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/util/NetworkElementConnectionEntitiyUtil.java
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/util/NetworkElementConnectionEntitiyUtil.java
@@ -30,7 +30,6 @@
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.NetworkElementConnectionEntity;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.NetworkElementDeviceType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.network.element.connection.entity.NodeDetailsBuilder;
-import org.opendaylight.yangtools.yang.common.QName;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -39,11 +38,8 @@
private static final Logger LOG = LoggerFactory.getLogger(NetworkElementConnectionEntitiyUtil.class);
- private static final QName QNAME_COREMODEL =
- QName.create("urn:onf:params:xml:ns:yang:core-model", "2017-03-20", "core-model").intern();
-
/**
- * Update devicetype and let all other field empty
+ * Update devicetype and let all other field empties
*
* @param deviceType that should be updated
* @return NetworkElementConnectionEntity with related parameter
@@ -75,8 +71,6 @@
Capabilities availableCapabilities = Capabilities.getAvailableCapabilities(nNode);
Capabilities unAvailableCapabilities = Capabilities.getUnavailableCapabilities(nNode);
- eb.setCoreModelCapability(availableCapabilities.getRevisionForNamespace(QNAME_COREMODEL));
-
NodeDetailsBuilder nodeDetails =
new NodeDetailsBuilder().setAvailableCapabilities(availableCapabilities.getCapabilities())
.setUnavailableCapabilities(unAvailableCapabilities.getCapabilities());
@@ -93,6 +87,7 @@
LoginPassword loginPassword = (LoginPassword) credentials;
eb.setUsername(loginPassword.getUsername()).setPassword(loginPassword.getPassword());
}
+ eb.setCoreModelCapability("Unsupported"); // Default value. Specific value (if any) is set in the specific devicemanagers
return eb.build();
}
}
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
index 6b790af..a348b29 100644
--- 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
@@ -49,6 +49,7 @@
private static final Logger LOG = LoggerFactory.getLogger(Capabilities.class);
private static final String METHODNAME = "getCapability";
+ private static final String UNSUPPORTED = "Unsupported";
private final List<String> capabilities = new ArrayList<>();
private final DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
@@ -218,9 +219,17 @@
return QName.create(capability).getRevision().get().toString();
}
}
- return "Unsupported";
+ return UNSUPPORTED;
}
+ /**
+ * Verify if QName namespace is supported by capabilities
+ * @param revision result of getRevisionForNamespace()
+ * @return true if namespace is supported.
+ */
+ static public boolean isNamespaceSupported(String revision) {
+ return revision != UNSUPPORTED;
+ }
@Override
public String toString() {