summaryrefslogtreecommitdiffstats
path: root/sdnr/wt/data-provider
diff options
context:
space:
mode:
Diffstat (limited to 'sdnr/wt/data-provider')
-rw-r--r--sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/DataProvider.java7
-rw-r--r--sdnr/wt/data-provider/model/src/main/java/org/opendaylight/yang/gen/v1/http/org/openroadm/pm/types/rev191129/PmDataTypeBuilder.java (renamed from sdnr/wt/data-provider/model/src/main/java/org/opendaylight/yang/gen/v1/http/org/openroadm/pm/types/rev200327/PmDataTypeBuilder.java)2
-rw-r--r--sdnr/wt/data-provider/model/src/main/yang/data-provider-v2@2020-07-02.yang1
-rw-r--r--sdnr/wt/data-provider/model/src/main/yang/org-openroadm-pm-types@2019-11-29.yang (renamed from sdnr/wt/data-provider/model/src/main/yang/org-openroadm-pm-types@2020-03-27.yang)31
-rw-r--r--sdnr/wt/data-provider/provider/pom.xml8
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/entity/HtDatabaseEventsService.java63
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/ReadyHttpServlet.java82
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/AboutHttpServlet.java68
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/ODLVersionLUT.java39
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/SystemInfo.java9
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/YangToolsCloner.java223
-rw-r--r--sdnr/wt/data-provider/provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml5
-rw-r--r--sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestTree.java78
-rw-r--r--sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/util/HostInfoForTest.java2
-rw-r--r--sdnr/wt/data-provider/provider/src/test/resources/testequipment/1.json17
-rw-r--r--sdnr/wt/data-provider/provider/src/test/resources/testequipment/10.json15
-rw-r--r--sdnr/wt/data-provider/provider/src/test/resources/testequipment/11.json18
-rw-r--r--sdnr/wt/data-provider/provider/src/test/resources/testequipment/12.json15
-rw-r--r--sdnr/wt/data-provider/provider/src/test/resources/testequipment/13.json20
-rw-r--r--sdnr/wt/data-provider/provider/src/test/resources/testequipment/14.json15
-rw-r--r--sdnr/wt/data-provider/provider/src/test/resources/testequipment/15.json15
-rw-r--r--sdnr/wt/data-provider/provider/src/test/resources/testequipment/16.json15
-rw-r--r--sdnr/wt/data-provider/provider/src/test/resources/testequipment/17.json17
-rw-r--r--sdnr/wt/data-provider/provider/src/test/resources/testequipment/18.json18
-rw-r--r--sdnr/wt/data-provider/provider/src/test/resources/testequipment/19.json20
-rw-r--r--sdnr/wt/data-provider/provider/src/test/resources/testequipment/2.json15
-rw-r--r--sdnr/wt/data-provider/provider/src/test/resources/testequipment/20.json20
-rw-r--r--sdnr/wt/data-provider/provider/src/test/resources/testequipment/21.json17
-rw-r--r--sdnr/wt/data-provider/provider/src/test/resources/testequipment/3.json15
-rw-r--r--sdnr/wt/data-provider/provider/src/test/resources/testequipment/4.json15
-rw-r--r--sdnr/wt/data-provider/provider/src/test/resources/testequipment/5.json25
-rw-r--r--sdnr/wt/data-provider/provider/src/test/resources/testequipment/6.json17
-rw-r--r--sdnr/wt/data-provider/provider/src/test/resources/testequipment/7.json17
-rw-r--r--sdnr/wt/data-provider/provider/src/test/resources/testequipment/8.json17
-rw-r--r--sdnr/wt/data-provider/provider/src/test/resources/testequipment/9.json19
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/DataMigrationProviderImpl.java16
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/Program.java98
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/ReleaseInformation.java20
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/Release.java13
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ReleaseGroup.java6
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/frankfurt/FrankfurtReleaseInformationR2.java10
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/guilin/GuilinReleaseInformation.java42
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/guilin/GuilinReleaseInformationR2.java81
-rw-r--r--sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestMigrationProvider.java3
44 files changed, 768 insertions, 501 deletions
diff --git a/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/DataProvider.java b/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/DataProvider.java
index f4578d5dc..639fe301b 100644
--- a/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/DataProvider.java
+++ b/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/DataProvider.java
@@ -102,10 +102,13 @@ public interface DataProvider extends ArchiveCleanProvider {
/**
* @param list
*/
- void doWritePerformanceData(List<PmdataEntity> list);
+ void doWritePerformanceData(List<PmdataEntity> list);
+
+ void doWritePerformanceData2(List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.v2.rev200702.PmdataEntity> list);
+
/**
- * @return
+ * @return raw database client
*/
HtDatabaseClient getRawClient();
diff --git a/sdnr/wt/data-provider/model/src/main/java/org/opendaylight/yang/gen/v1/http/org/openroadm/pm/types/rev200327/PmDataTypeBuilder.java b/sdnr/wt/data-provider/model/src/main/java/org/opendaylight/yang/gen/v1/http/org/openroadm/pm/types/rev191129/PmDataTypeBuilder.java
index f470fb6ba..98e93c363 100644
--- a/sdnr/wt/data-provider/model/src/main/java/org/opendaylight/yang/gen/v1/http/org/openroadm/pm/types/rev200327/PmDataTypeBuilder.java
+++ b/sdnr/wt/data-provider/model/src/main/java/org/opendaylight/yang/gen/v1/http/org/openroadm/pm/types/rev191129/PmDataTypeBuilder.java
@@ -1,4 +1,4 @@
-package org.opendaylight.yang.gen.v1.http.org.openroadm.pm.types.rev200327;
+package org.opendaylight.yang.gen.v1.http.org.openroadm.pm.types.rev191129;
import java.lang.String;
import java.lang.UnsupportedOperationException;
diff --git a/sdnr/wt/data-provider/model/src/main/yang/data-provider-v2@2020-07-02.yang b/sdnr/wt/data-provider/model/src/main/yang/data-provider-v2@2020-07-02.yang
index 358e30c8b..47cc009f1 100644
--- a/sdnr/wt/data-provider/model/src/main/yang/data-provider-v2@2020-07-02.yang
+++ b/sdnr/wt/data-provider/model/src/main/yang/data-provider-v2@2020-07-02.yang
@@ -6,6 +6,7 @@ module data-provider-v2 {
import org-openroadm-pm-types {
prefix org-openroadm-pm-types;
+ revision-date 2019-11-29;
reference
"OpenROADM: YANG definitions of performance management types";
}
diff --git a/sdnr/wt/data-provider/model/src/main/yang/org-openroadm-pm-types@2020-03-27.yang b/sdnr/wt/data-provider/model/src/main/yang/org-openroadm-pm-types@2019-11-29.yang
index 1fbd72e0f..78dd8934e 100644
--- a/sdnr/wt/data-provider/model/src/main/yang/org-openroadm-pm-types@2020-03-27.yang
+++ b/sdnr/wt/data-provider/model/src/main/yang/org-openroadm-pm-types@2019-11-29.yang
@@ -35,10 +35,6 @@ module org-openroadm-pm-types {
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE";
- revision 2020-03-27 {
- description
- "Version 7.0.0";
- }
revision 2019-11-29 {
description
"Version 6.1.0";
@@ -643,31 +639,6 @@ module org-openroadm-pm-types {
description
"unavailable Seconds Count on TCM6 down direction.";
}
- enum fecCorrectedCodewords {
- value 120;
- description
- "FEC Corrected Codewords Counter";
- }
- enum fecUncorrectedCodewords {
- value 121;
- description
- "FEC Uncorrected Codewords Counter";
- }
- enum fecSymbolErrors {
- value 122;
- description
- "FEC Symbol Error Counter";
- }
- enum localFaultSeconds {
- value 123;
- description
- "Local Fault Seconds";
- }
- enum remoteFaultSeconds {
- value 124;
- description
- "Remote Fault Seconds";
- }
}
}
@@ -706,4 +677,4 @@ module org-openroadm-pm-types {
name not found in pm-names-enum";
}
}
-} \ No newline at end of file
+}
diff --git a/sdnr/wt/data-provider/provider/pom.xml b/sdnr/wt/data-provider/provider/pom.xml
index a536d64b1..85b8f308d 100644
--- a/sdnr/wt/data-provider/provider/pom.xml
+++ b/sdnr/wt/data-provider/provider/pom.xml
@@ -58,6 +58,10 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>org.apache.karaf.bundle</groupId>
+ <artifactId>org.apache.karaf.bundle.core</artifactId>
+ </dependency>
+ <dependency>
<groupId>${project.groupId}</groupId>
<artifactId>sdnr-wt-data-provider-setup</artifactId>
<version>${project.version}</version>
@@ -82,6 +86,7 @@
<artifactId>org.osgi.core</artifactId>
<scope>provided</scope>
</dependency>
+
<dependency>
<groupId>org.apache.karaf.shell</groupId>
<artifactId>org.apache.karaf.shell.core</artifactId>
@@ -162,13 +167,12 @@
<plugin>
<groupId>com.github.alexcojocaru</groupId>
<artifactId>elasticsearch-maven-plugin</artifactId>
- <version>6.16</version>
<configuration>
<skip>${skipTests}</skip>
<clusterName>testCluster</clusterName>
<transportPort>9500</transportPort>
<httpPort>${databaseport}</httpPort>
- <version>7.1.1</version>
+ <version>7.6.1</version>
<timeout>120</timeout>
<pathInitScript>${project.build.directory}/EsInit.script</pathInitScript>
</configuration>
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/entity/HtDatabaseEventsService.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/entity/HtDatabaseEventsService.java
index 46475f02d..de6870571 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/entity/HtDatabaseEventsService.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/entity/HtDatabaseEventsService.java
@@ -25,9 +25,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
-
import javax.annotation.Nonnull;
-
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient;
@@ -83,6 +81,8 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid
private final EsDataObjectReaderWriter2<NetworkElementConnectionEntity> networkelementConnectionDB;
private final EsDataObjectReaderWriter2<PmdataEntity> pmData15mDB;
private final EsDataObjectReaderWriter2<PmdataEntity> pmData24hDB;
+ private final EsDataObjectReaderWriter2<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.v2.rev200702.PmdataEntity> pmData15mDBv2;
+ private final EsDataObjectReaderWriter2<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.v2.rev200702.PmdataEntity> pmData24hDBv2;
@SuppressWarnings("unused")
private final ElasticSearchDataProvider dataProvider;
@@ -124,6 +124,15 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid
pmData24hDB = new EsDataObjectReaderWriter2<>(client, Entity.Historicalperformance24h, PmdataEntity.class,
PmdataEntityBuilder.class);
+ pmData15mDBv2 = new EsDataObjectReaderWriter2<>(client, Entity.Historicalperformance15min,
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.v2.rev200702.PmdataEntity.class,
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.v2.rev200702.PmdataEntityBuilder.class);
+
+ pmData24hDBv2 = new EsDataObjectReaderWriter2<>(client, Entity.Historicalperformance24h,
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.v2.rev200702.PmdataEntity.class,
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.v2.rev200702.PmdataEntityBuilder.class);
+
+
} catch (Exception e) {
LOG.error("Can not start database client. Exception: {}", e);
throw new Exception("Can not start database client. Exception: {}", e);
@@ -251,7 +260,7 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid
/**
* write internal equipment to database
- *
+ *
* @param internalEquipment with mandatory fields.
*/
@Override
@@ -276,7 +285,7 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid
/**
* join base with parameters of toJoin (only non null values)
- *
+ *
* @param base base object
* @param toJoin object with new property values
* @return new joined object
@@ -335,7 +344,7 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid
/**
* Update after new mountpoint registration
- *
+ *
* @param networkElementConnectionEntitiy data
* @param nodeId of device (mountpoint name)
*/
@@ -411,7 +420,7 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid
/**
* Verify status of client
- *
+ *
* @param event that is printed with message
* @return true if client is null
*/
@@ -425,7 +434,7 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid
/**
* Verify status of client
- *
+ *
* @param message to print including {} for object printout.
* @return true if client is null
*/
@@ -443,7 +452,7 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid
private static class EsEventBase {
/**
* Query to get older Elements
- *
+ *
* @param netconfTimeStamp to identify older Elements
* @return QueryBuilder for older elements related to timestamp
*/
@@ -454,7 +463,7 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid
private static class EsFaultLogDevicemanager {
/**
* Get older Elements
- *
+ *
* @param netconfTimeStamp to identify query elements older than this timestamp.
* @return QueryBuilder for related elements
*/
@@ -513,15 +522,51 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid
});
}
+ @Override
+ public void doWritePerformanceData2(
+ List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.v2.rev200702.PmdataEntity> list) {
+
+ list.forEach(elem -> {
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.v2.rev200702.GranularityPeriodType
+ granularityPeriod = nnGetGranularityPeriodType2(elem.getGranularityPeriod());
+ //_id": "Sim12600/LP-MWPS-TTP-01/2017-07-04T15:15:00.0+00:00"
+ StringBuffer id = new StringBuffer();
+ DateAndTime date = elem.getTimeStamp();
+ id.append(elem.getNodeName());
+ id.append("/");
+ id.append(elem.getUuidInterface());
+ id.append("/");
+ id.append(date != null ? date.getValue() : "null");
+ switch (granularityPeriod) {
+ case Period15Min:
+ pmData15mDB.write(elem, id.toString());
+ break;
+ case Period24Hours:
+ pmData24hDB.write(elem, id.toString());
+ break;
+ case Unknown:
+ default:
+ LOG.debug("Unknown granularity {} id {}", granularityPeriod, id);
+ break;
+ }
+ });
+ }
@NonNull
GranularityPeriodType nnGetGranularityPeriodType(@Nullable GranularityPeriodType granularityPeriod) {
return granularityPeriod != null ? granularityPeriod : GranularityPeriodType.Unknown;
}
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.v2.rev200702.GranularityPeriodType nnGetGranularityPeriodType2(
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.v2.rev200702.@Nullable GranularityPeriodType granularityPeriod) {
+ return granularityPeriod != null ? granularityPeriod :
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.v2.rev200702.GranularityPeriodType.Unknown;
+ }
@Override
public HtDatabaseClient getRawClient() {
return this.client;
}
+
+
}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/ReadyHttpServlet.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/ReadyHttpServlet.java
index e20f453a1..284365021 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/ReadyHttpServlet.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/ReadyHttpServlet.java
@@ -22,28 +22,39 @@
package org.onap.ccsdk.features.sdnr.wt.dataprovider.http;
import java.io.IOException;
-
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-
+import org.apache.karaf.bundle.core.BundleInfo;
+import org.apache.karaf.bundle.core.BundleService;
+import org.apache.karaf.bundle.core.BundleState;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.http.about.MarkdownTable;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.FrameworkUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ReadyHttpServlet extends HttpServlet {
/**
- *
+ *
*/
private static final long serialVersionUID = 1L;
private static final Logger LOG = LoggerFactory.getLogger(ReadyHttpServlet.class);
private static boolean status;
+
+ private BundleService bundleService = null;
+
+ public void setBundleService(BundleService bundleService) {
+ this.bundleService = bundleService;
+ }
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- if (isReady()) {
+ if (isReady() && this.getBundleStatesReady()) {
resp.setStatus(HttpServletResponse.SC_OK);
} else {
@@ -63,4 +74,67 @@ public class ReadyHttpServlet extends HttpServlet {
status = s;
LOG.info("status is set to ready: {}", status);
}
+
+ private boolean getBundleStatesReady() {
+ Bundle thisbundle = FrameworkUtil.getBundle(this.getClass());
+ BundleContext context = thisbundle ==null?null:thisbundle.getBundleContext();
+ if (context == null) {
+ LOG.debug("no bundle context available");
+ return true;
+ }
+ Bundle[] bundles = context.getBundles();
+ if (bundles == null || bundles.length <= 0) {
+ LOG.debug("no bundles found");
+ return true;
+ }
+ LOG.debug("found {} bundles", bundles.length);
+ MarkdownTable table = new MarkdownTable();
+ table.setHeader(new String[] {"Bundle-Id","Version","Symbolic-Name","Status"});
+ int cntNotActive=0;
+
+ for (Bundle bundle : bundles) {
+ if(this.bundleService!=null) {
+ BundleInfo info = this.bundleService.getInfo(bundle);
+ if(info.getState()==BundleState.Active ) {
+ continue;
+ }
+ if(info.getState()==BundleState.Resolved ) {
+ if(!this.isBundleImportant(bundle.getSymbolicName())) {
+ LOG.trace("ignore not important bundle {} with state {}",bundle.getSymbolicName(),info.getState());
+ continue;
+ }
+ }
+
+ LOG.trace("bundle {} is in state {}",bundle.getSymbolicName(),info.getState());
+ }
+ else {
+ LOG.warn("bundle service is null");
+ }
+ cntNotActive++;
+ }
+
+ return cntNotActive==0;
+ }
+
+ private boolean isBundleImportant(String symbolicName) {
+ symbolicName = symbolicName.toLowerCase();
+ if(symbolicName.contains("mdsal")) {
+ return true;
+ }
+ if(symbolicName.contains("netconf")) {
+ return true;
+ }
+ if(symbolicName.contains("ccsdk")) {
+ return true;
+ }
+ if(symbolicName.contains("devicemanager")) {
+ return true;
+ }
+ if(symbolicName.contains("restconf")) {
+ return true;
+ }
+
+ return false;
+ }
+
}
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 9ac0cc0c3..81b9645fe 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
@@ -38,6 +38,9 @@ import javax.servlet.http.HttpServletResponse;
import org.onap.ccsdk.features.sdnr.wt.common.Resources;
import org.onap.ccsdk.features.sdnr.wt.common.file.PomFile;
import org.onap.ccsdk.features.sdnr.wt.common.file.PomPropertiesFile;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.FrameworkUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -59,7 +62,6 @@ public class AboutHttpServlet extends HttpServlet {
private static final String PLACEHOLDER_ONAP_RELEASEVERSION = "{release-version}";
private static final String PLACEHOLDER_ODL_RELEASENAME = "{odl-version}";
private static final String PLACEHOLDER_BUILD_TIMESTAMP = "{build-time}";
- private static final String PLACEHOLDER_ODLUX_REVISION = "{odlux-revision}";
private static final String PLACEHOLDER_PACKAGE_GITHASH = "{package-githash}";
private static final String PLACEHOLDER_PACAKGE_VERSION = "{package-version}";
private static final String PLACEHOLDER_CCSDK_VERSION = "{ccsdk-version}";
@@ -69,10 +71,12 @@ public class AboutHttpServlet extends HttpServlet {
private static final String PLACEHOLDER_KARAF_INFO = "{karaf-info}";
private static final String PLACEHOLDER_DEVICEMANAGER_TABLE = "{devicemanagers}";
private static final String README_FILE = "README.md";
+ private static final String NO_DEVICEMANAGERS_RUNNING_MESSAGE = null;
private final String groupId = "org.onap.ccsdk.features.sdnr.wt";
private final String artifactId = "sdnr-wt-data-provider-provider";
+ private final Map<Integer,String> BUNDLESTATE_LUT;
private final Map<String, String> data;
private final String readmeContent;
// private BundleService bundleService;
@@ -83,7 +87,13 @@ public class AboutHttpServlet extends HttpServlet {
this.data = new HashMap<>();
this.collectStaticData();
this.readmeContent = this.render(this.getResourceFileContent(README_FILE));
- //BundleContext context = FrameworkUtil.getBundle(this.getClass()).getBundleContext();
+ this.BUNDLESTATE_LUT = new HashMap<>();
+ this.BUNDLESTATE_LUT.put(Bundle.UNINSTALLED, "uninstalled");
+ this.BUNDLESTATE_LUT.put(Bundle.INSTALLED, "installed");
+ this.BUNDLESTATE_LUT.put(Bundle.RESOLVED, "resolved");
+ this.BUNDLESTATE_LUT.put(Bundle.STARTING, "starting");
+ this.BUNDLESTATE_LUT.put(Bundle.STOPPING, "stopping");
+ this.BUNDLESTATE_LUT.put(Bundle.ACTIVE, "active");
}
@@ -97,13 +107,14 @@ public class AboutHttpServlet extends HttpServlet {
private void collectStaticData() {
PomPropertiesFile props = this.getPomProperties();
final String ccsdkVersion = this.getPomParentVersion();
+ final String mdsalVersion = SystemInfo.getMdSalVersion(UNKNOWN);
this.data.put(PLACEHOLDER_ONAP_RELEASENAME, ODLVersionLUT.getONAPReleaseName(ccsdkVersion, UNKNOWN));
- this.data.put(PLACEHOLDER_ODL_RELEASENAME, ODLVersionLUT.getOdlVersion(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_PACAKGE_VERSION, this.getManifestValue("Bundle-Version"));
this.data.put(PLACEHOLDER_CCSDK_VERSION, ccsdkVersion);
- this.data.put(PLACEHOLDER_ONAP_RELEASEVERSION, "2.0.0-SNAPSHOT");
- this.data.put(PLACEHOLDER_MDSAL_VERSION, SystemInfo.getMdSalVersion(UNKNOWN));
+ this.data.put(PLACEHOLDER_ONAP_RELEASEVERSION, SystemInfo.getOnapVersion(UNKNOWN));
+ this.data.put(PLACEHOLDER_MDSAL_VERSION, mdsalVersion);
this.data.put(PLACEHOLDER_YANGTOOLS_VERSION, SystemInfo.getYangToolsVersion(UNKNOWN));
this.data.put(PLACEHOLDER_PACKAGE_GITHASH, this.getGitHash(UNKNOWN));
}
@@ -272,25 +283,34 @@ public class AboutHttpServlet extends HttpServlet {
}
private String getDevicemanagerBundles() {
- // if(this.bundleService==null) {
- // LOG.debug("no bundle service available");
- // return "";
- // }
- //
- // List<String> ids = new ArrayList<String>();
- // List<Bundle> bundles = bundleService.selectBundles("0", ids , true);
- // if(bundles==null || bundles.size()<=0) {
- // LOG.debug("no bundles found");
- // return "";
- // }
- // LOG.debug("found {} bundles",bundles.size());
- // MarkdownTable table = new MarkdownTable();
- // for(Bundle bundle:bundles) {
- // BundleInfo info = this.bundleService.getInfo(bundle);
- // table.addRow(new String[] {String.valueOf(info.getBundleId()),info.getVersion(),info.getName(),info.getState().toString()});
- // }
- // return table.toMarkDown();
- return "";
+ Bundle thisbundle = FrameworkUtil.getBundle(this.getClass());
+ BundleContext context = thisbundle ==null?null:thisbundle.getBundleContext();
+ if (context == null) {
+ LOG.debug("no bundle context available");
+ return "";
+ }
+ Bundle[] bundles = context.getBundles();
+ if (bundles == null || bundles.length <= 0) {
+ LOG.debug("no bundles found");
+ return NO_DEVICEMANAGERS_RUNNING_MESSAGE;
+ }
+ LOG.debug("found {} bundles", bundles.length);
+ MarkdownTable table = new MarkdownTable();
+ table.setHeader(new String[] {"Bundle-Id","Version","Symbolic-Name","Status"});
+ String name;
+ for (Bundle bundle : bundles) {
+ name = bundle.getSymbolicName();
+ if(!(name.contains("devicemanager") && name.contains("provider"))) {
+ continue;
+ }
+ if(name.equals("org.onap.ccsdk.features.sdnr.wt.sdnr-wt-devicemanager-provider")) {
+ continue;
+ }
+ table.addRow(new String[] {String.valueOf(bundle.getBundleId()), bundle.getVersion().toString(), name,
+ BUNDLESTATE_LUT.getOrDefault(bundle.getState(),"unknown")});
+
+ }
+ return table.toMarkDown();
}
/**
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 bd8fae6a0..991231f87 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
@@ -21,8 +21,13 @@
*/
package org.onap.ccsdk.features.sdnr.wt.dataprovider.http.about;
+import java.util.HashMap;
+import java.util.Map;
+
public class ODLVersionLUT {
+ private static Map<String,String> odlMdsalVersionLUT=null;
+
public static String getONAPReleaseName(String onapCCSDKVersion, String def) {
if (onapCCSDKVersion == null) {
return def;
@@ -45,26 +50,26 @@ public class ODLVersionLUT {
return def;
}
- public static String getOdlVersion(String onapCCSDKVersion, String def) {
+ public static String getOdlVersion(String mdsalVersion, String def) {
- if (onapCCSDKVersion == null) {
+ if (mdsalVersion == null) {
return def;
}
- if (onapCCSDKVersion.startsWith("2.")) {
- return "sodium-SR3 (0.11.3)";
- }
- if (onapCCSDKVersion.startsWith("1.5.")) {
- return "neon-SR1 (0.10.1)";
- }
- if (onapCCSDKVersion.startsWith("1.4.")) {
- return "neon-SR1 (0.10.1)";
+ if(odlMdsalVersionLUT==null) {
+ odlMdsalVersionLUT = new HashMap<>();
+ odlMdsalVersionLUT.put("5.0.14","magnesium-SR2 (0.12.2)");
+ odlMdsalVersionLUT.put("5.0.10","magnesium-SR1 (0.12.1)");
+ odlMdsalVersionLUT.put("5.0.9","magnesium-SR0 (0.12.0)");
+ odlMdsalVersionLUT.put("4.0.14","sodium-SR3 (0.11.3)");
+ odlMdsalVersionLUT.put("4.0.11","sodium-SR2 (0.11.2)");
+ odlMdsalVersionLUT.put("4.0.6","sodium-SR1 (0.11.1)");
+ odlMdsalVersionLUT.put("4.0.4","sodium-SR0 (0.11.0)");
+ odlMdsalVersionLUT.put("3.0.13","neon-SR3 (0.10.3)");
+ odlMdsalVersionLUT.put("3.0.10","neon-SR2 (0.10.2)");
+ odlMdsalVersionLUT.put("3.0.8","neon-SR1 (0.10.1)");
+ odlMdsalVersionLUT.put("3.0.6","neon-SR0 (0.10.0)");
}
- if (onapCCSDKVersion.startsWith("1.3.")) {
- return "fluorine-SR2 (0.9.2)";
- }
- if (onapCCSDKVersion.startsWith("1.2.")) {
- return "sodium-SR3 (0.11.3)";
- }
- return def;
+
+ return odlMdsalVersionLUT.getOrDefault(mdsalVersion, def);
}
}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/SystemInfo.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/SystemInfo.java
index 1497362a6..134e3d37b 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/SystemInfo.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/SystemInfo.java
@@ -42,7 +42,6 @@ import java.util.concurrent.Callable;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Stream;
-
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.FrameworkUtil;
@@ -54,6 +53,10 @@ public class SystemInfo {
private static OperatingSystemMXBean os = ManagementFactory.getOperatingSystemMXBean();
protected static boolean showMemoryPools = false;
+ public static String getOnapVersion(String def) {
+ return getOnapVersion("", def);
+ }
+
public static String getMdSalVersion(String def) {
return getMdSalVersion("", def);
}
@@ -62,6 +65,10 @@ public class SystemInfo {
return getYangToolsVersion("", def);
}
+ public static String getOnapVersion(String baseOdlDirectory, String def) {
+ return getFeatureVersionByFolder(baseOdlDirectory, "system/org/onap/sdnc/northbound/sdnc-northbound-all/", def);
+ }
+
public static String getMdSalVersion(String baseOdlDirectory, String def) {
return getFeatureVersionByFolder(baseOdlDirectory, "system/org/opendaylight/mdsal/mdsal-binding-api/", def);
}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/YangToolsCloner.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/YangToolsCloner.java
deleted file mode 100644
index a9a658387..000000000
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/YangToolsCloner.java
+++ /dev/null
@@ -1,223 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * ONAP : ccsdk features
- * ================================================================================
- * 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.dataprovider.yangtools;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.annotation.Nullable;
-import org.opendaylight.yangtools.concepts.Builder;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class YangToolsCloner {
-
- private static YangToolsMapper yangtoolsMapper = new YangToolsMapper();
- private static final Logger LOG = LoggerFactory.getLogger(YangToolsCloner.class);
- public static final int ACCESSOR_FIELD = 0;
- public static final int ACCESSOR_METHOD = 1;
-
-
- private final int accessor;
-
- private YangToolsCloner(int ac) {
- this.accessor = ac;
- }
-
- public static YangToolsCloner instance() {
- return instance(ACCESSOR_METHOD);
- }
-
- public static YangToolsCloner instance(int ac) {
- return new YangToolsCloner(ac);
- }
-
- /**
- *
- * @param source source object
- * @param clazz Class of return object
- * @return list of cloned object
- * @return
- */
- public <S extends DataObject, T extends DataObject> List<T> cloneList(List<S> source, Class<T> clazz) {
- return cloneList(source, clazz, null);
- }
-
- /**
- *
- * @param source source object
- * @param clazz Class of return object
- * @attrList filter for attribute Names to clone
- * @return list of cloned object
- */
- public <S extends DataObject, T extends DataObject> List<T> cloneList(List<S> source, Class<T> clazz,
- @Nullable List<String> attrList) {
- if (source == null) {
- return null;
- }
- List<T> list = new ArrayList<>();
- for (S s : source) {
- list.add(clone(s, clazz, attrList));
- }
- return list;
- }
-
- /**
- *
- * @param source source object
- * @param clazz Class of return object
- * @return cloned object
- */
- public <S, T extends DataObject> T clone(S source, Class<T> clazz) {
- return clone(source, clazz, null);
- }
-
- /**
- *
- * @param source source object
- * @param clazz Class of return object
- * @attrList if empty copy all else list of attribute Names to clone
- * @return cloned object
- */
- public <S, T extends DataObject> T clone(S source, Class<T> clazz, @Nullable List<String> attrList) {
- if (source == null) {
- return (T) null;
- }
- Field[] attributeFields;
- Field sourceField;
- Method m;
- Builder<T> builder = yangtoolsMapper.getBuilder(clazz);
- T object = builder.build();
- attributeFields = object.getClass().getDeclaredFields();
- for (Field attributeField : attributeFields) {
- // check if attr is in inclusion list
- if (attrList != null && !attrList.contains(attributeField.getName())) {
- continue;
- }
- // ignore QNAME
- if (attributeField.getName().equals("QNAME")) {
- continue;
- }
-
- attributeField.setAccessible(true);
- try {
- if (accessor == ACCESSOR_FIELD) {
- sourceField = source.getClass().getDeclaredField(attributeField.getName());
- sourceField.setAccessible(true);
- if (attributeField.getType().equals(String.class) && !sourceField.getType().equals(String.class)) {
- attributeField.set(object, String.valueOf(sourceField.get(source)));
- } else {
- attributeField.set(object, sourceField.get(source));
- }
- } else if (accessor == ACCESSOR_METHOD) {
- String getter = getter(attributeField.getName());
- System.out.println("getter=" + getter);
- m = source.getClass().getDeclaredMethod(getter);
- m.setAccessible(true);
- if (attributeField.getType().equals(String.class) && !m.getReturnType().equals(String.class)) {
- attributeField.set(object, String.valueOf(m.invoke(source)));
- } else {
- attributeField.set(object, m.invoke(source));
- }
- }
-
- } catch (NoSuchMethodException | NoSuchFieldException e) {
- // Convert to run-time exception
- String msg = "no such field " + attributeField.getName() + " in class " + source.getClass().getName();
- LOG.debug(msg);
- // throw new IllegalArgumentException(msg);
- } catch (IllegalAccessException | SecurityException e) {
- LOG.debug("Access problem " + attributeField.getName(), e);
- } catch (IllegalArgumentException e) {
- LOG.debug("argument problem " + attributeField.getName(), e);
- } catch (InvocationTargetException e) {
- LOG.debug("invocation problem " + attributeField.getName(), e);
- }
- }
-
- return object;
- }
-
- private static String getter(String name) {
- return String.format("%s%s%s", "get", name.substring(1, 2).toUpperCase(), name.substring(2));
- }
-
- public <S extends DataObject, T extends DataObject, B extends Builder<T>> B cloneToBuilder(S source, B builder) {
- return cloneToBuilder(source, builder, null);
- }
-
- public <S extends DataObject, T extends DataObject, B extends Builder<T>> B cloneToBuilder(S source, B builder,
- @Nullable List<String> attrList) {
- Field[] attributeFields;
- Field sourceField;
- Method m;
- attributeFields = builder.getClass().getDeclaredFields();
- for (Field attributeField : attributeFields) {
- // check if attr is in inclusion list
- if (attrList != null && !attrList.contains(attributeField.getName())) {
- continue;
- }
- // ignore QNAME
- if (attributeField.getName().equals("QNAME")) {
- continue;
- }
-
- attributeField.setAccessible(true);
- try {
- if (accessor == ACCESSOR_FIELD) {
- sourceField = source.getClass().getDeclaredField(attributeField.getName());
- sourceField.setAccessible(true);
- if (attributeField.getType().equals(String.class) && !sourceField.getType().equals(String.class)) {
- attributeField.set(builder, String.valueOf(sourceField.get(source)));
- } else {
- attributeField.set(builder, sourceField.get(source));
- }
- } else if (accessor == ACCESSOR_METHOD) {
- m = source.getClass().getDeclaredMethod(getter(attributeField.getName()));
- m.setAccessible(true);
- if (attributeField.getType().equals(String.class) && !m.getReturnType().equals(String.class)) {
- attributeField.set(builder, String.valueOf(m.invoke(source)));
- } else {
- attributeField.set(builder, m.invoke(source));
- }
- }
-
- } catch (NoSuchMethodException | NoSuchFieldException e) {
- // Convert to run-time exception
- String msg = "no such field " + attributeField.getName() + " in class " + source.getClass().getName();
- LOG.debug(msg);
- // throw new IllegalArgumentException(msg);
- } catch (IllegalAccessException | SecurityException e) {
- LOG.debug("Access problem " + attributeField.getName(), e);
- } catch (IllegalArgumentException e) {
- LOG.debug("argument problem " + attributeField.getName(), e);
- } catch (InvocationTargetException e) {
- LOG.debug("invocation problem " + attributeField.getName(), e);
- }
- }
- return builder;
- }
-}
diff --git a/sdnr/wt/data-provider/provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml b/sdnr/wt/data-provider/provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml
index ad9661f66..1be114612 100644
--- a/sdnr/wt/data-provider/provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml
+++ b/sdnr/wt/data-provider/provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml
@@ -29,11 +29,12 @@
<reference id="rpcProviderService"
interface="org.opendaylight.mdsal.binding.api.RpcProviderService"
odl:type="default"/>
-
-<!-- <reference id="bundleService" interface="org.apache.karaf.bundle.core.BundleService" odl:type="default"/> -->
+ <reference id="bundleService"
+ interface="org.apache.karaf.bundle.core.BundleService" />
<bean id="readyServlet"
class="org.onap.ccsdk.features.sdnr.wt.dataprovider.http.ReadyHttpServlet">
+ <property name="bundleService" ref="bundleService"/>
</bean>
<service interface="javax.servlet.http.HttpServlet"
ref="readyServlet">
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestTree.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestTree.java
index f2a7ff951..970816514 100644
--- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestTree.java
+++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestTree.java
@@ -22,14 +22,18 @@
package org.onap.ccsdk.features.sdnr.wt.dataprovider.test;
import java.io.IOException;
+import java.net.URISyntaxException;
import java.util.Arrays;
import java.util.concurrent.TimeUnit;
+import org.apache.sshd.common.util.io.IoUtils;
+import org.json.JSONObject;
import org.junit.BeforeClass;
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;
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.common.test.JSONAssert;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.ElasticSearchDataProvider;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.http.DataTreeHttpServlet;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.http.DataTreeHttpServlet.EntityWithTree;
@@ -54,23 +58,89 @@ public class TestTree {
dbProvider = new ElasticSearchDataProvider(hosts);
dbProvider.waitForYellowDatabaseStatus(30, TimeUnit.SECONDS);
dbRawProvider = HtDatabaseClient.getClient(hosts);
+ DeleteByQueryRequest query = new DeleteByQueryRequest(Entity.Inventoryequipment.getName(), true);
+ query.setQuery(QueryBuilders.matchAllQuery().toJSON());
+ dbRawProvider.deleteByQuery(query);
+ fillTestData();
+ }
+
+ private static void fillTestData() throws IOException {
+ dbRawProvider.doWriteRaw(Entity.Inventoryequipment.getName(), "sim1/a2.module-1.1.5.5", getFileContent("/testequipment/1.json"));
+ dbRawProvider.doWriteRaw(Entity.Inventoryequipment.getName(), "sim1/CARD-1.1.7.0", getFileContent("/testequipment/2.json"));
+ dbRawProvider.doWriteRaw(Entity.Inventoryequipment.getName(), "sim1/a2.module-1.55.1.2", getFileContent("/testequipment/3.json"));
+ dbRawProvider.doWriteRaw(Entity.Inventoryequipment.getName(), "sim1/a2.module-1.65.1.2", getFileContent("/testequipment/4.json"));
+ dbRawProvider.doWriteRaw(Entity.Inventoryequipment.getName(), "sim1/SHELF-1.1.0.0", getFileContent("/testequipment/5.json"));
+ dbRawProvider.doWriteRaw(Entity.Inventoryequipment.getName(), "sim1/a2.module-1.1.1.5", getFileContent("/testequipment/6.json"));
+ dbRawProvider.doWriteRaw(Entity.Inventoryequipment.getName(), "sim1/a2.module-1.1.1.8", getFileContent("/testequipment/7.json"));
+ dbRawProvider.doWriteRaw(Entity.Inventoryequipment.getName(), "sim1/a2.module-1.1.6.5", getFileContent("/testequipment/8.json"));
+ dbRawProvider.doWriteRaw(Entity.Inventoryequipment.getName(), "sim1/ODU-1.56.0.0", getFileContent("/testequipment/9.json"));
+ dbRawProvider.doWriteRaw(Entity.Inventoryequipment.getName(), "sim1/a2.module-1.56.1.2", getFileContent("/testequipment/10.json"));
+ dbRawProvider.doWriteRaw(Entity.Inventoryequipment.getName(), "sim1/IDU-1.65.0.0", getFileContent("/testequipment/11.json"));
+ dbRawProvider.doWriteRaw(Entity.Inventoryequipment.getName(), "sim1/CARD-1.65.1.4", getFileContent("/testequipment/12.json"));
+ dbRawProvider.doWriteRaw(Entity.Inventoryequipment.getName(), "sim1/CARD-1.1.6.0", getFileContent("/testequipment/13.json"));
+ dbRawProvider.doWriteRaw(Entity.Inventoryequipment.getName(), "sim1/CARD-1.1.8.0", getFileContent("/testequipment/14.json"));
+ dbRawProvider.doWriteRaw(Entity.Inventoryequipment.getName(), "sim1/CARD-1.1.9.0", getFileContent("/testequipment/15.json"));
+ dbRawProvider.doWriteRaw(Entity.Inventoryequipment.getName(), "sim1/CARD-1.55.1.4", getFileContent("/testequipment/16.json"));
+ dbRawProvider.doWriteRaw(Entity.Inventoryequipment.getName(), "sim1/a2.module-1.1.1.7", getFileContent("/testequipment/17.json"));
+ dbRawProvider.doWriteRaw(Entity.Inventoryequipment.getName(), "sim1/IDU-1.55.0.0", getFileContent("/testequipment/18.json"));
+ dbRawProvider.doWriteRaw(Entity.Inventoryequipment.getName(), "sim1/CARD-1.1.1.0", getFileContent("/testequipment/19.json"));
+ dbRawProvider.doWriteRaw(Entity.Inventoryequipment.getName(), "sim1/CARD-1.1.5.0", getFileContent("/testequipment/20.json"));
+ dbRawProvider.doWriteRaw(Entity.Inventoryequipment.getName(), "sim1/a2.module-1.1.5.6", getFileContent("/testequipment/21.json"));
+
+ }
+ /**
+ * @param string
+ * @return
+ * @throws URISyntaxException
+ * @throws IOException
+ */
+ private static String getFileContent(String filename) throws IOException {
+ return String.join("\n",IoUtils.readAllLines(TestTree.class.getResourceAsStream(filename)));
}
@Test
public void testInventoryTree() throws IOException {
DataTreeProviderImpl provider = new DataTreeProviderImpl();
provider.setDatabaseClient(dbRawProvider);
- DeleteByQueryRequest query = new DeleteByQueryRequest(Entity.Inventoryequipment.getName(), true);
- query.setQuery(QueryBuilders.matchAllQuery().toJSON());
- dbRawProvider.deleteByQuery(query);
+
DataTreeObject tree = provider.readInventoryTree(null, null, FilterMode.Lazy);
+ System.out.println(tree.toJSON());
+ JSONObject o = new JSONObject(tree.toJSON());
+ JSONAssert.assertContainsOnlyKey(o, "sim1");
+ JSONObject children = o.getJSONObject("sim1").getJSONObject("children");
+ this.assertSim1(children);
- tree = provider.readInventoryTree(Arrays.asList("sim1"), "CARD", FilterMode.Lazy);
+ tree = provider.readInventoryTree(Arrays.asList("sim1"), "*", FilterMode.Lazy);
+ this.assertSim1(new JSONObject(tree.toJSON()));
System.out.println(tree.toJSON());
}
+ private void assertSim1(JSONObject sim1Children) {
+ JSONAssert.assertContainsExactKeys(sim1Children,new String[] {"sim1/ODU-1.56.0.0", "sim1/IDU-1.55.0.0", "sim1/IDU-1.65.0.0", "sim1/SHELF-1.1.0.0"});
+ JSONObject c1 = sim1Children.getJSONObject("sim1/ODU-1.56.0.0");
+ JSONObject c2 = sim1Children.getJSONObject("sim1/IDU-1.55.0.0");
+ JSONObject c3 = sim1Children.getJSONObject("sim1/IDU-1.65.0.0");
+ JSONObject c4 = sim1Children.getJSONObject("sim1/SHELF-1.1.0.0");
+ JSONAssert.assertContainsExactKeys(c1.getJSONObject("children"),new String[] {"sim1/a2.module-1.56.1.2"});
+ JSONAssert.assertContainsExactKeys(c2.getJSONObject("children"),new String[] {"sim1/a2.module-1.55.1.2","sim1/CARD-1.55.1.4"});
+ JSONAssert.assertContainsExactKeys(c3.getJSONObject("children"),new String[] {"sim1/a2.module-1.65.1.2","sim1/CARD-1.65.1.4"});
+ JSONAssert.assertContainsExactKeys(c4.getJSONObject("children"),new String[] {"sim1/CARD-1.1.1.0",
+ "sim1/CARD-1.1.5.0", "sim1/CARD-1.1.7.0","sim1/CARD-1.1.6.0", "sim1/CARD-1.1.9.0","sim1/CARD-1.1.8.0"});
+ JSONObject c41 = c4.getJSONObject("children").getJSONObject("sim1/CARD-1.1.1.0");
+ JSONObject c42 = c4.getJSONObject("children").getJSONObject("sim1/CARD-1.1.5.0");
+ JSONObject c43 = c4.getJSONObject("children").getJSONObject("sim1/CARD-1.1.7.0");
+ JSONObject c44 = c4.getJSONObject("children").getJSONObject("sim1/CARD-1.1.6.0");
+ JSONObject c45 = c4.getJSONObject("children").getJSONObject("sim1/CARD-1.1.9.0");
+ JSONObject c46 = c4.getJSONObject("children").getJSONObject("sim1/CARD-1.1.8.0");
+ JSONAssert.assertContainsExactKeys(c41.getJSONObject("children"),new String[] {"sim1/a2.module-1.1.1.7","sim1/a2.module-1.1.1.5","sim1/a2.module-1.1.1.8"});
+ JSONAssert.assertContainsExactKeys(c42.getJSONObject("children"),new String[] {"sim1/a2.module-1.1.5.6","sim1/a2.module-1.1.5.5"});
+ JSONAssert.assertContainsNoKeys(c43.getJSONObject("children"));
+ JSONAssert.assertContainsExactKeys(c44.getJSONObject("children"),new String[] {"sim1/a2.module-1.1.6.5"});
+ JSONAssert.assertContainsNoKeys(c45.getJSONObject("children"));
+ JSONAssert.assertContainsNoKeys(c46.getJSONObject("children"));
+ }
@Test
public void testUriConversion() {
EntityWithTree e = DataTreeHttpServlet.getEntity("/tree/read-inventoryequipment-tree/sim1/sim1%2FODU");
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/util/HostInfoForTest.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/util/HostInfoForTest.java
index 8ea4b13aa..bd7e8ce5d 100644
--- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/util/HostInfoForTest.java
+++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/util/HostInfoForTest.java
@@ -41,7 +41,7 @@ public class HostInfoForTest {
int port;
String portAsString = System.getProperty("databaseport");
- if (portAsString == null | portAsString.isEmpty())
+ if (portAsString == null || portAsString.isEmpty())
port = 49200;
else
port = Integer.valueOf(portAsString);
diff --git a/sdnr/wt/data-provider/provider/src/test/resources/testequipment/1.json b/sdnr/wt/data-provider/provider/src/test/resources/testequipment/1.json
new file mode 100644
index 000000000..bcf5e1d0a
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/test/resources/testequipment/1.json
@@ -0,0 +1,17 @@
+ {
+ "description": "WS/p8.module/a2.module#5",
+ "date": "2013-04-13T00:00:00.0Z",
+ "version": "a2.module-newest",
+ "node-id": "sim1",
+ "uuid": "a2.module-1.1.5.5",
+ "parent-uuid": "CARD-1.1.5.0",
+ "contained-holder": [
+ "SUBRACK-1.55.0.0"
+ ],
+ "tree-level": 2,
+ "manufacturer-identifier": "ONF-Wireless-Transport",
+ "serial": "310330015",
+ "part-type-id": "3EM23141AD01",
+ "model-identifier": "CRPQABVFAA",
+ "type-name": "a2.module"
+} \ No newline at end of file
diff --git a/sdnr/wt/data-provider/provider/src/test/resources/testequipment/10.json b/sdnr/wt/data-provider/provider/src/test/resources/testequipment/10.json
new file mode 100644
index 000000000..6eed5d6a8
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/test/resources/testequipment/10.json
@@ -0,0 +1,15 @@
+ {
+ "description": "MWR#56Ch#1/a2.moduletraff",
+ "date": "2017-09-09T00:00:00.0Z",
+ "version": "a2.module-newest",
+ "node-id": "sim1",
+ "uuid": "a2.module-1.56.1.2",
+ "parent-uuid": "ODU-1.56.0.0",
+ "contained-holder": [],
+ "tree-level": 1,
+ "manufacturer-identifier": "ONF-Wireless-Transport",
+ "serial": "Serial1",
+ "part-type-id": "Partnumber",
+ "model-identifier": "model-id",
+ "type-name": "a2.module"
+} \ No newline at end of file
diff --git a/sdnr/wt/data-provider/provider/src/test/resources/testequipment/11.json b/sdnr/wt/data-provider/provider/src/test/resources/testequipment/11.json
new file mode 100644
index 000000000..46a4d0650
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/test/resources/testequipment/11.json
@@ -0,0 +1,18 @@
+ {
+ "description": "MWR-ng Dir#6.5-Ch#1",
+ "date": "2014-01-16T00:00:00.0Z",
+ "version": "MWR-ng",
+ "node-id": "sim1",
+ "uuid": "IDU-1.65.0.0",
+ "parent-uuid": "network-element",
+ "contained-holder": [
+ "PORT-1.65.1.4",
+ "PORT-1.65.1.2"
+ ],
+ "tree-level": 0,
+ "manufacturer-identifier": "ONF-Wireless-Transport",
+ "serial": "WAUZZI",
+ "part-type-id": "3DB76047BAAA02",
+ "model-identifier": "model-id-s3s",
+ "type-name": "MWR-ng"
+} \ No newline at end of file
diff --git a/sdnr/wt/data-provider/provider/src/test/resources/testequipment/12.json b/sdnr/wt/data-provider/provider/src/test/resources/testequipment/12.json
new file mode 100644
index 000000000..02d592e56
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/test/resources/testequipment/12.json
@@ -0,0 +1,15 @@
+ {
+ "description": "MWR#55Ch#0/RxDiv",
+ "date": "2014-01-08T00:00:00.0Z",
+ "version": "2017",
+ "node-id": "sim1",
+ "uuid": "CARD-1.65.1.4",
+ "parent-uuid": "IDU-1.65.0.0",
+ "contained-holder": [],
+ "tree-level": 1,
+ "manufacturer-identifier": "ONF-Wireless-Transport",
+ "serial": "Serie2017-13",
+ "part-type-id": "partNo2017-12",
+ "model-identifier": "model-id-s3s",
+ "type-name": "RxDiv"
+} \ No newline at end of file
diff --git a/sdnr/wt/data-provider/provider/src/test/resources/testequipment/13.json b/sdnr/wt/data-provider/provider/src/test/resources/testequipment/13.json
new file mode 100644
index 000000000..85c3723b7
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/test/resources/testequipment/13.json
@@ -0,0 +1,20 @@
+ {
+ "description": "WS/p8.module",
+ "date": "2013-11-23T00:00:00.0Z",
+ "version": "234",
+ "node-id": "sim1",
+ "uuid": "CARD-1.1.6.0",
+ "parent-uuid": "SHELF-1.1.0.0",
+ "contained-holder": [
+ "PORT-1.1.6.5",
+ "PORT-1.1.6.7",
+ "PORT-1.1.6.6",
+ "PORT-1.1.6.8"
+ ],
+ "tree-level": 1,
+ "manufacturer-identifier": "SAN",
+ "serial": "serial-number-124",
+ "part-type-id": "part-number-12",
+ "model-identifier": "model-id-12",
+ "type-name": "p8.module"
+} \ No newline at end of file
diff --git a/sdnr/wt/data-provider/provider/src/test/resources/testequipment/14.json b/sdnr/wt/data-provider/provider/src/test/resources/testequipment/14.json
new file mode 100644
index 000000000..1fa236e10
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/test/resources/testequipment/14.json
@@ -0,0 +1,15 @@
+{
+ "description": "WS/DS3",
+ "date": "2008-10-21T00:00:00.0Z",
+ "version": "unknown",
+ "node-id": "sim1",
+ "uuid": "CARD-1.1.8.0",
+ "parent-uuid": "SHELF-1.1.0.0",
+ "contained-holder": [],
+ "tree-level": 1,
+ "manufacturer-identifier": "ONF-Wireless-Transport",
+ "serial": "sd-dsa-eqw",
+ "part-type-id": "unknown",
+ "model-identifier": "model-id-s3s",
+ "type-name": "p4.module"
+} \ No newline at end of file
diff --git a/sdnr/wt/data-provider/provider/src/test/resources/testequipment/15.json b/sdnr/wt/data-provider/provider/src/test/resources/testequipment/15.json
new file mode 100644
index 000000000..ff40c4e8b
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/test/resources/testequipment/15.json
@@ -0,0 +1,15 @@
+{
+ "description": "WS/wind",
+ "date": "2007-02-19T00:00:00.0Z",
+ "version": "wind",
+ "node-id": "sim1",
+ "uuid": "CARD-1.1.9.0",
+ "parent-uuid": "SHELF-1.1.0.0",
+ "contained-holder": [],
+ "tree-level": 1,
+ "manufacturer-identifier": "CIT",
+ "serial": "proto-type",
+ "part-type-id": "party-yea",
+ "model-identifier": "model-id-s3s",
+ "type-name": "wind"
+} \ No newline at end of file
diff --git a/sdnr/wt/data-provider/provider/src/test/resources/testequipment/16.json b/sdnr/wt/data-provider/provider/src/test/resources/testequipment/16.json
new file mode 100644
index 000000000..fbd62e04d
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/test/resources/testequipment/16.json
@@ -0,0 +1,15 @@
+ {
+ "description": "MWR#55Ch#1/RxDiv",
+ "date": "2014-01-07T00:00:00.0Z",
+ "version": "2017",
+ "node-id": "sim1",
+ "uuid": "CARD-1.55.1.4",
+ "parent-uuid": "IDU-1.55.0.0",
+ "contained-holder": [],
+ "tree-level": 1,
+ "manufacturer-identifier": "ONF-Wireless-Transport",
+ "serial": "Serie2017-12",
+ "part-type-id": "partNo2017-12",
+ "model-identifier": "model-id-s3s",
+ "type-name": "RxDiv"
+} \ No newline at end of file
diff --git a/sdnr/wt/data-provider/provider/src/test/resources/testequipment/17.json b/sdnr/wt/data-provider/provider/src/test/resources/testequipment/17.json
new file mode 100644
index 000000000..1704468f3
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/test/resources/testequipment/17.json
@@ -0,0 +1,17 @@
+{
+ "description": "WS/CORE-MAIN/a2.module#7",
+ "date": "2009-01-19T00:00:00.0Z",
+ "version": "a2.module-newest",
+ "node-id": "sim1",
+ "uuid": "a2.module-1.1.1.7",
+ "parent-uuid": "CARD-1.1.1.0",
+ "contained-holder": [
+ "SUBRACK-1.17.0.0"
+ ],
+ "tree-level": 2,
+ "manufacturer-identifier": "ONF-Wireless-Transport",
+ "serial": "91T403003322",
+ "part-type-id": "1AB187280031",
+ "model-identifier": "mod2",
+ "type-name": "a2.module"
+} \ No newline at end of file
diff --git a/sdnr/wt/data-provider/provider/src/test/resources/testequipment/18.json b/sdnr/wt/data-provider/provider/src/test/resources/testequipment/18.json
new file mode 100644
index 000000000..eaec335b4
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/test/resources/testequipment/18.json
@@ -0,0 +1,18 @@
+ {
+ "description": "MWR-ng Dir#5.5-Ch#1",
+ "date": "2014-01-15T00:00:00.0Z",
+ "version": "MWR-ng",
+ "node-id": "sim1",
+ "uuid": "IDU-1.55.0.0",
+ "parent-uuid": "network-element",
+ "contained-holder": [
+ "PORT-1.55.1.2",
+ "PORT-1.55.1.4"
+ ],
+ "tree-level": 0,
+ "manufacturer-identifier": "ONF-Wireless-Transport",
+ "serial": "Serie2017-14",
+ "part-type-id": "3DB76047BAAA02",
+ "model-identifier": "model-id-s3s",
+ "type-name": "MWR-ng"
+} \ No newline at end of file
diff --git a/sdnr/wt/data-provider/provider/src/test/resources/testequipment/19.json b/sdnr/wt/data-provider/provider/src/test/resources/testequipment/19.json
new file mode 100644
index 000000000..9a7eb62a7
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/test/resources/testequipment/19.json
@@ -0,0 +1,20 @@
+ {
+ "description": "WS/CORE-MAIN",
+ "date": "2015-08-17T00:00:00.0Z",
+ "version": "123",
+ "node-id": "sim1",
+ "uuid": "CARD-1.1.1.0",
+ "parent-uuid": "SHELF-1.1.0.0",
+ "contained-holder": [
+ "PORT-1.1.1.6",
+ "PORT-1.1.1.5",
+ "PORT-1.1.1.8",
+ "PORT-1.1.1.7"
+ ],
+ "tree-level": 1,
+ "manufacturer-identifier": "SAN",
+ "serial": "asdf-asdasd-asd",
+ "part-type-id": "part-number-2",
+ "model-identifier": "model-id-2",
+ "type-name": "latest"
+} \ No newline at end of file
diff --git a/sdnr/wt/data-provider/provider/src/test/resources/testequipment/2.json b/sdnr/wt/data-provider/provider/src/test/resources/testequipment/2.json
new file mode 100644
index 000000000..ff352653a
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/test/resources/testequipment/2.json
@@ -0,0 +1,15 @@
+ {
+ "description": "WS/DS1",
+ "date": "2007-08-27T00:00:00.0Z",
+ "version": "p1.module",
+ "node-id": "sim1",
+ "uuid": "CARD-1.1.7.0",
+ "parent-uuid": "SHELF-1.1.0.0",
+ "contained-holder": [],
+ "tree-level": 1,
+ "manufacturer-identifier": "CIT",
+ "serial": "serial-number-s3s",
+ "part-type-id": "part-number-s3s",
+ "model-identifier": "model-id-s3s",
+ "type-name": "p1.module_A"
+} \ No newline at end of file
diff --git a/sdnr/wt/data-provider/provider/src/test/resources/testequipment/20.json b/sdnr/wt/data-provider/provider/src/test/resources/testequipment/20.json
new file mode 100644
index 000000000..179794027
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/test/resources/testequipment/20.json
@@ -0,0 +1,20 @@
+ {
+ "description": "WS/p8.module",
+ "date": "2013-10-21T00:00:00.0Z",
+ "version": "234",
+ "node-id": "sim1",
+ "uuid": "CARD-1.1.5.0",
+ "parent-uuid": "SHELF-1.1.0.0",
+ "contained-holder": [
+ "PORT-1.1.5.6",
+ "PORT-1.1.5.5",
+ "PORT-1.1.5.8",
+ "PORT-1.1.5.7"
+ ],
+ "tree-level": 1,
+ "manufacturer-identifier": "SAN",
+ "serial": "africa",
+ "part-type-id": "part-number-12",
+ "model-identifier": "model-id-12",
+ "type-name": "p8.module"
+} \ No newline at end of file
diff --git a/sdnr/wt/data-provider/provider/src/test/resources/testequipment/21.json b/sdnr/wt/data-provider/provider/src/test/resources/testequipment/21.json
new file mode 100644
index 000000000..c76d6715e
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/test/resources/testequipment/21.json
@@ -0,0 +1,17 @@
+{
+ "description": "WS/p8.module/a2.module#6",
+ "date": "",
+ "version": "",
+ "node-id": "sim1",
+ "uuid": "a2.module-1.1.5.6",
+ "parent-uuid": "CARD-1.1.5.0",
+ "contained-holder": [
+ "SUBRACK-1.56.0.0"
+ ],
+ "tree-level": 2,
+ "manufacturer-identifier": "",
+ "serial": "",
+ "part-type-id": "",
+ "model-identifier": "",
+ "type-name": "a2.module"
+} \ No newline at end of file
diff --git a/sdnr/wt/data-provider/provider/src/test/resources/testequipment/3.json b/sdnr/wt/data-provider/provider/src/test/resources/testequipment/3.json
new file mode 100644
index 000000000..1dc6dfce2
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/test/resources/testequipment/3.json
@@ -0,0 +1,15 @@
+{
+ "description": "MWR#55Ch#1/a2.moduletraff",
+ "date": "2013-04-13T00:00:00.0Z",
+ "version": "a2.module-newest",
+ "node-id": "sim1",
+ "uuid": "a2.module-1.55.1.2",
+ "parent-uuid": "IDU-1.55.0.0",
+ "contained-holder": [],
+ "tree-level": 1,
+ "manufacturer-identifier": "ONF-Wireless-Transport",
+ "serial": "310330015",
+ "part-type-id": "3EM23141AD01",
+ "model-identifier": "CRPQABVFAA",
+ "type-name": "a2.module"
+} \ No newline at end of file
diff --git a/sdnr/wt/data-provider/provider/src/test/resources/testequipment/4.json b/sdnr/wt/data-provider/provider/src/test/resources/testequipment/4.json
new file mode 100644
index 000000000..ab1132692
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/test/resources/testequipment/4.json
@@ -0,0 +1,15 @@
+ {
+ "description": "MWR#65Ch#1/a2.moduletraff",
+ "date": "2013-04-13T00:00:00.0Z",
+ "version": "a2.module-newest",
+ "node-id": "sim1",
+ "uuid": "a2.module-1.65.1.2",
+ "parent-uuid": "IDU-1.65.0.0",
+ "contained-holder": [],
+ "tree-level": 1,
+ "manufacturer-identifier": "ONF-Wireless-Transport",
+ "serial": "310330008",
+ "part-type-id": "3EM23141AD01",
+ "model-identifier": "CRPQABVFAA",
+ "type-name": "a2.module"
+} \ No newline at end of file
diff --git a/sdnr/wt/data-provider/provider/src/test/resources/testequipment/5.json b/sdnr/wt/data-provider/provider/src/test/resources/testequipment/5.json
new file mode 100644
index 000000000..e54173fe6
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/test/resources/testequipment/5.json
@@ -0,0 +1,25 @@
+{
+ "description": "WS-8",
+ "date": "2017-09-09T00:00:00.0Z",
+ "version": "a2.module-newest",
+ "node-id": "sim1",
+ "uuid": "SHELF-1.1.0.0",
+ "parent-uuid": "network-element",
+ "contained-holder": [
+ "SLOT-1.1.1.0",
+ "SLOT-1.1.2.0",
+ "SLOT-1.1.3.0",
+ "SLOT-1.1.4.0",
+ "SLOT-1.1.5.0",
+ "SLOT-1.1.6.0",
+ "SLOT-1.1.7.0",
+ "SLOT-1.1.8.0",
+ "SLOT-1.1.9.0"
+ ],
+ "tree-level": 0,
+ "manufacturer-identifier": "ONF-Wireless-Transport",
+ "serial": "Serial1",
+ "part-type-id": "Partnumber",
+ "model-identifier": "model-id",
+ "type-name": "WS-8"
+} \ No newline at end of file
diff --git a/sdnr/wt/data-provider/provider/src/test/resources/testequipment/6.json b/sdnr/wt/data-provider/provider/src/test/resources/testequipment/6.json
new file mode 100644
index 000000000..8486033b0
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/test/resources/testequipment/6.json
@@ -0,0 +1,17 @@
+ {
+ "description": "WS/CORE-MAIN/a2.module#5",
+ "date": "2005-11-09T00:00:00.0Z",
+ "version": "a2.module-newest",
+ "node-id": "sim1",
+ "uuid": "a2.module-1.1.1.5",
+ "parent-uuid": "CARD-1.1.1.0",
+ "contained-holder": [
+ "SUBRACK-1.15.0.0"
+ ],
+ "tree-level": 2,
+ "manufacturer-identifier": "ONF-Wireless-Transport",
+ "serial": "0003548168",
+ "part-type-id": "3FE25774AA01",
+ "model-identifier": "VAUIAEYAAA",
+ "type-name": "a2.module"
+} \ No newline at end of file
diff --git a/sdnr/wt/data-provider/provider/src/test/resources/testequipment/7.json b/sdnr/wt/data-provider/provider/src/test/resources/testequipment/7.json
new file mode 100644
index 000000000..5c583bec7
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/test/resources/testequipment/7.json
@@ -0,0 +1,17 @@
+{
+ "description": "WS/CORE-MAIN/a2.module#8",
+ "date": "2010-02-05T00:00:00.0Z",
+ "version": "a2.module-newest",
+ "node-id": "sim1",
+ "uuid": "a2.module-1.1.1.8",
+ "parent-uuid": "CARD-1.1.1.0",
+ "contained-holder": [
+ "SUBRACK-1.18.0.0"
+ ],
+ "tree-level": 2,
+ "manufacturer-identifier": "ONF-Wireless-Transport",
+ "serial": "01T441601301",
+ "part-type-id": "1AB376720002",
+ "model-identifier": "NGI7AMLMAA",
+ "type-name": "a2.module"
+} \ No newline at end of file
diff --git a/sdnr/wt/data-provider/provider/src/test/resources/testequipment/8.json b/sdnr/wt/data-provider/provider/src/test/resources/testequipment/8.json
new file mode 100644
index 000000000..a86819a7d
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/test/resources/testequipment/8.json
@@ -0,0 +1,17 @@
+{
+ "description": "WS/p8.module/a2.module#5",
+ "date": "2013-04-13T00:00:00.0Z",
+ "version": "a2.module-newest",
+ "node-id": "sim1",
+ "uuid": "a2.module-1.1.6.5",
+ "parent-uuid": "CARD-1.1.6.0",
+ "contained-holder": [
+ "SUBRACK-1.65.0.0"
+ ],
+ "tree-level": 2,
+ "manufacturer-identifier": "ONF-Wireless-Transport",
+ "serial": "310330008",
+ "part-type-id": "3EM23141AD01",
+ "model-identifier": "CRPQABVFAA",
+ "type-name": "a2.module"
+} \ No newline at end of file
diff --git a/sdnr/wt/data-provider/provider/src/test/resources/testequipment/9.json b/sdnr/wt/data-provider/provider/src/test/resources/testequipment/9.json
new file mode 100644
index 000000000..914033bb4
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/test/resources/testequipment/9.json
@@ -0,0 +1,19 @@
+ {
+ "description": "MWR-hyper Dir#5.6-Ch#1",
+ "date": "",
+ "version": "extrem-hyper",
+ "node-id": "sim1",
+ "uuid": "ODU-1.56.0.0",
+ "parent-uuid": "network-element",
+ "contained-holder": [
+ "PORT-1.56.1.2",
+ "PORT-1.56.1.3",
+ "PORT-1.56.1.4"
+ ],
+ "tree-level": 0,
+ "manufacturer-identifier": "",
+ "serial": "",
+ "part-type-id": "",
+ "model-identifier": "",
+ "type-name": "MWR-hyper"
+} \ No newline at end of file
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/DataMigrationProviderImpl.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/DataMigrationProviderImpl.java
index 100f52371..7d2adc5ad 100644
--- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/DataMigrationProviderImpl.java
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/DataMigrationProviderImpl.java
@@ -344,6 +344,7 @@ public class DataMigrationProviderImpl implements DataMigrationProviderService {
}
//check aliases
AliasesEntryList entries = this.readAliases();
+ IndicesEntryList entries2 = this.readIndices();
if (entries == null) {
return false;
}
@@ -381,9 +382,22 @@ public class DataMigrationProviderImpl implements DataMigrationProviderService {
return false;
}
}
+ else {
+ //try to find malformed typed index with alias name
+ IndicesEntry entry2ToDelete = entries2.findByIndex(aliasToDelete);
+ if (entry2ToDelete != null) {
+ try {
+ LOG.info("deleting index {}", entry2ToDelete.getName());
+ response = this.dbClient.deleteIndex(new DeleteIndexRequest(entry2ToDelete.getName()));
+ LOG.info(response.isResponseSucceeded() ? "succeeded" : "failed");
+ } catch (IOException e) {
+ LOG.error(e.getMessage());
+ return false;
+ }
+ }
+ }
}
}
- IndicesEntryList entries2 = this.readIndices();
if (entries2 == null) {
return false;
}
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/Program.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/Program.java
index 4b201bccc..54204f170 100644
--- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/Program.java
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/Program.java
@@ -23,8 +23,13 @@ package org.onap.ccsdk.features.sdnr.wt.dataprovider.setup;
import java.util.Arrays;
import java.util.List;
-
-import org.apache.commons.cli.*;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.CommandLineParser;
+import org.apache.commons.cli.DefaultParser;
+import org.apache.commons.cli.HelpFormatter;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.ParseException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.log4j.ConsoleAppender;
@@ -293,17 +298,13 @@ public class Program {
}
private static void cmd_dbimport(CommandLine cmd) throws Exception {
- String dbUrl = getOptionOrDefault(cmd, OPTION_DATABASE_SHORT, DEFAULT_DBURL);
- String username = getOptionOrDefault(cmd, OPTION_DATABASEUSER_SHORT, null);
- String password = getOptionOrDefault(cmd, OPTION_DATABASEPASSWORD_SHORT, null);
+ DatabaseOptions options = new DatabaseOptions(cmd);
String filename = getOptionOrDefault(cmd, OPTION_OUTPUTFILE_SHORT, null);
- boolean trustAll = getOptionOrDefault(cmd, OPTION_TRUSTINSECURESSL_SHORT, DEFAULT_TRUSTINSECURESSL);
if (filename == null) {
throw new Exception("please add output file parameter");
}
- long timeoutms = getTimeoutOptionMillis(cmd);
- DataMigrationProviderImpl service = new DataMigrationProviderImpl(new HostInfo[] {HostInfo.parse(dbUrl)},
- username, password, trustAll, timeoutms);
+ DataMigrationProviderImpl service = new DataMigrationProviderImpl(new HostInfo[] {HostInfo.parse(options.getUrl())},
+ options.getUsername(), options.getPassword(), options.doTrustAll(), options.getTimeoutMs());
DataMigrationReport report = service.importData(filename, false);
LOG.info(report);
if (!report.completed()) {
@@ -313,17 +314,13 @@ public class Program {
}
private static void cmd_dbexport(CommandLine cmd) throws Exception {
- String dbUrl = getOptionOrDefault(cmd, OPTION_DATABASE_SHORT, DEFAULT_DBURL);
- String username = getOptionOrDefault(cmd, OPTION_DATABASEUSER_SHORT, null);
- String password = getOptionOrDefault(cmd, OPTION_DATABASEPASSWORD_SHORT, null);
+ DatabaseOptions options = new DatabaseOptions(cmd);
String filename = getOptionOrDefault(cmd, OPTION_OUTPUTFILE_SHORT, null);
- boolean trustAll = getOptionOrDefault(cmd, OPTION_TRUSTINSECURESSL_SHORT, DEFAULT_TRUSTINSECURESSL);
if (filename == null) {
throw new Exception("please add output file parameter");
}
- long timeoutms = getTimeoutOptionMillis(cmd);
- DataMigrationProviderImpl service = new DataMigrationProviderImpl(new HostInfo[] {HostInfo.parse(dbUrl)},
- username, password, trustAll, timeoutms);
+ DataMigrationProviderImpl service = new DataMigrationProviderImpl(new HostInfo[] {HostInfo.parse(options.getUrl())},
+ options.getUsername(), options.getPassword(), options.doTrustAll(), options.getTimeoutMs());
DataMigrationReport report = service.exportData(filename);
LOG.info(report);
if (!report.completed()) {
@@ -343,29 +340,21 @@ public class Program {
private static void cmd_clear_db(CommandLine cmd) throws Exception {
Release r = getOptionOrDefault(cmd, OPTION_VERSION_SHORT, (Release) null);
- String dbUrl = getOptionOrDefault(cmd, OPTION_DATABASE_SHORT, DEFAULT_DBURL);
+ DatabaseOptions options = new DatabaseOptions(cmd);
String dbPrefix = getOptionOrDefault(cmd, OPTION_DATABASEPREFIX_SHORT, DEFAULT_DBPREFIX);
- String username = getOptionOrDefault(cmd, OPTION_DATABASEUSER_SHORT, null);
- String password = getOptionOrDefault(cmd, OPTION_DATABASEPASSWORD_SHORT, null);
- boolean trustAll = getOptionOrDefault(cmd, OPTION_TRUSTINSECURESSL_SHORT, DEFAULT_TRUSTINSECURESSL);
- long timeoutms = getTimeoutOptionMillis(cmd);
- DataMigrationProviderImpl service = new DataMigrationProviderImpl(new HostInfo[] {HostInfo.parse(dbUrl)},
- username, password, trustAll, timeoutms);
- if (!service.clearDatabase(r, dbPrefix, timeoutms)) {
+ DataMigrationProviderImpl service = new DataMigrationProviderImpl(new HostInfo[] {HostInfo.parse(options.getUrl())},
+ options.getUsername(), options.getPassword(), options.doTrustAll(), options.getTimeoutMs());
+ if (!service.clearDatabase(r, dbPrefix, options.getTimeoutMs())) {
throw new Exception("failed to init database");
}
LOG.info("database clear completed successfully");
}
private static void cmd_clear_db_complete(CommandLine cmd) throws Exception {
- String dbUrl = getOptionOrDefault(cmd, OPTION_DATABASE_SHORT, DEFAULT_DBURL);
- String username = getOptionOrDefault(cmd, OPTION_DATABASEUSER_SHORT, null);
- String password = getOptionOrDefault(cmd, OPTION_DATABASEPASSWORD_SHORT, null);
- boolean trustAll = getOptionOrDefault(cmd, OPTION_TRUSTINSECURESSL_SHORT, DEFAULT_TRUSTINSECURESSL);
- long timeoutms = getTimeoutOptionMillis(cmd);
- DataMigrationProviderImpl service = new DataMigrationProviderImpl(new HostInfo[] {HostInfo.parse(dbUrl)},
- username, password, trustAll, timeoutms);
- if (!service.clearCompleteDatabase(timeoutms)) {
+ DatabaseOptions options = new DatabaseOptions(cmd);
+ DataMigrationProviderImpl service = new DataMigrationProviderImpl(new HostInfo[] {HostInfo.parse(options.getUrl())},
+ options.getUsername(), options.getPassword(), options.doTrustAll(), options.getTimeoutMs());
+ if (!service.clearCompleteDatabase(options.getTimeoutMs())) {
throw new Exception("failed to init database");
}
LOG.info("database complete clear completed successfully");
@@ -375,16 +364,12 @@ public class Program {
Release r = getOptionOrDefault(cmd, OPTION_VERSION_SHORT, (Release) null);
int numShards = getOptionOrDefault(cmd, OPTION_SHARDS_SHORT, DEFAULT_SHARDS);
int numReplicas = getOptionOrDefault(cmd, OPTION_REPLICAS_SHORT, DEFAULT_REPLICAS);
- String dbUrl = getOptionOrDefault(cmd, OPTION_DATABASE_SHORT, DEFAULT_DBURL);
+ DatabaseOptions options = new DatabaseOptions(cmd);
String dbPrefix = getOptionOrDefault(cmd, OPTION_DATABASEPREFIX_SHORT, DEFAULT_DBPREFIX);
- String username = getOptionOrDefault(cmd, OPTION_DATABASEUSER_SHORT, null);
- String password = getOptionOrDefault(cmd, OPTION_DATABASEPASSWORD_SHORT, null);
- boolean trustAll = getOptionOrDefault(cmd, OPTION_TRUSTINSECURESSL_SHORT, DEFAULT_TRUSTINSECURESSL);
- long timeoutms = getTimeoutOptionMillis(cmd);
- DataMigrationProviderImpl service = new DataMigrationProviderImpl(new HostInfo[] {HostInfo.parse(dbUrl)},
- username, password, trustAll, timeoutms);
+ DataMigrationProviderImpl service = new DataMigrationProviderImpl(new HostInfo[] {HostInfo.parse(options.getUrl())},
+ options.getUsername(), options.getPassword(), options.doTrustAll(), options.getTimeoutMs());
boolean forceRecreate = cmd.hasOption(OPTION_FORCE_RECREATE_SHORT);
- if (!service.initDatabase(r, numShards, numReplicas, dbPrefix, forceRecreate, timeoutms)) {
+ if (!service.initDatabase(r, numShards, numReplicas, dbPrefix, forceRecreate, options.getTimeoutMs())) {
throw new Exception("failed to init database");
}
LOG.info("database init completed successfully");
@@ -425,7 +410,7 @@ public class Program {
/**
* create option for argparse lib
- *
+ *
* @param opt short option string
* @param longOpt long option string
* @param hasArg flag if has a parameter after option tag
@@ -440,4 +425,35 @@ public class Program {
return o;
}
// end of private methods
+
+ private static class DatabaseOptions{
+ private final String url;
+ private final String username;
+ private final String password;
+ private final boolean trustAll;
+ private final long timeoutMs;
+
+ public String getUrl() {
+ return this.url;
+ }
+ public String getUsername() {
+ return this.username;
+ }
+ public String getPassword() {
+ return this.password;
+ }
+ public boolean doTrustAll() {
+ return this.trustAll;
+ }
+ public long getTimeoutMs() {
+ return this.timeoutMs;
+ }
+ public DatabaseOptions(CommandLine cmd) throws ParseException {
+ this.url = getOptionOrDefault(cmd, OPTION_DATABASE_SHORT, DEFAULT_DBURL);
+ this.username = getOptionOrDefault(cmd, OPTION_DATABASEUSER_SHORT, null);
+ this.password = getOptionOrDefault(cmd, OPTION_DATABASEPASSWORD_SHORT, null);
+ this.trustAll = getOptionOrDefault(cmd, OPTION_TRUSTINSECURESSL_SHORT, DEFAULT_TRUSTINSECURESSL);
+ this.timeoutMs = getTimeoutOptionMillis(cmd);
+ }
+ }
}
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/ReleaseInformation.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/ReleaseInformation.java
index d772dc296..9b7a49346 100644
--- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/ReleaseInformation.java
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/ReleaseInformation.java
@@ -23,7 +23,6 @@ package org.onap.ccsdk.features.sdnr.wt.dataprovider.setup;
import java.util.Map;
import java.util.Set;
-
import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient;
import org.onap.ccsdk.features.sdnr.wt.common.database.data.IndicesEntryList;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.ComponentName;
@@ -35,7 +34,6 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.elalto.ElAltoReleaseIn
import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.frankfurt.FrankfurtReleaseInformation;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.frankfurt.FrankfurtReleaseInformationR2;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.guilin.GuilinReleaseInformation;
-import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.guilin.GuilinReleaseInformationR2;
public abstract class ReleaseInformation {
@@ -53,7 +51,7 @@ public abstract class ReleaseInformation {
/**
* get database alias for component
- *
+ *
* @param name
* @return alias or null if not exists
*/
@@ -67,7 +65,7 @@ public abstract class ReleaseInformation {
/**
* get index name for component
- *
+ *
* @param comp
* @return null if component does not exists in this release, otherwise index name
*/
@@ -77,7 +75,7 @@ public abstract class ReleaseInformation {
/**
* get index name for component with prefix
- *
+ *
* @param comp
* @param prefix
* @return null if component does not exists in this release, otherwise index name
@@ -88,7 +86,7 @@ public abstract class ReleaseInformation {
/**
* get database datatype (doctype) for component
- *
+ *
* @param name
* @return datatype or null if not exists
*/
@@ -102,7 +100,7 @@ public abstract class ReleaseInformation {
/**
* get database doctype definition for component
- *
+ *
* @param name
* @return mappings or null if not exists
*/
@@ -112,7 +110,7 @@ public abstract class ReleaseInformation {
/**
* get database settings definition for component
- *
+ *
* @param name
* @return settings or null if not exists
*/
@@ -122,7 +120,7 @@ public abstract class ReleaseInformation {
/**
* get converter for component data
- *
+ *
* @param dst destination release
* @param comp component to convert
* @return
@@ -144,8 +142,6 @@ public abstract class ReleaseInformation {
return new FrankfurtReleaseInformationR2();
case GUILIN_R1:
return new GuilinReleaseInformation();
- case GUILIN_R2:
- return new GuilinReleaseInformationR2();
default:
return null;
}
@@ -192,7 +188,7 @@ public abstract class ReleaseInformation {
protected abstract boolean runPreInitCommands(HtDatabaseClient dbClient);
/**
- *
+ *
* @param dbClient
* @return if succeeded or not
*/
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/Release.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/Release.java
index b2442df6b..4f55f4cd7 100644
--- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/Release.java
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/Release.java
@@ -26,15 +26,12 @@ import org.onap.ccsdk.features.sdnr.wt.common.database.data.EsVersion;
public enum Release {
- EL_ALTO("el alto", "_v1", new EsVersion(2, 2, 0), new EsVersion(2, 2, 0)), FRANKFURT_R1("frankfurt-R1", "-v2",
- new EsVersion(6, 4, 3), new EsVersion(6, 8, 6)), FRANKFURT_R2("frankfurt-R2", "-v3", new EsVersion(7, 0, 1),
- new EsVersion(7, 6, 1)),
- //FRANKFURT_R3("frankfurt-R3","",new EsVersion(6,4,3),new EsVersion(6,8,6)),
+ EL_ALTO("el alto", "_v1", new EsVersion(2, 2, 0), new EsVersion(2, 2, 0)),
+ FRANKFURT_R1("frankfurt-R1", "-v2", new EsVersion(6, 4, 3), new EsVersion(6, 8, 6)),
+ FRANKFURT_R2("frankfurt-R2", "-v3", new EsVersion(7, 0, 1), new EsVersion(7, 6, 1)),
+ GUILIN_R1("guilin-R1", "-v4", new EsVersion(7,1,1), new EsVersion(7,6,1));
- GUILIN_R1("guilin-R1", "-v4", new EsVersion(6, 4, 3), new EsVersion(6, 8, 6)), GUILIN_R2("guilin-R2", "-v5",
- new EsVersion(7, 0, 1), new EsVersion(7, 6, 1));
-
- public static final Release CURRENT_RELEASE = Release.FRANKFURT_R1;
+ public static final Release CURRENT_RELEASE = Release.GUILIN_R1;
private final String value;
private final String dbSuffix;
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ReleaseGroup.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ReleaseGroup.java
index c7d26dbed..993d0261f 100644
--- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ReleaseGroup.java
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ReleaseGroup.java
@@ -23,7 +23,6 @@ package org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data;
import java.util.ArrayList;
import java.util.List;
-
import org.onap.ccsdk.features.sdnr.wt.common.database.data.EsVersion;
/**
@@ -32,10 +31,9 @@ import org.onap.ccsdk.features.sdnr.wt.common.database.data.EsVersion;
*/
public enum ReleaseGroup {
- EL_ALTO(Release.EL_ALTO), FRANKFURT(Release.FRANKFURT_R1, Release.FRANKFURT_R2), GUILIN(Release.GUILIN_R1,
- Release.GUILIN_R2);
+ EL_ALTO(Release.EL_ALTO), FRANKFURT(Release.FRANKFURT_R1, Release.FRANKFURT_R2), GUILIN(Release.GUILIN_R1);
- public static final ReleaseGroup CURRENT_RELEASE = FRANKFURT;
+ public static final ReleaseGroup CURRENT_RELEASE = GUILIN;
private final List<Release> releases;
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/frankfurt/FrankfurtReleaseInformationR2.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/frankfurt/FrankfurtReleaseInformationR2.java
index e842b5c7b..f972777b9 100644
--- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/frankfurt/FrankfurtReleaseInformationR2.java
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/frankfurt/FrankfurtReleaseInformationR2.java
@@ -24,6 +24,10 @@ package org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.frankfurt;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
+import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient;
+import org.onap.ccsdk.features.sdnr.wt.common.database.requests.ClusterSettingsRequest;
+import org.onap.ccsdk.features.sdnr.wt.common.database.responses.ClusterSettingsResponse;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.ReleaseInformation;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.ComponentName;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.DatabaseInfo;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.DatabaseInfo7;
@@ -31,10 +35,6 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.Release;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.SearchHitConverter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient;
-import org.onap.ccsdk.features.sdnr.wt.common.database.requests.ClusterSettingsRequest;
-import org.onap.ccsdk.features.sdnr.wt.common.database.responses.ClusterSettingsResponse;
-import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.ReleaseInformation;
public class FrankfurtReleaseInformationR2 extends ReleaseInformation {
@@ -45,7 +45,7 @@ public class FrankfurtReleaseInformationR2 extends ReleaseInformation {
super(Release.FRANKFURT_R2, createDBMap());
}
- private static Map<ComponentName, DatabaseInfo> createDBMap() {
+ public static Map<ComponentName, DatabaseInfo> createDBMap() {
Map<ComponentName, DatabaseInfo> map = new HashMap<>();
map.put(ComponentName.CONNECTIONLOG, new DatabaseInfo7("connectionlog", "connectionlog",
"{\"node-id\": {\"type\": \"keyword\"},\"timestamp\": {\"type\": \"date\"},\"status\": {\"type\": \"keyword\"}}"));
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/guilin/GuilinReleaseInformation.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/guilin/GuilinReleaseInformation.java
index 2c2ac25a9..e057d82f2 100644
--- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/guilin/GuilinReleaseInformation.java
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/guilin/GuilinReleaseInformation.java
@@ -21,43 +21,25 @@
*/
package org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.guilin;
-import java.util.HashMap;
-import java.util.Map;
-
+import java.io.IOException;
import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient;
+import org.onap.ccsdk.features.sdnr.wt.common.database.requests.ClusterSettingsRequest;
+import org.onap.ccsdk.features.sdnr.wt.common.database.responses.ClusterSettingsResponse;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.ReleaseInformation;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.ComponentName;
-import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.DatabaseInfo;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.KeepDataSearchHitConverter;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.Release;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.SearchHitConverter;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.frankfurt.FrankfurtReleaseInformationR2;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class GuilinReleaseInformation extends ReleaseInformation {
- /**
- * @param r
- * @param dbMap
- */
+ private final Logger LOG = LoggerFactory.getLogger(GuilinReleaseInformation.class);
public GuilinReleaseInformation() {
- super(Release.GUILIN_R1, createDBMap());
-
- }
+ super(Release.GUILIN_R1, FrankfurtReleaseInformationR2.createDBMap());
- private static Map<ComponentName, DatabaseInfo> createDBMap() {
- Map<ComponentName, DatabaseInfo> map = new HashMap<>();
- map.put(ComponentName.EVENTLOG, new DatabaseInfo("eventlog", "eventlog", ""));
- map.put(ComponentName.FAULTCURRENT, new DatabaseInfo("faultcurrent", "faultcurrent", ""));
- map.put(ComponentName.FAULTLOG, new DatabaseInfo("faultlog", "faultlog", ""));
- map.put(ComponentName.INVENTORY, new DatabaseInfo("inventoryequipment", "inventoryequipment", ""));
- map.put(ComponentName.HISTORICAL_PERFORMANCE_15M,
- new DatabaseInfo("historicalperformance15min", "historicalperformance15min", ""));
- map.put(ComponentName.HISTORICAL_PERFORMANCE_24H,
- new DatabaseInfo("historicalperformance24h", "historicalperformance24h", ""));
- map.put(ComponentName.REQUIRED_NETWORKELEMENT,
- new DatabaseInfo("networkelement-connection", "networkelement-connection", ""));
- map.put(ComponentName.MEDIATOR_SERVER, new DatabaseInfo("mediator-server", "mediator-server", ""));
- map.put(ComponentName.MAINTENANCE, new DatabaseInfo("maintenancemode", "maintenancemode", ""));
- return map;
}
@Override
@@ -70,7 +52,13 @@ public class GuilinReleaseInformation extends ReleaseInformation {
@Override
protected boolean runPreInitCommands(HtDatabaseClient dbClient) {
- return true;
+ ClusterSettingsResponse response = null;
+ try {
+ response = dbClient.setupClusterSettings(new ClusterSettingsRequest(false).maxCompilationsPerMinute(400));
+ } catch (IOException e) {
+ LOG.warn("problem setting up cluster: {}", e);
+ }
+ return response == null ? false : response.isAcknowledged();
}
@Override
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/guilin/GuilinReleaseInformationR2.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/guilin/GuilinReleaseInformationR2.java
deleted file mode 100644
index 29c79f3da..000000000
--- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/guilin/GuilinReleaseInformationR2.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * ONAP : ccsdk features
- * ================================================================================
- * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property.
- * All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- *
- */
-package org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.guilin;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient;
-import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.ReleaseInformation;
-import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.ComponentName;
-import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.DatabaseInfo;
-import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.KeepDataSearchHitConverter;
-import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.Release;
-import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.SearchHitConverter;
-
-public class GuilinReleaseInformationR2 extends ReleaseInformation {
-
- /**
- * @param r
- * @param dbMap
- */
- public GuilinReleaseInformationR2() {
- super(Release.GUILIN_R2, createDBMap());
-
- }
-
- private static Map<ComponentName, DatabaseInfo> createDBMap() {
- Map<ComponentName, DatabaseInfo> map = new HashMap<>();
- map.put(ComponentName.EVENTLOG, new DatabaseInfo("eventlog", "eventlog", ""));
- map.put(ComponentName.FAULTCURRENT, new DatabaseInfo("faultcurrent", "faultcurrent", ""));
- map.put(ComponentName.FAULTLOG, new DatabaseInfo("faultlog", "faultlog", ""));
- map.put(ComponentName.INVENTORY, new DatabaseInfo("inventoryequipment", "inventoryequipment", ""));
- map.put(ComponentName.HISTORICAL_PERFORMANCE_15M,
- new DatabaseInfo("historicalperformance15min", "historicalperformance15min", ""));
- map.put(ComponentName.HISTORICAL_PERFORMANCE_24H,
- new DatabaseInfo("historicalperformance24h", "historicalperformance24h", ""));
- map.put(ComponentName.REQUIRED_NETWORKELEMENT,
- new DatabaseInfo("networkelement-connection", "networkelement-connection", ""));
- map.put(ComponentName.MEDIATOR_SERVER, new DatabaseInfo("mediator-server", "mediator-server", ""));
- map.put(ComponentName.MAINTENANCE, new DatabaseInfo("maintenancemode", "maintenancemode", ""));
- return map;
- }
-
- @Override
- public SearchHitConverter getConverter(Release dst, ComponentName comp) {
- if (dst == Release.GUILIN_R2) {
- return new KeepDataSearchHitConverter(comp);
- }
- return null;
- }
-
- @Override
- protected boolean runPreInitCommands(HtDatabaseClient dbClient) {
- return true;
- }
-
- @Override
- protected boolean runPostInitCommands(HtDatabaseClient dbClient) {
- return true;
- }
-
-}
diff --git a/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestMigrationProvider.java b/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestMigrationProvider.java
index 32438410f..aaa33839f 100644
--- a/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestMigrationProvider.java
+++ b/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestMigrationProvider.java
@@ -24,7 +24,6 @@ package org.onap.ccsdk.features.sdnr.wt.dataprovider.setup;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-
import org.junit.Test;
import org.onap.ccsdk.features.sdnr.wt.common.database.config.HostInfo;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.DataMigrationReport;
@@ -54,7 +53,7 @@ public class TestMigrationProvider {
//import data into database
DataMigrationReport report = provider.importData(FRANKFURT_BACKUP_FILE, false, Release.FRANKFURT_R2);
assertTrue(report.completed());
- assertEquals(Release.FRANKFURT_R2, provider.autoDetectRelease());
+ assertEquals(Release.CURRENT_RELEASE, provider.autoDetectRelease());
} catch (Exception e) {
fail(e.getMessage());
}