aboutsummaryrefslogtreecommitdiffstats
path: root/sdnr/wt/data-provider/provider
diff options
context:
space:
mode:
Diffstat (limited to 'sdnr/wt/data-provider/provider')
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/data/entity/FaultEntityManager.java12
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/data/entity/HtDatabaseEventsService.java39
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/impl/ElasticSearchDataProvider.java32
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/impl/HtUserdataManagerImpl.java102
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/AboutHttpServlet.java2
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/ODLVersionLUT.java4
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/yangschema/YangFileProvider.java45
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/yangschema/YangFilename.java2
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/yangschema/YangSchemaHttpServlet.java10
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataProviderServiceImpl.java20
-rw-r--r--sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestCRUDforDatabase.java133
-rw-r--r--sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestEventService.java62
-rw-r--r--sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestUserdata.java11
-rw-r--r--sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangProvider.java11
-rw-r--r--sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/util/MariaDBTestBase.java4
15 files changed, 356 insertions, 133 deletions
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/data/entity/FaultEntityManager.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/data/entity/FaultEntityManager.java
index 36ab39845..64156dc07 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/data/entity/FaultEntityManager.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/data/entity/FaultEntityManager.java
@@ -24,14 +24,13 @@ package org.onap.ccsdk.features.sdnr.wt.dataprovider.database.elasticsearch.data
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.annotation.Nonnull;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.data.entity.DatabaseIdGenerator;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Fault;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.FaultcurrentEntity;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SeverityType;
public class FaultEntityManager {
- private static final Pattern pattern = Pattern.compile(".*\\[layerProtocol=(.*)\\]");
-
/**
* The leading indication for notification or events that are not in the currentProblem data of the ONF Coremodel
*/
@@ -68,14 +67,7 @@ public class FaultEntityManager {
*/
public static String genSpecificEsId(String nodeName, String objectId, String problemName) {
- String uuId;
-
- Matcher matcher = pattern.matcher(objectId);
- if (matcher.matches() && matcher.groupCount() == 1) {
- uuId = matcher.group(1);
- } else {
- uuId = objectId;
- }
+ String uuId = DatabaseIdGenerator.extractUuid(objectId);
StringBuffer strBuf = new StringBuffer();
strBuf.append(nodeName);
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/data/entity/HtDatabaseEventsService.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/data/entity/HtDatabaseEventsService.java
index ea3296acb..13438ef15 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/data/entity/HtDatabaseEventsService.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/data/entity/HtDatabaseEventsService.java
@@ -5,6 +5,8 @@
* Copyright (C) 2019 highstreet technologies GmbH Intellectual Property.
* All rights reserved.
* ================================================================================
+ * Update Copyright (C) 2021 Samsung Electronics 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
@@ -44,6 +46,8 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.NetconfTimeStamp;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.types.NetconfTimeStampImpl;
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.params.xml.ns.yang.data.provider.rev201110.CmlogBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CmlogEntity;
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.ConnectionlogBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ConnectionlogEntity;
@@ -87,6 +91,7 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid
private EsDataObjectReaderWriter2<InventoryEntity> eventRWEquipment;
private EsDataObjectReaderWriter2<FaultcurrentEntity> eventRWFaultCurrentDB;
private EsDataObjectReaderWriter2<FaultlogEntity> eventRWFaultLogDB;
+ private EsDataObjectReaderWriter2<CmlogEntity> eventRWFCMLogDB;
private EsDataObjectReaderWriter2<ConnectionlogEntity> eventRWConnectionLogDB;
private final EsDataObjectReaderWriter2<NetworkElementConnectionEntity> networkelementConnectionDB;
private final EsDataObjectReaderWriter2<GuicutthroughEntity> guiCutThroughDB;
@@ -119,6 +124,9 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid
eventRWFaultLogDB = new EsDataObjectReaderWriter2<>(client, Entity.Faultlog, FaultlogEntity.class,
FaultlogBuilder.class);
+ eventRWFCMLogDB = new EsDataObjectReaderWriter2<>(client, Entity.Cmlog, CmlogEntity.class,
+ CmlogBuilder.class);
+
eventRWConnectionLogDB = new EsDataObjectReaderWriter2<>(client, Entity.Connectionlog,
ConnectionlogEntity.class, ConnectionlogBuilder.class);
@@ -179,6 +187,18 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid
eventRWFaultLogDB.write(fault, null);
}
+ //-- CM log
+
+ @Override
+ public void writeCMLog(CmlogEntity cm) {
+ if (assertIfClientNull(cm)) {
+ return;
+ }
+
+ LOG.debug("Write CM to cmlog: {}", cm.toString());
+ eventRWFCMLogDB.write(cm, null);
+ }
+
// -- Fault current
@Override
@@ -491,6 +511,10 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid
QueryBuilder queryFaultLog = EsFaultLogDevicemanager.getQueryForTimeStamp(netconfTimeStamp);
removed += eventRWFaultLogDB.remove(queryFaultLog);
+
+ QueryBuilder queryCMLog = EsCMLogDevicemanager.getQueryForTimeStamp(netconfTimeStamp);
+ removed += eventRWFCMLogDB.remove(queryCMLog);
+
return removed;
}
@@ -506,6 +530,9 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid
QueryBuilder queryFaultLog = EsFaultLogDevicemanager.getQueryForTimeStamp(netconfTimeStamp);
numberOfElements += eventRWFaultLogDB.doReadAll(queryFaultLog).getTotal();
+ QueryBuilder queryCMLog = EsCMLogDevicemanager.getQueryForTimeStamp(netconfTimeStamp);
+ numberOfElements += eventRWFCMLogDB.doReadAll(queryCMLog).getTotal();
+
return numberOfElements;
}
@@ -565,6 +592,18 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid
}
}
+ private static class EsCMLogDevicemanager {
+ /**
+ * Get older Elements
+ *
+ * @param netconfTimeStamp to identify query elements older than this timestamp.
+ * @return QueryBuilder for related elements
+ */
+ public static QueryBuilder getQueryForTimeStamp(String netconfTimeStamp) {
+ return new RangeQueryBuilder("timestamp").lte(netconfTimeStamp);
+ }
+ }
+
public static class EsFaultCurrent {
/**
* @param nodeName name of the node
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/impl/ElasticSearchDataProvider.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/impl/ElasticSearchDataProvider.java
index 53b21e0ed..38ea8044e 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/impl/ElasticSearchDataProvider.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/impl/ElasticSearchDataProvider.java
@@ -5,6 +5,8 @@
* Copyright (C) 2020 highstreet technologies GmbH Intellectual Property.
* All rights reserved.
* ================================================================================
+ * Update Copyright (C) 2021 Samsung Electronics 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
@@ -39,6 +41,7 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.elasticsearch.data.
import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.HtDatabaseMaintenance;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.HtDatabaseMediatorserver;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.HtUserdataManager;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CreateMaintenanceInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CreateMaintenanceOutputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CreateMediatorServerInput;
@@ -56,6 +59,7 @@ 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.MaintenanceEntity;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.MediatorServerEntity;
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.ReadCmlogListOutputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadConnectionlogListOutputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadEventlogListOutputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadFaultcurrentListOutputBuilder;
@@ -92,6 +96,7 @@ public class ElasticSearchDataProvider implements DatabaseDataProvider {
private final HtDatabaseClient dbClient;
private final DataObjectAcessorWithId<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.faultcurrent.list.output.Data> eventRWFaultCurrent;
private final DataObjectAcessorWithId<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.faultlog.list.output.Data> eventRWFaultLog;
+ private final DataObjectAcessorWithId<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.cmlog.list.output.Data> eventRWCMLog;
private final DataObjectAcessorWithId<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.mediator.server.list.output.Data> mediatorserverRW;
private final DataObjectAcessorWithId<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.maintenance.list.output.Data> maintenanceRW;
private final DataObjectAcessorWithId<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.gui.cut.through.entry.output.Data> guicutthroughRW;
@@ -105,6 +110,7 @@ public class ElasticSearchDataProvider implements DatabaseDataProvider {
private final DataObjectAcessorStatus readStatus;
private final HtDatabaseEventsService databaseService;
private final HtDatabaseMaintenanceService databaseMaintenanceService;
+ private final HtUserdataManager usermanager;
private final HtDatabaseMediatorserver dbMediatorServerService = new HtDatabaseMediatorserver() {
@@ -114,6 +120,7 @@ public class ElasticSearchDataProvider implements DatabaseDataProvider {
}
};
+
@Override
public HtDatabaseClient getRawClient() {
return this.dbClient;
@@ -163,6 +170,10 @@ public class ElasticSearchDataProvider implements DatabaseDataProvider {
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.faultlog.list.output.Data.class,
doFullsizeRequests);
+ this.eventRWCMLog = new DataObjectAcessorWithId<>(dbClient, Entity.Cmlog,
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.cmlog.list.output.Data.class,
+ doFullsizeRequests);
+
this.connnectionlogRW = new DataObjectAcessorWithId<>(dbClient, Entity.Connectionlog,
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.connectionlog.list.output.Data.class,
doFullsizeRequests);
@@ -188,6 +199,7 @@ public class ElasticSearchDataProvider implements DatabaseDataProvider {
this.databaseService = new HtDatabaseEventsService(dbClient, this);
this.databaseMaintenanceService = new HtDatabaseMaintenanceService(dbClient);
+ this.usermanager = new HtUserdataManagerImpl(this.dbClient);
}
/*-------------------------
@@ -222,6 +234,19 @@ public class ElasticSearchDataProvider implements DatabaseDataProvider {
}
@Override
+ public ReadCmlogListOutputBuilder readCMLogList(EntityInput input) {
+ ReadCmlogListOutputBuilder outputBuilder = new ReadCmlogListOutputBuilder();
+ QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.cmlog.list.output.Data> result =
+ this.eventRWCMLog.getData(input);
+ outputBuilder.setData(result.getResult().getHits());
+ outputBuilder.setPagination(
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.cmlog.list.output.PaginationBuilder(
+ result.getPagination()).build());
+ return outputBuilder;
+ }
+
+
+ @Override
public ReadMaintenanceListOutputBuilder readMaintenanceList(EntityInput input) {
ReadMaintenanceListOutputBuilder outputBuilder = new ReadMaintenanceListOutputBuilder();
QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.maintenance.list.output.Data> result =
@@ -393,7 +418,7 @@ public class ElasticSearchDataProvider implements DatabaseDataProvider {
}
CreateNetworkElementConnectionOutputBuilder builder = new CreateNetworkElementConnectionOutputBuilder();
builder.setId(id).setNodeId(input.getNodeId()).setHost(input.getHost()).setPort(input.getPort())
- .setUsername(input.getUsername()).setPassword(input.getPassword()).setIsRequired(input.isIsRequired())
+ .setUsername(input.getUsername()).setPassword(input.getPassword()).setIsRequired(input.getIsRequired())
.setCoreModelCapability(input.getCoreModelCapability()).setDeviceType(input.getDeviceType());
return builder;
}
@@ -516,5 +541,10 @@ public class ElasticSearchDataProvider implements DatabaseDataProvider {
return dbMediatorServerService;
}
+ @Override
+ public HtUserdataManager getUserManager() {
+ return this.usermanager;
+ }
+
}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/impl/HtUserdataManagerImpl.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/impl/HtUserdataManagerImpl.java
index 9dbdb136a..7b7dccc96 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/impl/HtUserdataManagerImpl.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/impl/HtUserdataManagerImpl.java
@@ -21,44 +21,15 @@
*/
package org.onap.ccsdk.features.sdnr.wt.dataprovider.database.elasticsearch.impl;
-import java.io.File;
-import java.io.IOException;
-import java.nio.file.Files;
-import org.json.JSONException;
import org.json.JSONObject;
import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient;
import org.onap.ccsdk.features.sdnr.wt.common.database.SearchHit;
import org.onap.ccsdk.features.sdnr.wt.common.database.SearchResult;
import org.onap.ccsdk.features.sdnr.wt.common.database.queries.QueryBuilders;
-import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.HtUserdataManager;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.data.HtUserdataManagerBase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Entity;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class HtUserdataManagerImpl implements HtUserdataManager {
-
- private static final Logger LOG = LoggerFactory.getLogger(HtUserdataManagerImpl.class);
-
- private static final String USERDATA_DEFAULTS_FILENAME = "etc/userdata-defaults.json";
- private static final JSONObject USERDATA_DEFAULTS_CONTENT = loadDefaults();
-
- private static JSONObject loadDefaults() {
- File f = new File(USERDATA_DEFAULTS_FILENAME);
- String content;
- JSONObject o = null;
- if (f.exists()) {
- try {
- content = Files.readString(f.toPath());
- o = new JSONObject(content);
- } catch (IOException e) {
- LOG.warn("problem loading defaults: ", e);
- } catch (JSONException e) {
- LOG.warn("problem parsing defaults: ", e);
- }
- }
- return o;
- }
+public class HtUserdataManagerImpl extends HtUserdataManagerBase {
private final HtDatabaseClient dbClient;
@@ -67,84 +38,23 @@ public class HtUserdataManagerImpl implements HtUserdataManager {
}
@Override
- public String getUserdata(String username) {
+ protected String readUserdata(String username, String defaultValue) {
+
SearchResult<SearchHit> result = this.dbClient.doReadByQueryJsonData(Entity.Userdata.getName(),
QueryBuilders.matchQuery("_id", username));
- String json = result.getHits().size() > 0 ? result.getHits().get(0).getSourceAsString() : "{}";
- if (USERDATA_DEFAULTS_CONTENT != null) {
- JSONObject merge = mergeData(new JSONObject(json), USERDATA_DEFAULTS_CONTENT);
- json = merge.toString();
- }
- return json;
- }
-
- @Override
- public String getUserdata(String username, String key) {
- JSONObject o = new JSONObject(this.getUserdata(username));
- return o.has(key) ? o.get(key).toString() : "{}";
+ return result.getHits().size() > 0 ? result.getHits().get(0).getSourceAsString() : defaultValue;
}
@Override
public boolean setUserdata(String username, String data) {
JSONObject o = new JSONObject(this.getUserdata(username));
- JSONObject merge = mergeData(o, new JSONObject(data));
+ JSONObject merge = mergeData(new JSONObject(data), o);
return this.dbClient.doWriteRaw(Entity.Userdata.getName(), username, merge.toString()) != null;
}
@Override
- public boolean setUserdata(String username, String key, String data) {
- JSONObject o = new JSONObject(this.getUserdata(username));
- o = mergeData(o, key, new JSONObject(data));
- return this.dbClient.doWriteRaw(Entity.Userdata.getName(), username, o.toString()) != null;
- }
-
- @Override
public boolean removeUserdata(String username) {
return this.dbClient.doRemove(Entity.Userdata.getName(), username);
}
- @Override
- public boolean removeUserdata(String username, String key) {
- JSONObject o = new JSONObject(this.getUserdata(username));
- if (o.has(key)) {
- o.remove(key);
- return this.setUserdata(username, o.toString());
- }
- return true;
- }
-
- private static JSONObject mergeData(JSONObject o, String key, JSONObject subObject) {
- if (!o.has(key)) {
- o.put(key, subObject);
- } else {
- JSONObject tmp = new JSONObject();
- tmp.put(key, subObject);
- o = mergeData(tmp, o);
- }
- return o;
- }
-
- private static JSONObject mergeData(JSONObject source, JSONObject target) throws JSONException {
- String[] keys = JSONObject.getNames(source);
- if (keys == null) {
- return target;
- }
- for (String key : keys) {
- Object value = source.get(key);
- if (!target.has(key)) {
- // new value for "key":
- target.put(key, value);
- } else {
- // existing value for "key" - recursively deep merge:
- if (value instanceof JSONObject) {
- JSONObject valueJson = (JSONObject) value;
- mergeData(valueJson, target.getJSONObject(key));
- } else {
- target.put(key, value);
- }
- }
- }
- return target;
- }
-
}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/AboutHttpServlet.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/AboutHttpServlet.java
index cd75ca2a8..310444fd6 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/AboutHttpServlet.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/AboutHttpServlet.java
@@ -120,7 +120,7 @@ public class AboutHttpServlet extends HttpServlet {
final String mdsalVersion = SystemInfo.getMdSalVersion(UNKNOWN);
this.data.put(PLACEHOLDER_ONAP_RELEASENAME, ODLVersionLUT.getONAPReleaseName(ccsdkVersion, UNKNOWN));
this.data.put(PLACEHOLDER_ODL_RELEASENAME, ODLVersionLUT.getOdlVersion(mdsalVersion, UNKNOWN));
- this.data.put(PLACEHOLDER_BUILD_TIMESTAMP, props != null ? props.getBuildDate().toString() : "");
+ this.data.put(PLACEHOLDER_BUILD_TIMESTAMP, props != null ? String.valueOf(props.getBuildDate()) : "");
this.data.put(PLACEHOLDER_PACAKGE_VERSION, this.getManifestValue("Bundle-Version"));
this.data.put(PLACEHOLDER_CCSDK_VERSION, ccsdkVersion);
this.data.put(PLACEHOLDER_ONAP_RELEASEVERSION, SystemInfo.getOnapVersion(UNKNOWN));
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/ODLVersionLUT.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/ODLVersionLUT.java
index 0e43cd251..5211030eb 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/ODLVersionLUT.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/ODLVersionLUT.java
@@ -32,6 +32,9 @@ public class ODLVersionLUT {
if (onapCCSDKVersion == null) {
return def;
}
+ if (onapCCSDKVersion.startsWith("2.3.")) {
+ return "ONAP Jakarta";
+ }
if (onapCCSDKVersion.startsWith("2.2.")) {
return "ONAP Istanbul";
}
@@ -63,6 +66,7 @@ public class ODLVersionLUT {
}
if(odlMdsalVersionLUT==null) {
odlMdsalVersionLUT = new HashMap<>();
+ odlMdsalVersionLUT.put("7.0.9","silicon-SR2 (0.14.2)");
odlMdsalVersionLUT.put("7.0.7","silicon-SR1 (0.14.1)");
odlMdsalVersionLUT.put("7.0.6","silicon-SR0 (0.14.0)");
odlMdsalVersionLUT.put("6.0.8","aluminium-SR3 (0.13.3)");
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/yangschema/YangFileProvider.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/yangschema/YangFileProvider.java
index c6758e240..797e8d72b 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/yangschema/YangFileProvider.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/yangschema/YangFileProvider.java
@@ -27,6 +27,8 @@ import java.io.FilenameFilter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.nio.file.DirectoryStream;
+import java.nio.file.Files;
import java.nio.file.Path;
import java.text.ParseException;
import java.util.ArrayList;
@@ -53,10 +55,12 @@ public class YangFileProvider {
private static final int BUFFER_SIZE = 1024;
private final Path mainSourcePath;
+ private final Path basePath;
private final List<Path> additionalSources;
- public YangFileProvider(String path) {
- this.mainSourcePath = new File(path).toPath();
+ public YangFileProvider(String path, String primaryPath) {
+ this.mainSourcePath = new File(primaryPath).toPath();
+ this.basePath = new File(path).toPath();
this.additionalSources = new ArrayList<>();
}
@@ -83,7 +87,17 @@ public class YangFileProvider {
LOG.warn("unable to handle yangfile {}: {}", fn, e);
}
}
-
+ List<String> filesInSeperateSubfolders = this.getSubFolderYangfiles();
+ for (String file : filesInSeperateSubfolders) {
+ try {
+ yangfile = new YangFilename(file);
+ if (yangfile.getModule().equals(module)) {
+ list.add(yangfile);
+ }
+ } catch (ParseException e) {
+ LOG.warn("unable to handle yangfile {}: {}", file, e);
+ }
+ }
for (Path addPath : this.additionalSources) {
files = addPath.toFile().list(yangFilenameFilter);
for (String file : files) {
@@ -100,6 +114,30 @@ public class YangFileProvider {
return list;
}
+ private List<String> getSubFolderYangfiles() {
+
+ return this.getSubFolderYangfiles(new ArrayList<>(), this.basePath);
+ }
+
+ private List<String> getSubFolderYangfiles(List<String> list, Path root) {
+ try (DirectoryStream<Path> stream = Files.newDirectoryStream(root)) {
+ for (Path path : stream) {
+ if (path.toFile().isDirectory()) {
+ this.getSubFolderYangfiles(list, path);
+ } else {
+
+ if (yangFilenameFilter.accept(root.toFile(), path.toString())) {
+ list.add(path.toAbsolutePath().toString());
+ }
+
+ }
+ }
+ } catch (IOException e) {
+ LOG.warn("unable to scan directory {} for yang files", root);
+ }
+ return list;
+ }
+
/**
* get yang file from source with specified version or least newer one if version is null then the latest one
*
@@ -201,5 +239,4 @@ public class YangFileProvider {
public boolean hasFileOrNewerForModule(String module, String version) throws ParseException {
return this.getYangFile(module, version) != null;
}
-
}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/yangschema/YangFilename.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/yangschema/YangFilename.java
index eb4961a66..70cddee58 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/yangschema/YangFilename.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/yangschema/YangFilename.java
@@ -29,7 +29,7 @@ import java.util.regex.Pattern;
public class YangFilename {
- private static final String REGEX = "([^\\/]*)@([0-9]{4}-[0-9]{2}-[0-9]{2}).yang";
+ private static final String REGEX = "([^\\/]{1,2048})@([0-9]{4}-[0-9]{2}-[0-9]{2}).yang";
private static final Pattern pattern = Pattern.compile(REGEX, Pattern.MULTILINE);
private final String filename;
private final Matcher matcher;
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/yangschema/YangSchemaHttpServlet.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/yangschema/YangSchemaHttpServlet.java
index 83518ecb2..86f67b1de 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/yangschema/YangSchemaHttpServlet.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/yangschema/YangSchemaHttpServlet.java
@@ -23,28 +23,26 @@ package org.onap.ccsdk.features.sdnr.wt.dataprovider.http.yangschema;
import java.io.IOException;
import java.text.ParseException;
-
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class YangSchemaHttpServlet extends HttpServlet {
/**
- *
+ *
*/
private static final long serialVersionUID = 1L;
private static final Logger LOG = LoggerFactory.getLogger(YangSchemaHttpServlet.class);
-
- private static final String schemaCachePath = "cache/schema/";
+ private static final String CACHEPATH = "cache/";
+ private static final String SCHEMACACHEPATH_PRIMARY = CACHEPATH+"schema/";
private final YangFileProvider fileProvider;
public YangSchemaHttpServlet() {
- this.fileProvider = new YangFileProvider(schemaCachePath);
+ this.fileProvider = new YangFileProvider(CACHEPATH, SCHEMACACHEPATH_PRIMARY);
}
@Override
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 5a99c8ab3..251ba90f2 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
@@ -5,6 +5,8 @@
* Copyright (C) 2019 highstreet technologies GmbH Intellectual Property.
* All rights reserved.
* ================================================================================
+ * Update Copyright (C) 2021 Samsung Electronics 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
@@ -64,6 +66,8 @@ 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.DeleteMediatorServerOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.DeleteNetworkElementConnectionInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.DeleteNetworkElementConnectionOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadCmlogListInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadCmlogListOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadConnectionlogListInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadConnectionlogListOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadEventlogListInput;
@@ -146,12 +150,12 @@ public class DataProviderServiceImpl implements DataProviderService, AutoCloseab
this.mediatorServerServlet = mediatorServerServlet;
if (this.dbConfig.getDbType() == SdnrDbType.ELASTICSEARCH) {
this.dataProvider = new ElasticSearchDataProvider(this.dbConfig.getEsConfig());
- } else {
+ } else {
this.dataProvider = new SqlDBDataProvider(this.dbConfig.getMariadbConfig());
}
+ this.dbUserManager = this.dataProvider.getUserManager();
this.dataProvider.waitForYellowDatabaseStatus(DATABASE_TIMEOUT_MS, TimeUnit.MILLISECONDS);
mediatorServerServlet.setDataProvider(this.dataProvider.getHtDatabaseMediatorServer());
- this.dbUserManager = new HtUserdataManagerImpl(this.dataProvider.getRawClient());
// Register ourselves as the REST API RPC implementation
LOG.info("Register RPC Service {}", DataProviderServiceImpl.class.getSimpleName());
this.rpcReg = rpcProviderService.registerRpcImplementation(DataProviderService.class, this);
@@ -213,6 +217,14 @@ public class DataProviderServiceImpl implements DataProviderService, AutoCloseab
}
@Override
+ public ListenableFuture<RpcResult<ReadCmlogListOutput>> readCmlogList(ReadCmlogListInput input) {
+ LOG.debug("RPC Request: readCMlogList with input {}", input);
+ RpcResultBuilder<ReadCmlogListOutput> result =
+ read(() -> DataProviderServiceImpl.this.dataProvider.readCMLogList(input));
+ return result.buildFuture();
+ }
+
+ @Override
public ListenableFuture<RpcResult<ReadMaintenanceListOutput>> readMaintenanceList(ReadMaintenanceListInput input) {
LOG.debug("RPC Request: readMaintenanceList with input {}", input);
RpcResultBuilder<ReadMaintenanceListOutput> result =
@@ -427,7 +439,9 @@ public class DataProviderServiceImpl implements DataProviderService, AutoCloseab
private ReadTlsKeyEntryOutputBuilder readTlsKeys(ReadTlsKeyEntryInput input) {
Optional<Keystore> result = Optional.empty();
- try (ReadTransaction transaction = this.dataBroker.newReadOnlyTransaction()) {
+ // The implicite close is not handled correctly by underlaying opendaylight netconf service
+ ReadTransaction transaction = this.dataBroker.newReadOnlyTransaction();
+ try {
result = transaction.read(LogicalDatastoreType.CONFIGURATION, KEYSTORE_IIF).get();
} catch (ExecutionException e) {
LOG.warn("problem reading netconf-keystore: ", e);
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestCRUDforDatabase.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestCRUDforDatabase.java
index c407859d5..d59a0784f 100644
--- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestCRUDforDatabase.java
+++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestCRUDforDatabase.java
@@ -5,6 +5,8 @@
* Copyright (C) 2019 highstreet technologies GmbH Intellectual Property.
* All rights reserved.
* ================================================================================
+ * Update Copyright (C) 2021 Samsung Electronics 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
@@ -47,6 +49,9 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.types.YangHelper2;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.test.util.HostInfoForTest;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.yangtools.DataProviderYangToolsMapper;
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.params.xml.ns.yang.data.provider.rev201110.CmNotificationType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CmOperation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CmSourceIndicator;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CreateMaintenanceInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CreateMaintenanceInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CreateMaintenanceOutputBuilder;
@@ -66,6 +71,9 @@ 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.Faultlog;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.FaultlogBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.GranularityPeriodType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadCmlogListInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadCmlogListInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadCmlogListOutputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadConnectionlogListInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadConnectionlogListInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadConnectionlogListOutputBuilder;
@@ -588,6 +596,92 @@ public class TestCRUDforDatabase {
}
@Test
+ public void testCMLog() {
+ System.out.println("Starting CM log test...");
+ String dbId = clearAndCreateCMEntity("1", Entity.Cmlog.getName(),
+ "org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CreateCmlogInput");
+ // ==READ===========================
+ System.out.println("try to read entry");
+
+ ReadCmlogListInput readinput = new ReadCmlogListInputBuilder()
+ .setFilter(YangHelper2.getListOrMap(FilterKey.class,
+ new FilterBuilder().setProperty("id").setFiltervalue(dbId).build()))
+ .setPagination(getPagination(20, 1)).build();
+
+ ReadCmlogListOutputBuilder readResult = null;
+ try {
+ readResult = dbProvider.readCMLogList(readinput);
+
+ } catch (Exception e) {
+ fail("CM log not read: " + e.getMessage());
+ }
+
+ List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.cmlog.list.output.Data>
+ data = readResult.getData();
+
+ assertNotNull(data);
+ assertEquals("1", dbId);
+ assertEquals(1, data.size());
+ assertEquals("node-1", data.get(0).getNodeId());
+ assertEquals(1, data.get(0).getCounter().intValue());
+ assertEquals(CmNotificationType.NotifyMOIChanges, data.get(0).getNotificationType());
+ assertEquals("123", data.get(0).getNotificationId());
+ assertEquals(CmSourceIndicator.MANAGEMENTOPERATION, data.get(0).getSourceIndicator());
+ assertEquals(CmOperation.REPLACE, data.get(0).getOperation());
+ assertEquals("pnf-registration:true", data.get(0).getValue());
+
+ //== UPDATE ================================
+ System.out.println("try to update entry");
+
+ dbRawProvider.doUpdateOrCreate(Entity.Cmlog.getName(), "1",
+ "{'node-id': 'test4657-78','operation': 'CREATE', 'notification-id': '1'}");
+
+ System.out.println("try to search entry 1");
+ readinput = new ReadCmlogListInputBuilder()
+ .setFilter(YangHelper2.getListOrMap(FilterKey.class,
+ new FilterBuilder().setProperty("node-id").setFiltervalue("test").build()))
+ .setPagination(getPagination(20, 1)).build();
+
+ //== VERIFY UPDATE ================================
+ readResult = dbProvider.readCMLogList(readinput);
+ data = readResult.getData();
+
+ assertNotNull(data);
+ System.out.println(data);
+ assertEquals(0, data.size());
+
+ System.out.println("try to search entry 2");
+ readinput = new ReadCmlogListInputBuilder()
+ .setFilter(YangHelper2.getListOrMap(FilterKey.class,
+ new FilterBuilder().setProperty("node-id").setFiltervalue("test*").build()))
+ .setPagination(getPagination(20, 1)).build();
+
+ readResult = dbProvider.readCMLogList(readinput);
+ data = readResult.getData();
+
+ assertEquals(1, data.size());
+ assertEquals("test4657-78", data.get(0).getNodeId());
+ assertEquals("CREATE", data.get(0).getOperation().toString());
+ assertEquals("1", data.get(0).getNotificationId());
+
+ //== DELETE ================================
+
+ System.out.println("try to clear entry");
+ try {
+ dbRawProvider.doRemove(Entity.Cmlog.getName(), dbId);
+ } catch (Exception e) {
+ fail("problem deleting entry: " + e.getMessage());
+ }
+
+ //== VERIFY DELETE ===========================
+ System.out.println("verify entries deleted");
+ readResult = dbProvider
+ .readCMLogList(new ReadFaultlogListInputBuilder().setPagination(getPagination(20, 1)).build());
+ data = readResult.getData();
+ assertEquals(0, data.size());
+ }
+
+ @Test
public void testFaultCurrent() {
System.out.println("Starting faultCurrent test...");
String dbId = null;
@@ -1459,6 +1553,45 @@ public class TestCRUDforDatabase {
return dbId;
}
+ private String clearAndCreateCMEntity(String initialDbId, String entityType, String implementedInterface) {
+ // ==CLEAR BEFORE TEST============================
+ System.out.println("try to clear entry");
+ try {
+ dbRawProvider.doRemove(entityType, QueryBuilders.matchAllQuery());
+ } catch (Exception e) {
+ fail("problem deleting: " + e.getMessage());
+ }
+ return createCMEntity(initialDbId, entityType, implementedInterface);
+ }
+
+ private String createCMEntity(String initialDbId, String entityType, String implementedInterface) {
+ // ==CREATE============================
+ System.out.println("try to create entry");
+ String dbId = null;
+
+ try {
+ dbId = dbRawProvider.doUpdateOrCreate(entityType, initialDbId,
+ "{\n" + "\"timestamp\": \"2019-10-28T11:55:58.3Z\",\n"
+ + "\" object-id\": \"LP-MWPS-RADIO\",\n"
+ + "\"node-id\": \"node-1\",\n"
+ + "\"counter\": 1,\n"
+ + "\"notification-type\": \"" + CmNotificationType.NotifyMOIChanges.toString() + "\",\n"
+ + "\"notification-id\": 123,\n"
+ + "\"source-indicator\": \"" + CmSourceIndicator.MANAGEMENTOPERATION.toString() + "\",\n"
+ + "\" path\": \"https://samsung.com/3GPP/simulation/network-function/ves=1\",\n"
+ + "\"operation\": \"" + CmOperation.REPLACE.toString() + "\",\n"
+ + "\"value\": \"pnf-registration:true\",\n"
+ + "\"implemented-interface\": \"" + implementedInterface + "\"\n"
+ + "}");
+
+ } catch (Exception e) {
+ fail("Problem creating CM log entry" + e.getMessage());
+ }
+
+ return dbId;
+ }
+
+
private String createPerformanceData(String initialDbId, GranularityPeriodType timeInterval, String scannerId,
String uuidInterface, String nodename) {
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestEventService.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestEventService.java
index dc5e049fd..0db019005 100644
--- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestEventService.java
+++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestEventService.java
@@ -5,6 +5,8 @@
* Copyright (C) 2020 highstreet technologies GmbH Intellectual Property.
* All rights reserved.
* ================================================================================
+ * Update Copyright (C) 2021 Samsung Electronics 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
@@ -38,12 +40,18 @@ import org.onap.ccsdk.features.sdnr.wt.common.database.config.HostInfo;
import org.onap.ccsdk.features.sdnr.wt.common.database.queries.QueryBuilders;
import org.onap.ccsdk.features.sdnr.wt.common.database.requests.DeleteByQueryRequest;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.DatabaseDataProvider;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.elasticsearch.data.entity.FaultEntityManager;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.elasticsearch.data.entity.HtDatabaseEventsService;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.elasticsearch.impl.ElasticSearchDataProvider;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.types.NetconfTimeStampImpl;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.types.YangHelper2;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.test.util.HostInfoForTest;
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.params.xml.ns.yang.data.provider.rev201110.CmNotificationType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CmOperation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CmSourceIndicator;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CmlogBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CmlogEntity;
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.ConnectionlogBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ConnectionlogEntity;
@@ -77,6 +85,7 @@ public class TestEventService {
private static final String NODEID = "node1";
private static final String NODEID2 = "node2";
+ private static final String NODEID3 = "node3";
private static final String OBJECTREFID1 = "objid1";
private static final String OBJECTREFID2 = "objid2";
@@ -122,6 +131,19 @@ public class TestEventService {
assertTrue(nodeIds.size() == 1);
}
+
+ @Test
+ public void testGenSpecificEsId() {
+ String objectRefOld = FaultEntityManager.genSpecificEsId(createFault(NODEID, "[layerProtocol="+OBJECTREFID1+"]", "abc", SeverityType.Major));
+ assertEquals(String.format("%s/%s/%s", NODEID, OBJECTREFID1, "abc"), objectRefOld);
+ String objectRefOld2 = FaultEntityManager.genSpecificEsId(createFault(NODEID2, "[layerProtocol="+OBJECTREFID2+"]", "abcde", SeverityType.Major));
+ assertEquals(String.format("%s/%s/%s", NODEID2, OBJECTREFID2, "abcde"), objectRefOld2);
+ String objectRef = FaultEntityManager.genSpecificEsId(createFault(NODEID, OBJECTREFID1, "abc", SeverityType.Major));
+ assertEquals(String.format("%s/%s/%s", NODEID, OBJECTREFID1, "abc"), objectRef);
+ String objectRef2 = FaultEntityManager.genSpecificEsId(createFault(NODEID2, OBJECTREFID2, "abcde", SeverityType.Major));
+ assertEquals(String.format("%s/%s/%s", NODEID2, OBJECTREFID2, "abcde"), objectRef2);
+ }
+
private static FaultcurrentEntity createFault(String nodeId, String objectRefId, String problem,
SeverityType severity) {
return createFault(nodeId, objectRefId, problem, severity, NetconfTimeStampImpl.getConverter().getTimeStamp());
@@ -146,6 +168,7 @@ public class TestEventService {
service.doIndexClean(now);
clearDbEntity(Entity.Eventlog);
clearDbEntity(Entity.Faultlog);
+ clearDbEntity(Entity.Cmlog);
TestCRUDforDatabase.trySleep(1000);
service.writeEventLog(createEventLog(NODEID, OBJECTREFID1, "aaa", "abc", 1));
service.writeEventLog(createEventLog(NODEID, OBJECTREFID1, "aaa", "avasvas", 2));
@@ -153,19 +176,27 @@ public class TestEventService {
service.writeFaultLog(createFaultLog(NODEID, OBJECTREFID2, "problem", SeverityType.Major, 1));
service.writeFaultLog(createFaultLog(NODEID, OBJECTREFID2, "problem", SeverityType.NonAlarmed, 2));
service.writeFaultLog(createFaultLog(NODEID2, OBJECTREFID2, "problem", SeverityType.Major, 1));
+
+ service.writeCMLog(createCMLog(NODEID3, 1, CmNotificationType.NotifyMOIChanges,
+ "1", CmSourceIndicator.MANAGEMENTOPERATION, CmOperation.CREATE, "value"));
+
TestCRUDforDatabase.trySleep(100);
now = new Date();
long numOlds = service.getNumberOfOldObjects(now);
- assertEquals(5, numOlds);
+ assertEquals(6, numOlds);
TestCRUDforDatabase.trySleep(100);
service.writeFaultLog(createFaultLog(NODEID, OBJECTREFID2, "problem", SeverityType.Major, 3));
service.writeFaultLog(createFaultLog(NODEID, OBJECTREFID2, "problem", SeverityType.NonAlarmed, 5));
service.writeFaultLog(createFaultLog(NODEID, OBJECTREFID2, "problem", SeverityType.Major, 6));
+
+ service.writeCMLog(createCMLog(NODEID3, 2, CmNotificationType.NotifyMOIChanges,
+ "2", CmSourceIndicator.SONOPERATION, CmOperation.REPLACE, "value2"));
+
numOlds = service.getNumberOfOldObjects(now);
- assertEquals(5, numOlds);
+ assertEquals(6, numOlds);
now = new Date();
numOlds = service.getNumberOfOldObjects(now);
- assertEquals(8, numOlds);
+ assertEquals(10, numOlds);
service.doIndexClean(now);
numOlds = service.getNumberOfOldObjects(now);
assertEquals(0, numOlds);
@@ -292,6 +323,31 @@ public class TestEventService {
/**
* @param nodeId
+ * @param counter
+ * @param notificationType
+ * @param notificationId
+ * @param sourceIndicator
+ * @param operation
+ * @param value
+ * @return
+ */
+ private static CmlogEntity createCMLog(String nodeId, int counter, CmNotificationType notificationType,
+ String notificationId, CmSourceIndicator sourceIndicator,
+ CmOperation operation, String value) {
+ return new CmlogBuilder()
+ .setNodeId(nodeId)
+ .setCounter(counter)
+ .setNotificationType(notificationType)
+ .setNotificationId(notificationId)
+ .setSourceIndicator(sourceIndicator)
+ .setOperation(operation)
+ .setValue(value)
+ .setTimestamp(NetconfTimeStampImpl.getConverter().getTimeStamp())
+ .build();
+ }
+
+ /**
+ * @param nodeId
* @param objectId
* @param problem
* @param severity
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestUserdata.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestUserdata.java
index 3fcbdb84c..ce4044780 100644
--- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestUserdata.java
+++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestUserdata.java
@@ -21,11 +21,11 @@
*/
package org.onap.ccsdk.features.sdnr.wt.dataprovider.test;
+import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.IOException;
import org.apache.sshd.common.util.io.IoUtils;
import org.junit.BeforeClass;
-import org.junit.Ignore;
import org.junit.Test;
import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient;
import org.onap.ccsdk.features.sdnr.wt.common.database.config.HostInfo;
@@ -35,7 +35,7 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.test.util.HostInfoForTest;
public class TestUserdata {
- private static final String USERNAME = "admin";
+ private static final String USERNAME = "admin132";
private static HtDatabaseClient dbRawProvider;
private static HtUserdataManagerImpl userDbProvider;
@@ -55,17 +55,18 @@ public class TestUserdata {
}
}
- @Ignore
@Test
public void test1() {
String fullContent = "";
+ boolean success = false;
try {
fullContent = getFileContent("/userdata/full.json");
- userDbProvider.setUserdata(USERNAME, fullContent);
+ success = userDbProvider.setUserdata(USERNAME, fullContent);
} catch (IOException e) {
e.printStackTrace();
fail(e.getMessage());
}
+ assertTrue("problem writing data into db",success);
trySleep(2000);
@@ -89,6 +90,6 @@ public class TestUserdata {
}
private static String getFileContent(String filename) throws IOException {
- return String.join("\n", IoUtils.readAllLines(TestTree.class.getResourceAsStream(filename)));
+ return String.join("\n", IoUtils.readAllLines(TestUserdata.class.getResourceAsStream(filename)));
}
}
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangProvider.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangProvider.java
index f3171d3b1..adcb523c0 100644
--- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangProvider.java
+++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangProvider.java
@@ -54,6 +54,8 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.http.yangschema.YangSchemaHt
public class TestYangProvider {
private static final String TESTPATH = "cache/schema/";
+ private static final String TESTPATH_BASE = "cache/";
+ private static final String TESTPATH_SEPERATE_1 = TESTPATH_BASE+"abc1/";
@BeforeClass
@@ -76,7 +78,9 @@ public class TestYangProvider {
new File(TESTPATH + new YangFilename("module4", "2010-05-01").getFilename()).createNewFile();
new File(TESTPATH + new YangFilename("module5", "2010-01-11").getFilename()).createNewFile();
new File(TESTPATH + new YangFilename("module6", "2010-01-01").getFilename()).createNewFile();
- } catch (IOException | ParseException e) {
+ Files.createDirectories(new File(TESTPATH_SEPERATE_1).toPath(), attr);
+ new File(TESTPATH_SEPERATE_1 + new YangFilename("module7", "2011-01-01").getFilename()).createNewFile();
+ } catch (IOException | ParseException e) {
}
}
@@ -93,17 +97,18 @@ public class TestYangProvider {
@Test
public void testExisting() {
- YangFileProvider provider = new YangFileProvider(TESTPATH);
+ YangFileProvider provider = new YangFileProvider(TESTPATH_BASE, TESTPATH);
assertTrue(provider.hasFileForModule("module1", "2010-01-01"));
assertTrue(provider.hasFileForModule("module2"));
assertTrue(provider.hasFileForModule("module3"));
assertFalse(provider.hasFileForModule("module5", "2010-01-01"));
+ assertTrue(provider.hasFileForModule("module7"));
}
@Test
public void testRevision() throws ParseException {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
- YangFileProvider provider = new YangFileProvider(TESTPATH);
+ YangFileProvider provider = new YangFileProvider(TESTPATH_BASE, TESTPATH);
YangFilename f1 = provider.getFileForModule("module1", "2010-01-01");
assertEquals("module1", f1.getModule());
assertEquals(sdf.parse("2010-01-01"), f1.getRevision());
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/util/MariaDBTestBase.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/util/MariaDBTestBase.java
index 276bcf4a1..18efde235 100644
--- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/util/MariaDBTestBase.java
+++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/util/MariaDBTestBase.java
@@ -5,6 +5,8 @@
* Copyright (C) 2021 highstreet technologies GmbH Intellectual Property.
* All rights reserved.
* ================================================================================
+ * Update Copyright (C) 2021 Samsung Electronics 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
@@ -34,6 +36,7 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.SqlDBConfig;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.data.SqlDBDataProvider;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.database.SqlDBMapper;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.database.SqlDBMapper.UnableToMapClassException;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CmlogEntity;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ConnectionlogEntity;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Entity;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.EventlogEntity;
@@ -127,6 +130,7 @@ public class MariaDBTestBase {
createTable(dbService, EventlogEntity.class, Entity.Eventlog, true);
createTable(dbService, FaultcurrentEntity.class, Entity.Faultcurrent, false);
createTable(dbService, FaultlogEntity.class, Entity.Faultlog, true);
+ createTable(dbService, CmlogEntity.class, Entity.Cmlog, true);
createTable(dbService, GuicutthroughEntity.class, Entity.Guicutthrough, true);
createTable(dbService, Pmdata15mEntity.class, Entity.Historicalperformance15min, false);
createTable(dbService, Pmdata24hEntity.class, Entity.Historicalperformance24h, false);