summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Timoney <dtimoney@att.com>2022-02-03 11:20:27 -0500
committerDan Timoney <dtimoney@att.com>2022-02-08 08:20:14 -0500
commitab8492989092ed8fccdc7f063c9ddb982cce1a8a (patch)
tree863148249b222a15b05d96098e0023412a51f1e7
parent2a546f93ac1c3686f099549fc88cd8bf2d39bd20 (diff)
Remove unused data-migrator code
Remove data-migrator code, which is no longer being actively used or supported, and which contains log4j vulnerability. Issue-ID: SDNC-1591 Signed-off-by: Dan Timoney <dtimoney@att.com> Change-Id: Id022338b0ab8643efa751296c94760387dc384e7 Former-commit-id: e7593db6f1a55c135a2c381a7d8d4ad3d666a839
-rw-r--r--data-migrator/pom.xml125
-rw-r--r--data-migrator/src/assembly/assemble_zip.xml59
-rw-r--r--data-migrator/src/main/java/org/onap/sdnc/oam/datamigrator/DataMigration.java39
-rw-r--r--data-migrator/src/main/java/org/onap/sdnc/oam/datamigrator/DataMigrationInternal.java148
-rw-r--r--data-migrator/src/main/java/org/onap/sdnc/oam/datamigrator/common/Description.java31
-rw-r--r--data-migrator/src/main/java/org/onap/sdnc/oam/datamigrator/common/MigratorConfiguration.java119
-rw-r--r--data-migrator/src/main/java/org/onap/sdnc/oam/datamigrator/common/Operation.java24
-rw-r--r--data-migrator/src/main/java/org/onap/sdnc/oam/datamigrator/common/RestconfClient.java144
-rw-r--r--data-migrator/src/main/java/org/onap/sdnc/oam/datamigrator/exceptions/RestconfException.java46
-rw-r--r--data-migrator/src/main/java/org/onap/sdnc/oam/datamigrator/migrators/Migrator.java136
-rw-r--r--data-migrator/src/main/java/org/onap/sdnc/oam/datamigrator/migrators/PreloadInformationMigrator.java61
-rw-r--r--data-migrator/src/main/java/org/onap/sdnc/oam/datamigrator/migrators/RenameDeleteLeafMigrator.java62
-rw-r--r--data-migrator/src/main/resources/data-migrator.properties27
-rw-r--r--data-migrator/src/main/resources/log4j.properties37
-rw-r--r--data-migrator/src/main/scripts/runMigration.sh48
-rw-r--r--data-migrator/src/test/java/org/onap/sdnc/oam/datamigrator/DataMigrationInternalTest.java92
-rw-r--r--data-migrator/src/test/java/org/onap/sdnc/oam/datamigrator/common/RestconfClientTest.java107
-rw-r--r--data-migrator/src/test/java/org/onap/sdnc/oam/datamigrator/datamigrator/PreloadInformationMigratorTest.java80
-rw-r--r--data-migrator/src/test/resources/log4j.properties29
-rw-r--r--data-migrator/src/test/resources/migration/props/data-migrator.properties27
-rw-r--r--data-migrator/src/test/resources/wiremock/preloadInformationRequest.json1
-rw-r--r--data-migrator/src/test/resources/wiremock/preloadVnfResponse.json132
-rw-r--r--installation/sdnc/pom.xml18
-rwxr-xr-xpom.xml1
24 files changed, 0 insertions, 1593 deletions
diff --git a/data-migrator/pom.xml b/data-migrator/pom.xml
deleted file mode 100644
index 69b3e43f..00000000
--- a/data-migrator/pom.xml
+++ /dev/null
@@ -1,125 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.onap.sdnc.oam</groupId>
- <artifactId>sdnc-oam</artifactId>
- <version>2.3.0-SNAPSHOT</version>
- </parent>
-
- <artifactId>data-migrator</artifactId>
- <packaging>jar</packaging>
-
- <name>sdnc-oam :: data-migrator</name>
- <description>MDSAL Data Migrator</description>
-
- <properties>
- <skip.SWM>true</skip.SWM>
- <java.version>11</java.version>
- <maven.build.timestamp.format>yyyyMMdd'T'HHmmss'Z'</maven.build.timestamp.format>
- <build.number>${maven.build.timestamp}</build.number>
- <SWM_VERSION>${project.version}-${build.number}</SWM_VERSION>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>${junit.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>com.google.code.gson</groupId>
- <artifactId>gson</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-lang3</artifactId>
- </dependency>
- <dependency>
- <groupId>org.reflections</groupId>
- <artifactId>reflections</artifactId>
- <version>0.9.9-RC1</version>
- </dependency>
- <dependency>
- <groupId>com.beust</groupId>
- <artifactId>jcommander</artifactId>
- <version>1.48</version>
- </dependency>
- <dependency>
- <groupId>com.github.tomakehurst</groupId>
- <artifactId>wiremock-standalone</artifactId>
- <version>2.18.0</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.onap.ccsdk.sli.core</groupId>
- <artifactId>utils-provider</artifactId>
- <version>${ccsdk.sli.version}</version>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>${maven-compiler-plugin.version}</version>
- <configuration>
- <release>${java.version}</release>
- <!--explicitly remove source and target-->
- <source combine.self="override"/>
- <target combine.self="override"/>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <configuration>
- <archive>
- <manifest>
- <addClasspath>true</addClasspath>
- <mainClass>org.onap.sdnc.oam.datamigrator.DataMigration</mainClass>
- </manifest>
- </archive>
- </configuration>
- </plugin>
- <plugin>
- <artifactId>maven-assembly-plugin</artifactId>
- <executions>
- <execution>
- <id>create-zip</id>
- <goals>
- <goal>single</goal>
- </goals>
- <phase>package</phase>
- <configuration>
- <attach>true</attach>
- <finalName>${project.artifactId}.${project.version}</finalName>
- <attach>true</attach>
- <descriptors>
- <descriptor>src/assembly/assemble_zip.xml</descriptor>
- </descriptors>
- <appendAssemblyId>false</appendAssemblyId>
- </configuration>
- </execution>
- </executions>
- </plugin>
-
- </plugins>
- </build>
-</project>
diff --git a/data-migrator/src/assembly/assemble_zip.xml b/data-migrator/src/assembly/assemble_zip.xml
deleted file mode 100644
index 604adf30..00000000
--- a/data-migrator/src/assembly/assemble_zip.xml
+++ /dev/null
@@ -1,59 +0,0 @@
-<!--
- ============LICENSE_START=======================================================
- ONAP : SDNC
- ================================================================================
- Copyright (C) 2019 AMDOCS
- ================================================================================
- 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=========================================================
- -->
-
-<!-- Defines how we build the .zip file which is our distribution. -->
-
-<assembly
- xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
- <id>assemble_zip</id>
- <formats>
- <format>zip</format>
- </formats>
-
- <includeBaseDirectory>false</includeBaseDirectory>
-
- <fileSets>
- <fileSet>
- <directory>src/main/scripts</directory>
- <outputDirectory>bin</outputDirectory>
- </fileSet>
- <fileSet>
- <directory>target</directory>
- <outputDirectory>lib</outputDirectory>
- <includes>
- <include>*.jar</include>
- </includes>
- </fileSet>
- <fileSet>
- <directory>src/main/resources</directory>
- <outputDirectory>properties</outputDirectory>
- <includes>
- <include>*.properties</include>
- </includes>
- </fileSet>
- </fileSets>
- <dependencySets>
- <dependencySet>
- <outputDirectory>lib</outputDirectory>
- <useProjectArtifact>true</useProjectArtifact>
- <scope>runtime</scope>
- </dependencySet>
- </dependencySets>
-</assembly>
diff --git a/data-migrator/src/main/java/org/onap/sdnc/oam/datamigrator/DataMigration.java b/data-migrator/src/main/java/org/onap/sdnc/oam/datamigrator/DataMigration.java
deleted file mode 100644
index ac53f448..00000000
--- a/data-migrator/src/main/java/org/onap/sdnc/oam/datamigrator/DataMigration.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * ONAP : SDNC
- * ================================================================================
- * Copyright 2019 AMDOCS
- *=================================================================================
- * 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.sdnc.oam.datamigrator;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class DataMigration {
-
- private static final Logger LOG = LoggerFactory.getLogger(DataMigration.class);
-
- public static void main(String[] args) {
- try {
- DataMigrationInternal dataMigrationInternal = new DataMigrationInternal(LOG);
- dataMigrationInternal.run(args);
- }catch (Exception e){
- e.printStackTrace();
- LOG.error("Error in DataMigration" + e.getMessage());
- }
- return;
- }
-}
diff --git a/data-migrator/src/main/java/org/onap/sdnc/oam/datamigrator/DataMigrationInternal.java b/data-migrator/src/main/java/org/onap/sdnc/oam/datamigrator/DataMigrationInternal.java
deleted file mode 100644
index ae497235..00000000
--- a/data-migrator/src/main/java/org/onap/sdnc/oam/datamigrator/DataMigrationInternal.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * ONAP : SDNC
- * ================================================================================
- * Copyright 2019 AMDOCS
- *=================================================================================
- * 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.sdnc.oam.datamigrator;
-
-import com.beust.jcommander.JCommander;
-import com.beust.jcommander.Parameter;
-import com.beust.jcommander.Strings;
-import org.onap.sdnc.oam.datamigrator.common.Description;
-import org.onap.sdnc.oam.datamigrator.common.MigratorConfiguration;
-import org.onap.sdnc.oam.datamigrator.common.Operation;
-import org.onap.sdnc.oam.datamigrator.migrators.Migrator;
-import org.reflections.Reflections;
-import org.slf4j.Logger;
-
-import java.lang.reflect.Modifier;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-import java.util.stream.Collectors;
-
-public class DataMigrationInternal {
-
- private final Logger log;
-
- public DataMigrationInternal(Logger log) {
- this.log = log;
- }
-
- private void logAndPrint(String msg) {
- System.out.println(msg);
- log.info(msg);
- }
-
- public void run(String[] args){
- CommandLineArgs cArgs = new CommandLineArgs();
- JCommander jCommander = new JCommander(cArgs, args);
- jCommander.setProgramName(DataMigration.class.getSimpleName());
-
- if (cArgs.help) {
- jCommander.usage();
- return;
- }
-
- Set<Class<? extends Migrator>> migratorList = getMigratorList();
- if(cArgs.scripts.size() > 0){
- migratorList = migratorList.stream().filter(aClass -> cArgs.scripts.contains(aClass.getSimpleName())).collect(Collectors.toSet());
- }
- if(cArgs.excludeClasses.size() > 0){
- migratorList = migratorList.stream().filter(aClass -> !cArgs.excludeClasses.contains(aClass.getSimpleName())).collect(Collectors.toSet());
- }
-
- if(migratorList.size()>0) {
- logAndPrint("Total number of available migrations: " + migratorList.size());
- if(cArgs.list) {
- logAndPrint("List of available migrations:");
- for (Class<? extends Migrator> migrator : migratorList) {
- if(migrator.getAnnotation(Description.class) != null && !migrator.getAnnotation(Description.class).value().isEmpty()) {
- logAndPrint(migrator.getSimpleName()+ ": " + migrator.getAnnotation(Description.class).value() );
- }else {
- logAndPrint(migrator.getSimpleName());
- }
- }
- }else {
- Operation operation;
- try {
- operation = Operation.valueOf(cArgs.operation.toUpperCase());
- logAndPrint("Starting operation: " + operation.name());
- }catch (IllegalArgumentException e) {
- logAndPrint("Invalid operation: " + cArgs.operation +". Supported operations are: Migrate, Backup, Restore.");
- return;
- }
- boolean success = true;
- MigratorConfiguration config;
- if(!Strings.isStringEmpty(cArgs.config)){
- config = new MigratorConfiguration(cArgs.config);
- }else {
- logAndPrint("No external configuration provided. Initializing Default configuration.");
- config = new MigratorConfiguration();
- }
- for (Class<? extends Migrator> migratorClass : migratorList) {
- logAndPrint("Started executing migrator: "+ migratorClass.getSimpleName());
- try {
- Migrator migrator = migratorClass.newInstance();
- migrator.init(config);
- migrator.run(operation);
- success = success && migrator.isSuccess();
- } catch (InstantiationException | IllegalAccessException e) {
- logAndPrint("Error instantiating migrator: " + migratorClass);
- success=false;
- }
- logAndPrint("Completed execution for migrator "+ migratorClass.getSimpleName() +" with status: " + success);
- }
- if(success){
- logAndPrint(operation.name()+ " operation completed Successfully.");
- }else{
- logAndPrint("Error during "+ operation.name() +" operation. Check logs for details.");
- }
- }
- }else{
- logAndPrint("No migrations available.");
- }
- }
-
- private Set<Class<? extends Migrator>> getMigratorList() {
- Reflections reflections = new Reflections("org.onap.sdnc.oam.datamigrator.migrators");
- return reflections.getSubTypesOf(Migrator.class).stream().filter(aClass -> !Modifier.isAbstract(aClass.getModifiers())).collect(Collectors.toSet());
- }
-
- class CommandLineArgs {
-
- @Parameter(names = "--h", help = true)
- public boolean help;
-
- @Parameter(names = "-o", description = "Operation to be performed. Default is Migrate. Supported operations: Migrate , Backup , Restore.")
- public String operation = "Migrate";
-
- @Parameter(names = "-c", description = "Configuration File path / directory")
- public String config;
-
- @Parameter(names = "-m", description = "Names of migration scripts to run")
- public List<String> scripts = new ArrayList<>();
-
- @Parameter(names = "-l", description = "List the available of migrations")
- public boolean list = false;
-
- @Parameter(names = "-e", description = "Exclude list of migrator classes")
- public List<String> excludeClasses = new ArrayList<>();
- }
-
-
-}
diff --git a/data-migrator/src/main/java/org/onap/sdnc/oam/datamigrator/common/Description.java b/data-migrator/src/main/java/org/onap/sdnc/oam/datamigrator/common/Description.java
deleted file mode 100644
index 3eaf562d..00000000
--- a/data-migrator/src/main/java/org/onap/sdnc/oam/datamigrator/common/Description.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * ONAP : SDNC
- * ================================================================================
- * Copyright 2019 AMDOCS
- *=================================================================================
- * 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.sdnc.oam.datamigrator.common;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.TYPE)
-public @interface Description {
- String value() default "";
-}
diff --git a/data-migrator/src/main/java/org/onap/sdnc/oam/datamigrator/common/MigratorConfiguration.java b/data-migrator/src/main/java/org/onap/sdnc/oam/datamigrator/common/MigratorConfiguration.java
deleted file mode 100644
index 9c3f7ac9..00000000
--- a/data-migrator/src/main/java/org/onap/sdnc/oam/datamigrator/common/MigratorConfiguration.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * ONAP : SDNC
- * ================================================================================
- * Copyright 2019 AMDOCS
- *=================================================================================
- * 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.sdnc.oam.datamigrator.common;
-
-import org.onap.ccsdk.sli.core.utils.common.EnvProperties;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.net.URL;
-import java.util.Properties;
-
-public class MigratorConfiguration {
-
- private String sourceHost ;
- private String sourceUser ;
- private String sourcePassword ;
- private String targetHost ;
- private String targetUser ;
- private String targetPassword ;
- private String dataPath;
-
- private static final String SDNC_CONFIG_DIR = "SDNC_CONFIG_DIR";
- private static final Logger LOG = LoggerFactory
- .getLogger(MigratorConfiguration.class);
-
- public MigratorConfiguration (){
- String propDir = System.getenv(SDNC_CONFIG_DIR);
- if (propDir == null) {
- propDir = "/opt/sdnc/data/properties";
- }
- try {
- init(propDir);
- } catch (Exception e) {
- LOG.error("Cannot initialize MigratorConfiguration", e);
- }
- }
-
- public MigratorConfiguration (String propDir){
- try {
- init(propDir);
- } catch (Exception e) {
- LOG.error("Cannot initialize MigratorConfiguration", e);
- }
- }
-
- public void init(String propDir) throws IOException {
- String propPath = propDir + "/data-migrator.properties";
- URL propPathUrl= getClass().getClassLoader().getResource(propPath);
- File propFile = (propPathUrl != null) ? new File(propPathUrl.getFile()) : new File(propPath);
- if (!propFile.exists()) {
- throw new FileNotFoundException(
- "Missing configuration properties file : "
- + propFile);
- }
-
- Properties props = new EnvProperties();
- props.load(new FileInputStream(propFile));
- this.sourceHost = props.getProperty("org.onap.sdnc.datamigrator.source.host");
- this.sourceUser = props.getProperty("org.onap.sdnc.datamigrator.source.user");
- this.sourcePassword = props.getProperty("org.onap.sdnc.datamigrator.source.password");
- this.targetHost = props.getProperty("org.onap.sdnc.datamigrator.target.host");
- this.targetUser = props.getProperty("org.onap.sdnc.datamigrator.target.user");
- this.targetPassword = props.getProperty("org.onap.sdnc.datamigrator.target.password");
- this.dataPath = props.getProperty("org.onap.sdnc.datamigrator.data.path");
- }
-
- public String getSourceHost() {
- return sourceHost;
- }
-
- public String getSourceUser() {
- return sourceUser;
- }
-
- public String getSourcePassword() {
- return sourcePassword;
- }
-
- public String getTargetHost() {
- return targetHost;
- }
-
- public String getTargetUser() {
- return targetUser;
- }
-
- public String getTargetPassword() {
- return targetPassword;
- }
-
- public String getDataPath() {
- return dataPath;
- }
-
- public void setDataPath(String dataPath) {
- this.dataPath = dataPath;
- }
-}
diff --git a/data-migrator/src/main/java/org/onap/sdnc/oam/datamigrator/common/Operation.java b/data-migrator/src/main/java/org/onap/sdnc/oam/datamigrator/common/Operation.java
deleted file mode 100644
index df6cd00a..00000000
--- a/data-migrator/src/main/java/org/onap/sdnc/oam/datamigrator/common/Operation.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * ONAP : SDNC
- * ================================================================================
- * Copyright 2019 AMDOCS
- *=================================================================================
- * 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.sdnc.oam.datamigrator.common;
-
-public enum Operation {
- RESTORE,MIGRATE,BACKUP
-}
diff --git a/data-migrator/src/main/java/org/onap/sdnc/oam/datamigrator/common/RestconfClient.java b/data-migrator/src/main/java/org/onap/sdnc/oam/datamigrator/common/RestconfClient.java
deleted file mode 100644
index b7722b6d..00000000
--- a/data-migrator/src/main/java/org/onap/sdnc/oam/datamigrator/common/RestconfClient.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * ONAP : SDNC
- * ================================================================================
- * Copyright 2019 AMDOCS
- *=================================================================================
- * 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.sdnc.oam.datamigrator.common;
-
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParser;
-import org.onap.sdnc.oam.datamigrator.exceptions.RestconfException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.net.ssl.HostnameVerifier;
-import javax.net.ssl.HttpsURLConnection;
-import java.io.BufferedReader;
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.net.Authenticator;
-import java.net.HttpURLConnection;
-import java.net.PasswordAuthentication;
-import java.net.URL;
-import java.util.Base64;
-
-public class RestconfClient {
-
- private HttpURLConnection httpConn = null;
- private final String host ;
- private final String user ;
- private final String password ;
- private static final String CONFIG_PATH = "/restconf/config/";
- private static final String CONTENT_TYPE_JSON = "application/json";
- private final Logger log = LoggerFactory.getLogger(RestconfClient.class);
-
- public RestconfClient (String host , String user , String password){
- this.host = host;
- this.user = user;
- this.password = password;
- }
-
- private class SdncAuthenticator extends Authenticator {
-
- private final String user;
- private final String passwd;
-
- SdncAuthenticator(String user, String passwd) {
- this.user = user;
- this.passwd = passwd;
- }
- @Override
- protected PasswordAuthentication getPasswordAuthentication() {
- return new PasswordAuthentication(user, passwd.toCharArray());
- }
- }
-
- public JsonObject get(String path) throws RestconfException {
- String getResponse = send(path,"GET",CONTENT_TYPE_JSON,"");
- JsonParser parser = new JsonParser();
- return parser.parse(getResponse).getAsJsonObject();
- }
-
- public void put(String path, String data) throws RestconfException {
- send(path,"PUT",CONTENT_TYPE_JSON, data );
- }
-
- private String send(String path,String method, String contentType, String msg) throws RestconfException {
- Authenticator.setDefault(new SdncAuthenticator(user, password));
- String url = host + CONFIG_PATH + path;
- try {
- URL sdncUrl = new URL(url);
- log.info("SDNC url: " + url);
- log.info("Method: " + method);
- this.httpConn = (HttpURLConnection) sdncUrl.openConnection();
- String authStr = user + ":" + password;
- String encodedAuthStr = new String(Base64.getEncoder().encode(authStr.getBytes()));
- httpConn.addRequestProperty("Authentication", "Basic " + encodedAuthStr);
-
- httpConn.setRequestMethod(method);
- httpConn.setRequestProperty("Content-Type", contentType);
- httpConn.setRequestProperty("Accept", contentType);
-
- httpConn.setDoInput(true);
- httpConn.setDoOutput(true);
- httpConn.setUseCaches(false);
-
- if (httpConn instanceof HttpsURLConnection) {
- HostnameVerifier hostnameVerifier = (hostname, session) -> true;
- ((HttpsURLConnection) httpConn).setHostnameVerifier(hostnameVerifier);
- }
- if (!method.equals("GET")) {
- log.info("Request payload: " + msg);
- httpConn.setRequestProperty("Content-Length", "" + msg.length());
- DataOutputStream outStr = new DataOutputStream(httpConn.getOutputStream());
- outStr.write(msg.getBytes());
- outStr.close();
- }
-
- BufferedReader respRdr;
- log.info("Response: " + httpConn.getResponseCode() + " " + httpConn.getResponseMessage());
-
- if (httpConn.getResponseCode() < 300) {
- respRdr = new BufferedReader(new InputStreamReader(httpConn.getInputStream()));
- } else {
- respRdr = new BufferedReader(new InputStreamReader(httpConn.getErrorStream()));
- log.error("Error during restconf operation: "+ method + ". URL:" + sdncUrl.toString()+". Response:"+respRdr);
- throw new RestconfException(httpConn.getResponseCode(),"Error during restconf operation: "+ method +". Response:"+respRdr);
- }
-
- StringBuilder respBuff = new StringBuilder();
- String respLn;
- while ((respLn = respRdr.readLine()) != null) {
- respBuff.append(respLn).append("\n");
- }
- respRdr.close();
- String respString = respBuff.toString();
-
- log.info("Response body :\n" + respString);
- return respString;
- }catch (IOException e){
- throw new RestconfException(500,e.getMessage(),e);
- }finally {
- if (httpConn != null) {
- httpConn.disconnect();
- }
- }
- }
-
-
-}
diff --git a/data-migrator/src/main/java/org/onap/sdnc/oam/datamigrator/exceptions/RestconfException.java b/data-migrator/src/main/java/org/onap/sdnc/oam/datamigrator/exceptions/RestconfException.java
deleted file mode 100644
index 6b714c29..00000000
--- a/data-migrator/src/main/java/org/onap/sdnc/oam/datamigrator/exceptions/RestconfException.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * ONAP : SDNC
- * ================================================================================
- * Copyright 2019 AMDOCS
- *=================================================================================
- * 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.sdnc.oam.datamigrator.exceptions;
-
-public class RestconfException extends Exception{
-
- private final int errorCode;
- private final String errorMessage;
-
- public RestconfException(int errorCode, String errorMessage) {
- super(errorMessage);
- this.errorCode = errorCode;
- this.errorMessage = errorMessage;
- }
-
- public RestconfException(int errorCode, String errorMessage, Throwable e) {
- super(errorMessage,e);
- this.errorCode = errorCode;
- this.errorMessage = errorMessage;
- }
-
- public int getErrorCode() {
- return errorCode;
- }
-
- public String getErrorMessage() {
- return errorMessage;
- }
-}
diff --git a/data-migrator/src/main/java/org/onap/sdnc/oam/datamigrator/migrators/Migrator.java b/data-migrator/src/main/java/org/onap/sdnc/oam/datamigrator/migrators/Migrator.java
deleted file mode 100644
index e44a2c73..00000000
--- a/data-migrator/src/main/java/org/onap/sdnc/oam/datamigrator/migrators/Migrator.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * ONAP : SDNC
- * ================================================================================
- * Copyright 2019 AMDOCS
- *=================================================================================
- * 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.sdnc.oam.datamigrator.migrators;
-
-import com.google.gson.Gson;
-import com.google.gson.JsonObject;
-import org.onap.sdnc.oam.datamigrator.common.MigratorConfiguration;
-import org.onap.sdnc.oam.datamigrator.common.Operation;
-import org.onap.sdnc.oam.datamigrator.common.RestconfClient;
-import org.onap.sdnc.oam.datamigrator.exceptions.RestconfException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.IOException;
-
-public abstract class Migrator {
-
- protected RestconfClient sourceClient;
- protected RestconfClient targetClient;
- protected boolean success = true;
- private MigratorConfiguration config;
- private final Logger log = LoggerFactory.getLogger(PreloadInformationMigrator.class);
-
-
- public void run(Operation operation){
- {
- JsonObject sourceData;
- if(operation != Operation.RESTORE) {
-
- try {
- sourceData = sourceClient.get(getYangModuleName()+":"+ getSourcePath());
- if(operation == Operation.BACKUP){
- String fileName = getFileName();
- try {
- BufferedWriter writer = new BufferedWriter(new FileWriter(fileName));
- writer.write(sourceData.toString());
- writer.close();
- } catch (IOException e) {
- log.error("Error writing data to file : " + fileName, e);
- success = false;
- return;
- }
- return;
- }
- } catch (RestconfException e) {
- if(e.getErrorCode() == 404){
- log.error("No data available for migration. Returning silent success.", e);
- success = true;
- }else {
- log.error("Error retrieving data from MD-SAL store. Error code: " + e.getErrorCode() + ". Error message:" + e.getErrorMessage(), e);
- success = false;
- }
- return;
- }
- }else {
- String fileName = getFileName();
- try {
- Gson gson = new Gson();
- sourceData = gson.fromJson(new BufferedReader(new FileReader(fileName)),JsonObject.class);
- } catch (IOException e) {
- log.error("Error Reading data from file : " + fileName, e);
- success = false;
- return;
- }
- }
- try {
- String targetData = convertData(sourceData);
- targetClient.put(getYangModuleName()+":"+ getTargetPath(),targetData);
- } catch (RestconfException e) {
- log.error("Error loading data to MD-SAL store. Error code: "+e.getErrorCode()+". Error message:"+e.getErrorMessage(),e);
- success=false;
- }
- }
- }
-
- private String getFileName() {
- return config.getDataPath()+ "/" + getYangModuleName()+ "_"+ getSourcePath()+"_"+ getTargetPath() + ".json";
- }
-
- protected abstract String convertData(JsonObject sourceData);
-
- public abstract String getYangModuleName();
- public abstract String getSourcePath();
- public abstract String getTargetPath();
-
- public void init(MigratorConfiguration config){
- this.config = config;
- sourceClient = new RestconfClient(config.getSourceHost(),config.getSourceUser(),config.getSourcePassword());
- targetClient = new RestconfClient(config.getTargetHost(),config.getTargetUser(),config.getTargetPassword());
- }
-
- public RestconfClient getSourceClient() {
- return sourceClient;
- }
-
- public void setSourceClient(RestconfClient sourceClient) {
- this.sourceClient = sourceClient;
- }
-
- public RestconfClient getTargetClient() {
- return targetClient;
- }
-
- public void setTargetClient(RestconfClient targetClient) {
- this.targetClient = targetClient;
- }
-
- public boolean isSuccess() {
- return success;
- }
-
- public void setSuccess(boolean success) {
- this.success = success;
- }
-}
-
diff --git a/data-migrator/src/main/java/org/onap/sdnc/oam/datamigrator/migrators/PreloadInformationMigrator.java b/data-migrator/src/main/java/org/onap/sdnc/oam/datamigrator/migrators/PreloadInformationMigrator.java
deleted file mode 100644
index d259c216..00000000
--- a/data-migrator/src/main/java/org/onap/sdnc/oam/datamigrator/migrators/PreloadInformationMigrator.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * ONAP : SDNC
- * ================================================================================
- * Copyright 2019 AMDOCS
- *=================================================================================
- * 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.sdnc.oam.datamigrator.migrators;
-
-import org.onap.sdnc.oam.datamigrator.common.Description;
-
-import java.util.HashMap;
-import java.util.HashSet;
-
-@Description("Migrator for container 'preload-vnf' in GENERIC-RESOURCE-API.yang")
-public class PreloadInformationMigrator extends RenameDeleteLeafMigrator {
-
- private static final String YANG_MODULE = "GENERIC-RESOURCE-API";
-
- static{
- deletedFields = new HashSet<>();
- deletedFields.add("preload-vnfs.vnf-preload-list.preload-data.vnf-topology-information");
- deletedFields.add("preload-vnfs.vnf-preload-list.preload-data.network-topology-information.network-topology-identifier.service-type");
- deletedFields.add("preload-vnfs.vnf-preload-list.preload-data.oper-status.last-action");
- renamedFields = new HashMap<>();
- renamedFields.put("preload-vnfs","preload-information");
- renamedFields.put("preload-vnfs.vnf-preload-list","preload-list");
- renamedFields.put("preload-vnfs.vnf-preload-list.vnf-type","preload-type");
- renamedFields.put("preload-vnfs.vnf-preload-list.vnf-name","preload-id");
- renamedFields.put("preload-vnfs.vnf-preload-list.preload-data.oper-status","preload-oper-status");
- renamedFields.put("preload-vnfs.vnf-preload-list.preload-data.network-topology-information","preload-network-topology-information");
- renamedFields.put("preload-vnfs.vnf-preload-list.preload-data.network-topology-information.network-topology-identifier","network-topology-identifier-structure");
- }
-
- @Override
- public String getYangModuleName() {
- return YANG_MODULE;
- }
-
- @Override
- public String getSourcePath() {
- return "preload-vnfs";
- }
-
- @Override
- public String getTargetPath() {
- return "preload-information";
- }
-}
diff --git a/data-migrator/src/main/java/org/onap/sdnc/oam/datamigrator/migrators/RenameDeleteLeafMigrator.java b/data-migrator/src/main/java/org/onap/sdnc/oam/datamigrator/migrators/RenameDeleteLeafMigrator.java
deleted file mode 100644
index 8c0adc0c..00000000
--- a/data-migrator/src/main/java/org/onap/sdnc/oam/datamigrator/migrators/RenameDeleteLeafMigrator.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * ONAP : SDNC
- * ================================================================================
- * Copyright 2019 AMDOCS
- *=================================================================================
- * 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.sdnc.oam.datamigrator.migrators;
-
-import com.google.gson.JsonArray;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-import org.apache.commons.lang3.StringUtils;
-import java.util.Map;
-import java.util.Set;
-
-public abstract class RenameDeleteLeafMigrator extends Migrator {
-
- protected static Map<String,String> renamedFields ;
- protected static Set<String> deletedFields ;
-
- @Override
- protected String convertData(JsonObject sourceData) {
- JsonObject target = convert(sourceData,"");
- return target.toString();
- }
-
- protected JsonObject convert(JsonObject source,String parent) {
- JsonObject target = new JsonObject();
- for (String key : source.keySet()){
- String prefixKey = StringUtils.isNotEmpty(parent) ? parent + "."+key : key;
- if(!deletedFields.contains(prefixKey)) {
- JsonElement value = source.get(key);
- if (value.isJsonPrimitive()) {
- target.add(renamedFields.getOrDefault(prefixKey,key), value);
- } else if(value.isJsonArray()){
- JsonArray targetList = new JsonArray();
- JsonArray sourceArray = value.getAsJsonArray();
- for(JsonElement e : sourceArray){
- targetList.add(convert(e.getAsJsonObject(),prefixKey));
- }
- target.add(renamedFields.getOrDefault(prefixKey,key), targetList);
- } else{
- target.add(renamedFields.getOrDefault(prefixKey,key), convert(value.getAsJsonObject(),prefixKey));
- }
- }
- }
- return target;
- }
-}
diff --git a/data-migrator/src/main/resources/data-migrator.properties b/data-migrator/src/main/resources/data-migrator.properties
deleted file mode 100644
index f5f55a5e..00000000
--- a/data-migrator/src/main/resources/data-migrator.properties
+++ /dev/null
@@ -1,27 +0,0 @@
-###
-# ============LICENSE_START=======================================================
-# openECOMP : SDN-C
-# ================================================================================
-# Copyright (C) 2019 AMDOCS
-# ================================================================================
-# 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=========================================================
-###
-
-org.onap.sdnc.datamigrator.source.host=http://localhost:8081
-org.onap.sdnc.datamigrator.source.user=admin
-org.onap.sdnc.datamigrator.source.password=Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U
-org.onap.sdnc.datamigrator.target.host=http://localhost:8082
-org.onap.sdnc.datamigrator.target.user=admin
-org.onap.sdnc.datamigrator.target.password=Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U
-org.onap.sdnc.datamigrator.data.path=C:/DATA \ No newline at end of file
diff --git a/data-migrator/src/main/resources/log4j.properties b/data-migrator/src/main/resources/log4j.properties
deleted file mode 100644
index d53dc5a8..00000000
--- a/data-migrator/src/main/resources/log4j.properties
+++ /dev/null
@@ -1,37 +0,0 @@
-###
-# ============LICENSE_START=======================================================
-# openECOMP : SDN-C
-# ================================================================================
-# Copyright (C) 2019 AMDOCS
-# ================================================================================
-# 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=========================================================
-###
-
-log4j.rootLogger=DEBUG,CONSOLE,LOGFILE
-
-# CONSOLE is set to be a ConsoleAppender using a PatternLayout.
-log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
-log4j.appender.CONSOLE.Threshold=DEBUG
-log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
-log4j.appender.CONSOLE.layout.ConversionPattern=%p %d{yyyy-MM-dd HH:mm:ss.SSS Z} %c{1} - %m%n
-
-
-# LOGFILE is set to be a File appender using a PatternLayout.
-log4j.appender.LOGFILE=org.apache.log4j.RollingFileAppender
-log4j.appender.LOGFILE.File=/opt/app/data-migrator/data-migrator.log
-log4j.appender.LOGFILE.Append=true
-log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout
-log4j.appender.LOGFILE.layout.ConversionPattern=%p %d{yyyy-MM-dd HH:mm:ss.SSS Z} %c{1} - %m%n
-log4j.appender.LOGFILE.MaxFileSize=10MB
-log4j.appender.LOGFILE.MaxBackupIndex=10
diff --git a/data-migrator/src/main/scripts/runMigration.sh b/data-migrator/src/main/scripts/runMigration.sh
deleted file mode 100644
index e763acbe..00000000
--- a/data-migrator/src/main/scripts/runMigration.sh
+++ /dev/null
@@ -1,48 +0,0 @@
-#!/bin/bash
-
-###
-# ============LICENSE_START=======================================================
-# openECOMP : SDN-C
-# ================================================================================
-# Copyright (C) 2019 AMDOCS
-# ================================================================================
-# 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=========================================================
-###
-
-PROPERTY_DIR=${PROPERTY_DIR:-/opt/onap/sdnc/data/properties}
-MIGRATION=data-migrator
-MIGRATION_ROOT=${MIGRATION_ROOT:-/opt/onap/sdnc/data-migrator}
-JAVA_HOME=${JAVA_HOME:-/usr/lib/jvm/java-8-oracle}
-JAVA_OPTS=${JAVA_OPTS:--Dhttps.protocols=TLSv1.1,TLSv1.2}
-JAVA=${JAVA:-${JAVA_HOME}/bin/java}
-
-# Redirect output from script to MIGRATION.out
-exec >> ${MIGRATION_ROOT}/logs/$MIGRATION.out
-exec 2>&1
-
-if [ ! -d ${MIGRATION_ROOT}/logs ]
-then
- mkdir ${MIGRATION_ROOT}/logs
-fi
-
-for file in ${MIGRATION_ROOT}/lib/*.jar
-do
- CLASSPATH=$CLASSPATH:$file
-done
-
-${JAVA} ${JAVA_OPTS} -Dlog4j.configuration=file:${MIGRATION_ROOT}/properties/log4j.properties -cp ${CLASSPATH} org.onap.sdnc.oam.datamigrator.DataMigration $@
-
-echo $!
-
-exit 0
diff --git a/data-migrator/src/test/java/org/onap/sdnc/oam/datamigrator/DataMigrationInternalTest.java b/data-migrator/src/test/java/org/onap/sdnc/oam/datamigrator/DataMigrationInternalTest.java
deleted file mode 100644
index 18cd662f..00000000
--- a/data-migrator/src/test/java/org/onap/sdnc/oam/datamigrator/DataMigrationInternalTest.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * ONAP : SDNC
- * ================================================================================
- * Copyright 2019 AMDOCS
- *=================================================================================
- * 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.sdnc.oam.datamigrator;
-
-import com.github.tomakehurst.wiremock.client.WireMock;
-import com.github.tomakehurst.wiremock.junit.WireMockRule;
-import org.junit.Rule;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.PrintStream;
-import java.net.URISyntaxException;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-
-import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
-import static com.github.tomakehurst.wiremock.client.WireMock.get;
-import static com.github.tomakehurst.wiremock.client.WireMock.put;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-public class DataMigrationInternalTest {
-
- @Rule
- public WireMockRule source = new WireMockRule(8081);
- @Rule
- public WireMockRule target = new WireMockRule(8082);
-
- private static final Logger LOG = LoggerFactory.getLogger(DataMigrationInternal.class);
- DataMigrationInternal dataMigrationInternal = new DataMigrationInternal(LOG);
- private ClassLoader classLoader = getClass().getClassLoader();
- private String preloadVnfResponseJson = new String(Files.readAllBytes(Paths.get(classLoader.getResource("wiremock/preloadVnfResponse.json").toURI())));
- private String preloadInformationRequestJson = new String(Files.readAllBytes(Paths.get(classLoader.getResource("wiremock/preloadInformationRequest.json").toURI())));
-
- public DataMigrationInternalTest() throws IOException, URISyntaxException {
- }
-
- @Test
- public void runPositiveTest() {
- String [] args = {"-c","migration/props"};
- PrintStream oldOutputStream = System.out;
- final ByteArrayOutputStream myOut = new ByteArrayOutputStream();
- System.setOut(new PrintStream(myOut));
- source.stubFor(get(urlEqualTo("/restconf/config/GENERIC-RESOURCE-API:preload-vnfs")).willReturn(
- aResponse()
- .withStatus(200)
- .withBody(preloadVnfResponseJson)));
- target.stubFor(put(urlEqualTo("/restconf/config/GENERIC-RESOURCE-API:preload-information")).withRequestBody(WireMock.equalTo(preloadInformationRequestJson)).willReturn(
- aResponse()
- .withStatus(200)));
- dataMigrationInternal.run(args);
- String content = myOut.toString();
- assertThat("Migration failed", content.contains("MIGRATE operation completed Successfully."));
- System.setOut(oldOutputStream);
- }
-
- @Test
- public void runTestWithNoData() {
- String [] args = {"-c","migration/props"};
- PrintStream oldOutputStream = System.out;
- final ByteArrayOutputStream myOut = new ByteArrayOutputStream();
- System.setOut(new PrintStream(myOut));
- source.stubFor(get(urlEqualTo("/restconf/config/GENERIC-RESOURCE-API:preload-vnfs"))
- .willReturn(aResponse().withStatus(404)));
- target.stubFor(put(urlEqualTo("/restconf/config/GENERIC-RESOURCE-API:preload-information"))
- .withRequestBody(WireMock.equalTo(preloadInformationRequestJson)).willReturn(aResponse().withStatus(200)));
- dataMigrationInternal.run(args);
- String content = myOut.toString();
- assertThat("Migration failed", content.contains("MIGRATE operation completed Successfully."));
- System.setOut(oldOutputStream);
- }
-} \ No newline at end of file
diff --git a/data-migrator/src/test/java/org/onap/sdnc/oam/datamigrator/common/RestconfClientTest.java b/data-migrator/src/test/java/org/onap/sdnc/oam/datamigrator/common/RestconfClientTest.java
deleted file mode 100644
index bbffd608..00000000
--- a/data-migrator/src/test/java/org/onap/sdnc/oam/datamigrator/common/RestconfClientTest.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * ONAP : SDNC
- * ================================================================================
- * Copyright 2019 AMDOCS
- *=================================================================================
- * 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.sdnc.oam.datamigrator.common;
-
-import com.github.tomakehurst.wiremock.client.WireMock;
-import com.github.tomakehurst.wiremock.junit.WireMockRule;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParser;
-import org.junit.Rule;
-import org.junit.Test;
-import org.onap.sdnc.oam.datamigrator.exceptions.RestconfException;
-
-import java.io.IOException;
-import java.net.URISyntaxException;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-
-import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
-import static com.github.tomakehurst.wiremock.client.WireMock.get;
-import static com.github.tomakehurst.wiremock.client.WireMock.put;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-public class RestconfClientTest {
-
- @Rule
- public WireMockRule service = new WireMockRule(8081);
- private RestconfClient restconfClient = new RestconfClient("http://localhost:8081","admin","Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U");
- private ClassLoader classLoader = getClass().getClassLoader();
- private String preloadVnfResponseJson = new String(Files.readAllBytes(Paths.get(classLoader.getResource("wiremock/preloadVnfResponse.json").toURI())));
- private String preloadInformationRequestJson = new String(Files.readAllBytes(Paths.get(classLoader.getResource("wiremock/preloadInformationRequest.json").toURI())));
-
-
- JsonObject expectedJsonObject = new JsonParser().parse(preloadVnfResponseJson).getAsJsonObject();
-
- public RestconfClientTest() throws IOException, URISyntaxException {
- }
-
- @Test
- public void getPositiveTest() {
- service.stubFor(get(urlEqualTo("/restconf/config/GENERIC-RESOURCE-API:preload-vnfs"))
- .willReturn(aResponse().withStatus(200).withBody(preloadVnfResponseJson)));
- JsonObject actualResponse=null;
- try {
- actualResponse = restconfClient.get("GENERIC-RESOURCE-API:preload-vnfs");
- } catch (RestconfException e) {
- e.printStackTrace();
- }
- assertEquals(expectedJsonObject,actualResponse);
- }
-
- @Test
- public void getNegativeTest() {
- service.stubFor(get(urlEqualTo("/restconf/config/GENERIC-RESOURCE-API:preload-vnfs"))
- .willReturn(aResponse().withStatus(404)));
- JsonObject actualResponse=null;
- try {
- actualResponse = restconfClient.get("GENERIC-RESOURCE-API:preload-vnfs");
- } catch (RestconfException e) {
- e.printStackTrace();
- }
- assertNull(actualResponse);
- }
-
- @Test
- public void putPositiveTest() {
- service.stubFor(put(urlEqualTo("/restconf/config/GENERIC-RESOURCE-API:preload-information"))
- .withRequestBody(WireMock.equalTo(preloadInformationRequestJson)).willReturn(aResponse().withStatus(200)));
- Exception ex = null;
- try {
- restconfClient.put("GENERIC-RESOURCE-API:preload-information", preloadInformationRequestJson);
- } catch (RestconfException e) {
- ex =e;
- }
- assertNull(ex);
- }
-
- @Test
- public void putNegativeTest() {
- service.stubFor(put(urlEqualTo("/restconf/config/GENERIC-RESOURCE-API:preload-information"))
- .withRequestBody(WireMock.equalTo(preloadInformationRequestJson)).willReturn(aResponse().withStatus(500)));
- try {
- restconfClient.put("GENERIC-RESOURCE-API:preload-information", preloadInformationRequestJson);
- } catch (RestconfException e) {
- assertTrue(e.getErrorMessage().contains("Error during restconf operation: PUT."));
- }
- }
-} \ No newline at end of file
diff --git a/data-migrator/src/test/java/org/onap/sdnc/oam/datamigrator/datamigrator/PreloadInformationMigratorTest.java b/data-migrator/src/test/java/org/onap/sdnc/oam/datamigrator/datamigrator/PreloadInformationMigratorTest.java
deleted file mode 100644
index 7972b7ab..00000000
--- a/data-migrator/src/test/java/org/onap/sdnc/oam/datamigrator/datamigrator/PreloadInformationMigratorTest.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * ONAP : SDNC
- * ================================================================================
- * Copyright 2019 AMDOCS
- *=================================================================================
- * 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.sdnc.oam.datamigrator.datamigrator;
-
-import com.github.tomakehurst.wiremock.client.WireMock;
-import com.github.tomakehurst.wiremock.junit.WireMockRule;
-import org.junit.Rule;
-import org.junit.Test;
-import org.onap.sdnc.oam.datamigrator.common.Operation;
-import org.onap.sdnc.oam.datamigrator.common.RestconfClient;
-import org.onap.sdnc.oam.datamigrator.migrators.PreloadInformationMigrator;
-
-import java.io.IOException;
-import java.net.URISyntaxException;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-
-public class PreloadInformationMigratorTest {
-
- @Rule
- public WireMockRule service1 = new WireMockRule(8081);
-
- @Rule
- public WireMockRule service2 = new WireMockRule(8082);
- PreloadInformationMigrator migrator = new PreloadInformationMigrator();
- private ClassLoader classLoader = getClass().getClassLoader();
- private String preloadVnfResponseJson = new String(Files.readAllBytes(Paths.get(classLoader.getResource("wiremock/preloadVnfResponse.json").toURI())));
- private String preloadInformationRequestJson = new String(Files.readAllBytes(Paths.get(classLoader.getResource("wiremock/preloadInformationRequest.json").toURI())));
-
- public PreloadInformationMigratorTest() throws IOException, URISyntaxException {
- }
-
- @Test
- public void testRun (){
- service1.stubFor(WireMock.get(WireMock.urlEqualTo("/restconf/config/GENERIC-RESOURCE-API:preload-vnfs")).willReturn(
- WireMock.aResponse()
- .withStatus(200)
- .withBody(preloadVnfResponseJson)));
- service2.stubFor(WireMock.put(WireMock.urlEqualTo("/restconf/config/GENERIC-RESOURCE-API:preload-information")).withRequestBody(WireMock.equalTo(preloadInformationRequestJson)).willReturn(
- WireMock.aResponse()
- .withStatus(200)));
- RestconfClient sourceClient = new RestconfClient("http://localhost:8081","admin","Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U");
- migrator.setSourceClient(sourceClient);
- RestconfClient targetClient = new RestconfClient("http://localhost:8082","admin","Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U");
- migrator.setTargetClient(targetClient);
- migrator.run(Operation.MIGRATE);
- }
-
- @Test
- public void testRunNoData (){
- service1.stubFor(WireMock.get(WireMock.urlEqualTo("/restconf/config/GENERIC-RESOURCE-API:preload-vnfs")).willReturn(
- WireMock.aResponse()
- .withStatus(404)));
- service2.stubFor(WireMock.put(WireMock.urlEqualTo("/restconf/config/GENERIC-RESOURCE-API:preload-information")).withRequestBody(WireMock.equalTo(preloadInformationRequestJson)).willReturn(
- WireMock.aResponse()
- .withStatus(200)));
- RestconfClient sourceClient = new RestconfClient("http://localhost:8081","admin","Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U");
- migrator.setSourceClient(sourceClient);
- RestconfClient targetClient = new RestconfClient("http://localhost:8082","admin","Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U");
- migrator.setTargetClient(targetClient);
- migrator.run(Operation.MIGRATE);
- }
-}
diff --git a/data-migrator/src/test/resources/log4j.properties b/data-migrator/src/test/resources/log4j.properties
deleted file mode 100644
index 82f1f470..00000000
--- a/data-migrator/src/test/resources/log4j.properties
+++ /dev/null
@@ -1,29 +0,0 @@
-###
-# ============LICENSE_START=======================================================
-# ONAP : SDN-C
-# ================================================================================
-# Copyright (C) 2019 AMDOCS
-# ================================================================================
-# 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=========================================================
-###
-
-log4j.rootLogger=DEBUG,CONSOLE
-
-# CONSOLE is set to be a ConsoleAppender using a PatternLayout.
-log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
-log4j.appender.CONSOLE.Threshold=DEBUG
-log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
-log4j.appender.CONSOLE.layout.ConversionPattern=%p %d{yyyy-MM-dd HH:mm:ss.SSS Z} %c{1} - %m%n
-
-
diff --git a/data-migrator/src/test/resources/migration/props/data-migrator.properties b/data-migrator/src/test/resources/migration/props/data-migrator.properties
deleted file mode 100644
index d9ddadbb..00000000
--- a/data-migrator/src/test/resources/migration/props/data-migrator.properties
+++ /dev/null
@@ -1,27 +0,0 @@
-###
-# ============LICENSE_START=======================================================
-# ONAP : SDN-C
-# ================================================================================
-# Copyright (C) 2019 AMDOCS
-# ================================================================================
-# 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=========================================================
-###
-
-org.onap.sdnc.datamigrator.source.host=http://localhost:8081
-org.onap.sdnc.datamigrator.source.user=admin
-org.onap.sdnc.datamigrator.source.password=Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U
-org.onap.sdnc.datamigrator.target.host=http://localhost:8082
-org.onap.sdnc.datamigrator.target.user=admin
-org.onap.sdnc.datamigrator.target.password=Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U
-org.onap.sdnc.datamigrator.data.path=C:/DATA \ No newline at end of file
diff --git a/data-migrator/src/test/resources/wiremock/preloadInformationRequest.json b/data-migrator/src/test/resources/wiremock/preloadInformationRequest.json
deleted file mode 100644
index 82df627b..00000000
--- a/data-migrator/src/test/resources/wiremock/preloadInformationRequest.json
+++ /dev/null
@@ -1 +0,0 @@
-{"preload-information":{"preload-list":[{"preload-type":"vnf-type","preload-id":"vnf-name","preload-data":{"preload-oper-status":{"modify-timestamp":"Some modify-timestamp","create-timestamp":"Some create-timestamp","last-order-status":"Active","order-status":"Active","maintenance-indicator":"Y","last-svc-request-id":"Some last-svc-request-id"},"preload-network-topology-information":{"is-provider-network":true,"network-topology-identifier-structure":{"network-role":"Some network-role","network-technology":"Some network-technology","network-type":"Some network-type","network-name":"Some network-name"},"route-table-reference":[{"route-table-reference-fqdn":"Some route-table-reference-fqdn","route-table-reference-id":"Some route-table-reference-id"}],"network-policy":[{"network-policy-fqdn":"Some network-policy-fqdn","network-policy-id":"Some network-policy-id"}],"subnets":[{"start-address":"1.1.11.2","gateway-address":"8.0.25.2","cidr-mask":"Some cidr-mask","dhcp-end-address":"Some dhcp-end-address","subnet-name":"Some subnet-name","dhcp-start-address":"Some dhcp-start-address","ip-version":"Some ip-version","dhcp-enabled":"Y"}],"vpn-bindings":[{"vpn-binding-id":"Some vpn-binding-id","global-route-target":"Some global-route-target"}],"is-external-network":true,"is-shared-network":true,"physical-network-name":"Some physical-network-name"}}}]}} \ No newline at end of file
diff --git a/data-migrator/src/test/resources/wiremock/preloadVnfResponse.json b/data-migrator/src/test/resources/wiremock/preloadVnfResponse.json
deleted file mode 100644
index 006d62f7..00000000
--- a/data-migrator/src/test/resources/wiremock/preloadVnfResponse.json
+++ /dev/null
@@ -1,132 +0,0 @@
-{
- "preload-vnfs": {
- "vnf-preload-list": [
- {
- "vnf-type": "vnf-type",
- "vnf-name": "vnf-name",
- "preload-data": {
- "oper-status": {
- "last-action": "VNFActivateRequest",
- "modify-timestamp": "Some modify-timestamp",
- "create-timestamp": "Some create-timestamp",
- "last-order-status": "Active",
- "order-status": "Active",
- "maintenance-indicator": "Y",
- "last-svc-request-id": "Some last-svc-request-id"
- },
- "vnf-topology-information": {
- "vnf-topology-identifier": {
- "service-type": "Some service-type",
- "service-id": "Some service-id",
- "generic-vnf-name": "Some generic-vnf-name",
- "generic-vnf-id": "Some generic-vnf-id",
- "generic-vnf-type": "Some generic-vnf-type",
- "vnf-type": "vnf-type",
- "vnf-name": "vnf-name"
- },
- "vnf-parameters": [
- {
- "vnf-parameter-name": "Some vnf-parameter-name",
- "vnf-parameter-value": "Some vnf-parameter-value"
- }
- ],
- "vnf-assignments": {
- "vnf-vms": [
- {
- "vm-type": "Some vm-type",
- "vm-count": 0,
- "vm-names": [
- {"vm-name": "Some vm-name"}
- ],
- "vm-networks": [
- {
- "network-role": "Some network-role",
- "use-dhcp": "Y",
- "floating-ip": "2.12.250.0",
- "network-macs": [
- {"mac-address": "Some mac-address"}
- ],
- "network-ips": [
- {"ip-address": "13.2.219.8"}
- ],
- "interface-route-prefixes": [
- {
- "interface-route-prefix-cidr": "Some interface-route-prefix-cidr",
- "interface-route-prefix": "24.0.45.1"
- }
- ],
- "ip-count": 0
- }
- ]
- }
- ],
- "vnf-status": "Some vnf-status",
- "vnf-networks": [
- {
- "network-role": "Some network-role",
- "network-id": "Some network-id",
- "ipv6-subnet-id": "Some ipv6-subnet-id",
- "ipv6-subnet-name": "Some ipv6-subnet-name",
- "subnet-name": "Some subnet-name",
- "contrail-network-fqdn": "Some contrail-network-fqdn",
- "subnet-id": "Some subnet-id",
- "sriov-vlan-filter-list": [
- {"sriov-vlan-filter": "Some sriov-vlan-filter"}
- ],
- "network-name": "Some network-name",
- "neutron-id": "Some neutron-id"
- }
- ],
- "availability-zones": [
- {"availability-zone": "Some availability-zone"}
- ]
- }
- },
- "network-topology-information": {
- "is-provider-network": true,
- "network-topology-identifier": {
- "service-type": "Some service-type",
- "network-role": "Some network-role",
- "network-technology": "Some network-technology",
- "network-type": "Some network-type",
- "network-name": "Some network-name"
- },
- "route-table-reference": [
- {
- "route-table-reference-fqdn": "Some route-table-reference-fqdn",
- "route-table-reference-id": "Some route-table-reference-id"
- }
- ],
- "network-policy": [
- {
- "network-policy-fqdn": "Some network-policy-fqdn",
- "network-policy-id": "Some network-policy-id"
- }
- ],
- "subnets": [
- {
- "start-address": "1.1.11.2",
- "gateway-address": "8.0.25.2",
- "cidr-mask": "Some cidr-mask",
- "dhcp-end-address": "Some dhcp-end-address",
- "subnet-name": "Some subnet-name",
- "dhcp-start-address": "Some dhcp-start-address",
- "ip-version": "Some ip-version",
- "dhcp-enabled": "Y"
- }
- ],
- "vpn-bindings": [
- {
- "vpn-binding-id": "Some vpn-binding-id",
- "global-route-target": "Some global-route-target"
- }
- ],
- "is-external-network": true,
- "is-shared-network": true,
- "physical-network-name": "Some physical-network-name"
- }
- }
- }
- ]
- }
-} \ No newline at end of file
diff --git a/installation/sdnc/pom.xml b/installation/sdnc/pom.xml
index 11118491..81ea8bd3 100644
--- a/installation/sdnc/pom.xml
+++ b/installation/sdnc/pom.xml
@@ -388,24 +388,6 @@
</artifactItems>
</configuration>
</execution>
- <execution>
- <id>unpack-data-migrator</id>
- <phase>generate-sources</phase>
- <goals>
- <goal>unpack</goal>
- </goals>
- <configuration>
- <outputDirectory>${basedir}/target/docker-stage/opt/onap/sdnc/data-migrator</outputDirectory>
- <artifactItems>
- <artifactItem>
- <groupId>org.onap.sdnc.oam</groupId>
- <artifactId>data-migrator</artifactId>
- <version>${project.version}</version>
- <type>zip</type>
- </artifactItem>
- </artifactItems>
- </configuration>
- </execution>
</executions>
</plugin>
<plugin>
diff --git a/pom.xml b/pom.xml
index dcb6064d..b22b5f8b 100755
--- a/pom.xml
+++ b/pom.xml
@@ -40,7 +40,6 @@
<modules>
<module>platform-logic</module>
- <module>data-migrator</module>
</modules>
<scm>