aboutsummaryrefslogtreecommitdiffstats
path: root/aai-resources/src/main
diff options
context:
space:
mode:
authorVenkata Harish K Kajur <vk250x@att.com>2018-01-18 02:25:31 -0500
committerVenkata Harish K Kajur <vk250x@att.com>2018-02-12 15:44:18 -0500
commit4c4412642e40a92bebd26f2966bc72619e16ae79 (patch)
treea9c0c08aa8dd2de651cdaad684155ec4962dd3eb /aai-resources/src/main
parent9c04bb4a324af0857dacc65880c3540dc18d5b89 (diff)
Sync up the latest logging code changes
Issue-ID: AAI-493 Change-Id: I778acf7726b1f9881dee62b128b1fbc457bf7a7e Signed-off-by: Venkata Harish K Kajur <vk250x@att.com>
Diffstat (limited to 'aai-resources/src/main')
-rw-r--r--aai-resources/src/main/config/caet.properties0
-rw-r--r--aai-resources/src/main/config/logback-migration.xml56
-rw-r--r--aai-resources/src/main/java/org/onap/aai/dbgen/DataSnapshot.java34
-rw-r--r--aai-resources/src/main/java/org/onap/aai/dbgen/ForceDeleteTool.java80
-rw-r--r--aai-resources/src/main/java/org/onap/aai/dbgen/UpdateEdgeTags.java36
-rw-r--r--aai-resources/src/main/java/org/onap/aai/interceptors/PostAaiAjscInterceptor.java13
-rw-r--r--aai-resources/src/main/java/org/onap/aai/interceptors/PreAaiAjscInterceptor.java14
-rw-r--r--aai-resources/src/main/java/org/onap/aai/migration/EdgeMigrator.java21
-rw-r--r--aai-resources/src/main/java/org/onap/aai/migration/MigrationController.java21
-rw-r--r--aai-resources/src/main/java/org/onap/aai/migration/MigrationControllerInternal.java273
-rw-r--r--aai-resources/src/main/java/org/onap/aai/migration/MigrationDangerRating.java (renamed from aai-resources/src/main/java/org/onap/aai/rest/util/LogFormatTools.java)43
-rw-r--r--aai-resources/src/main/java/org/onap/aai/migration/MigrationPriority.java42
-rw-r--r--aai-resources/src/main/java/org/onap/aai/migration/Migrator.java68
-rw-r--r--aai-resources/src/main/java/org/onap/aai/migration/PropertyMigrator.java22
-rw-r--r--aai-resources/src/main/java/org/onap/aai/migration/v12/ContainmentDeleteOtherVPropertyMigration.java105
-rw-r--r--aai-resources/src/main/java/org/onap/aai/migration/v12/EdgeReportForToscaMigration.java142
-rw-r--r--aai-resources/src/main/java/org/onap/aai/migration/v12/MigrateDataFromASDCToConfiguration.java107
-rw-r--r--aai-resources/src/main/java/org/onap/aai/migration/v12/MigrateServiceInstanceToConfiguration.java171
-rw-r--r--aai-resources/src/main/java/org/onap/aai/migration/v12/ToscaMigration.java160
-rw-r--r--aai-resources/src/main/java/org/onap/aai/rest/BulkConsumer.java42
-rw-r--r--aai-resources/src/main/java/org/onap/aai/rest/BulkProcessConsumer.java2
-rw-r--r--aai-resources/src/main/java/org/onap/aai/rest/ExampleConsumer.java2
-rw-r--r--aai-resources/src/main/java/org/onap/aai/rest/LegacyMoxyConsumer.java149
-rw-r--r--aai-resources/src/main/java/org/onap/aai/rest/URLFromVertexIdConsumer.java11
-rw-r--r--aai-resources/src/main/java/org/onap/aai/rest/VertexIdConsumer.java2
-rw-r--r--aai-resources/src/main/java/org/onap/aai/rest/tools/ModelVersionTransformer.java13
-rw-r--r--aai-resources/src/main/java/org/onap/aai/util/AAIAppServletContextListener.java56
-rw-r--r--aai-resources/src/main/resources/edgeLabelMigration.csv212
-rw-r--r--aai-resources/src/main/scripts/createDBSchema.sh3
-rw-r--r--aai-resources/src/main/scripts/dynamicPayloadArchive.sh63
-rw-r--r--aai-resources/src/main/scripts/dynamicPayloadGenerator.sh101
-rw-r--r--aai-resources/src/main/scripts/forceDeleteTool.sh1
-rw-r--r--aai-resources/src/main/scripts/install/addManualData.sh131
-rw-r--r--aai-resources/src/main/scripts/putTool.sh27
-rw-r--r--aai-resources/src/main/scripts/run_Migrations.sh76
-rw-r--r--aai-resources/src/main/scripts/updateTool.sh24
36 files changed, 1986 insertions, 337 deletions
diff --git a/aai-resources/src/main/config/caet.properties b/aai-resources/src/main/config/caet.properties
deleted file mode 100644
index e69de29..0000000
--- a/aai-resources/src/main/config/caet.properties
+++ /dev/null
diff --git a/aai-resources/src/main/config/logback-migration.xml b/aai-resources/src/main/config/logback-migration.xml
new file mode 100644
index 0000000..88ade33
--- /dev/null
+++ b/aai-resources/src/main/config/logback-migration.xml
@@ -0,0 +1,56 @@
+<!--
+ ============LICENSE_START=======================================================
+ org.onap.aai
+ ================================================================================
+ Copyright (C) 2017 AT&T 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=========================================================
+ -->
+
+<configuration>
+ <appender name="MIGRATION_FILE_LOG"
+ class="ch.qos.logback.core.FileAppender">
+ <append>true</append>
+ <file>logs/migrationAic3.log</file>
+ <encoder class="org.onap.aai.logging.CustomLogPatternLayoutEncoder">
+ <Pattern>%a %u %z [%t] "%m %U" %s %b</Pattern>
+ </encoder>
+ </appender>
+ <root level="DEBUG">
+ <appender-ref ref="MIGRATION_FILE_LOG" />
+ </root>
+</configuration>
+
+<!--
+%a - Remote IP address
+%A - Local IP address
+%b - Bytes sent, excluding HTTP headers, or '-' if no bytes were sent
+%B - Bytes sent, excluding HTTP headers
+%h - Remote host name
+%H - Request protocol
+%l - Remote logical username from identd (always returns '-')
+%m - Request method
+%p - Local port
+%q - Query string (prepended with a '?' if it exists, otherwise an empty string
+%r - First line of the request
+%s - HTTP status code of the response
+%S - User session ID
+%t - Date and time, in Common Log Format format
+%u - Remote user that was authenticated
+%U - Requested URL path
+%v - Local server name
+%I - current request thread name (can compare later with stacktraces)
+
+%z - Custom pattern that parses the cert for the subject
+ -->
diff --git a/aai-resources/src/main/java/org/onap/aai/dbgen/DataSnapshot.java b/aai-resources/src/main/java/org/onap/aai/dbgen/DataSnapshot.java
index 01c6185..993b72f 100644
--- a/aai-resources/src/main/java/org/onap/aai/dbgen/DataSnapshot.java
+++ b/aai-resources/src/main/java/org/onap/aai/dbgen/DataSnapshot.java
@@ -35,6 +35,7 @@ import org.onap.aai.exceptions.AAIException;
import org.onap.aai.logging.ErrorLogHelper;
import org.onap.aai.util.AAIConfig;
import org.onap.aai.util.AAIConstants;
+import org.onap.aai.util.AAISystemExitUtil;
import org.onap.aai.util.FormatDate;
import com.att.eelf.configuration.Configuration;
@@ -54,6 +55,7 @@ public class DataSnapshot {
*/
public static void main(String[] args) {
// Set the logging file properties to be used by EELFManager
+ System.setProperty("aai.service.name", DataSnapshot.class.getSimpleName());
Properties props = System.getProperties();
props.setProperty(Configuration.PROPERTY_LOGGING_FILE_NAME, AAIConstants.AAI_DATA_SNAPSHOT_LOGBACK_PROPS);
props.setProperty(Configuration.PROPERTY_LOGGING_FILE_PATH, AAIConstants.AAI_HOME_ETC_APP_PROPERTIES);
@@ -90,7 +92,7 @@ public class DataSnapshot {
if (graph == null) {
String emsg = "Not able to get a graph object in DataSnapshot.java\n";
System.out.println(emsg);
- System.exit(1);
+ AAISystemExitUtil.systemExitCloseAAIGraph(1);
}
if (command.equals("JUST_TAKE_SNAPSHOT")) {
@@ -123,22 +125,22 @@ public class DataSnapshot {
if (oldSnapshotFileName.equals("")) {
String emsg = "No oldSnapshotFileName passed to DataSnapshot.";
System.out.println(emsg);
- System.exit(1);
+ AAISystemExitUtil.systemExitCloseAAIGraph(1);
}
String oldSnapshotFullFname = targetDir + AAIConstants.AAI_FILESEP + oldSnapshotFileName;
File f = new File(oldSnapshotFullFname);
if (!f.exists()) {
String emsg = "oldSnapshotFile " + oldSnapshotFullFname + " could not be found.";
System.out.println(emsg);
- System.exit(1);
+ AAISystemExitUtil.systemExitCloseAAIGraph(1);
} else if (!f.canRead()) {
String emsg = "oldSnapshotFile " + oldSnapshotFullFname + " could not be read.";
System.out.println(emsg);
- System.exit(1);
+ AAISystemExitUtil.systemExitCloseAAIGraph(1);
} else if (f.length() == 0) {
String emsg = "oldSnapshotFile " + oldSnapshotFullFname + " had no data.";
System.out.println(emsg);
- System.exit(1);
+ AAISystemExitUtil.systemExitCloseAAIGraph(1);
}
System.out.println("\n>>> WARNING <<<< ");
@@ -151,7 +153,7 @@ public class DataSnapshot {
Thread.sleep(5000);
} catch (java.lang.InterruptedException ie) {
System.out.println(" DB Clearing has been aborted. ");
- System.exit(1);
+ AAISystemExitUtil.systemExitCloseAAIGraph(1);
}
System.out.println(" Begin clearing out old data. ");
@@ -169,22 +171,22 @@ public class DataSnapshot {
if (oldSnapshotFileName.equals("")) {
String emsg = "No oldSnapshotFileName passed to DataSnapshot when RELOAD_LEGACY_DATA used.";
System.out.println(emsg);
- System.exit(1);
+ AAISystemExitUtil.systemExitCloseAAIGraph(1);
}
String oldSnapshotFullFname = targetDir + AAIConstants.AAI_FILESEP + oldSnapshotFileName;
File f = new File(oldSnapshotFullFname);
if (!f.exists()) {
String emsg = "oldSnapshotFile " + oldSnapshotFullFname + " could not be found.";
System.out.println(emsg);
- System.exit(1);
+ AAISystemExitUtil.systemExitCloseAAIGraph(1);
} else if (!f.canRead()) {
String emsg = "oldSnapshotFile " + oldSnapshotFullFname + " could not be read.";
System.out.println(emsg);
- System.exit(1);
+ AAISystemExitUtil.systemExitCloseAAIGraph(1);
} else if (f.length() == 0) {
String emsg = "oldSnapshotFile " + oldSnapshotFullFname + " had no data.";
System.out.println(emsg);
- System.exit(1);
+ AAISystemExitUtil.systemExitCloseAAIGraph(1);
}
System.out.println("We will load data IN from the file = " + oldSnapshotFullFname);
@@ -207,22 +209,22 @@ public class DataSnapshot {
if (oldSnapshotFileName.equals("")) {
String emsg = "No oldSnapshotFileName passed to DataSnapshot when RELOAD_DATA used.";
System.out.println(emsg);
- System.exit(1);
+ AAISystemExitUtil.systemExitCloseAAIGraph(1);
}
String oldSnapshotFullFname = targetDir + AAIConstants.AAI_FILESEP + oldSnapshotFileName;
File f = new File(oldSnapshotFullFname);
if (!f.exists()) {
String emsg = "oldSnapshotFile " + oldSnapshotFullFname + " could not be found.";
System.out.println(emsg);
- System.exit(1);
+ AAISystemExitUtil.systemExitCloseAAIGraph(1);
} else if (!f.canRead()) {
String emsg = "oldSnapshotFile " + oldSnapshotFullFname + " could not be read.";
System.out.println(emsg);
- System.exit(1);
+ AAISystemExitUtil.systemExitCloseAAIGraph(1);
} else if (f.length() == 0) {
String emsg = "oldSnapshotFile " + oldSnapshotFullFname + " had no data.";
System.out.println(emsg);
- System.exit(1);
+ AAISystemExitUtil.systemExitCloseAAIGraph(1);
}
System.out.println("We will load data IN from the file = " + oldSnapshotFullFname);
@@ -238,7 +240,7 @@ public class DataSnapshot {
} else {
String emsg = "Bad command passed to DataSnapshot: [" + command + "]";
System.out.println(emsg);
- System.exit(1);
+ AAISystemExitUtil.systemExitCloseAAIGraph(1);
}
} catch (AAIException e) {
@@ -260,7 +262,7 @@ public class DataSnapshot {
}
}
- System.exit(0);
+ AAISystemExitUtil.systemExitCloseAAIGraph(0);
}// End of main()
diff --git a/aai-resources/src/main/java/org/onap/aai/dbgen/ForceDeleteTool.java b/aai-resources/src/main/java/org/onap/aai/dbgen/ForceDeleteTool.java
index 56af86f..9a7fc39 100644
--- a/aai-resources/src/main/java/org/onap/aai/dbgen/ForceDeleteTool.java
+++ b/aai-resources/src/main/java/org/onap/aai/dbgen/ForceDeleteTool.java
@@ -24,6 +24,7 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.Properties;
import java.util.Scanner;
+import java.util.UUID;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
@@ -31,7 +32,10 @@ import org.apache.tinkerpop.gremlin.structure.Direction;
import org.apache.tinkerpop.gremlin.structure.Edge;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.apache.tinkerpop.gremlin.structure.VertexProperty;
+import org.onap.aai.dbmap.AAIGraphConfig;
import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.logging.LoggingContext;
+import org.onap.aai.logging.LoggingContext.StatusCode;
import org.onap.aai.serialization.db.AAIDirection;
import org.onap.aai.serialization.db.EdgeProperty;
import org.onap.aai.util.AAIConfig;
@@ -47,6 +51,8 @@ import com.thinkaurelius.titan.core.TitanGraph;
public class ForceDeleteTool {
+ private static final String FROMAPPID = "AAI-DB";
+ private static final String TRANSID = UUID.randomUUID().toString();
/*
* The main method.
*
@@ -56,6 +62,7 @@ public class ForceDeleteTool {
//SWGK 01/21/2016 - To suppress the warning message when the tool is run from the Terminal.
+ System.setProperty("aai.service.name", ForceDelete.class.getSimpleName());
// Set the logging file properties to be used by EELFManager
Properties props = System.getProperties();
props.setProperty(Configuration.PROPERTY_LOGGING_FILE_NAME, "forceDelete-logback.xml");
@@ -63,6 +70,16 @@ public class ForceDeleteTool {
EELFLogger logger = EELFManager.getInstance().getLogger(ForceDeleteTool.class.getSimpleName());
MDC.put("logFilenameAppender", ForceDeleteTool.class.getSimpleName());
+ LoggingContext.init();
+ LoggingContext.partnerName(FROMAPPID);
+ LoggingContext.serviceName(AAIConstants.AAI_RESOURCES_MS);
+ LoggingContext.component("forceDeleteTool");
+ LoggingContext.targetEntity(AAIConstants.AAI_RESOURCES_MS);
+ LoggingContext.targetServiceName("main");
+ LoggingContext.requestId(TRANSID);
+ LoggingContext.statusCode(StatusCode.COMPLETE);
+ LoggingContext.responseCode(LoggingContext.SUCCESS);
+
String actionVal = "";
String userIdVal = "";
String dataString = "";
@@ -81,6 +98,8 @@ public class ForceDeleteTool {
if (thisArg.equals("-action")) {
i++;
if (i >= args.length) {
+ LoggingContext.statusCode(StatusCode.ERROR);
+ LoggingContext.responseCode(LoggingContext.BUSINESS_PROCESS_ERROR);
logger.error(" No value passed with -action option. ");
System.exit(0);
}
@@ -90,6 +109,8 @@ public class ForceDeleteTool {
else if (thisArg.equals("-userId")) {
i++;
if (i >= args.length) {
+ LoggingContext.statusCode(StatusCode.ERROR);
+ LoggingContext.responseCode(LoggingContext.BUSINESS_PROCESS_ERROR);
logger.error(" No value passed with -userId option. ");
System.exit(0);
}
@@ -105,6 +126,8 @@ public class ForceDeleteTool {
else if (thisArg.equals("-vertexId")) {
i++;
if (i >= args.length) {
+ LoggingContext.statusCode(StatusCode.ERROR);
+ LoggingContext.responseCode(LoggingContext.BUSINESS_PROCESS_ERROR);
logger.error(" No value passed with -vertexId option. ");
System.exit(0);
}
@@ -113,6 +136,8 @@ public class ForceDeleteTool {
try {
vertexIdLong = Long.parseLong(nextArg);
} catch (Exception e) {
+ LoggingContext.statusCode(StatusCode.ERROR);
+ LoggingContext.responseCode(LoggingContext.BUSINESS_PROCESS_ERROR);
logger.error("Bad value passed with -vertexId option: ["
+ nextArg + "]");
System.exit(0);
@@ -121,6 +146,8 @@ public class ForceDeleteTool {
else if (thisArg.equals("-params4Collect")) {
i++;
if (i >= args.length) {
+ LoggingContext.statusCode(StatusCode.ERROR);
+ LoggingContext.responseCode(LoggingContext.BUSINESS_PROCESS_ERROR);
logger.error(" No value passed with -params4Collect option. ");
System.exit(0);
}
@@ -130,6 +157,8 @@ public class ForceDeleteTool {
else if (thisArg.equals("-edgeId")) {
i++;
if (i >= args.length) {
+ LoggingContext.statusCode(StatusCode.ERROR);
+ LoggingContext.responseCode(LoggingContext.BUSINESS_PROCESS_ERROR);
logger.error(" No value passed with -edgeId option. ");
System.exit(0);
}
@@ -138,6 +167,8 @@ public class ForceDeleteTool {
edgeIdStr = nextArg;
}
else {
+ LoggingContext.statusCode(StatusCode.ERROR);
+ LoggingContext.responseCode(LoggingContext.BUSINESS_PROCESS_ERROR);
logger.error(" Unrecognized argument passed to ForceDeleteTool: ["
+ thisArg + "]. ");
logger.error(" Valid values are: -action -userId -vertexId -edgeId -overRideProtection -params4Collect -DISPLAY_ALL_VIDS");
@@ -149,6 +180,8 @@ public class ForceDeleteTool {
if( !actionVal.equals("COLLECT_DATA") && !actionVal.equals("DELETE_NODE") && !actionVal.equals("DELETE_EDGE")){
String emsg = "Bad action parameter [" + actionVal + "] passed to ForceDeleteTool(). Valid values = COLLECT_DATA or DELETE_NODE or DELETE_EDGE\n";
System.out.println(emsg);
+ LoggingContext.statusCode(StatusCode.ERROR);
+ LoggingContext.responseCode(LoggingContext.BUSINESS_PROCESS_ERROR);
logger.error(emsg);
System.exit(0);
}
@@ -156,12 +189,16 @@ public class ForceDeleteTool {
if( actionVal.equals("DELETE_NODE") && vertexIdLong == 0 ){
String emsg = "ERROR: No vertex ID passed on DELETE_NODE request. \n";
System.out.println(emsg);
+ LoggingContext.statusCode(StatusCode.ERROR);
+ LoggingContext.responseCode(LoggingContext.BUSINESS_PROCESS_ERROR);
logger.error(emsg);
System.exit(0);
}
else if( actionVal.equals("DELETE_EDGE") && edgeIdStr.equals("")){
String emsg = "ERROR: No edge ID passed on DELETE_EDGE request. \n";
System.out.println(emsg);
+ LoggingContext.statusCode(StatusCode.ERROR);
+ LoggingContext.responseCode(LoggingContext.BUSINESS_PROCESS_ERROR);
logger.error(emsg);
System.exit(0);
}
@@ -171,6 +208,8 @@ public class ForceDeleteTool {
if( (userIdVal.length() < 6) || userIdVal.toUpperCase().equals("AAIADMIN") ){
String emsg = "Bad userId parameter [" + userIdVal + "] passed to ForceDeleteTool(). must be not empty and not aaiadmin \n";
System.out.println(emsg);
+ LoggingContext.statusCode(StatusCode.ERROR);
+ LoggingContext.responseCode(LoggingContext.BUSINESS_PROCESS_ERROR);
logger.error(emsg);
System.exit(0);
}
@@ -180,10 +219,12 @@ public class ForceDeleteTool {
try {
AAIConfig.init();
System.out.println(" ---- NOTE --- about to open graph (takes a little while)--------\n");
- graph = TitanFactory.open(AAIConstants.REALTIME_DB_CONFIG);
+ graph = TitanFactory.open(new AAIGraphConfig.Builder(AAIConstants.REALTIME_DB_CONFIG).forService(ForceDelete.class.getSimpleName()).withGraphType("realtime1").buildConfiguration());
if( graph == null ){
String emsg = "could not get graph object in ForceDeleteTool() \n";
System.out.println(emsg);
+ LoggingContext.statusCode(StatusCode.ERROR);
+ LoggingContext.responseCode(LoggingContext.AVAILABILITY_TIMEOUT_ERROR);
logger.error(emsg);
System.exit(0);
}
@@ -191,12 +232,16 @@ public class ForceDeleteTool {
catch (AAIException e1) {
msg = e1.getErrorObject().toString();
System.out.println(msg);
+ LoggingContext.statusCode(StatusCode.ERROR);
+ LoggingContext.responseCode(LoggingContext.UNKNOWN_ERROR);
logger.error(msg);
System.exit(0);
- }
+ }
catch (Exception e2) {
msg = e2.toString();
System.out.println(msg);
+ LoggingContext.statusCode(StatusCode.ERROR);
+ LoggingContext.responseCode(LoggingContext.UNKNOWN_ERROR);
logger.error(msg);
System.exit(0);
}
@@ -217,6 +262,8 @@ public class ForceDeleteTool {
if( firstPipeLoc <= 0 ){
msg = "Must use the -params4Collect option when collecting data with data string in a format like: 'propName1|propVal1,propName2|propVal2'";
System.out.println(msg);
+ LoggingContext.statusCode(StatusCode.ERROR);
+ LoggingContext.responseCode(LoggingContext.BUSINESS_PROCESS_ERROR);
logger.error(msg);
System.exit(0);
}
@@ -229,6 +276,8 @@ public class ForceDeleteTool {
if( pipeLoc <= 0 ){
msg = "Must use the -params4Collect option when collecting data with data string in a format like: 'propName1|propVal1,propName2|propVal2'";
System.out.println(msg);
+ LoggingContext.statusCode(StatusCode.ERROR);
+ LoggingContext.responseCode(LoggingContext.BUSINESS_PROCESS_ERROR);
logger.error(msg);
System.exit(0);
}
@@ -239,7 +288,7 @@ public class ForceDeleteTool {
qStringForMsg = qStringForMsg + ".has(" + propName + "," + propVal + ")";
}
}
- if(g != null){
+ if( (g != null)){
Iterator<Vertex> vertItor = g;
while( vertItor.hasNext() ){
resCount++;
@@ -254,6 +303,8 @@ public class ForceDeleteTool {
else {
msg = "Bad TitanGraphQuery object. ";
System.out.println(msg);
+ LoggingContext.statusCode(StatusCode.ERROR);
+ LoggingContext.responseCode(LoggingContext.DATA_ERROR);
logger.error(msg);
System.exit(0);
}
@@ -339,7 +390,7 @@ public class ForceDeleteTool {
public static class ForceDelete {
- private static final int MAXDESCENDENTDEPTH = 15;
+ private final int MAXDESCENDENTDEPTH = 15;
private final TitanGraph graph;
public ForceDelete(TitanGraph graph) {
this.graph = graph;
@@ -367,7 +418,10 @@ public class ForceDeleteTool {
catch (Exception e){
String warnMsg = " -- Error -- trying to display edge info. [" + e.getMessage() + "]";
System.out.println( warnMsg );
+ LoggingContext.statusCode(StatusCode.ERROR);
+ LoggingContext.responseCode(LoggingContext.DATA_ERROR);
logger.warn(warnMsg);
+ LoggingContext.successStatusFields();
}
}// End of showNodeInfo()
@@ -519,7 +573,10 @@ public class ForceDeleteTool {
catch (Exception e) {
String wMsg = "-- ERROR -- Stopping the counting of edges because of Exception [" + e.getMessage() + "]";
System.out.println( wMsg );
+ LoggingContext.statusCode(StatusCode.ERROR);
+ LoggingContext.responseCode(LoggingContext.DATA_ERROR);
logger.warn( wMsg );
+ LoggingContext.successStatusFields();
}
return edgeCount;
@@ -533,6 +590,8 @@ public class ForceDeleteTool {
if( thisLevel > MAXDESCENDENTDEPTH ){
String wMsg = "Warning -- Stopping the counting of descendents because we reached the max depth of " + MAXDESCENDENTDEPTH;
System.out.println( wMsg );
+ LoggingContext.statusCode(StatusCode.ERROR);
+ LoggingContext.responseCode(LoggingContext.DATA_ERROR);
logger.warn( wMsg );
return totalCount;
}
@@ -548,7 +607,11 @@ public class ForceDeleteTool {
catch (Exception e) {
String wMsg = "Error -- Stopping the counting of descendents because of Exception [" + e.getMessage() + "]";
System.out.println( wMsg );
+ LoggingContext.statusCode(StatusCode.ERROR);
+ LoggingContext.responseCode(LoggingContext.DATA_ERROR);
logger.warn( wMsg );
+ LoggingContext.successStatusFields();
+
}
return totalCount;
@@ -591,7 +654,10 @@ public class ForceDeleteTool {
// Let the user know something is going on - but they can confirm the delete if they want to.
String infMsg = " -- WARNING -- could not get an aai-node-type for this vertex. -- WARNING -- ";
System.out.println( infMsg );
+ LoggingContext.statusCode(StatusCode.ERROR);
+ LoggingContext.responseCode(LoggingContext.DATA_ERROR);
logger.warn( infMsg );
+ LoggingContext.successStatusFields();
}
String ntListString = "";
@@ -612,7 +678,10 @@ public class ForceDeleteTool {
// Don't worry, we will use default values
String infMsg = "-- WARNING -- could not get aai.forceDel.protected values from aaiconfig.properties -- will use default values. ";
System.out.println( infMsg );
+ LoggingContext.statusCode(StatusCode.ERROR);
+ LoggingContext.responseCode(LoggingContext.DATA_ERROR);
logger.warn( infMsg );
+ LoggingContext.successStatusFields();
}
if( maxDescString != null && !maxDescString.equals("") ){
@@ -695,7 +764,10 @@ public class ForceDeleteTool {
else if( giveProtErrorMsg ) {
String errMsg = " ERROR >> this kind of node can only be deleted if you pass the overRideProtection parameter.";
System.out.println("\n" + errMsg);
+ LoggingContext.statusCode(StatusCode.ERROR);
+ LoggingContext.responseCode(LoggingContext.BUSINESS_PROCESS_ERROR);
logger.error(errMsg);
+ LoggingContext.successStatusFields();
return false;
}
diff --git a/aai-resources/src/main/java/org/onap/aai/dbgen/UpdateEdgeTags.java b/aai-resources/src/main/java/org/onap/aai/dbgen/UpdateEdgeTags.java
index 9fbed5d..e17e1f3 100644
--- a/aai-resources/src/main/java/org/onap/aai/dbgen/UpdateEdgeTags.java
+++ b/aai-resources/src/main/java/org/onap/aai/dbgen/UpdateEdgeTags.java
@@ -29,9 +29,13 @@ import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.onap.aai.dbmap.AAIGraph;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.logging.ErrorLogHelper;
+import org.onap.aai.logging.LoggingContext;
+import org.onap.aai.logging.LoggingContext.StatusCode;
import org.onap.aai.serialization.db.EdgeRule;
import org.onap.aai.serialization.db.EdgeRules;
import org.onap.aai.util.AAIConfig;
+import org.onap.aai.util.AAISystemExitUtil;
+import org.onap.aai.util.AAIConstants;
import java.util.*;
@@ -47,12 +51,24 @@ public class UpdateEdgeTags {
* @param args the arguments
*/
public static void main(String[] args) {
-
- if( args == null || args.length != 1 ){
+
+ System.setProperty("aai.service.name", UpdateEdgeTags.class.getSimpleName());
+
+ if( args == null || args.length != 1 ){
String msg = "usage: UpdateEdgeTags edgeRuleKey (edgeRuleKey can be either, all, or a rule key like 'nodeTypeA|nodeTypeB') \n";
System.out.println(msg);
- System.exit(1);
+ AAISystemExitUtil.systemExitCloseAAIGraph(1);
}
+ LoggingContext.init();
+ LoggingContext.partnerName(FROMAPPID);
+ LoggingContext.serviceName(AAIConstants.AAI_RESOURCES_MS);
+ LoggingContext.component("updateEdgeTags");
+ LoggingContext.targetEntity(AAIConstants.AAI_RESOURCES_MS);
+ LoggingContext.targetServiceName("main");
+ LoggingContext.requestId(TRANSID);
+ LoggingContext.statusCode(StatusCode.COMPLETE);
+ LoggingContext.responseCode("0");
+
String edgeRuleKeyVal = args[0];
TitanGraph graph = null;
@@ -112,7 +128,7 @@ public class UpdateEdgeTags {
else {
String msg = " Error - Unrecognized edgeRuleKey: [" + edgeRuleKeyVal + "]. ";
System.out.println(msg);
- System.exit(0);
+ AAISystemExitUtil.systemExitCloseAAIGraph(0);
}
}
else {
@@ -130,19 +146,19 @@ public class UpdateEdgeTags {
if( graph == null ){
String emsg = "null graph object in updateEdgeTags() \n";
System.out.println(emsg);
- System.exit(0);
+ AAISystemExitUtil.systemExitCloseAAIGraph(0);
}
}
catch (AAIException e1) {
String msg = e1.getErrorObject().toString();
System.out.println(msg);
- System.exit(0);
+ AAISystemExitUtil.systemExitCloseAAIGraph(0);
}
catch (Exception e2) {
String msg = e2.toString();
System.out.println(msg);
e2.printStackTrace();
- System.exit(0);
+ AAISystemExitUtil.systemExitCloseAAIGraph(0);
}
Graph g = graph.newTransaction();
@@ -231,10 +247,10 @@ public class UpdateEdgeTags {
if( graph != null ){
graph.tx().rollback();
}
- System.exit(0);
+ AAISystemExitUtil.systemExitCloseAAIGraph(0);
}
- System.exit(0);
+ AAISystemExitUtil.systemExitCloseAAIGraph(0);
}// end of main()
@@ -303,8 +319,6 @@ public class UpdateEdgeTags {
} // End of getEdgeTagPropPutHash()
-
-
}
diff --git a/aai-resources/src/main/java/org/onap/aai/interceptors/PostAaiAjscInterceptor.java b/aai-resources/src/main/java/org/onap/aai/interceptors/PostAaiAjscInterceptor.java
index 30382e4..2a34774 100644
--- a/aai-resources/src/main/java/org/onap/aai/interceptors/PostAaiAjscInterceptor.java
+++ b/aai-resources/src/main/java/org/onap/aai/interceptors/PostAaiAjscInterceptor.java
@@ -48,16 +48,17 @@ public class PostAaiAjscInterceptor implements AjscInterceptor {
@Override
public boolean allowOrReject(HttpServletRequest req, HttpServletResponse resp, Map<?, ?> paramMap)
throws Exception {
- final String responseCode = LoggingContext.responseCode();
-
- if (responseCode != null && responseCode.startsWith("ERR.")) {
+
+ final int httpStatusCode = resp.getStatus();
+ LoggingContext.responseCode(Integer.toString(httpStatusCode));
+ if ( httpStatusCode < 200 || httpStatusCode > 299 ) {
LoggingContext.statusCode(StatusCode.ERROR);
- LOGGER.error(req.getRequestURL() + " call failed with responseCode=" + responseCode);
- } else {
+ LOGGER.error(req.getRequestURL() + " call failed with responseCode=" + httpStatusCode);
+ }
+ else {
LoggingContext.statusCode(StatusCode.COMPLETE);
LOGGER.info(req.getRequestURL() + " call succeeded");
}
-
LoggingContext.clear();
return true;
}
diff --git a/aai-resources/src/main/java/org/onap/aai/interceptors/PreAaiAjscInterceptor.java b/aai-resources/src/main/java/org/onap/aai/interceptors/PreAaiAjscInterceptor.java
index 7d1ae73..360ebe4 100644
--- a/aai-resources/src/main/java/org/onap/aai/interceptors/PreAaiAjscInterceptor.java
+++ b/aai-resources/src/main/java/org/onap/aai/interceptors/PreAaiAjscInterceptor.java
@@ -31,7 +31,7 @@ import org.onap.aai.logging.LoggingContext;
import ajsc.beans.interceptors.AjscInterceptor;
public class PreAaiAjscInterceptor implements AjscInterceptor {
-
+ private final static String TARGET_ENTITY = "aai-resources";
private static class LazyAaiAjscInterceptor {
public static final PreAaiAjscInterceptor INSTANCE = new PreAaiAjscInterceptor();
}
@@ -45,10 +45,16 @@ public class PreAaiAjscInterceptor implements AjscInterceptor {
throws Exception {
LoggingContext.init();
-
- LoggingContext.requestId(req.getHeader("X-TransactionId"));
+ String serviceName = req.getMethod() + " " + req.getRequestURI().toString();
+ String queryStr = req.getQueryString();
+ if ( queryStr != null ) {
+ serviceName = serviceName + "?" + queryStr;
+ }
LoggingContext.partnerName(req.getHeader("X-FromAppId"));
- LoggingContext.serviceName(req.getMethod() + " " + req.getRequestURI().toString());
+ LoggingContext.serviceName(serviceName);
+ LoggingContext.targetEntity(TARGET_ENTITY);
+ LoggingContext.targetServiceName(serviceName);
+ LoggingContext.requestId(req.getHeader("X-TransactionId"));
return true;
}
diff --git a/aai-resources/src/main/java/org/onap/aai/migration/EdgeMigrator.java b/aai-resources/src/main/java/org/onap/aai/migration/EdgeMigrator.java
index 4e2fde4..ed29c84 100644
--- a/aai-resources/src/main/java/org/onap/aai/migration/EdgeMigrator.java
+++ b/aai-resources/src/main/java/org/onap/aai/migration/EdgeMigrator.java
@@ -39,16 +39,13 @@ import org.onap.aai.serialization.db.EdgeRules;
* A migration template for migrating all edge properties between "from" and "to" node from the DbedgeRules.json
*
*/
+@MigrationPriority(0)
+@MigrationDangerRating(1)
public abstract class EdgeMigrator extends Migrator {
private boolean success = true;
private EdgeRules rules;
- public EdgeMigrator() {
- // used for not great reflection implementation
- super();
- }
-
public EdgeMigrator(TransactionalGraphEngine engine) {
super(engine);
rules = EdgeRules.getInstance();
@@ -140,20 +137,6 @@ public abstract class EdgeMigrator extends Migrator {
}
}
- @Override
- public int getPriority() {
- return 0;
- }
-
- /*
- * Higher danger rating of 10 only for all edge property changes
- * or when a quorum of edges change which can be overridden by inheritors
- */
- @Override
- public int getDangerRating() {
- return 1;
- }
-
/**
* List of node pairs("from" and "to"), you would like EdgeMigrator to migrate from json files
* @return
diff --git a/aai-resources/src/main/java/org/onap/aai/migration/MigrationController.java b/aai-resources/src/main/java/org/onap/aai/migration/MigrationController.java
index 93d58b3..6742c8a 100644
--- a/aai-resources/src/main/java/org/onap/aai/migration/MigrationController.java
+++ b/aai-resources/src/main/java/org/onap/aai/migration/MigrationController.java
@@ -21,10 +21,15 @@
*/
package org.onap.aai.migration;
+import java.util.UUID;
+
import org.onap.aai.dbmap.AAIGraph;
+import org.onap.aai.logging.LoggingContext;
+import org.onap.aai.logging.LoggingContext.StatusCode;
+import org.onap.aai.util.AAIConstants;
/**
- * Wrapper class to allow {@link com.openecomp.aai.migration.MigrationControllerInternal MigrationControllerInternal}
+ * Wrapper class to allow {@link org.onap.aai.migration.MigrationControllerInternal MigrationControllerInternal}
* to be run from a shell script
*/
public class MigrationController {
@@ -36,15 +41,23 @@ public class MigrationController {
* the arguments
*/
public static void main(String[] args) {
-
+ LoggingContext.init();
+ LoggingContext.partnerName("Migration");
+ LoggingContext.serviceName(AAIConstants.AAI_RESOURCES_MS);
+ LoggingContext.component("MigrationController");
+ LoggingContext.targetEntity(AAIConstants.AAI_RESOURCES_MS);
+ LoggingContext.targetServiceName("main");
+ LoggingContext.requestId(UUID.randomUUID().toString());
+ LoggingContext.statusCode(StatusCode.COMPLETE);
+ LoggingContext.responseCode(LoggingContext.SUCCESS);
MigrationControllerInternal internal = new MigrationControllerInternal();
try {
internal.run(args);
} catch (Exception e) {
- //ignore
+ e.printStackTrace();
}
- AAIGraph.getInstance().getGraph().close();
+ AAIGraph.getInstance().graphShutdown();
System.exit(0);
}
}
diff --git a/aai-resources/src/main/java/org/onap/aai/migration/MigrationControllerInternal.java b/aai-resources/src/main/java/org/onap/aai/migration/MigrationControllerInternal.java
index 6da9321..fbc4e03 100644
--- a/aai-resources/src/main/java/org/onap/aai/migration/MigrationControllerInternal.java
+++ b/aai-resources/src/main/java/org/onap/aai/migration/MigrationControllerInternal.java
@@ -29,10 +29,10 @@ import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.Comparator;
import java.util.List;
import java.util.Properties;
import java.util.Set;
+import java.util.stream.Collectors;
import org.apache.activemq.broker.BrokerService;
import org.apache.commons.configuration.ConfigurationException;
@@ -48,6 +48,8 @@ import org.onap.aai.introspection.Loader;
import org.onap.aai.introspection.LoaderFactory;
import org.onap.aai.introspection.ModelType;
import org.onap.aai.introspection.Version;
+import org.onap.aai.logging.LoggingContext;
+import org.onap.aai.logging.LoggingContext.StatusCode;
import org.onap.aai.serialization.engines.QueryStyle;
import org.onap.aai.serialization.engines.TitanDBEngine;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
@@ -63,20 +65,20 @@ import com.beust.jcommander.JCommander;
import com.beust.jcommander.Parameter;
/**
- * Runs a series of migrations from a defined directory based on the presence of
- * the {@link com.openecomp.aai.migration.Enabled Enabled} annotation
- *
+ * Runs a series of migrations from a defined directory based on the presence of
+ * the {@link org.onap.aai.migration.Enabled Enabled} annotation
+ *
* It will also write a record of the migrations run to the database.
*/
public class MigrationControllerInternal {
private EELFLogger logger;
private final int DANGER_ZONE = 10;
- private final String vertexType = "migration-list-1707";
+ private static final String VERTEX_TYPE = "migration-list-" + Version.getLatest().toString();
private final List<String> resultsSummary = new ArrayList<>();
private BrokerService broker;
private final List<NotificationHelper> notifications = new ArrayList<>();
- private final String snapshotLocation = AAIConstants.AAI_HOME + AAIConstants.AAI_FILESEP + "logs" + AAIConstants.AAI_FILESEP + "data" + AAIConstants.AAI_FILESEP + "migrationSnapshots";
+ private static final String SNAPSHOT_LOCATION = AAIConstants.AAI_HOME + AAIConstants.AAI_FILESEP + "logs" + AAIConstants.AAI_FILESEP + "data" + AAIConstants.AAI_FILESEP + "migrationSnapshots";
/**
* The main method.
*
@@ -85,6 +87,7 @@ public class MigrationControllerInternal {
*/
public void run(String[] args) {
// Set the logging file properties to be used by EELFManager
+ System.setProperty("aai.service.name", MigrationController.class.getSimpleName());
Properties props = System.getProperties();
props.setProperty(Configuration.PROPERTY_LOGGING_FILE_NAME, "migration-logback.xml");
props.setProperty(Configuration.PROPERTY_LOGGING_FILE_PATH, AAIConstants.AAI_HOME_ETC_APP_PROPERTIES);
@@ -98,6 +101,7 @@ public class MigrationControllerInternal {
JCommander jCommander = new JCommander(cArgs, args);
jCommander.setProgramName(MigrationController.class.getSimpleName());
+
// Set flag to load from snapshot based on the presence of snapshot and
// graph storage backend of inmemory
if (cArgs.dataSnapshot != null && !cArgs.dataSnapshot.isEmpty()) {
@@ -109,6 +113,8 @@ public class MigrationControllerInternal {
System.setProperty("snapshot.location", cArgs.dataSnapshot);
}
} catch (ConfigurationException e) {
+ LoggingContext.statusCode(StatusCode.ERROR);
+ LoggingContext.responseCode(LoggingContext.DATA_ERROR);
logAndPrint("ERROR: Could not load titan configuration.\n" + ExceptionUtils.getFullStackTrace(e));
return;
}
@@ -123,80 +129,76 @@ public class MigrationControllerInternal {
ModelType introspectorFactoryType = ModelType.MOXY;
Loader loader = LoaderFactory.createLoaderForVersion(introspectorFactoryType, version);
TransactionalGraphEngine engine = new TitanDBEngine(queryStyle, DBConnectionType.REALTIME, loader);
-
+
if (cArgs.help) {
jCommander.usage();
engine.rollback();
return;
- } else if (cArgs.list) {
- Reflections reflections = new Reflections("org.onap.aai.migration");
- Set<Class<? extends Migrator>> migratorClasses = findClasses(reflections);
- List<Migrator> migratorList = createMigratorList(cArgs, migratorClasses);
-
- sortList(migratorList);
- engine.startTransaction();
- System.out.println("---------- List of all migrations ----------");
- migratorList.forEach(migrator -> {
- boolean enabledAnnotation = migrator.getClass().isAnnotationPresent(Enabled.class);
- String enabled = enabledAnnotation ? "Enabled" : "Disabled";
- StringBuilder sb = new StringBuilder();
- sb.append(migrator.getClass().getSimpleName() + " " + enabled);
- sb.append(" ");
- sb.append("[" + getDbStatus(migrator.getClass().getSimpleName(), engine) + "]");
- System.out.println(sb.toString());
- });
- engine.rollback();
- System.out.println("---------- Done ----------");
- return;
}
-
Reflections reflections = new Reflections("org.onap.aai.migration");
+ List<Class<? extends Migrator>> migratorClasses = new ArrayList<>(findClasses(reflections));
+ //Displays list of migration classes which needs to be executed.Pass flag "-l" following by the class names
+ if (cArgs.list) {
+ listMigrationWithStatus(cArgs, migratorClasses, engine);
+ return;
+ }
logAndPrint("---------- Looking for migration scripts to be executed. ----------");
- Set<Class<? extends Migrator>> migratorClasses = findClasses(reflections);
- List<Migrator> migratorList = createMigratorList(cArgs, migratorClasses);
+ //Excluding any migration class when run migration from script.Pass flag "-e" following by the class names
+ if (!cArgs.excludeClasses.isEmpty()) {
+ migratorClasses = filterMigrationClasses(cArgs.excludeClasses, migratorClasses);
+ listMigrationWithStatus(cArgs, migratorClasses, engine);
+ }
+ List<Class<? extends Migrator>> migratorClassesToRun = createMigratorList(cArgs, migratorClasses);
- sortList(migratorList);
+ sortList(migratorClassesToRun);
- if (!cArgs.scripts.isEmpty() && migratorList.size() == 0) {
+ if (!cArgs.scripts.isEmpty() && migratorClassesToRun.isEmpty()) {
+ LoggingContext.statusCode(StatusCode.ERROR);
+ LoggingContext.responseCode(LoggingContext.BUSINESS_PROCESS_ERROR);
logAndPrint("\tERROR: Failed to find migrations " + cArgs.scripts + ".");
logAndPrint("---------- Done ----------");
+ LoggingContext.successStatusFields();
}
- logAndPrint("\tFound " + migratorList.size() + " migration scripts.");
+ logAndPrint("\tFound " + migratorClassesToRun.size() + " migration scripts.");
logAndPrint("---------- Executing Migration Scripts ----------");
-
-
- takeSnapshotIfRequired(engine, cArgs, migratorList);
- for (Migrator migratorClass : migratorList) {
- String name = migratorClass.getClass().getSimpleName();
+ if (!cArgs.skipPreMigrationSnapShot) {
+ takePreSnapshotIfRequired(engine, cArgs, migratorClassesToRun);
+ }
+
+ for (Class<? extends Migrator> migratorClass : migratorClassesToRun) {
+ String name = migratorClass.getSimpleName();
Migrator migrator;
- if (migratorClass.getClass().isAnnotationPresent(Enabled.class)) {
-
+ if (migratorClass.isAnnotationPresent(Enabled.class)) {
+
try {
engine.startTransaction();
if (!cArgs.forced && hasAlreadyRun(name, engine)) {
logAndPrint("Migration " + name + " has already been run on this database and will not be executed again. Use -f to force execution");
continue;
}
- migrator = migratorClass.getClass().getConstructor(TransactionalGraphEngine.class).newInstance(engine);
+ migrator = migratorClass.getConstructor(TransactionalGraphEngine.class).newInstance(engine);
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) {
- logAndPrint("EXCEPTION caught initalizing migration class " + migratorClass.getClass().getSimpleName() + ".\n" + ExceptionUtils.getFullStackTrace(e));
+ LoggingContext.statusCode(StatusCode.ERROR);
+ LoggingContext.responseCode(LoggingContext.DATA_ERROR);
+ logAndPrint("EXCEPTION caught initalizing migration class " + migratorClass.getSimpleName() + ".\n" + ExceptionUtils.getFullStackTrace(e));
+ LoggingContext.successStatusFields();
engine.rollback();
continue;
}
- logAndPrint("\tRunning " + migratorClass.getClass().getSimpleName() + " migration script.");
- logAndPrint("\t\t See " + System.getProperty("AJSC_HOME") + "/logs/migration/" + migratorClass.getClass().getSimpleName() + "/* for logs.");
- MDC.put("logFilenameAppender", migratorClass.getClass().getSimpleName() + "/" + migratorClass.getClass().getSimpleName());
-
+ logAndPrint("\tRunning " + migratorClass.getSimpleName() + " migration script.");
+ logAndPrint("\t\t See " + System.getProperty("AJSC_HOME") + "/logs/migration/" + migratorClass.getSimpleName() + "/* for logs.");
+ MDC.put("logFilenameAppender", migratorClass.getSimpleName() + "/" + migratorClass.getSimpleName());
+
migrator.run();
-
+
commitChanges(engine, migrator, cArgs);
} else {
- logAndPrint("\tSkipping " + migratorClass.getClass().getSimpleName() + " migration script because it has been disabled.");
+ logAndPrint("\tSkipping " + migratorClass.getSimpleName() + " migration script because it has been disabled.");
}
}
MDC.put("logFilenameAppender", MigrationController.class.getSimpleName());
@@ -204,27 +206,76 @@ public class MigrationControllerInternal {
try {
notificationHelper.triggerEvents();
} catch (AAIException e) {
+ LoggingContext.statusCode(StatusCode.ERROR);
+ LoggingContext.responseCode(LoggingContext.AVAILABILITY_TIMEOUT_ERROR);
logAndPrint("\tcould not event");
logger.error("could not event", e);
+ LoggingContext.successStatusFields();
}
}
logAndPrint("---------- Done ----------");
// Save post migration snapshot if snapshot was loaded
- generateSnapshot(engine, "post");
-
+ if (!cArgs.skipPostMigrationSnapShot) {
+ generateSnapshot(engine, "post");
+ }
+
outputResultsSummary();
}
+ /**
+ * This method is used to remove excluded classes from migration from the
+ * script command.
+ *
+ * @param excludeClasses
+ * : Classes to be removed from Migration
+ * @param migratorClasses
+ * : Classes to execute migration.
+ * @return
+ */
+ private List<Class<? extends Migrator>> filterMigrationClasses(
+ List<String> excludeClasses,
+ List<Class<? extends Migrator>> migratorClasses) {
+
+ List<Class<? extends Migrator>> filteredMigratorClasses = migratorClasses
+ .stream()
+ .filter(migratorClass -> !excludeClasses.contains(migratorClass
+ .getSimpleName())).collect(Collectors.toList());
+
+ return filteredMigratorClasses;
+ }
+
+ private void listMigrationWithStatus(CommandLineArgs cArgs,
+ List<Class<? extends Migrator>> migratorClasses, TransactionalGraphEngine engine) {
+ sortList(migratorClasses);
+ engine.startTransaction();
+ System.out.println("---------- List of all migrations ----------");
+ migratorClasses.forEach(migratorClass -> {
+ boolean enabledAnnotation = migratorClass.isAnnotationPresent(Enabled.class);
+ String enabled = enabledAnnotation ? "Enabled" : "Disabled";
+ StringBuilder sb = new StringBuilder();
+ sb.append(migratorClass.getSimpleName());
+ sb.append(" in package ");
+ sb.append(migratorClass.getPackage().getName().substring(migratorClass.getPackage().getName().lastIndexOf('.')+1));
+ sb.append(" is ");
+ sb.append(enabled);
+ sb.append(" ");
+ sb.append("[" + getDbStatus(migratorClass.getSimpleName(), engine) + "]");
+ System.out.println(sb.toString());
+ });
+ engine.rollback();
+ System.out.println("---------- Done ----------");
+ }
+
private String getDbStatus(String name, TransactionalGraphEngine engine) {
if (hasAlreadyRun(name, engine)) {
return "Already executed in this env";
}
- return "Will be run on next execution";
+ return "Will be run on next execution if Enabled";
}
private boolean hasAlreadyRun(String name, TransactionalGraphEngine engine) {
- return engine.asAdmin().getReadOnlyTraversalSource().V().has(AAIProperties.NODE_TYPE, vertexType).has(name, true).hasNext();
+ return engine.asAdmin().getReadOnlyTraversalSource().V().has(AAIProperties.NODE_TYPE, VERTEX_TYPE).has(name, true).hasNext();
}
private Set<Class<? extends Migrator>> findClasses(Reflections reflections) {
Set<Class<? extends Migrator>> migratorClasses = reflections.getSubTypesOf(Migrator.class);
@@ -232,85 +283,75 @@ public class MigrationControllerInternal {
* TODO- Change this to make sure only classes in the specific $release are added in the runList
* Or add a annotation like exclude which folks again need to remember to add ??
*/
-
+
migratorClasses.remove(PropertyMigrator.class);
migratorClasses.remove(EdgeMigrator.class);
return migratorClasses;
}
- private void takeSnapshotIfRequired(TransactionalGraphEngine engine, CommandLineArgs cArgs, List<Migrator> migratorList) {
+ private void takePreSnapshotIfRequired(TransactionalGraphEngine engine, CommandLineArgs cArgs, List<Class<? extends Migrator>> migratorClassesToRun) {
/*int sum = 0;
- for (Migrator migrator : migratorList) {
- if (migrator.getClass().isAnnotationPresent(Enabled.class)) {
- sum += migrator.getDangerRating();
+ for (Class<? extends Migrator> migratorClass : migratorClassesToRun) {
+ if (migratorClass.isAnnotationPresent(Enabled.class)) {
+ sum += migratorClass.getAnnotation(MigrationPriority.class).value();
}
}
-
+
if (sum >= DANGER_ZONE) {
-
+
logAndPrint("Entered Danger Zone. Taking snapshot.");
}*/
-
+
//always take snapshot for now
+
generateSnapshot(engine, "pre");
}
- private List<Migrator> createMigratorList(CommandLineArgs cArgs,
- Set<Class<? extends Migrator>> migratorClasses) {
- List<Migrator> migratorList = new ArrayList<>();
+ private List<Class<? extends Migrator>> createMigratorList(CommandLineArgs cArgs,
+ List<Class<? extends Migrator>> migratorClasses) {
+ List<Class<? extends Migrator>> migratorClassesToRun = new ArrayList<>();
for (Class<? extends Migrator> migratorClass : migratorClasses) {
if (!cArgs.scripts.isEmpty() && !cArgs.scripts.contains(migratorClass.getSimpleName())) {
continue;
} else {
- Migrator migrator;
- try {
-
- migrator = migratorClass.getConstructor().newInstance();
- } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) {
- logAndPrint("EXCEPTION caught initalizing migration class " + migratorClass.getSimpleName() + ".\n" + ExceptionUtils.getFullStackTrace(e));
- continue;
- }
- migratorList.add(migrator);
+ migratorClassesToRun.add(migratorClass);
}
}
- return migratorList;
+ return migratorClassesToRun;
}
- private void sortList(List<Migrator> migratorList) {
- Collections.sort(migratorList, new Comparator<Migrator>() {
- public int compare(Migrator m1, Migrator m2) {
- try {
-
- if (m1.getPriority() > m2.getPriority()) {
- return 1;
- } else if (m1.getPriority() < m2.getPriority()) {
- return -1;
- } else {
- return m1.getClass().getSimpleName().compareTo(m2.getClass().getSimpleName());
- }
- } catch (Exception e) {
- return 0;
+ private void sortList(List<Class<? extends Migrator>> migratorClasses) {
+ Collections.sort(migratorClasses, (m1, m2) -> {
+ try {
+ if (m1.getAnnotation(MigrationPriority.class).value() > m2.getAnnotation(MigrationPriority.class).value()) {
+ return 1;
+ } else if (m1.getAnnotation(MigrationPriority.class).value() < m2.getAnnotation(MigrationPriority.class).value()) {
+ return -1;
+ } else {
+ return m1.getSimpleName().compareTo(m2.getSimpleName());
}
+ } catch (Exception e) {
+ return 0;
}
});
}
-
+
private void generateSnapshot(TransactionalGraphEngine engine, String phase) {
-
+
FormatDate fd = new FormatDate("yyyyMMddHHmm", "GMT");
String dateStr= fd.getDateTime();
- String fileName = snapshotLocation + File.separator + phase + "Migration." + dateStr + ".graphson";
+ String fileName = SNAPSHOT_LOCATION + File.separator + phase + "Migration." + dateStr + ".graphson";
logAndPrint("Saving snapshot of inmemory graph " + phase + " migration to " + fileName);
Graph transaction = null;
try {
-
+
Path pathToFile = Paths.get(fileName);
if (!pathToFile.toFile().exists()) {
Files.createDirectories(pathToFile.getParent());
@@ -319,17 +360,18 @@ public class MigrationControllerInternal {
transaction.io(IoCore.graphson()).writeGraph(fileName);
engine.rollback();
} catch (IOException e) {
+ LoggingContext.statusCode(StatusCode.ERROR);
+ LoggingContext.responseCode(LoggingContext.AVAILABILITY_TIMEOUT_ERROR);
logAndPrint("ERROR: Could not write in memory graph to " + phase + "Migration file. \n" + ExceptionUtils.getFullStackTrace(e));
+ LoggingContext.successStatusFields();
engine.rollback();
- }
+ }
logAndPrint( phase + " migration snapshot saved to " + fileName);
}
/**
* Log and print.
*
- * @param logger
- * the logger
* @param msg
* the msg
*/
@@ -341,12 +383,11 @@ public class MigrationControllerInternal {
/**
* Commit changes.
*
- * @param g
- * the g
+ * @param engine
+ * the graph transaction
* @param migrator
* the migrator
- * @param logger
- * the logger
+ * @param cArgs
*/
protected void commitChanges(TransactionalGraphEngine engine, Migrator migrator, CommandLineArgs cArgs) {
@@ -354,20 +395,26 @@ public class MigrationControllerInternal {
String message;
if (migrator.getStatus().equals(Status.FAILURE)) {
message = "Migration " + simpleName + " Failed. Rolling back.";
+ LoggingContext.statusCode(StatusCode.ERROR);
+ LoggingContext.responseCode(LoggingContext.DATA_ERROR);
logAndPrint("\t" + message);
+ LoggingContext.successStatusFields();
migrator.rollback();
} else if (migrator.getStatus().equals(Status.CHECK_LOGS)) {
- message = "Migration " + simpleName + " encountered an anomily, check logs. Rolling back.";
+ message = "Migration " + simpleName + " encountered an anomaly, check logs. Rolling back.";
+ LoggingContext.statusCode(StatusCode.ERROR);
+ LoggingContext.responseCode(LoggingContext.DATA_ERROR);
logAndPrint("\t" + message);
+ LoggingContext.successStatusFields();
migrator.rollback();
} else {
- MDC.put("logFilenameAppender", simpleName + "/" + migrator.getClass().getSimpleName());
+ MDC.put("logFilenameAppender", simpleName + "/" + simpleName);
if (cArgs.commit) {
- if (!engine.asAdmin().getTraversalSource().V().has(AAIProperties.NODE_TYPE, vertexType).hasNext()) {
- engine.asAdmin().getTraversalSource().addV(AAIProperties.NODE_TYPE, vertexType).iterate();
+ if (!engine.asAdmin().getTraversalSource().V().has(AAIProperties.NODE_TYPE, VERTEX_TYPE).hasNext()) {
+ engine.asAdmin().getTraversalSource().addV(AAIProperties.NODE_TYPE, VERTEX_TYPE).iterate();
}
- engine.asAdmin().getTraversalSource().V().has(AAIProperties.NODE_TYPE, vertexType)
+ engine.asAdmin().getTraversalSource().V().has(AAIProperties.NODE_TYPE, VERTEX_TYPE)
.property(simpleName, true).iterate();
MDC.put("logFilenameAppender", MigrationController.class.getSimpleName());
notifications.add(migrator.getNotificationHelper());
@@ -381,11 +428,11 @@ public class MigrationControllerInternal {
}
}
-
+
resultsSummary.add(message);
}
-
+
private void outputResultsSummary() {
logAndPrint("---------------------------------");
logAndPrint("-------------Summary-------------");
@@ -395,7 +442,7 @@ public class MigrationControllerInternal {
logAndPrint("---------------------------------");
logAndPrint("---------------------------------");
}
-
+
}
class CommandLineArgs {
@@ -411,14 +458,22 @@ class CommandLineArgs {
@Parameter(names = "-l", description = "list the status of migrations")
public boolean list = false;
-
+
@Parameter(names = "-d", description = "location of data snapshot", hidden = true)
public String dataSnapshot;
-
+
@Parameter(names = "-f", description = "force migrations to be rerun")
public boolean forced = false;
-
+
@Parameter(names = "--commit", description = "commit changes to graph")
public boolean commit = false;
+ @Parameter(names = "-e", description = "exclude list of migrator classes")
+ public List<String> excludeClasses = new ArrayList<>();
+
+ @Parameter(names = "--skipPreMigrationSnapShot", description = "skips taking the PRE migration snapshot")
+ public boolean skipPreMigrationSnapShot = false;
+
+ @Parameter(names = "--skipPostMigrationSnapShot", description = "skips taking the POST migration snapshot")
+ public boolean skipPostMigrationSnapShot = false;
}
diff --git a/aai-resources/src/main/java/org/onap/aai/rest/util/LogFormatTools.java b/aai-resources/src/main/java/org/onap/aai/migration/MigrationDangerRating.java
index cfda0c3..a1d456c 100644
--- a/aai-resources/src/main/java/org/onap/aai/rest/util/LogFormatTools.java
+++ b/aai-resources/src/main/java/org/onap/aai/migration/MigrationDangerRating.java
@@ -1,37 +1,42 @@
-/**
+/*-
* ============LICENSE_START=======================================================
* org.onap.aai
* ================================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 AT&T 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
- *
+ *
+ * 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=========================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/
-package org.onap.aai.rest.util;
-import java.time.ZoneOffset;
-import java.time.ZonedDateTime;
-import java.time.format.DateTimeFormatter;
+package org.onap.aai.migration;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+
+/**
+ * Used to enable a migration to be picked up by the {@link com.openecomp.aai.migration.MigrationControllerInternal MigrationController}
+ *
+ * The larger the number, the more danger
+ *
+ * Range is 0-10
+ */
+@Target(ElementType.TYPE)
+@Retention(value = RetentionPolicy.RUNTIME)
+public @interface MigrationDangerRating {
-public class LogFormatTools {
+ int value();
- private static final String DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSSZ";
- private static final DateTimeFormatter DTF = DateTimeFormatter.ofPattern(DATE_FORMAT)
- .withZone(ZoneOffset.UTC);
-
- public static String getCurrentDateTime() {
- return DTF.format(ZonedDateTime.now());
- }
}
diff --git a/aai-resources/src/main/java/org/onap/aai/migration/MigrationPriority.java b/aai-resources/src/main/java/org/onap/aai/migration/MigrationPriority.java
new file mode 100644
index 0000000..fb7b06f
--- /dev/null
+++ b/aai-resources/src/main/java/org/onap/aai/migration/MigrationPriority.java
@@ -0,0 +1,42 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright (C) 2017 AT&T 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.aai.migration;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+
+/**
+ * Used to enable a migration to be picked up by the {@link com.openecomp.aai.migration.MigrationControllerInternal MigrationController}
+ *
+ * The priority of the migration.
+ *
+ * Lower number has higher priority
+ */
+@Target(ElementType.TYPE)
+@Retention(value = RetentionPolicy.RUNTIME)
+public @interface MigrationPriority {
+
+ int value();
+
+}
diff --git a/aai-resources/src/main/java/org/onap/aai/migration/Migrator.java b/aai-resources/src/main/java/org/onap/aai/migration/Migrator.java
index 900c914..e5e4c52 100644
--- a/aai-resources/src/main/java/org/onap/aai/migration/Migrator.java
+++ b/aai-resources/src/main/java/org/onap/aai/migration/Migrator.java
@@ -21,6 +21,7 @@
*/
package org.onap.aai.migration;
+import java.util.Collections;
import java.util.Iterator;
import java.util.Optional;
@@ -50,6 +51,8 @@ import com.att.eelf.configuration.EELFManager;
/**
* This class defines an A&AI Migration
*/
+@MigrationPriority(0)
+@MigrationDangerRating(0)
public abstract class Migrator implements Runnable {
protected EELFLogger logger = null;
@@ -59,10 +62,7 @@ public abstract class Migrator implements Runnable {
protected TransactionalGraphEngine engine;
protected NotificationHelper notificationHelper;
-
- public Migrator() {
- //used for not great reflection implementation
- }
+
/**
* Instantiates a new migrator.
*
@@ -97,24 +97,8 @@ public abstract class Migrator implements Runnable {
engine.commit();
}
- /**
- * Gets the priority.
- *
- * Lower number has higher priority
- *
- * @return the priority
- */
- public abstract int getPriority();
/**
- * The larger the number, the more danger
- *
- * Range is 0-10
- *
- * @return danger rating
- */
- public abstract int getDangerRating();
- /**
* As string.
*
* @param v the v
@@ -157,12 +141,48 @@ public abstract class Migrator implements Runnable {
return result.toString();
}
+
+ /**
+ *
+ * @param v
+ * @param numLeadingTabs number of leading \t char's
+ * @return
+ */
+ protected String toStringForPrinting(Vertex v, int numLeadingTabs) {
+ String prefix = String.join("", Collections.nCopies(numLeadingTabs, "\t"));
+ if (v == null) {
+ return "";
+ }
+ final StringBuilder sb = new StringBuilder();
+ sb.append(prefix + v + "\n");
+ v.properties().forEachRemaining(prop -> sb.append(prefix + prop + "\n"));
+ return sb.toString();
+ }
+
+ /**
+ *
+ * @param e
+ * @param numLeadingTabs number of leading \t char's
+ * @return
+ */
+ protected String toStringForPrinting(Edge e, int numLeadingTabs) {
+ String prefix = String.join("", Collections.nCopies(numLeadingTabs, "\t"));
+ if (e == null) {
+ return "";
+ }
+ final StringBuilder sb = new StringBuilder();
+ sb.append(prefix + e + "\n");
+ sb.append(prefix + e.label() + "\n");
+ e.properties().forEachRemaining(prop -> sb.append(prefix + "\t" + prop + "\n"));
+ return sb.toString();
+ }
+
/**
* Checks for edge between.
*
- * @param vertex a
- * @param vertex b
- * @param direction d
+ * @param a a
+ * @param b b
+ * @param d d
* @param edgeLabel the edge label
* @return true, if successful
*/
@@ -179,7 +199,7 @@ public abstract class Migrator implements Runnable {
/**
* Creates the edge
*
- * @param edgeType the edge type - COUSIN or TREE
+ * @param type the edge type - COUSIN or TREE
* @param out the out
* @param in the in
* @return the edge
diff --git a/aai-resources/src/main/java/org/onap/aai/migration/PropertyMigrator.java b/aai-resources/src/main/java/org/onap/aai/migration/PropertyMigrator.java
index c42862a..28c78ea 100644
--- a/aai-resources/src/main/java/org/onap/aai/migration/PropertyMigrator.java
+++ b/aai-resources/src/main/java/org/onap/aai/migration/PropertyMigrator.java
@@ -36,6 +36,8 @@ import com.thinkaurelius.titan.core.schema.TitanManagement;
/**
* A migration template for migrating a property from one name to another
*/
+@MigrationPriority(0)
+@MigrationDangerRating(1)
public abstract class PropertyMigrator extends Migrator {
protected final String OLD_FIELD;
@@ -43,15 +45,7 @@ public abstract class PropertyMigrator extends Migrator {
protected final Class<?> fieldType;
protected final Cardinality cardinality;
protected final TitanManagement graphMgmt;
- public PropertyMigrator() {
- //used for not great reflection implementation
- super();
- this.OLD_FIELD = null;
- this.NEW_FIELD = null;
- this.fieldType = null;
- this.cardinality = null;
- this.graphMgmt = null;
- }
+
public PropertyMigrator(TransactionalGraphEngine engine, String oldName, String newName, Class<?> type, Cardinality cardinality) {
super(engine);
this.OLD_FIELD = oldName;
@@ -111,17 +105,7 @@ public abstract class PropertyMigrator extends Migrator {
return Status.FAILURE;
}
}
-
- @Override
- public int getPriority() {
- return 0;
- }
- @Override
- public int getDangerRating() {
- return 1;
- }
-
protected Optional<PropertyKey> addProperty() {
if (!graphMgmt.containsPropertyKey(this.NEW_FIELD)) {
diff --git a/aai-resources/src/main/java/org/onap/aai/migration/v12/ContainmentDeleteOtherVPropertyMigration.java b/aai-resources/src/main/java/org/onap/aai/migration/v12/ContainmentDeleteOtherVPropertyMigration.java
new file mode 100644
index 0000000..643517d
--- /dev/null
+++ b/aai-resources/src/main/java/org/onap/aai/migration/v12/ContainmentDeleteOtherVPropertyMigration.java
@@ -0,0 +1,105 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright (C) 2017 AT&T 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.aai.migration.v12;
+
+import java.util.Optional;
+
+import org.apache.commons.lang.exception.ExceptionUtils;
+import org.apache.tinkerpop.gremlin.structure.Edge;
+import org.onap.aai.migration.MigrationDangerRating;
+import org.onap.aai.migration.Enabled;
+import org.onap.aai.migration.MigrationPriority;
+import org.onap.aai.migration.Migrator;
+import org.onap.aai.migration.Status;
+import org.onap.aai.serialization.db.AAIDirection;
+import org.onap.aai.serialization.db.EdgeProperty;
+import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+
+
+
+@Enabled
+@MigrationPriority(-100)
+@MigrationDangerRating(10)
+public class ContainmentDeleteOtherVPropertyMigration extends Migrator {
+
+ private boolean success = true;
+
+ public ContainmentDeleteOtherVPropertyMigration(TransactionalGraphEngine engine) {
+ super(engine);
+ }
+
+ //just for testing using test edge rule files
+ public ContainmentDeleteOtherVPropertyMigration(TransactionalGraphEngine engine, String edgeRulesFile) {
+ super(engine);
+ }
+
+ @Override
+ public void run() {
+ try {
+ engine.asAdmin().getTraversalSource().E().sideEffect(t -> {
+ Edge e = t.get();
+ logger.info("out vertex: " + e.outVertex().property("aai-node-type").value() +
+ " in vertex: " + e.inVertex().property("aai-node-type").value() +
+ " label : " + e.label());
+ if (e.property(EdgeProperty.CONTAINS.toString()).isPresent() &&
+ e.property(EdgeProperty.DELETE_OTHER_V.toString()).isPresent()) {
+ //in case of orphans
+ if (!("constrained-element-set".equals(e.inVertex().property("aai-node-type").value())
+ && "model-element".equals(e.outVertex().property("aai-node-type").value()))) {
+ //skip the weird horrible problem child edge
+ String containment = (String) e.property(EdgeProperty.CONTAINS.toString()).value();
+ if (AAIDirection.OUT.toString().equalsIgnoreCase(containment) ||
+ AAIDirection.IN.toString().equalsIgnoreCase(containment) ||
+ AAIDirection.BOTH.toString().equalsIgnoreCase(containment)) {
+ logger.info("updating delete-other-v property");
+ e.property(EdgeProperty.DELETE_OTHER_V.toString(), containment);
+ }
+ }
+ }
+ }).iterate();
+ } catch (Exception e) {
+ logger.info("error encountered " + e.getClass() + " " + e.getMessage() + " " + ExceptionUtils.getFullStackTrace(e));
+ logger.error("error encountered " + e.getClass() + " " + e.getMessage() + " " + ExceptionUtils.getFullStackTrace(e));
+ success = false;
+ }
+
+ }
+
+ @Override
+ public Status getStatus() {
+ if (success) {
+ return Status.SUCCESS;
+ } else {
+ return Status.FAILURE;
+ }
+ }
+
+ @Override
+ public Optional<String[]> getAffectedNodeTypes() {
+ return Optional.empty();
+ }
+
+ @Override
+ public String getMigrationName() {
+ return "migrate-containment-delete-other-v";
+ }
+
+}
diff --git a/aai-resources/src/main/java/org/onap/aai/migration/v12/EdgeReportForToscaMigration.java b/aai-resources/src/main/java/org/onap/aai/migration/v12/EdgeReportForToscaMigration.java
new file mode 100644
index 0000000..859e52f
--- /dev/null
+++ b/aai-resources/src/main/java/org/onap/aai/migration/v12/EdgeReportForToscaMigration.java
@@ -0,0 +1,142 @@
+package org.onap.aai.migration.v12;
+/*-
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright (C) 2017 AT&T 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=========================================================
+ */
+
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.Edge;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.onap.aai.migration.*;
+import org.onap.aai.serialization.db.EdgeRules;
+import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+
+import java.util.*;
+
+@Enabled
+@MigrationPriority(0)
+@MigrationDangerRating(0)
+public class EdgeReportForToscaMigration extends Migrator {
+
+ private boolean success = true;
+ EdgeRules ers = EdgeRules.getInstance();
+
+ public EdgeReportForToscaMigration(TransactionalGraphEngine graphEngine){
+ super(graphEngine);
+ }
+
+ @Override
+ public Status getStatus() {
+ if (success) {
+ return Status.SUCCESS;
+ } else {
+ return Status.FAILURE;
+ }
+ }
+
+ @Override
+ public void run() {
+ Vertex out = null;
+ Vertex in = null;
+ String label = "";
+ String outURI = "";
+ String inURI = "";
+ String parentCousinIndicator = "NONE";
+ String oldEdgeString = null;
+ List<String> edgeMissingParentProperty = new ArrayList<>();
+ StringBuilder sb = new StringBuilder();
+ Set<String> noURI = new HashSet<>();
+ sb.append("----------EDGES----------\n");
+
+ GraphTraversalSource g = engine.asAdmin().getTraversalSource();
+
+ try {
+ Set<Edge> edges = g.E().toSet();
+ for (Edge edge : edges) {
+ out = edge.outVertex();
+ in = edge.inVertex();
+ label = edge.label();
+ outURI = this.getVertexURI(out);
+ inURI = this.getVertexURI(in);
+ parentCousinIndicator = "NONE";
+ oldEdgeString = this.toStringForPrinting(edge, 1);
+
+ if (!outURI.startsWith("/")) {
+ noURI.add(outURI);
+ }
+ if (!inURI.startsWith("/")) {
+ noURI.add(inURI);
+ }
+
+ if (out == null || in == null) {
+ logger.error(edge.id() + " invalid because one vertex was null: out=" + edge.outVertex() + " in=" + edge.inVertex());
+ } else {
+
+ if (edge.property("contains-other-v").isPresent()) {
+ parentCousinIndicator = edge.property("contains-other-v").value().toString();
+ } else if (edge.property("isParent").isPresent()) {
+ if ((Boolean)edge.property("isParent").value()) {
+ parentCousinIndicator = "OUT";
+ } else if (edge.property("isParent-REV").isPresent() && (Boolean)edge.property("isParent-REV").value()) {
+ parentCousinIndicator = "IN";
+ }
+ } else {
+ edgeMissingParentProperty.add(this.toStringForPrinting(edge, 1));
+ }
+
+ sb.append(outURI + "|" + label + "|" + inURI + "|" + parentCousinIndicator + "\n");
+ }
+ }
+ } catch(Exception ex){
+ logger.error("exception occurred during migration, failing: out=" + out + " in=" + in + "edge=" + oldEdgeString, ex);
+ success = false;
+ }
+ sb.append("--------EDGES END--------\n");
+
+ logger.info(sb.toString());
+ edgeMissingParentProperty.forEach(s -> logger.warn("Edge Missing Parent Property: " + s));
+ logger.info("Edge Missing Parent Property Count: " + edgeMissingParentProperty.size());
+ logger.info("Vertex Missing URI Property Count: " + noURI.size());
+
+ }
+
+ private String getVertexURI(Vertex v) {
+ if (v.property("aai-uri").isPresent()) {
+ return v.property("aai-uri").value().toString();
+ } else {
+ return v.id().toString() + "(" + v.property("aai-node-type").value().toString() + ")";
+ }
+ }
+
+ @Override
+ public Optional<String[]> getAffectedNodeTypes() {
+ return Optional.empty();
+ }
+
+ @Override
+ public String getMigrationName() {
+ return "edge-report-for-tosca-migration";
+ }
+
+ @Override
+ public void commit() {
+ engine.rollback();
+ }
+
+}
diff --git a/aai-resources/src/main/java/org/onap/aai/migration/v12/MigrateDataFromASDCToConfiguration.java b/aai-resources/src/main/java/org/onap/aai/migration/v12/MigrateDataFromASDCToConfiguration.java
new file mode 100644
index 0000000..5185db3
--- /dev/null
+++ b/aai-resources/src/main/java/org/onap/aai/migration/v12/MigrateDataFromASDCToConfiguration.java
@@ -0,0 +1,107 @@
+package org.onap.aai.migration.v12;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.onap.aai.db.props.AAIProperties;
+import org.onap.aai.migration.*;
+import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+import org.onap.aai.util.AAIConstants;
+
+import java.io.*;
+import java.util.Optional;
+
+@MigrationPriority(20)
+@MigrationDangerRating(2)
+@Enabled
+public class MigrateDataFromASDCToConfiguration extends Migrator {
+ private final String PARENT_NODE_TYPE = "generic-vnf";
+ private boolean success = true;
+ private String entitlementPoolUuid = "";
+ private String VNT = "";
+
+
+ public MigrateDataFromASDCToConfiguration(TransactionalGraphEngine engine) {
+ super(engine);
+ }
+
+
+ @Override
+ public void run() {
+ String csvFile = AAIConstants.AAI_HOME_ETC + "VNT-migration-data" + AAIConstants.AAI_FILESEP + "VNT-migration-input.csv";
+ logger.info("Reading Csv file: " + csvFile);
+ BufferedReader br = null;
+ String line = "";
+ String cvsSplitBy = "\t";
+ try {
+
+ br = new BufferedReader(new FileReader(new File(csvFile)));
+ while ((line = br.readLine()) != null) {
+ line = line.replaceAll("\"", "");
+ String[] temp = line.split(cvsSplitBy);
+ if ("entitlement-pool-uuid".equals(temp[0]) || "vendor-allowed-max-bandwidth (VNT)".equals(temp[1])) {
+ continue;
+ }
+ entitlementPoolUuid = temp[0];
+ VNT = temp[1];
+ GraphTraversal<Vertex, Vertex> f = this.engine.asAdmin().getTraversalSource().V().has(AAIProperties.NODE_TYPE, "entitlement").has("group-uuid", entitlementPoolUuid)
+ .out("org.onap.relationships.inventory.BelongsTo").has(AAIProperties.NODE_TYPE, "generic-vnf")
+ .has("vnf-type", "vHNF").in("org.onap.relationships.inventory.ComposedOf").has(AAIProperties.NODE_TYPE, "service-instance").out("org.onap.relationships.inventory.Uses").has(AAIProperties.NODE_TYPE, "configuration");
+
+ modify(f);
+ }
+
+ } catch (FileNotFoundException e) {
+ success = false;
+ logger.error("Found Exception" , e);
+ } catch (IOException e) {
+ success = false;
+ logger.error("Found Exception" , e);
+ } catch (Exception a) {
+ success= false;
+ logger.error("Found Exception" , a);
+ } finally {
+ try {
+ br.close();
+ } catch (IOException e) {
+ success = false;
+ logger.error("Found Exception" , e);
+ }
+ }
+
+ }
+
+ public void modify(GraphTraversal<Vertex, Vertex> g) {
+ int count = 0;
+ while (g.hasNext()) {
+ Vertex v = g.next();
+ logger.info("Found node type " + v.property("aai-node-type").value().toString() + " with configuration id: " + v.property("configuration-id").value().toString());
+ v.property("vendor-allowed-max-bandwidth", VNT);
+ logger.info("VNT val after migration: " + v.property("vendor-allowed-max-bandwidth").value().toString());
+ count++;
+ }
+
+ logger.info("modified " + count + " configuration nodes related to Entitlement UUID: " +entitlementPoolUuid);
+
+ }
+
+ @Override
+ public Status getStatus() {
+ if (success) {
+ return Status.SUCCESS;
+ } else {
+ return Status.FAILURE;
+ }
+ }
+
+ @Override
+ public Optional<String[]> getAffectedNodeTypes() {
+ return Optional.of(new String[]{PARENT_NODE_TYPE});
+ }
+
+ @Override
+ public String getMigrationName() {
+ return "MigrateDataFromASDCToConfiguration";
+ }
+
+
+}
diff --git a/aai-resources/src/main/java/org/onap/aai/migration/v12/MigrateServiceInstanceToConfiguration.java b/aai-resources/src/main/java/org/onap/aai/migration/v12/MigrateServiceInstanceToConfiguration.java
new file mode 100644
index 0000000..f36fb2d
--- /dev/null
+++ b/aai-resources/src/main/java/org/onap/aai/migration/v12/MigrateServiceInstanceToConfiguration.java
@@ -0,0 +1,171 @@
+package org.onap.aai.migration.v12;
+
+import java.io.UnsupportedEncodingException;
+import java.util.Iterator;
+import java.util.Optional;
+import java.util.UUID;
+
+import org.apache.tinkerpop.gremlin.process.traversal.P;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.structure.Direction;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.onap.aai.db.props.AAIProperties;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.introspection.Introspector;
+import org.onap.aai.introspection.exceptions.AAIUnknownObjectException;
+import org.onap.aai.migration.Enabled;
+import org.onap.aai.migration.MigrationDangerRating;
+import org.onap.aai.migration.MigrationPriority;
+import org.onap.aai.migration.Migrator;
+import org.onap.aai.migration.Status;
+import org.onap.aai.serialization.db.EdgeType;
+import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+
+@Enabled
+@MigrationPriority(10)
+@MigrationDangerRating(10)
+public class MigrateServiceInstanceToConfiguration extends Migrator {
+
+ private boolean success = true;
+ private final String CONFIGURATION_NODE_TYPE = "configuration";
+ private final String SERVICE_INSTANCE_NODE_TYPE = "service-instance";
+ private Introspector configObj;
+
+ public MigrateServiceInstanceToConfiguration(TransactionalGraphEngine engine) {
+ super(engine);
+ try {
+ this.configObj = this.loader.introspectorFromName(CONFIGURATION_NODE_TYPE);
+ } catch (AAIUnknownObjectException e) {
+ this.configObj = null;
+ }
+ }
+
+ @Override
+ public void run() {
+ Vertex serviceInstance = null;
+ Vertex configuration = null;
+ String serviceInstanceId = "", tunnelBandwidth = "";
+ String bandwidthTotal, configType, nodeType;
+ GraphTraversal<Vertex, Vertex> serviceInstanceItr;
+ Iterator<Vertex> configurationItr;
+
+ try {
+ serviceInstanceItr = this.engine.asAdmin().getTraversalSource().V()
+ .has(AAIProperties.NODE_TYPE, P.within(getAffectedNodeTypes().get()))
+ .where(this.engine.getQueryBuilder()
+ .createEdgeTraversal(EdgeType.TREE, "service-instance", "service-subscription")
+ .getVerticesByProperty("service-type", "DHV")
+ .<GraphTraversal<?, ?>>getQuery());
+
+ if (serviceInstanceItr == null || !serviceInstanceItr.hasNext()) {
+ logger.info("No servince-instance nodes found with service-type of DHV");
+ return;
+ }
+
+ // iterate through all service instances of service-type DHV
+ while (serviceInstanceItr.hasNext()) {
+ serviceInstance = serviceInstanceItr.next();
+
+ if (serviceInstance != null && serviceInstance.property("bandwidth-total").isPresent()) {
+ serviceInstanceId = serviceInstance.value("service-instance-id");
+ logger.info("Processing service instance with id=" + serviceInstanceId);
+ bandwidthTotal = serviceInstance.value("bandwidth-total");
+
+ if (bandwidthTotal != null && !bandwidthTotal.isEmpty()) {
+
+ // check for existing edges to configuration nodes
+ configurationItr = serviceInstance.vertices(Direction.OUT, "has");
+
+ // create new configuration node if service-instance does not have existing ones
+ if (!configurationItr.hasNext()) {
+ logger.info(serviceInstanceId + " has no existing configuration nodes, creating new node");
+ createConfigurationNode(serviceInstance, bandwidthTotal);
+ continue;
+ }
+
+ // in case if configuration nodes exist, but none are DHV
+ boolean hasDHVConfig = false;
+
+ // service-instance has existing configuration nodes
+ while (configurationItr.hasNext()) {
+ configuration = configurationItr.next();
+ nodeType = configuration.value("aai-node-type").toString();
+
+ if (configuration != null && "configuration".equalsIgnoreCase(nodeType)) {
+ logger.info("Processing configuration node with id=" + configuration.property("configuration-id").value());
+ configType = configuration.value("configuration-type");
+ logger.info("Configuration type: " + configType);
+
+ // if configuration-type is DHV, update tunnel-bandwidth to bandwidth-total value
+ if ("DHV".equalsIgnoreCase(configType)) {
+ if (configuration.property("tunnel-bandwidth").isPresent()) {
+ tunnelBandwidth = configuration.value("tunnel-bandwidth");
+ } else {
+ tunnelBandwidth = "";
+ }
+
+ logger.info("Existing tunnel-bandwidth: " + tunnelBandwidth);
+ configuration.property("tunnel-bandwidth", bandwidthTotal);
+ touchVertexProperties(configuration, false);
+ logger.info("Updated tunnel-bandwidth: " + configuration.value("tunnel-bandwidth"));
+ hasDHVConfig = true;
+ }
+ }
+ }
+
+ // create new configuration node if none of existing config nodes are of type DHV
+ if (!hasDHVConfig) {
+ logger.info(serviceInstanceId + " has existing configuration nodes, but none are DHV, create new node");
+ createConfigurationNode(serviceInstance, bandwidthTotal);
+ }
+ }
+ }
+ }
+ } catch (AAIException | UnsupportedEncodingException e) {
+ logger.error("Caught exception while processing service instance with id=" + serviceInstanceId + " | " + e.toString());
+ success = false;
+ }
+ }
+
+ private void createConfigurationNode(Vertex serviceInstance, String bandwidthTotal) throws UnsupportedEncodingException, AAIException {
+ // create new vertex
+ Vertex configurationNode = serializer.createNewVertex(configObj);
+
+ // configuration-id: UUID format
+ String configurationUUID = UUID.randomUUID().toString();
+ configObj.setValue("configuration-id", configurationUUID);
+
+ // configuration-type: DHV
+ configObj.setValue("configuration-type", "DHV");
+
+ // migrate the bandwidth-total property from the service-instance to the
+ // tunnel-bandwidth property of the related configuration object
+ configObj.setValue("tunnel-bandwidth", bandwidthTotal);
+
+ // create edge between service instance and configuration: cousinEdge(out, in)
+ createCousinEdge(serviceInstance, configurationNode);
+
+ // serialize edge & vertex, takes care of everything
+ serializer.serializeSingleVertex(configurationNode, configObj, "migrations");
+ logger.info("Created configuration node with uuid=" + configurationUUID + ", tunnel-bandwidth=" + bandwidthTotal);
+ }
+
+ @Override
+ public Status getStatus() {
+ if (success) {
+ return Status.SUCCESS;
+ } else {
+ return Status.FAILURE;
+ }
+ }
+
+ @Override
+ public Optional<String[]> getAffectedNodeTypes() {
+ return Optional.of(new String[] {SERVICE_INSTANCE_NODE_TYPE});
+ }
+
+ @Override
+ public String getMigrationName() {
+ return "service-instance-to-configuration";
+ }
+}
diff --git a/aai-resources/src/main/java/org/onap/aai/migration/v12/ToscaMigration.java b/aai-resources/src/main/java/org/onap/aai/migration/v12/ToscaMigration.java
new file mode 100644
index 0000000..274f1b6
--- /dev/null
+++ b/aai-resources/src/main/java/org/onap/aai/migration/v12/ToscaMigration.java
@@ -0,0 +1,160 @@
+package org.onap.aai.migration.v12;
+/*-
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright (C) 2017 AT&T 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=========================================================
+ */
+
+
+import java.util.*;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.Edge;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.onap.aai.db.props.AAIProperties;
+import org.onap.aai.migration.Enabled;
+import org.onap.aai.migration.MigrationDangerRating;
+import org.onap.aai.migration.MigrationPriority;
+import org.onap.aai.migration.Migrator;
+import org.onap.aai.migration.Status;
+import org.onap.aai.serialization.db.*;
+import org.onap.aai.serialization.db.exceptions.EdgeMultiplicityException;
+import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+
+@Enabled
+
+@MigrationPriority(0)
+@MigrationDangerRating(1000)
+public class ToscaMigration extends Migrator {
+
+ private boolean success = true;
+ EdgeRules ers = EdgeRules.getInstance();
+
+ public ToscaMigration(TransactionalGraphEngine graphEngine){
+ super(graphEngine);
+ }
+
+ @Override
+ public Status getStatus() {
+ if (success) {
+ return Status.SUCCESS;
+ } else {
+ return Status.FAILURE;
+ }
+ }
+
+ @Override
+ public void run() {
+ Vertex out = null;
+ Vertex in = null;
+ boolean isCousin = false;
+ String oldEdgeString = null;
+ Map<String,Integer> edgeMultiplicityExceptionCtr = new HashMap<>();
+ List<String> edgeMissingParentProperty = new ArrayList<>();
+
+ GraphTraversalSource g = engine.asAdmin().getTraversalSource();
+
+ try {
+ Set<Edge> edges = g.E().toSet();
+ for (Edge edge : edges) {
+ // skip if this edge was migrated in a previous run
+ if (edge.label().contains("org.") || edge.label().contains("tosca.")) {
+ continue;
+ }
+ out = edge.outVertex();
+ in = edge.inVertex();
+ isCousin = false;
+
+ if (out == null || in == null) {
+ logger.error(edge.id() + " invalid because one vertex was null: out=" + edge.outVertex() + " in=" + edge.inVertex());
+ } else {
+
+ if (edge.property("contains-other-v").isPresent()) {
+ isCousin = "NONE".equals(edge.property("contains-other-v").value());
+ } else if (edge.property("isParent").isPresent()) {
+ isCousin = !(Boolean)edge.property("isParent").value();
+ } else {
+ edgeMissingParentProperty.add(this.toStringForPrinting(edge, 1));
+ }
+
+ String inVertexNodeType = in.value(AAIProperties.NODE_TYPE);
+ String outVertexNodeType = out.value(AAIProperties.NODE_TYPE);
+ String label = null;
+
+
+ Set<String> edgeLabels = ers.getEdgeRules(outVertexNodeType,inVertexNodeType).keySet();
+
+ if (edgeLabels.isEmpty()) {
+ logger.error(edge.id() + " did not migrate as no edge rule found for: out=" + outVertexNodeType + " in=" + inVertexNodeType);
+ continue;
+ } else if (edgeLabels.size() > 1) {
+ if (edgeLabels.contains("org.onap.relationships.inventory.Source")) {
+ if ("sourceLInterface".equals(edge.label())) {
+ label = "org.onap.relationships.inventory.Source";
+ } else if ("targetLInterface".equals(edge.label())) {
+ label = "org.onap.relationships.inventory.Destination";
+ } else {
+ label = "tosca.relationships.network.LinksTo";
+ }
+ }
+ }
+
+ try {
+ if (isCousin) {
+ ers.addEdgeIfPossible(g, in, out, label);
+ } else {
+ ers.addTreeEdge(g, out, in);
+ }
+ edge.remove();
+ } catch (EdgeMultiplicityException edgeMultiplicityException) {
+ logger.warn("Edge Multiplicity Exception: "
+ + "\nInV:\n" + this.toStringForPrinting(in, 1)
+ + "Edge:\n" + this.toStringForPrinting(edge, 1)
+ + "OutV:\n" + this.toStringForPrinting(out, 1)
+ );
+
+ final String mapKey = "OUT:" + outVertexNodeType + " " + (isCousin ? EdgeType.COUSIN.toString():EdgeType.TREE.toString()) + " " + "IN:" + inVertexNodeType;
+ if (edgeMultiplicityExceptionCtr.containsKey(mapKey)) {
+ edgeMultiplicityExceptionCtr.put(mapKey, edgeMultiplicityExceptionCtr.get(mapKey)+1);
+ } else {
+ edgeMultiplicityExceptionCtr.put(mapKey, 1);
+ }
+ }
+ }
+ }
+ } catch(Exception ex){
+ logger.error("exception occurred during migration, failing: out=" + out + " in=" + in + "edge=" + oldEdgeString, ex);
+ success = false;
+ }
+
+ logger.info("Edge Missing Parent Property Count: " + edgeMissingParentProperty.size());
+ logger.info("Edge Multiplicity Exception Count : " + edgeMultiplicityExceptionCtr.values().stream().mapToInt(Number::intValue).sum());
+ logger.info("Edge Multiplicity Exception Breakdown : " + edgeMultiplicityExceptionCtr);
+
+ }
+
+ @Override
+ public Optional<String[]> getAffectedNodeTypes() {
+ return Optional.empty();
+ }
+
+ @Override
+ public String getMigrationName() {
+ return "migrate-all-edges";
+ }
+
+}
diff --git a/aai-resources/src/main/java/org/onap/aai/rest/BulkConsumer.java b/aai-resources/src/main/java/org/onap/aai/rest/BulkConsumer.java
index e03c7fd..51f919e 100644
--- a/aai-resources/src/main/java/org/onap/aai/rest/BulkConsumer.java
+++ b/aai-resources/src/main/java/org/onap/aai/rest/BulkConsumer.java
@@ -53,6 +53,7 @@ import org.onap.aai.introspection.ModelType;
import org.onap.aai.introspection.Version;
import org.onap.aai.introspection.exceptions.AAIUnmarshallingException;
import org.onap.aai.logging.ErrorObjectNotFoundException;
+import org.onap.aai.logging.LoggingContext;
import org.onap.aai.parsers.query.QueryParser;
import org.onap.aai.rest.bulk.BulkOperation;
import org.onap.aai.rest.bulk.BulkOperationResponse;
@@ -94,6 +95,7 @@ public abstract class BulkConsumer extends RESTAPI {
private static final String BULK_PATCH_METHOD = "patch";
private static final String BULK_DELETE_METHOD = "delete";
private static final String BULK_PUT_METHOD = "put";
+ private static final String TARGET_ENTITY = "aai-resources";
/** The introspector factory type. */
private ModelType introspectorFactoryType = ModelType.MOXY;
@@ -122,18 +124,26 @@ public abstract class BulkConsumer extends RESTAPI {
String realTime = headers.getRequestHeaders().getFirst("Real-Time");
String outputMediaType = getMediaType(headers.getAcceptableMediaTypes());
Version version = Version.valueOf(versionParam);
-
Response response = null;
-
- /* A Response will be generated for each object in each transaction.
- * To keep track of what came from where to give organized feedback to the client,
- * we keep responses from a given transaction together in one list (hence all being a list of lists)
- * and BulkOperationResponse each response with its matching URI (which will be null if there wasn't one).
- */
- List<List<BulkOperationResponse>> allResponses = new ArrayList<>();
+
try {
- DBConnectionType type = this.determineConnectionType(sourceOfTruth, realTime);
-
+ DBConnectionType type = this.determineConnectionType(sourceOfTruth, realTime);
+
+ String serviceName = req.getMethod() + " " + req.getRequestURI().toString();
+ LoggingContext.requestId(transId);
+ LoggingContext.partnerName(sourceOfTruth);
+ LoggingContext.serviceName(serviceName);
+ LoggingContext.targetEntity(TARGET_ENTITY);
+ LoggingContext.targetServiceName(serviceName);
+
+
+ /* A Response will be generated for each object in each transaction.
+ * To keep track of what came from where to give organized feedback to the client,
+ * we keep responses from a given transaction together in one list (hence all being a list of lists)
+ * and BulkOperationResponse each response with its matching URI (which will be null if there wasn't one).
+ */
+ List<List<BulkOperationResponse>> allResponses = new ArrayList<>();
+
JsonArray transactions = getTransactions(content, headers);
for (int i = 0; i < transactions.size(); i++){
@@ -150,7 +160,7 @@ public abstract class BulkConsumer extends RESTAPI {
throw new AAIException("AAI_6111", "input payload does not follow bulk interface");
}
- fillBulkOperationObjectFromTransaction(bulkOperations, transObj.getAsJsonObject(), loader, dbEngine, outputMediaType);
+ fillBulkOperationsObjectFromTransaction(bulkOperations, transObj.getAsJsonObject(), loader, dbEngine, outputMediaType);
if (bulkOperations.isEmpty()) {
//case where user sends a validly formatted transactions object but
//which has no actual things in it for A&AI to do anything with
@@ -183,7 +193,7 @@ public abstract class BulkConsumer extends RESTAPI {
if (!bulkOperations.isEmpty()) { //failed somewhere in the middle of bulkOperation-filling
BulkOperation lastBulkOperation = bulkOperations.get(bulkOperations.size()-1); //last one in there was the problem
if (lastBulkOperation.getIntrospector() == null){
- //failed out before thisUri could be set but after bulkOperation started being filled
+ //failed out before thisUri could be set but after bulkOperations started being filled
thisUri = lastBulkOperation.getUri();
method = lastBulkOperation.getHttpMethod();
}
@@ -262,7 +272,7 @@ public abstract class BulkConsumer extends RESTAPI {
/**
* Fill object bulkOperations from transaction.
*
- * @param bulkOperations the bulk Operations
+ * @param bulkOperations the bulkOperations
* @param transaction - JSON body containing the objects to be added
* each object must have a URI and an object body
* @param loader the loader
@@ -274,9 +284,9 @@ public abstract class BulkConsumer extends RESTAPI {
* @throws UnsupportedEncodingException Walks through the given transaction and unmarshals each object in it, then bundles each
* with its URI.
*/
- private void fillBulkOperationObjectFromTransaction(List<BulkOperation> bulkOperations,
+ private void fillBulkOperationsObjectFromTransaction(List<BulkOperation> bulkOperations,
JsonObject transaction, Loader loader, TransactionalGraphEngine dbEngine, String inputMediaType)
- throws AAIException,UnsupportedEncodingException {
+ throws AAIException, JsonSyntaxException, UnsupportedEncodingException {
if (transaction.has(BULK_PUT_METHOD) && this.functionAllowed(HttpMethod.PUT)) {
@@ -416,7 +426,7 @@ public abstract class BulkConsumer extends RESTAPI {
}
} catch (AAIException e) {
- // even if bulkOperations doesn't have a uri or body, this way we keep all information associated with this error together
+ // even if bulkOperation doesn't have a uri or body, this way we keep all information associated with this error together
// even if both are null, that indicates how the input was messed up, so still useful to carry around like this
bulkOperations.add(bulkOperation);
throw e; //rethrow so the right response is generated on the level above
diff --git a/aai-resources/src/main/java/org/onap/aai/rest/BulkProcessConsumer.java b/aai-resources/src/main/java/org/onap/aai/rest/BulkProcessConsumer.java
index bffeac3..d82abd4 100644
--- a/aai-resources/src/main/java/org/onap/aai/rest/BulkProcessConsumer.java
+++ b/aai-resources/src/main/java/org/onap/aai/rest/BulkProcessConsumer.java
@@ -25,7 +25,7 @@ import javax.ws.rs.Path;
import org.onap.aai.restcore.HttpMethod;
-@Path("{version: v[2789]|v1[012]}/bulkprocess")
+@Path("{version: v[789]|v1[012]}/bulkprocess")
public class BulkProcessConsumer extends BulkConsumer {
@Override
diff --git a/aai-resources/src/main/java/org/onap/aai/rest/ExampleConsumer.java b/aai-resources/src/main/java/org/onap/aai/rest/ExampleConsumer.java
index e99d68e..497eeb9 100644
--- a/aai-resources/src/main/java/org/onap/aai/rest/ExampleConsumer.java
+++ b/aai-resources/src/main/java/org/onap/aai/rest/ExampleConsumer.java
@@ -47,7 +47,7 @@ import org.onap.aai.restcore.RESTAPI;
/**
* The Class ExampleConsumer.
*/
-@Path("/{version: v[2789]|v1[012]}/examples")
+@Path("/{version: v[789]|v1[012]}/examples")
public class ExampleConsumer extends RESTAPI {
diff --git a/aai-resources/src/main/java/org/onap/aai/rest/LegacyMoxyConsumer.java b/aai-resources/src/main/java/org/onap/aai/rest/LegacyMoxyConsumer.java
index b4c3593..15d8296 100644
--- a/aai-resources/src/main/java/org/onap/aai/rest/LegacyMoxyConsumer.java
+++ b/aai-resources/src/main/java/org/onap/aai/rest/LegacyMoxyConsumer.java
@@ -27,6 +27,7 @@ import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
+import java.util.concurrent.Callable;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Consumes;
@@ -55,6 +56,7 @@ import org.onap.aai.introspection.Introspector;
import org.onap.aai.introspection.Loader;
import org.onap.aai.introspection.ModelType;
import org.onap.aai.introspection.Version;
+import org.onap.aai.logging.LoggingContext;
import org.onap.aai.parsers.query.QueryParser;
import org.onap.aai.rest.db.DBRequest;
import org.onap.aai.rest.db.HttpEntry;
@@ -64,6 +66,7 @@ import org.onap.aai.restcore.HttpMethod;
import org.onap.aai.restcore.RESTAPI;
import org.onap.aai.serialization.engines.QueryStyle;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+import org.onap.aai.util.AAIConstants;
import org.onap.aai.workarounds.RemoveDME2QueryParams;
import com.att.eelf.configuration.EELFLogger;
@@ -74,14 +77,14 @@ import com.google.common.base.Joiner;
/**
* The Class LegacyMoxyConsumer.
*/
-@Path("{version: v[2789]|v1[012]}")
+@Path("{version: v[789]|v1[012]}")
public class LegacyMoxyConsumer extends RESTAPI {
private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(LegacyMoxyConsumer.class.getName());
protected static String authPolicyFunctionName = "REST";
private ModelType introspectorFactoryType = ModelType.MOXY;
private QueryStyle queryStyle = QueryStyle.TRAVERSAL;
-
+ private final static String TARGET_ENTITY = "aai-resources";
/**
* Update.
*
@@ -98,12 +101,17 @@ public class LegacyMoxyConsumer extends RESTAPI {
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response update (String content, @PathParam("version")String versionParam, @PathParam("uri") @Encoded String uri, @Context HttpHeaders headers, @Context UriInfo info, @Context HttpServletRequest req) {
-
+ String serviceName = "PUT " + uri.toString();
+ String queryStr = req.getQueryString();
+ if ( queryStr != null ) {
+ serviceName = serviceName + "?" + queryStr;
+ }
+ LoggingContext.serviceName(serviceName);
+ LoggingContext.targetServiceName(serviceName);
MediaType mediaType = headers.getMediaType();
-
return this.handleWrites(mediaType, HttpMethod.PUT, content, versionParam, uri, headers, info);
}
-
+
/**
* Update relationship.
*
@@ -120,7 +128,7 @@ public class LegacyMoxyConsumer extends RESTAPI {
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response updateRelationship (String content, @PathParam("version")String versionParam, @PathParam("uri") @Encoded String uri, @Context HttpHeaders headers, @Context UriInfo info, @Context HttpServletRequest req) {
-
+
String sourceOfTruth = headers.getRequestHeaders().getFirst("X-FromAppId");
String transId = headers.getRequestHeaders().getFirst("X-TransactionId");
String realTime = headers.getRequestHeaders().getFirst("Real-Time");
@@ -130,6 +138,17 @@ public class LegacyMoxyConsumer extends RESTAPI {
TransactionalGraphEngine dbEngine = null;
boolean success = true;
+ String serviceName = req.getMethod() + " " + req.getRequestURI().toString();
+ String queryStr = req.getQueryString();
+ if ( queryStr != null ) {
+ serviceName = serviceName + "?" + queryStr;
+ }
+ LoggingContext.requestId(transId);
+ LoggingContext.partnerName(sourceOfTruth);
+ LoggingContext.serviceName(serviceName);
+ LoggingContext.targetEntity(TARGET_ENTITY);
+ LoggingContext.targetServiceName(serviceName);
+
try {
validateRequest(info);
Version version = Version.valueOf(versionParam);
@@ -138,19 +157,19 @@ public class LegacyMoxyConsumer extends RESTAPI {
HttpEntry httpEntry = new HttpEntry(version, introspectorFactoryType, queryStyle, type);
loader = httpEntry.getLoader();
dbEngine = httpEntry.getDbEngine();
-
+
URI uriObject = UriBuilder.fromPath(uri).build();
this.validateURI(uriObject);
QueryParser uriQuery = dbEngine.getQueryBuilder().createQueryFromURI(uriObject);
-
+
Introspector wrappedEntity = loader.unmarshal("relationship", content, org.onap.aai.restcore.MediaType.getEnum(this.getInputMediaType(inputMediaType)));
-
+
DBRequest request = new DBRequest.Builder(HttpMethod.PUT_EDGE, uriObject, uriQuery, wrappedEntity, headers, info, transId).build();
List<DBRequest> requests = new ArrayList<>();
requests.add(request);
Pair<Boolean, List<Pair<URI, Response>>> responsesTuple = httpEntry.process(requests, sourceOfTruth);
-
+
response = responsesTuple.getValue1().get(0).getValue1();
success = responsesTuple.getValue0();
@@ -166,13 +185,12 @@ public class LegacyMoxyConsumer extends RESTAPI {
if (success) {
dbEngine.commit();
} else {
- LOGGER.warn("Rolling back Titan transaction");
dbEngine.rollback();
}
}
}
-
+
return response;
}
@@ -192,11 +210,17 @@ public class LegacyMoxyConsumer extends RESTAPI {
@Consumes({ "application/merge-patch+json" })
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response patch (String content, @PathParam("version")String versionParam, @PathParam("uri") @Encoded String uri, @Context HttpHeaders headers, @Context UriInfo info, @Context HttpServletRequest req) {
-
+
MediaType mediaType = MediaType.APPLICATION_JSON_TYPE;
-
+ String serviceName = "PATCH " + uri.toString();
+ String queryStr = req.getQueryString();
+ if ( queryStr != null ) {
+ serviceName = serviceName + "?" + queryStr;
+ }
+ LoggingContext.serviceName(serviceName);
+ LoggingContext.targetServiceName(serviceName);
return this.handleWrites(mediaType, HttpMethod.MERGE_PATCH, content, versionParam, uri, headers, info);
-
+
}
/**
@@ -217,8 +241,19 @@ public class LegacyMoxyConsumer extends RESTAPI {
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getLegacy (String content, @PathParam("version")String versionParam, @PathParam("uri") @Encoded String uri, @DefaultValue("all") @QueryParam("depth") String depthParam, @DefaultValue("false") @QueryParam("cleanup") String cleanUp, @Context HttpHeaders headers, @Context UriInfo info, @Context HttpServletRequest req) {
-
- return this.getLegacy(content, versionParam, uri, depthParam, cleanUp, headers, info, req, new HashSet<String>());
+ return runner(AAIConstants.AAI_CRUD_TIMEOUT_ENABLED,
+ AAIConstants.AAI_CRUD_TIMEOUT_APP,
+ AAIConstants.AAI_CRUD_TIMEOUT_LIMIT,
+ headers,
+ info,
+ HttpMethod.GET,
+ new Callable<Response>() {
+ @Override
+ public Response call() {
+ return getLegacy(content, versionParam, uri, depthParam, cleanUp, headers, info, req, new HashSet<String>());
+ }
+ }
+ );
}
/**
@@ -243,6 +278,17 @@ public class LegacyMoxyConsumer extends RESTAPI {
TransactionalGraphEngine dbEngine = null;
Loader loader = null;
+ String serviceName = req.getMethod() + " " + req.getRequestURI().toString();
+ String queryStr = req.getQueryString();
+ if ( queryStr != null ) {
+ serviceName = serviceName + "?" + queryStr;
+ }
+ LoggingContext.requestId(transId);
+ LoggingContext.partnerName(sourceOfTruth);
+ LoggingContext.serviceName(serviceName);
+ LoggingContext.targetEntity(TARGET_ENTITY);
+ LoggingContext.targetServiceName(serviceName);
+
try {
validateRequest(info);
Version version = Version.valueOf(versionParam);
@@ -289,7 +335,7 @@ public class LegacyMoxyConsumer extends RESTAPI {
response = consumerExceptionResponseGenerator(headers, info, HttpMethod.GET, e);
} catch (Exception e ) {
AAIException ex = new AAIException("AAI_4000", e);
-
+
response = consumerExceptionResponseGenerator(headers, info, HttpMethod.GET, ex);
} finally {
if (dbEngine != null) {
@@ -300,7 +346,7 @@ public class LegacyMoxyConsumer extends RESTAPI {
}
}
}
-
+
return response;
}
/**
@@ -318,17 +364,27 @@ public class LegacyMoxyConsumer extends RESTAPI {
@Path("/{uri: .+}")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response delete (@PathParam("version")String versionParam, @PathParam("uri") @Encoded String uri, @Context HttpHeaders headers, @Context UriInfo info, @QueryParam("resource-version")String resourceVersion, @Context HttpServletRequest req) {
-
-
+
+
String outputMediaType = getMediaType(headers.getAcceptableMediaTypes());
String sourceOfTruth = headers.getRequestHeaders().getFirst("X-FromAppId");
String transId = headers.getRequestHeaders().getFirst("X-TransactionId");
String realTime = headers.getRequestHeaders().getFirst("Real-Time");
+ String serviceName = req.getMethod() + " " + req.getRequestURI().toString();
+ String queryStr = req.getQueryString();
+ if ( queryStr != null ) {
+ serviceName = serviceName + "?" + queryStr;
+ }
+ LoggingContext.requestId(transId);
+ LoggingContext.partnerName(sourceOfTruth);
+ LoggingContext.serviceName(serviceName);
+ LoggingContext.targetEntity(TARGET_ENTITY);
+ LoggingContext.targetServiceName(serviceName);
TransactionalGraphEngine dbEngine = null;
Response response = Response.status(404)
.type(outputMediaType).build();
-
+
boolean success = true;
try {
@@ -337,7 +393,7 @@ public class LegacyMoxyConsumer extends RESTAPI {
Version version = Version.valueOf(versionParam);
DBConnectionType type = this.determineConnectionType(sourceOfTruth, realTime);
HttpEntry httpEntry = new HttpEntry(version, introspectorFactoryType, queryStyle, type);
-
+
dbEngine = httpEntry.getDbEngine();
Loader loader = httpEntry.getLoader();
@@ -351,7 +407,7 @@ public class LegacyMoxyConsumer extends RESTAPI {
List<DBRequest> requests = new ArrayList<>();
requests.add(request);
Pair<Boolean, List<Pair<URI, Response>>> responsesTuple = httpEntry.process(requests, sourceOfTruth);
-
+
response = responsesTuple.getValue1().get(0).getValue1();
success = responsesTuple.getValue0();
@@ -367,15 +423,14 @@ public class LegacyMoxyConsumer extends RESTAPI {
if (success) {
dbEngine.commit();
} else {
- LOGGER.warn("Rolling back Titan transaction");
dbEngine.rollback();
}
}
}
-
+
return response;
}
-
+
/**
* This whole method does nothing because the body is being dropped while fielding the request.
*
@@ -391,8 +446,8 @@ public class LegacyMoxyConsumer extends RESTAPI {
@Path("/{uri: .+}/relationship-list/relationship")
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
- public Response deleteRelationship (String content, @PathParam("version")String versionParam, @PathParam("uri") @Encoded String uri, @Context HttpHeaders headers, @Context UriInfo info, @Context HttpServletRequest req) {
-
+ public Response deleteRelationship (String content, @PathParam("version")String versionParam, @PathParam("uri") @Encoded String uri, @Context HttpHeaders headers, @Context UriInfo info, @Context HttpServletRequest req) {
+
MediaType inputMediaType = headers.getMediaType();
String outputMediaType = getMediaType(headers.getAcceptableMediaTypes());
@@ -400,11 +455,22 @@ public class LegacyMoxyConsumer extends RESTAPI {
String transId = headers.getRequestHeaders().getFirst("X-TransactionId");
String realTime = headers.getRequestHeaders().getFirst("Real-Time");
+ String serviceName = req.getMethod() + " " + req.getRequestURI().toString();
+ String queryStr = req.getQueryString();
+ if ( queryStr != null ) {
+ serviceName = serviceName + "?" + queryStr;
+ }
+ LoggingContext.requestId(transId);
+ LoggingContext.partnerName(sourceOfTruth);
+ LoggingContext.serviceName(serviceName);
+ LoggingContext.targetEntity(TARGET_ENTITY);
+ LoggingContext.targetServiceName(serviceName);
+
Loader loader = null;
TransactionalGraphEngine dbEngine = null;
Response response = Response.status(404)
.type(outputMediaType).build();
-
+
boolean success = true;
try {
@@ -414,7 +480,7 @@ public class LegacyMoxyConsumer extends RESTAPI {
HttpEntry httpEntry = new HttpEntry(version, introspectorFactoryType, queryStyle, type);
loader = httpEntry.getLoader();
dbEngine = httpEntry.getDbEngine();
-
+
if (content.equals("")) {
throw new AAIException("AAI_3102", "You must supply a relationship");
}
@@ -422,14 +488,14 @@ public class LegacyMoxyConsumer extends RESTAPI {
this.validateURI(uriObject);
QueryParser uriQuery = dbEngine.getQueryBuilder().createQueryFromURI(uriObject);
-
+
Introspector wrappedEntity = loader.unmarshal("relationship", content, org.onap.aai.restcore.MediaType.getEnum(this.getInputMediaType(inputMediaType)));
DBRequest request = new DBRequest.Builder(HttpMethod.DELETE_EDGE, uriObject, uriQuery, wrappedEntity, headers, info, transId).build();
List<DBRequest> requests = new ArrayList<>();
requests.add(request);
Pair<Boolean, List<Pair<URI, Response>>> responsesTuple = httpEntry.process(requests, sourceOfTruth);
-
+
response = responsesTuple.getValue1().get(0).getValue1();
success = responsesTuple.getValue0();
} catch (AAIException e) {
@@ -444,22 +510,17 @@ public class LegacyMoxyConsumer extends RESTAPI {
if (success) {
dbEngine.commit();
} else {
- LOGGER.warn("Rolling back Titan transaction");
dbEngine.rollback();
}
}
}
-
+
return response;
}
/**
* Validate request.
*
- * @param uri the uri
- * @param headers the headers
- * @param req the req
- * @param action the action
* @param info the info
* @throws AAIException the AAI exception
* @throws UnsupportedEncodingException the unsupported encoding exception
@@ -499,7 +560,6 @@ public class LegacyMoxyConsumer extends RESTAPI {
/**
* Handle writes.
*
- * @param aaiAction the aai action
* @param mediaType the media type
* @param method the method
* @param content the content
@@ -507,11 +567,10 @@ public class LegacyMoxyConsumer extends RESTAPI {
* @param uri the uri
* @param headers the headers
* @param info the info
- * @param req the req
* @return the response
*/
private Response handleWrites(MediaType mediaType, HttpMethod method, String content, String versionParam, String uri, HttpHeaders headers, UriInfo info) {
-
+
Response response = null;
TransactionalGraphEngine dbEngine = null;
Loader loader = null;
@@ -521,6 +580,11 @@ public class LegacyMoxyConsumer extends RESTAPI {
String realTime = headers.getRequestHeaders().getFirst("Real-Time");
Boolean success = true;
+ //LoggingContext service name and target service name set in calling method
+ LoggingContext.requestId(transId);
+ LoggingContext.partnerName(sourceOfTruth);
+ LoggingContext.targetEntity(TARGET_ENTITY);
+
try {
validateRequest(info);
@@ -572,7 +636,6 @@ public class LegacyMoxyConsumer extends RESTAPI {
if (success) {
dbEngine.commit();
} else {
- LOGGER.warn("Rolling back Titan transaction");
dbEngine.rollback();
}
}
diff --git a/aai-resources/src/main/java/org/onap/aai/rest/URLFromVertexIdConsumer.java b/aai-resources/src/main/java/org/onap/aai/rest/URLFromVertexIdConsumer.java
index f9a48d9..66677c2 100644
--- a/aai-resources/src/main/java/org/onap/aai/rest/URLFromVertexIdConsumer.java
+++ b/aai-resources/src/main/java/org/onap/aai/rest/URLFromVertexIdConsumer.java
@@ -8,7 +8,7 @@
* 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
+ * 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,
@@ -19,6 +19,7 @@
*
* ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/
+
package org.onap.aai.rest;
import java.net.URI;
@@ -55,7 +56,7 @@ import org.onap.aai.workarounds.LegacyURITransformer;
/**
* The Class URLFromVertexIdConsumer.
*/
-@Path("{version: v[2789]|v1[012]}/generateurl")
+@Path("{version: v[789]|v1[012]}/generateurl")
public class URLFromVertexIdConsumer extends RESTAPI {
private ModelType introspectorFactoryType = ModelType.MOXY;
private QueryStyle queryStyle = QueryStyle.TRAVERSAL;
@@ -73,6 +74,7 @@ public class URLFromVertexIdConsumer extends RESTAPI {
* @param req the req
* @return the response
*/
+ @GET
@Path(ID_ENDPOINT)
@Produces({ MediaType.TEXT_PLAIN })
public Response generateUrlFromVertexId(String content, @PathParam("version")String versionParam, @PathParam("vertexid")long vertexid, @Context HttpHeaders headers, @Context UriInfo info, @Context HttpServletRequest req) {
@@ -103,6 +105,11 @@ public class URLFromVertexIdConsumer extends RESTAPI {
result.insert(0, AAIConfig.get("aai.server.url.base"));
LegacyURITransformer urlTransformer = LegacyURITransformer.getInstance();
URI output = new URI(result.toString());
+ /*if (version.compareTo(Version.v2) == 0) {
+ output = urlTransformer.getLegacyURI(output);
+ result = new StringBuilder();
+ result.append(output.toString());
+ }*/
response = Response.ok().entity(result.toString()).status(Status.OK).type(MediaType.TEXT_PLAIN).build();
} catch (AAIException e) {
diff --git a/aai-resources/src/main/java/org/onap/aai/rest/VertexIdConsumer.java b/aai-resources/src/main/java/org/onap/aai/rest/VertexIdConsumer.java
index 453297e..af6022c 100644
--- a/aai-resources/src/main/java/org/onap/aai/rest/VertexIdConsumer.java
+++ b/aai-resources/src/main/java/org/onap/aai/rest/VertexIdConsumer.java
@@ -64,7 +64,7 @@ import org.onap.aai.serialization.engines.TransactionalGraphEngine;
/**
* The Class VertexIdConsumer.
*/
-@Path("{version: v[2789]|v1[012]}/resources")
+@Path("{version: v[789]|v1[012]}/resources")
public class VertexIdConsumer extends RESTAPI {
private ModelType introspectorFactoryType = ModelType.MOXY;
diff --git a/aai-resources/src/main/java/org/onap/aai/rest/tools/ModelVersionTransformer.java b/aai-resources/src/main/java/org/onap/aai/rest/tools/ModelVersionTransformer.java
index dd1dcda..979f340 100644
--- a/aai-resources/src/main/java/org/onap/aai/rest/tools/ModelVersionTransformer.java
+++ b/aai-resources/src/main/java/org/onap/aai/rest/tools/ModelVersionTransformer.java
@@ -55,6 +55,7 @@ import org.onap.aai.introspection.ModelType;
import org.onap.aai.introspection.Version;
import org.onap.aai.introspection.exceptions.AAIUnknownObjectException;
import org.onap.aai.logging.ErrorLogHelper;
+import org.onap.aai.logging.LogFormatTools;
import org.onap.aai.rest.db.HttpEntry;
import org.onap.aai.rest.exceptions.AAIInvalidXMLNamespace;
import org.onap.aai.rest.util.ValidateEncoding;
@@ -182,7 +183,7 @@ public class ModelVersionTransformer extends RESTAPI {
modelVerObj.setValue("model-version", oldModelVersion);
- if (obj.hasProperty(MODEL_ELEMENTS)) {
+ if (obj.hasProperty(MODEL_ELEMENTS)) {
Introspector oldModelElements = obj.getWrappedValue(MODEL_ELEMENTS);
if (oldModelElements != null) {
Introspector newModelElements = modelVerObj.newIntrospectorInstanceOfProperty(MODEL_ELEMENTS);
@@ -271,7 +272,7 @@ public class ModelVersionTransformer extends RESTAPI {
Introspector newRelationship = newModelElements.getLoader().introspectorFromName(RELATIONSHIP);
newRelationshipListList.add(newRelationship.getUnderlyingObject());
- List<Introspector> oldRelationshipData = oldRelationship.getWrappedListValue(RELATIONSHIP);
+ List<Introspector> oldRelationshipData = oldRelationship.getWrappedListValue("relationship-data");
List<Object> newRelationshipData = (List<Object>)newRelationship.getValue("relationship-data");
newRelationship.setValue("related-to", "model-ver");
@@ -331,10 +332,10 @@ public class ModelVersionTransformer extends RESTAPI {
}
- private Map<String, String> getCurrentModelsFromGraph(HttpHeaders headers, String transactionId, UriInfo info) throws AAIException {
+ private Map<String, String> getCurrentModelsFromGraph(HttpHeaders headers, String transactionId, UriInfo info) throws NoEdgeRuleFoundException, AAIException {
TransactionalGraphEngine dbEngine = null;
- Map<String, String> modelVerModelMap = new HashMap<>() ;
+ Map<String, String> modelVerModelMap = new HashMap<String,String>() ;
try {
Version version = AAIProperties.LATEST;
@@ -353,8 +354,8 @@ public class ModelVersionTransformer extends RESTAPI {
}
} catch (NoSuchElementException e) {
throw new NoSuchElementException();
- } catch (Exception e1) {
- LOGGER.error("Exception while getting current models from graph"+e1);
+ } catch (Exception e1) {
+ LOGGER.error("Exception while getting current models from graph"+ LogFormatTools.getStackTop(e1));
}
return modelVerModelMap;
diff --git a/aai-resources/src/main/java/org/onap/aai/util/AAIAppServletContextListener.java b/aai-resources/src/main/java/org/onap/aai/util/AAIAppServletContextListener.java
index 58dc29b..e3e2d97 100644
--- a/aai-resources/src/main/java/org/onap/aai/util/AAIAppServletContextListener.java
+++ b/aai-resources/src/main/java/org/onap/aai/util/AAIAppServletContextListener.java
@@ -22,31 +22,37 @@
package org.onap.aai.util;
import java.io.IOException;
+import java.util.UUID;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
+import org.apache.activemq.broker.BrokerService;
import org.onap.aai.dbmap.AAIGraph;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.introspection.ModelInjestor;
import org.onap.aai.logging.ErrorLogHelper;
+import org.onap.aai.logging.LogFormatTools;
+import org.onap.aai.logging.LoggingContext;
+import org.onap.aai.logging.LoggingContext.StatusCode;
import org.onap.aai.migration.MigrationControllerInternal;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
public class AAIAppServletContextListener implements ServletContextListener {
+ private static final String ACTIVEMQ_TCP_URL = "tcp://localhost:61447";
+
private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(AAIAppServletContextListener.class.getName());
+ private BrokerService broker = new BrokerService();
+
/**
* Destroys Context
- *
+ *
* @param arg0 the ServletContextEvent
*/
- public void contextDestroyed(ServletContextEvent arg0) {
- LOGGER.info("AAIGraph shutting down");
- AAIGraph.getInstance().graphShutdown();
- LOGGER.info("AAIGraph shutdown");
+ public void contextDestroyed(ServletContextEvent arg0) {
}
/**
@@ -56,8 +62,18 @@ public class AAIAppServletContextListener implements ServletContextListener {
*/
public void contextInitialized(ServletContextEvent arg0) {
System.setProperty("org.onap.aai.serverStarted", "false");
- LOGGER.info("***AAI Server initialization started...");
+ System.setProperty("aai.service.name", "resources");
+
+ LoggingContext.save();
+ LoggingContext.component("init");
+ LoggingContext.partnerName("NA");
+ LoggingContext.targetEntity("aai-resources");
+ LoggingContext.requestId(UUID.randomUUID().toString());
+ LoggingContext.serviceName("aai-resources");
+ LoggingContext.targetServiceName("contextInitialized");
+ LoggingContext.statusCode(StatusCode.COMPLETE);
+ LOGGER.info("AAI Server initialization started...");
try {
LOGGER.info("Loading aaiconfig.properties");
AAIConfig.init();
@@ -70,12 +86,36 @@ public class AAIAppServletContextListener implements ServletContextListener {
AAIGraph.getInstance();
ModelInjestor.getInstance();
+ // Jsm internal broker for aai events
+ broker = new BrokerService();
+ broker.addConnector(ACTIVEMQ_TCP_URL);
+ broker.setPersistent(false);
+ broker.setUseJmx(false);
+ broker.setSchedulerSupport(false);
+ broker.start();
+
LOGGER.info("A&AI Server initialization succcessful.");
+ System.setProperty("activemq.tcp.url", ACTIVEMQ_TCP_URL);
System.setProperty("org.onap.aai.serverStarted", "true");
if ("true".equals(AAIConfig.get("aai.run.migrations", "false"))) {
MigrationControllerInternal migrations = new MigrationControllerInternal();
migrations.run(new String[]{"--commit"});
}
+
+ Runtime.getRuntime().addShutdownHook(new Thread() {
+ public void run() {
+ LOGGER.info("AAIGraph shutting down");
+ AAIGraph.getInstance().graphShutdown();
+ LOGGER.info("AAIGraph shutdown");
+ try {
+ broker.stop();
+ } catch (Exception e) {
+ LOGGER.error("Issue closing broker "+ LogFormatTools.getStackTop(e));
+ }
+ System.out.println("Shutdown hook triggered.");
+ }
+ });
+
} catch (AAIException e) {
ErrorLogHelper.logException(e);
throw new RuntimeException("AAIException caught while initializing A&AI server", e);
@@ -83,12 +123,12 @@ public class AAIAppServletContextListener implements ServletContextListener {
ErrorLogHelper.logError("AAI_4000", e.getMessage());
throw new RuntimeException("IOException caught while initializing A&AI server", e);
} catch (Exception e) {
- LOGGER.error("Unknown failure while initializing A&AI Server", e);
+ LOGGER.error("Unknown failure while initializing A&AI Server " + LogFormatTools.getStackTop(e));
throw new RuntimeException("Unknown failure while initializing A&AI server", e);
}
LOGGER.info("Resources MicroService Started");
- LOGGER.error("Resources MicroService Started");
LOGGER.debug("Resources MicroService Started");
+ LoggingContext.restore();
}
}
diff --git a/aai-resources/src/main/resources/edgeLabelMigration.csv b/aai-resources/src/main/resources/edgeLabelMigration.csv
new file mode 100644
index 0000000..53639e5
--- /dev/null
+++ b/aai-resources/src/main/resources/edgeLabelMigration.csv
@@ -0,0 +1,212 @@
+from,to,label,direction,multiplicity,contains-other-v,delete-other-v,SVC-INFRA,prevent-delete,new from,new to,new label,new direction,new multiplicity,new contains-other-v,new delete-other-v,new SVC-INFRA,new prevent-delete,new default
+allotted-resource,allotted-resource,bindsTo,OUT,ONE2ONE,NONE,NONE,NONE,NONE,allotted-resource,allotted-resource,tosca.relationships.network.BindsTo,OUT,ONE2ONE,NONE,NONE,NONE,NONE,T
+allotted-resource,generic-vnf,isPartOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,allotted-resource,generic-vnf,org.onap.relationships.inventory.PartOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T
+allotted-resource,instance-group,isMemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,allotted-resource,instance-group,org.onap.relationships.inventory.MemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T
+allotted-resource,l3-network,isPartOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,allotted-resource,l3-network,org.onap.relationships.inventory.PartOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T
+allotted-resource,l-interface,uses,OUT,ONE2MANY,NONE,NONE,NONE,NONE,allotted-resource,l-interface,org.onap.relationships.inventory.Uses,OUT,ONE2MANY,NONE,NONE,NONE,NONE,T
+allotted-resource,network-policy,uses,OUT,ONE2ONE,NONE,NONE,NONE,NONE,allotted-resource,network-policy,org.onap.relationships.inventory.Uses,OUT,ONE2ONE,NONE,NONE,NONE,NONE,T
+allotted-resource,vlan,isPartOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,allotted-resource,vlan,org.onap.relationships.inventory.PartOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T
+allotted-resource,vpn-binding,belongsTo,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},allotted-resource,vpn-binding,org.onap.relationships.inventory.BelongsTo,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},T
+allotted-resource,tunnel-xconnect,has,OUT,ONE2ONE,${direction},${direction},NONE,NONE,tunnel-xconnect,allotted-resource,org.onap.relationships.inventory.BelongsTo,OUT,ONE2ONE,!${direction},!${direction},NONE,NONE,T
+availability-zone,complex,groupsResourcesIn,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},availability-zone,complex,org.onap.relationships.inventory.LocatedIn,OUT,MANY2ONE,NONE,NONE,NONE,!${direction},T
+availability-zone,service-capability,supportsServiceCapability,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},availability-zone,service-capability,org.onap.relationships.inventory.AppliesTo,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},T
+cloud-region,availability-zone,has,OUT,ONE2MANY,${direction},${direction},NONE,${direction},availability-zone,cloud-region,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T
+cloud-region,complex,locatedIn,OUT,MANY2ONE,NONE,NONE,NONE,!${direction},cloud-region,complex,org.onap.relationships.inventory.LocatedIn,OUT,MANY2ONE,NONE,NONE,NONE,!${direction},T
+cloud-region,l3-network,uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,cloud-region,l3-network,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T
+cloud-region,zone,isMemberOf,OUT,MANY2ONE,NONE,NONE,NONE,NONE,cloud-region,zone,org.onap.relationships.inventory.LocatedIn,OUT,MANY2ONE,NONE,NONE,NONE,NONE,T
+cloud-region,dvs-switch,has,OUT,ONE2MANY,${direction},${direction},NONE,${direction},dvs-switch,cloud-region,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},NONE,NONE,!${direction},T
+cloud-region,flavor,has,OUT,ONE2MANY,${direction},${direction},NONE,${direction},flavor,cloud-region,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},NONE,NONE,!${direction},T
+cloud-region,group-assignment,has,OUT,ONE2MANY,${direction},${direction},NONE,${direction},group-assignment,cloud-region,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},NONE,NONE,!${direction},T
+cloud-region,image,has,OUT,ONE2MANY,${direction},${direction},NONE,${direction},image,cloud-region,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},NONE,NONE,!${direction},T
+cloud-region,oam-network,has,OUT,ONE2MANY,${direction},${direction},NONE,${direction},oam-network,cloud-region,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},NONE,NONE,!${direction},T
+cloud-region,snapshot,has,OUT,ONE2MANY,${direction},${direction},NONE,${direction},snapshot,cloud-region,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},NONE,NONE,!${direction},T
+cloud-region,tenant,has,OUT,ONE2MANY,${direction},${direction},!${direction},${direction},tenant,cloud-region,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},NONE,${direction},!${direction},T
+cloud-region,vip-ipv4-address-list,hasIpAddress,OUT,ONE2MANY,${direction},${direction},${direction},NONE,vip-ipv4-address-list,cloud-region,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},NONE,NONE,!${direction},T
+cloud-region,vip-ipv6-address-list,hasIpAddress,OUT,ONE2MANY,${direction},${direction},${direction},NONE,vip-ipv6-address-list,cloud-region,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},NONE,NONE,!${direction},T
+cloud-region,volume-group,has,OUT,ONE2MANY,${direction},${direction},NONE,${direction},volume-group,cloud-region,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},NONE,NONE,!${direction},T
+complex,l3-network,usesL3Network,OUT,MANY2MANY,NONE,NONE,${direction},NONE,complex,l3-network,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,${direction},NONE,T
+complex,ctag-pool,hasCtagPool,OUT,MANY2MANY,${direction},${direction},NONE,NONE,ctag-pool,complex,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T
+configuration,allotted-resource,uses,OUT,ONE2ONE,NONE,${direction},NONE,NONE,configuration,allotted-resource,org.onap.relationships.inventory.Uses,OUT,ONE2ONE,NONE,${direction},NONE,NONE,T
+configuration,logical-link,has,OUT,ONE2MANY,NONE,${direction},NONE,NONE,configuration,logical-link,org.onap.relationships.inventory.Uses,OUT,ONE2MANY,NONE,${direction},NONE,NONE,T
+configuration,metadatum,owns,OUT,ONE2MANY,${direction},${direction},NONE,NONE,metadatum,configuration,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T
+connector,virtual-data-center,contains,OUT,MANY2MANY,NONE,NONE,NONE,NONE,connector,virtual-data-center,org.onap.relationships.inventory.LocatedIn,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T
+connector,metadatum,hasMetaData,OUT,MANY2MANY,${direction},${direction},NONE,NONE,metadatum,connector,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T
+constrained-element-set,element-choice-set,uses,OUT,ONE2MANY,${direction},${direction},NONE,NONE,element-choice-set,constrained-element-set,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T
+ctag-pool,availability-zone,supportsAvailabilityZone,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},ctag-pool,availability-zone,org.onap.relationships.inventory.AppliesTo,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},T
+customer,service-subscription,subscribesTo,OUT,MANY2MANY,${direction},${direction},!${direction},NONE,service-subscription,customer,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},${direction},NONE,T
+dvs-switch,availability-zone,existsIn,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},dvs-switch,availability-zone,org.onap.relationships.inventory.AppliesTo,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},T
+element-choice-set,model-element,has,OUT,ONE2MANY,${direction},${direction},NONE,NONE,model-element,element-choice-set,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T
+generic-vnf,entitlement,has,OUT,ONE2MANY,${direction},${direction},NONE,NONE,entitlement,generic-vnf,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T
+generic-vnf,availability-zone,hasAvailabilityZone,OUT,MANY2MANY,NONE,NONE,${direction},!${direction},generic-vnf,availability-zone,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,${direction},!${direction},T
+generic-vnf,complex,locatedIn,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},generic-vnf,complex,org.onap.relationships.inventory.LocatedIn,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},T
+generic-vnf,configuration,uses,OUT,ONE2MANY,NONE,${direction},NONE,NONE,generic-vnf,configuration,org.onap.relationships.inventory.Uses,OUT,ONE2MANY,NONE,${direction},NONE,NONE,T
+generic-vnf,ctag-pool,usesCtagPool,OUT,MANY2MANY,NONE,NONE,NONE,NONE,generic-vnf,ctag-pool,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T
+generic-vnf,instance-group,isMemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,generic-vnf,instance-group,org.onap.relationships.inventory.MemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T
+generic-vnf,ipsec-configuration,uses,OUT,MANY2ONE,NONE,NONE,NONE,NONE,generic-vnf,ipsec-configuration,org.onap.relationships.inventory.Uses,OUT,MANY2ONE,NONE,NONE,NONE,NONE,T
+generic-vnf,l3-network,usesL3Network,OUT,MANY2MANY,NONE,NONE,${direction},NONE,generic-vnf,l3-network,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,${direction},NONE,T
+generic-vnf,license-key-resource,uses,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},generic-vnf,license-key-resource,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},T
+generic-vnf,pnf,hostedOn,OUT,MANY2MANY,NONE,NONE,NONE,NONE,generic-vnf,pnf,tosca.relationships.HostedOn,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T
+generic-vnf,pserver,runsOnPserver,OUT,MANY2MANY,NONE,NONE,${direction},!${direction},generic-vnf,pserver,tosca.relationships.HostedOn,OUT,MANY2MANY,NONE,NONE,${direction},!${direction},T
+generic-vnf,vnfc,uses,OUT,ONE2MANY,NONE,${direction},${direction},NONE,vnfc,generic-vnf,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,NONE,!${direction},!${direction},NONE,T
+generic-vnf,vnf-image,usesVnfImage,OUT,MANY2ONE,NONE,NONE,${direction},!${direction},generic-vnf,vnf-image,org.onap.relationships.inventory.Uses,OUT,MANY2ONE,NONE,NONE,${direction},!${direction},T
+generic-vnf,volume-group,uses,OUT,ONE2MANY,NONE,NONE,${direction},NONE,generic-vnf,volume-group,org.onap.relationships.inventory.DependsOn,OUT,ONE2MANY,NONE,NONE,${direction},NONE,T
+generic-vnf,vserver,runsOnVserver,OUT,ONE2MANY,NONE,NONE,${direction},NONE,generic-vnf,vserver,tosca.relationships.HostedOn,OUT,ONE2MANY,NONE,NONE,${direction},NONE,T
+generic-vnf,lag-interface,hasLAGInterface,OUT,MANY2MANY,${direction},${direction},${direction},NONE,lag-interface,generic-vnf,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T
+generic-vnf,license,has,OUT,ONE2MANY,${direction},${direction},NONE,NONE,license,generic-vnf,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T
+generic-vnf,l-interface,hasLInterface,OUT,MANY2MANY,${direction},${direction},${direction},NONE,l-interface,generic-vnf,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T
+generic-vnf,network-profile,hasNetworkProfile,OUT,MANY2MANY,NONE,NONE,NONE,NONE,network-profile,generic-vnf,org.onap.relationships.inventory.AppliesTo,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T
+generic-vnf,service-instance,hasInstance,OUT,MANY2MANY,NONE,NONE,${direction},NONE,service-instance,generic-vnf,org.onap.relationships.inventory.ComposedOf,OUT,ONE2MANY,NONE,NONE,!${direction},NONE,T
+generic-vnf,site-pair-set,hasSitePairSet,OUT,MANY2MANY,NONE,NONE,NONE,NONE,site-pair-set,generic-vnf,org.onap.relationships.inventory.AppliesTo,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T
+generic-vnf,vf-module,has,OUT,ONE2MANY,${direction},${direction},${direction},NONE,vf-module,generic-vnf,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T
+group-assignment,pserver,has,OUT,ONE2MANY,NONE,NONE,NONE,!${direction},pserver,group-assignment,org.onap.relationships.inventory.MemberOf,OUT,MANY2ONE,NONE,NONE,NONE,${direction},T
+group-assignment,tenant,has,OUT,MANY2MANY,NONE,NONE,NONE,NONE,tenant,group-assignment,org.onap.relationships.inventory.MemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T
+image,metadatum,hasMetaDatum,OUT,MANY2MANY,${direction},${direction},NONE,NONE,metadatum,image,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T
+instance-group,model,targets,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},instance-group,model,org.onap.relationships.inventory.Targets,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},T
+ipsec-configuration,vig-server,hasVigServer,OUT,ONE2MANY,${direction},${direction},NONE,NONE,vig-server,ipsec-configuration,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T
+l3-interface-ipv4-address-list,instance-group,isMemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,l3-interface-ipv4-address-list,instance-group,org.onap.relationships.inventory.network.MemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T
+l3-interface-ipv4-address-list,l3-network,isMemberOf,OUT,MANY2MANY,NONE,NONE,${direction},NONE,l3-interface-ipv4-address-list,l3-network,org.onap.relationships.inventory.network.MemberOf,OUT,MANY2MANY,NONE,NONE,${direction},NONE,T
+l3-interface-ipv4-address-list,subnet,isMemberOf,OUT,MANY2MANY,NONE,NONE,${direction},!${direction},l3-interface-ipv4-address-list,subnet,org.onap.relationships.inventory.network.MemberOf,OUT,MANY2MANY,NONE,NONE,${direction},!${direction},T
+l3-interface-ipv6-address-list,instance-group,isMemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,l3-interface-ipv6-address-list,instance-group,org.onap.relationships.inventory.network.MemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T
+l3-interface-ipv6-address-list,l3-network,isMemberOf,OUT,MANY2MANY,NONE,NONE,${direction},NONE,l3-interface-ipv6-address-list,l3-network,org.onap.relationships.inventory.network.MemberOf,OUT,MANY2MANY,NONE,NONE,${direction},NONE,T
+l3-interface-ipv6-address-list,subnet,isMemberOf,OUT,MANY2MANY,NONE,NONE,${direction},!${direction},l3-interface-ipv6-address-list,subnet,org.onap.relationships.inventory.network.MemberOf,OUT,MANY2MANY,NONE,NONE,${direction},!${direction},T
+l3-network,ctag-assignment,hasCtagAssignment,OUT,MANY2MANY,${direction},${direction},${direction},NONE,ctag-assignment,l3-network,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T
+l3-network,instance-group,memberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,l3-network,instance-group,org.onap.relationships.inventory.MemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T
+l3-network,network-policy,uses,OUT,MANY2MANY,NONE,NONE,${direction},NONE,l3-network,network-policy,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,${direction},NONE,T
+l3-network,route-table-reference,uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,l3-network,route-table-reference,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T
+l3-network,vpn-binding,usesVpnBinding,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},l3-network,vpn-binding,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},T
+l3-network,segmentation-assignment,has,OUT,ONE2MANY,${direction},${direction},NONE,NONE,segmentation-assignment,l3-network,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T
+l3-network,service-instance,hasInstance,OUT,MANY2MANY,NONE,NONE,!${direction},NONE,service-instance,l3-network,org.onap.relationships.inventory.ComposedOf,OUT,ONE2MANY,NONE,NONE,${direction},NONE,T
+l3-network,subnet,hasSubnet,OUT,MANY2MANY,${direction},${direction},!${direction},NONE,subnet,l3-network,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},${direction},NONE,T
+lag-interface,lag-link,usesLAGLink,OUT,MANY2MANY,NONE,${direction},${direction},NONE,lag-interface,lag-link,tosca.relationships.network.LinksTo,OUT,MANY2MANY,NONE,${direction},${direction},NONE,T
+lag-interface,logical-link,uses,OUT,MANY2MANY,NONE,${direction},${direction},NONE,lag-interface,logical-link,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,${direction},${direction},NONE,T
+lag-interface,p-interface,usesPInterface,OUT,MANY2MANY,NONE,NONE,${direction},NONE,lag-interface,p-interface,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,${direction},NONE,T
+lag-interface,l-interface,hasLInterface,OUT,MANY2MANY,${direction},${direction},${direction},NONE,l-interface,lag-interface,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T
+line-of-business,generic-vnf,realizedBy,OUT,MANY2MANY,NONE,NONE,NONE,NONE,line-of-business,generic-vnf,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T
+l-interface,l3-interface-ipv4-address-list,hasIpAddress,OUT,MANY2MANY,${direction},${direction},${direction},NONE,l3-interface-ipv4-address-list,l-interface,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T
+l-interface,l3-interface-ipv6-address-list,hasIpAddress,OUT,MANY2MANY,${direction},${direction},${direction},NONE,l3-interface-ipv6-address-list,l-interface,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T
+l-interface,instance-group,isMemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,l-interface,instance-group,org.onap.relationships.inventory.MemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T
+l-interface,l-interface,has,OUT,ONE2MANY,${direction},${direction},${direction},NONE,l-interface,l-interface,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T
+l-interface,logical-link,usesLogicalLink,OUT,MANY2MANY,NONE,${direction},${direction},NONE,l-interface,logical-link,tosca.relationships.network.LinksTo,OUT,MANY2ONE,NONE,${direction},${direction},NONE,T
+l-interface,logical-link,sourceLInterface,OUT,MANY2MANY,NONE,${direction},${direction},NONE,logical-link,l-interface,org.onap.relationships.inventory.Source,OUT,ONE2MANY,NONE,!${direction},!${direction},NONE,F
+l-interface,logical-link,targetLInterface,OUT,MANY2MANY,NONE,${direction},${direction},NONE,logical-link,l-interface,org.onap.relationships.inventory.Destination,OUT,ONE2MANY,NONE,!${direction},!${direction},NONE,F
+l-interface,sriov-vf,has,OUT,ONE2ONE,${direction},${direction},NONE,NONE,sriov-vf,l-interface,org.onap.relationships.inventory.BelongsTo,OUT,ONE2ONE,!${direction},!${direction},NONE,NONE,T
+l-interface,vlan,hasVlan,OUT,MANY2MANY,${direction},${direction},NONE,NONE,vlan,l-interface,tosca.relationships.network.LinksTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T
+logical-link,cloud-region,existsIn,OUT,MANY2MANY,NONE,NONE,NONE,NONE,logical-link,cloud-region,org.onap.relationships.inventory.LocatedIn,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T
+logical-link,generic-vnf,bridgedTo,OUT,MANY2MANY,NONE,NONE,NONE,NONE,logical-link,generic-vnf,org.onap.relationships.inventory.BridgedTo,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T
+logical-link,lag-link,usesLAGLink,OUT,MANY2MANY,NONE,NONE,${direction},NONE,logical-link,lag-link,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,${direction},NONE,T
+logical-link,logical-link,uses,OUT,ONE2MANY,NONE,NONE,${direction},NONE,logical-link,logical-link,org.onap.relationships.inventory.Uses,OUT,ONE2MANY,NONE,NONE,${direction},NONE,T
+logical-link,pnf,bridgedTo,OUT,MANY2MANY,NONE,NONE,NONE,NONE,logical-link,pnf,org.onap.relationships.inventory.BridgedTo,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T
+logical-link,pserver,bridgedTo,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},logical-link,pserver,org.onap.relationships.inventory.BridgedTo,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},T
+logical-link,vpn-binding,uses,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},logical-link,vpn-binding,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},T
+model,model-ver,has,OUT,ONE2MANY,${direction},${direction},NONE,NONE,model-ver,model,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T
+model-constraint,constrained-element-set,uses,OUT,ONE2MANY,${direction},${direction},NONE,NONE,constrained-element-set,model-constraint,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T
+model-element,constrained-element-set,connectsTo,OUT,ONE2MANY,${direction},${direction},NONE,NONE,constrained-element-set,model-element,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T
+model-element,model-constraint,uses,OUT,ONE2MANY,${direction},${direction},NONE,NONE,model-constraint,model-element,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T
+model-element,model-element,connectsTo,OUT,ONE2MANY,${direction},${direction},NONE,NONE,model-element,model-element,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T
+model-element,model-ver,isA,OUT,MANY2ONE,NONE,NONE,NONE,!${direction},model-element,model-ver,org.onap.relationships.inventory.IsA,OUT,MANY2ONE,NONE,NONE,NONE,!${direction},T
+model-ver,metadatum,hasMetaDatum,OUT,ONE2MANY,${direction},${direction},NONE,NONE,metadatum,model-ver,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T
+model-ver,model-element,startsWith,OUT,ONE2MANY,${direction},${direction},NONE,NONE,model-element,model-ver,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T
+named-query,model,relatedTo,OUT,ONE2MANY,NONE,NONE,NONE,!${direction},named-query,model,org.onap.relationships.inventory.AppliesTo,OUT,ONE2MANY,NONE,NONE,NONE,!${direction},T
+named-query,named-query-element,startsWith,OUT,ONE2ONE,${direction},${direction},NONE,NONE,named-query-element,named-query,org.onap.relationships.inventory.BelongsTo,OUT,ONE2ONE,!${direction},!${direction},NONE,NONE,T
+named-query-element,model,isA,OUT,MANY2ONE,NONE,NONE,NONE,!${direction},named-query-element,model,org.onap.relationships.inventory.IsA,OUT,MANY2ONE,NONE,NONE,NONE,!${direction},T
+named-query-element,named-query-element,connectsTo,OUT,MANY2MANY,${direction},${direction},NONE,NONE,named-query-element,named-query-element,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T
+named-query-element,property-constraint,uses,OUT,ONE2MANY,${direction},${direction},NONE,NONE,property-constraint,named-query-element,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T
+named-query-element,related-lookup,uses,OUT,ONE2MANY,${direction},${direction},NONE,NONE,related-lookup,named-query-element,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T
+newvce,l-interface,hasLInterface,OUT,MANY2MANY,${direction},${direction},NONE,NONE,l-interface,newvce,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T
+oam-network,complex,definedFor,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},oam-network,complex,org.onap.relationships.inventory.AppliesTo,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},T
+oam-network,service-capability,supportsServiceCapability,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},oam-network,service-capability,org.onap.relationships.inventory.AppliesTo,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},T
+operational-environment,operational-environment,managedBy,OUT,ONE2ONE,NONE,NONE,NONE,NONE,operational-environment,operational-environment,org.onap.relationships.inventory.Uses,OUT,ONE2ONE,NONE,NONE,NONE,NONE,T
+owning-entity,service-instance,owns,OUT,ONE2MANY,NONE,NONE,NONE,NONE,service-instance,owning-entity,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,NONE,NONE,NONE,NONE,T
+p-interface,l-interface,hasLInterface,OUT,MANY2MANY,${direction},${direction},${direction},NONE,l-interface,p-interface,tosca.relationships.network.BindsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T
+p-interface,logical-link,usesLogicalLink,OUT,MANY2ONE,NONE,NONE,${direction},NONE,p-interface,logical-link,tosca.relationships.network.LinksTo,OUT,MANY2ONE,NONE,NONE,${direction},NONE,T
+p-interface,physical-link,usesPhysicalLink,OUT,MANY2MANY,NONE,${direction},NONE,NONE,p-interface,physical-link,tosca.relationships.network.LinksTo,OUT,MANY2ONE,NONE,${direction},NONE,NONE,T
+p-interface,sriov-pf,has,OUT,ONE2ONE,${direction},${direction},NONE,NONE,sriov-pf,p-interface,org.onap.relationships.inventory.BelongsTo,OUT,ONE2ONE,!${direction},!${direction},NONE,NONE,T
+platform,generic-vnf,uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,platform,generic-vnf,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T
+pnf,lag-interface,has,OUT,ONE2MANY,${direction},${direction},${direction},NONE,lag-interface,pnf,tosca.relationships.network.BindsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T
+pnf,p-interface,hasPinterface,OUT,MANY2MANY,${direction},${direction},${direction},NONE,p-interface,pnf,tosca.relationships.network.BindsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T
+pnf,complex,locatedIn,OUT,MANY2ONE,NONE,NONE,NONE,!${direction},pnf,complex,org.onap.relationships.inventory.LocatedIn,OUT,MANY2ONE,NONE,NONE,NONE,!${direction},T
+pnf,instance-group,isMemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,pnf,instance-group,org.onap.relationships.inventory.MemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T
+pnf,zone,isMemberOf,OUT,MANY2ONE,NONE,NONE,NONE,NONE,pnf,zone,org.onap.relationships.inventory.LocatedIn,OUT,MANY2ONE,NONE,NONE,NONE,NONE,T
+port-group,cvlan-tag,hasCTag,OUT,MANY2MANY,${direction},${direction},${direction},NONE,cvlan-tag,port-group,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T
+project,service-instance,created,OUT,ONE2MANY,NONE,NONE,NONE,NONE,project,service-instance,org.onap.relationships.inventory.Uses,OUT,ONE2MANY,NONE,NONE,NONE,NONE,T
+pserver,lag-interface,hasLAGInterface,OUT,MANY2MANY,${direction},${direction},${direction},NONE,lag-interface,pserver,tosca.relationships.network.BindsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T
+pserver,p-interface,hasPinterface,OUT,MANY2MANY,${direction},${direction},${direction},NONE,p-interface,pserver,tosca.relationships.network.BindsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T
+pserver,availability-zone,existsIn,OUT,MANY2ONE,NONE,NONE,${direction},!${direction},pserver,availability-zone,org.onap.relationships.inventory.MemberOf,OUT,MANY2ONE,NONE,NONE,${direction},!${direction},T
+pserver,cloud-region,locatedIn,OUT,MANY2ONE,NONE,NONE,${direction},NONE,pserver,cloud-region,org.onap.relationships.inventory.LocatedIn,OUT,MANY2ONE,NONE,NONE,${direction},NONE,T
+pserver,complex,locatedIn,OUT,MANY2ONE,NONE,NONE,${direction},!${direction},pserver,complex,org.onap.relationships.inventory.LocatedIn,OUT,MANY2ONE,NONE,NONE,${direction},!${direction},T
+pserver,zone,isMemberOf,OUT,MANY2ONE,NONE,NONE,NONE,NONE,pserver,zone,org.onap.relationships.inventory.LocatedIn,OUT,MANY2ONE,NONE,NONE,NONE,NONE,T
+routing-instance,site-pair,hasSitePair,OUT,MANY2MANY,${direction},${direction},NONE,NONE,site-pair,routing-instance,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T
+service-instance,allotted-resource,has,OUT,MANY2MANY,${direction},${direction},NONE,NONE,allotted-resource,service-instance,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T
+service-instance,metadatum,hasMetaData,OUT,MANY2MANY,${direction},${direction},NONE,NONE,metadatum,service-instance,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T
+service-instance,allotted-resource,uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,service-instance,allotted-resource,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T
+service-instance,configuration,has,OUT,ONE2MANY,NONE,NONE,NONE,NONE,service-instance,configuration,org.onap.relationships.inventory.Uses,OUT,ONE2MANY,NONE,NONE,NONE,NONE,T
+service-instance,connector,uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,service-instance,connector,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T
+service-instance,ctag-assignment,uses,OUT,ONE2MANY,NONE,NONE,NONE,NONE,service-instance,ctag-assignment,org.onap.relationships.inventory.Uses,OUT,ONE2MANY,NONE,NONE,NONE,NONE,T
+service-instance,cvlan-tag,hasIPAGFacingVLAN,OUT,MANY2MANY,NONE,NONE,NONE,NONE,service-instance,cvlan-tag,org.onap.relationships.inventory.ComposedOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T
+service-instance,instance-group,isMemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,service-instance,instance-group,org.onap.relationships.inventory.MemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T
+service-instance,logical-link,uses,OUT,MANY2MANY,NONE,${direction},NONE,NONE,service-instance,logical-link,org.onap.relationships.inventory.Uses,OUT,ONE2MANY,NONE,${direction},NONE,NONE,T
+service-instance,pnf,uses,OUT,ONE2MANY,NONE,NONE,NONE,NONE,service-instance,pnf,org.onap.relationships.inventory.ComposedOf,OUT,ONE2MANY,NONE,NONE,NONE,NONE,T
+service-instance,service-instance,dependsOn,OUT,ONE2MANY,NONE,NONE,NONE,NONE,service-instance,service-instance,org.onap.relationships.inventory.ComposedOf,OUT,ONE2MANY,NONE,NONE,NONE,NONE,T
+service-instance,vlan,dependsOn,OUT,ONE2MANY,NONE,NONE,NONE,NONE,service-instance,vlan,org.onap.relationships.inventory.ComposedOf,OUT,ONE2MANY,NONE,NONE,NONE,NONE,T
+service-instance,zone,locatedIn,OUT,MANY2ONE,NONE,NONE,${direction},NONE,service-instance,zone,org.onap.relationships.inventory.LocatedIn,OUT,MANY2ONE,NONE,NONE,${direction},NONE,T
+service-subscription,service-instance,hasInstance,OUT,MANY2MANY,${direction},${direction},!${direction},NONE,service-instance,service-subscription,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},${direction},NONE,T
+site-pair,class-of-service,hasClassOfService,OUT,MANY2MANY,${direction},${direction},NONE,NONE,class-of-service,site-pair,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T
+site-pair-set,routing-instance,hasRoutingInstance,OUT,MANY2MANY,${direction},${direction},NONE,NONE,routing-instance,site-pair-set,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T
+sriov-vf,sriov-pf,uses,OUT,MANY2ONE,NONE,NONE,NONE,NONE,sriov-vf,sriov-pf,org.onap.relationships.inventory.Uses,OUT,MANY2ONE,NONE,NONE,NONE,NONE,T
+subnet,host-route,has,OUT,ONE2MANY,${direction},${direction},NONE,NONE,host-route,subnet,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T
+tenant,service-subscription,relatedTo,OUT,MANY2MANY,NONE,NONE,NONE,NONE,service-subscription,tenant,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T
+tenant,l3-network,usesL3Network,OUT,MANY2MANY,NONE,NONE,NONE,NONE,tenant,l3-network,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T
+tenant,vserver,owns,OUT,ONE2MANY,${direction},${direction},!${direction},${direction},vserver,tenant,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},NONE,${direction},!${direction},T
+vce,entitlement,has,OUT,ONE2MANY,${direction},${direction},NONE,NONE,entitlement,vce,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T
+vce,license,has,OUT,ONE2MANY,${direction},${direction},NONE,NONE,license,vce,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T
+vce,port-group,hasPortGroup,OUT,MANY2MANY,${direction},${direction},${direction},NONE,port-group,vce,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T
+vce,service-instance,hasServiceInstance,OUT,MANY2MANY,NONE,NONE,!${direction},NONE,service-instance,vce,org.onap.relationships.inventory.ComposedOf,OUT,ONE2MANY,NONE,NONE,${direction},NONE,T
+vce,availability-zone,hasAvailabilityZone,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},vce,availability-zone,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},T
+vce,complex,locatedIn,OUT,MANY2MANY,NONE,NONE,${direction},!${direction},vce,complex,org.onap.relationships.inventory.LocatedIn,OUT,MANY2MANY,NONE,NONE,${direction},!${direction},T
+vce,vserver,runsOnVserver,OUT,MANY2MANY,NONE,NONE,${direction},NONE,vce,vserver,tosca.relationships.HostedOn,OUT,ONE2MANY,NONE,NONE,${direction},NONE,T
+vf-module,l3-network,uses,OUT,MANY2MANY,NONE,NONE,${direction},NONE,vf-module,l3-network,org.onap.relationships.inventory.DependsOn,OUT,MANY2MANY,NONE,NONE,${direction},NONE,T
+vf-module,vnfc,uses,OUT,ONE2MANY,NONE,${direction},${direction},${direction},vf-module,vnfc,org.onap.relationships.inventory.Uses,OUT,ONE2MANY,NONE,NONE,${direction},${direction},T
+vf-module,volume-group,uses,OUT,ONE2ONE,NONE,NONE,${direction},NONE,vf-module,volume-group,org.onap.relationships.inventory.Uses,OUT,ONE2ONE,NONE,NONE,${direction},NONE,T
+vip-ipv4-address-list,instance-group,isMemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,vip-ipv4-address-list,instance-group,org.onap.relationships.inventory.MemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T
+vip-ipv4-address-list,subnet,isMemberOf,OUT,MANY2MANY,NONE,NONE,${direction},!${direction},vip-ipv4-address-list,subnet,org.onap.relationships.inventory.MemberOf,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},T
+vip-ipv6-address-list,instance-group,isMemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,vip-ipv6-address-list,instance-group,org.onap.relationships.inventory.MemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T
+vip-ipv6-address-list,subnet,isMemberOf,OUT,MANY2MANY,NONE,NONE,${direction},!${direction},vip-ipv6-address-list,subnet,org.onap.relationships.inventory.MemberOf,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},T
+virtual-data-center,generic-vnf,hasVNF,OUT,MANY2MANY,NONE,NONE,!${direction},NONE,generic-vnf,virtual-data-center,org.onap.relationships.inventory.LocatedIn,OUT,MANY2MANY,NONE,NONE,${direction},NONE,T
+virtual-data-center,logical-link,contains,OUT,MANY2MANY,NONE,NONE,NONE,NONE,logical-link,virtual-data-center,org.onap.relationships.inventory.LocatedIn,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T
+vlan,l3-interface-ipv4-address-list,hasIpAddress,OUT,MANY2MANY,${direction},${direction},${direction},NONE,l3-interface-ipv4-address-list,vlan,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T
+vlan,l3-interface-ipv6-address-list,hasIpAddress,OUT,MANY2MANY,${direction},${direction},${direction},NONE,l3-interface-ipv6-address-list,vlan,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T
+vlan,logical-link,usesLogicalLink,OUT,MANY2MANY,NONE,${direction},${direction},NONE,vlan,logical-link,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,${direction},${direction},NONE,T
+vlan,multicast-configuration,uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,vlan,multicast-configuration,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T
+vnfc,l3-interface-ipv4-address-list,hasIpAddress,OUT,ONE2MANY,${direction},${direction},NONE,NONE,l3-interface-ipv4-address-list,vnfc,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T
+vnfc,l3-interface-ipv6-address-list,hasIpAddress,OUT,ONE2MANY,${direction},${direction},NONE,NONE,l3-interface-ipv6-address-list,vnfc,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T
+vnfc,instance-group,isMemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,vnfc,instance-group,org.onap.relationships.inventory.MemberOf,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T
+vnfc,vip-ipv4-address-list,uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,vnfc,vip-ipv4-address-list,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T
+vnfc,vip-ipv6-address-list,uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,vnfc,vip-ipv6-address-list,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T
+volume-group,tenant,belongsTo,OUT,MANY2MANY,NONE,NONE,${direction},NONE,tenant,volume-group,org.onap.relationships.inventory.DependsOn,OUT,ONE2MANY,NONE,NONE,!${direction},NONE,T
+volume-group,complex,existsIn,OUT,MANY2MANY,NONE,NONE,${direction},!${direction},volume-group,complex,org.onap.relationships.inventory.LocatedIn,OUT,MANY2ONE,NONE,NONE,${direction},!${direction},T
+vpls-pe,lag-interface,hasLAGinterface,OUT,MANY2MANY,${direction},${direction},NONE,NONE,lag-interface,vpls-pe,tosca.relationships.network.BindsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T
+vpls-pe,p-interface,hasPinterface,OUT,MANY2MANY,${direction},${direction},NONE,NONE,p-interface,vpls-pe,tosca.relationships.network.BindsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T
+vpls-pe,complex,locatedIn,OUT,MANY2MANY,NONE,NONE,NONE,!${direction},vpls-pe,complex,org.onap.relationships.inventory.LocatedIn,OUT,MANY2ONE,NONE,NONE,NONE,!${direction},T
+vpls-pe,ctag-pool,usesCtagPool,OUT,MANY2MANY,NONE,NONE,NONE,NONE,vpls-pe,ctag-pool,org.onap.relationships.inventory.Uses,OUT,MANY2MANY,NONE,NONE,NONE,NONE,T
+vpn-binding,route-target,has,OUT,ONE2MANY,${direction},${direction},NONE,NONE,route-target,vpn-binding,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T
+vserver,l-interface,hasLInterface,OUT,MANY2MANY,${direction},${direction},${direction},NONE,l-interface,vserver,tosca.relationships.network.BindsTo,OUT,MANY2ONE,!${direction},!${direction},!${direction},NONE,T
+vserver,vf-module,isPartOf,OUT,MANY2ONE,NONE,NONE,${direction},NONE,vf-module,vserver,org.onap.relationships.inventory.Uses,OUT,ONE2MANY,NONE,NONE,!${direction},NONE,T
+vserver,vnfc,hosts,OUT,MANY2MANY,NONE,NONE,${direction},NONE,vnfc,vserver,tosca.relationships.HostedOn,OUT,ONE2MANY,NONE,NONE,!${direction},NONE,T
+vserver,flavor,hasFlavor,OUT,MANY2ONE,NONE,NONE,${direction},!${direction},vserver,flavor,org.onap.relationships.inventory.Uses,OUT,MANY2ONE,NONE,NONE,${direction},!${direction},T
+vserver,image,hasImage,OUT,MANY2ONE,NONE,NONE,${direction},!${direction},vserver,image,org.onap.relationships.inventory.Uses,OUT,MANY2ONE,NONE,NONE,${direction},!${direction},T
+vserver,pserver,runsOnPserver,OUT,MANY2ONE,NONE,NONE,${direction},!${direction},vserver,pserver,tosca.relationships.HostedOn,OUT,MANY2ONE,NONE,NONE,${direction},!${direction},T
+vserver,snapshot,uses,OUT,ONE2ONE,NONE,NONE,${direction},NONE,vserver,snapshot,org.onap.relationships.inventory.Uses,OUT,ONE2ONE,NONE,NONE,${direction},NONE,T
+vserver,volume,hasVolume,OUT,MANY2MANY,${direction},${direction},${direction},NONE,vserver,volume,tosca.relationships.AttachesTo,OUT,ONE2MANY,${direction},${direction},${direction},NONE,T
+zone,complex,existsIn,OUT,MANY2ONE,NONE,NONE,NONE,!${direction},zone,complex,org.onap.relationships.inventory.LocatedIn,OUT,MANY2ONE,NONE,NONE,NONE,!${direction},T
+,,,,,,,,,allotted-resource,model-ver,org.onap.relationships.inventory.IsA,OUT,Many2One,NONE,NONE,NONE,NONE,T
+,,,,,,,,,generic-vnf,model-ver,org.onap.relationships.inventory.IsA,OUT,Many2One,NONE,NONE,NONE,NONE,T
+,,,,,,,,,l3-network,model-ver,org.onap.relationships.inventory.IsA,OUT,Many2One,NONE,NONE,NONE,NONE,T
+,,,,,,,,,logical-link,model-ver,org.onap.relationships.inventory.IsA,OUT,Many2One,NONE,NONE,NONE,NONE,T
+,,,,,,,,,service-instance,model-ver,org.onap.relationships.inventory.IsA,OUT,Many2One,NONE,NONE,NONE,NONE,T
+,,,,,,,,,vf-module,model-ver,org.onap.relationships.inventory.IsA,OUT,Many2One,NONE,NONE,NONE,NONE,T
+configuration,l-interface,has,OUT,ONE2MANY,NONE,NONE,NONE,NONE,configuration,l-interface,org.onap.relationships.inventory.AppliesTo,OUT,ONE2MANY,NONE,NONE,NONE,NONE,T
+configuration,pnf,has,OUT,ONE2MANY,NONE,NONE,NONE,NONE,configuration,pnf,org.onap.relationships.inventory.AppliesTo,OUT,ONE2MANY,NONE,NONE,NONE,NONE,T
+forwarder,forwarding-path,belongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,forwarder,forwarding-path,org.onap.relationships.inventory.BelongsTo,OUT,MANY2ONE,!${direction},!${direction},NONE,NONE,T
+forwarding-path,service-instance,implements,OUT,MANY2ONE,NONE,!${direction},NONE,NONE,forwarding-path,service-instance,org.onap.relationships.inventory.AppliesTo,OUT,MANY2ONE,NONE,!${direction},NONE,NONE,T
+forwarder,l-interface,forwardsTo,OUT,ONE2ONE,NONE,NONE,NONE,NONE,forwarder,l-interface,org.onap.relationships.inventory.ForwardsTo,OUT,ONE2ONE,NONE,NONE,NONE,NONE,T
+forwarder,p-interface,forwardsTo,OUT,ONE2ONE,NONE,NONE,NONE,NONE,forwarder,p-interface,org.onap.relationships.inventory.ForwardsTo,OUT,ONE2ONE,NONE,NONE,NONE,NONE,T
diff --git a/aai-resources/src/main/scripts/createDBSchema.sh b/aai-resources/src/main/scripts/createDBSchema.sh
index 4751072..56f0fcc 100644
--- a/aai-resources/src/main/scripts/createDBSchema.sh
+++ b/aai-resources/src/main/scripts/createDBSchema.sh
@@ -47,8 +47,7 @@ do
CLASSPATH=$CLASSPATH:$JAR
done
-$JAVA_HOME/bin/java -classpath $CLASSPATH -Dhttps.protocols=TLSv1.1,TLSv1.2 -DAJSC_HOME=$PROJECT_HOME -Daai.home=$PROJECT_HOME \
- org.onap.aai.dbgen.GenTester $1
+$JAVA_HOME/bin/java -classpath $CLASSPATH -Dhttps.protocols=TLSv1.1,TLSv1.2 -DBUNDLECONFIG_DIR=bundleconfig -DAJSC_HOME=$PROJECT_HOME -Daai.home=$PROJECT_HOME -Dlogback.configurationFile=$PROJECT_HOME/bundleconfig/etc/appprops/createDBSchema-logback.xml org.onap.aai.dbgen.GenTester $1
echo `date` " Done $0"
exit 0
diff --git a/aai-resources/src/main/scripts/dynamicPayloadArchive.sh b/aai-resources/src/main/scripts/dynamicPayloadArchive.sh
new file mode 100644
index 0000000..f17f679
--- /dev/null
+++ b/aai-resources/src/main/scripts/dynamicPayloadArchive.sh
@@ -0,0 +1,63 @@
+#!/bin/ksh
+
+###
+# ============LICENSE_START=======================================================
+# org.onap.aai
+# ================================================================================
+# Copyright (C) 2017 AT&T 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=========================================================
+###
+
+#
+# The script is called to tar and gzip the files under /opt/app/aai-resources/bundleconfig/etc/scriptdata/addmanualdata/tenant_isolation which are the payload files created by the dynamicPayloadGenerator.sh tool.
+#
+#
+
+. /etc/profile.d/aai.sh
+PROJECT_HOME=/opt/app/aai-resources
+
+PROGNAME=$(basename $0)
+
+TS=$(date "+%Y_%m_%d_%H_%M_%S")
+
+CHECK_USER="aaiadmin"
+userid=$( id | cut -f2 -d"(" | cut -f1 -d")" )
+if [ "${userid}" != $CHECK_USER ]; then
+ echo "You must be $CHECK_USER to run $0. The id used $userid."
+ exit 1
+fi
+DIRECTORY=${PROJECT_HOME}/bundleconfig/etc/scriptdata/addmanualdata/tenant_isolation
+if [ ! -d ${DIRECTORY} ]
+then
+ echo " ${DIRECTORY} doesn't exist"
+ exit 1
+fi
+
+tar c ${DIRECTORY}/* -f /var/tmp/dynamicPayloadArchive_${TS}.tar
+if [ $? -ne 0 ]
+then
+ echo " Unable to tar ${DIRECTORY}"
+ exit 1
+fi
+
+cd /var/tmp
+gzip /var/tmp/dynamicPayloadArchive_${TS}.tar
+if [ $? -ne 0 ]
+then
+ echo " Unable to gzip /var/tmp/dynamicPayloadArchive_${TS}.tar"
+ exit 1
+fi
+echo "Completed successfully: /var/tmp/dynamicPayloadArchive_${TS}.tar.gz"
+exit 0
diff --git a/aai-resources/src/main/scripts/dynamicPayloadGenerator.sh b/aai-resources/src/main/scripts/dynamicPayloadGenerator.sh
new file mode 100644
index 0000000..c386bed
--- /dev/null
+++ b/aai-resources/src/main/scripts/dynamicPayloadGenerator.sh
@@ -0,0 +1,101 @@
+#!/bin/ksh
+
+###
+# ============LICENSE_START=======================================================
+# org.onap.aai
+# ================================================================================
+# Copyright (C) 2017 AT&T 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=========================================================
+###
+
+#
+# dynamicPayloadGenerator.sh -- This tool is used for Tenant-Isolation project
+# It is used to load a snapshot into memory and generate payloads for any input nodes
+#
+#
+# Parameters:
+#
+# -d (required) name of the fully qualified Datasnapshot file that you need to load
+# -s (optional) true or false to enable or disable schema, By default it is true for production,
+# you can change to false if the snapshot has duplicates
+# -c (optional) config file to use for loading snapshot into memory.
+# -o (required) output file to store the data files
+# -f (optional) PAYLOAD or DMAAP-MR
+# -n (optional) input file for the script
+#
+#
+# For example (there are many valid ways to use it):
+#
+# dynamicPayloadGenerator.sh -d '/opt/app/snapshots/snaphot.graphSON' -o '/opt/app/aai-resources/bundleconfig/etc/scriptdata/addmanualdata/tenant_isolation/'
+#
+# or
+# dynamicPayloadGenerator.sh -d '/opt/app/snapshots/snaphot.graphSON' -s false -c '/opt/app/aai-resources/bundleconfig/etc/appprops/dynamic.properties'
+# -o '/opt/app/aai-resources/bundleconfig/etc/scriptdata/addmanualdata/tenant_isolation/' -f PAYLOAD -n '/opt/app/aai-resources/bundleconfig/etc/scriptdata/nodes.json'
+#
+
+
+echo
+echo `date` " Starting $0"
+
+display_usage() {
+ cat <<EOF
+ Usage: $0 [options]
+
+ 1. Usage: dynamicPayloadGenerator -d <graphsonPath> -o <output-path>
+ 2. This script has 2 arguments that are required.
+ a. -d (required) Name of the fully qualified Datasnapshot file that you need to load
+ b. -o (required) output file to store the data files
+ 3. Optional Parameters:
+ a. -s (optional) true or false to enable or disable schema, By default it is true for production,
+ b. -c (optional) config file to use for loading snapshot into memory.
+ c. -f (optional) PAYLOAD or DMAAP-MR
+ d. -n (optional) input file for the script
+ 4. For example (there are many valid ways to use it):
+ dynamicPayloadGenerator.sh -d '/opt/app/snapshots/snaphot.graphSON' -o '/opt/app/aai-resources/bundleconfig/etc/scriptdata/addmanualdata/tenant_isolation/'
+
+ dynamicPayloadGenerator.sh -d '/opt/app/snapshots/snaphot.graphSON' -s false -c '/opt/app/aai-resources/bundleconfig/etc/appprops/dynamic.properties'
+ -o '/opt/app/aai-resources/bundleconfig/etc/scriptdata/addmanualdata/tenant_isolation/' -f PAYLOAD -n '/opt/app/aai-resources/bundleconfig/etc/scriptdata/nodes.json'
+
+EOF
+}
+if [ $# -eq 0 ]; then
+ display_usage
+ exit 1
+fi
+
+
+
+. /etc/profile.d/aai.sh
+PROJECT_HOME=/opt/app/aai-resources
+
+for JAR in `ls $PROJECT_HOME/extJars/*.jar`
+do
+ CLASSPATH=$CLASSPATH:$JAR
+done
+
+for JAR in `ls $PROJECT_HOME/lib/*.jar`
+do
+ CLASSPATH=$CLASSPATH:$JAR
+done
+
+
+$JAVA_HOME/bin/java -classpath $CLASSPATH -Dhttps.protocols=TLSv1.1,TLSv1.2 -DBUNDLECONFIG_DIR=bundleconfig -DAJSC_HOME=$PROJECT_HOME \
+ -Daai.home=$PROJECT_HOME -Dlogback.configurationFile=$PROJECT_HOME/bundleconfig/etc/appprops/dynamicPayloadGenerator-logback.xml -Xmx9000m -Xms9000m \
+ org.onap.aai.dbgen.DynamicPayloadGenerator "$@"
+
+
+echo `date` " Done $0"
+
+exit 0
diff --git a/aai-resources/src/main/scripts/forceDeleteTool.sh b/aai-resources/src/main/scripts/forceDeleteTool.sh
index ac84585..9c199bc 100644
--- a/aai-resources/src/main/scripts/forceDeleteTool.sh
+++ b/aai-resources/src/main/scripts/forceDeleteTool.sh
@@ -80,6 +80,7 @@ if [ "${userid}" != "aaiadmin" ]; then
fi
. /etc/profile.d/aai.sh
+PROJECT_HOME=/opt/app/aai-resources
for JAR in `ls $PROJECT_HOME/extJars/*.jar`
do
diff --git a/aai-resources/src/main/scripts/install/addManualData.sh b/aai-resources/src/main/scripts/install/addManualData.sh
new file mode 100644
index 0000000..930b9ba
--- /dev/null
+++ b/aai-resources/src/main/scripts/install/addManualData.sh
@@ -0,0 +1,131 @@
+#!/bin/ksh
+
+###
+# ============LICENSE_START=======================================================
+# org.onap.aai
+# ================================================================================
+# Copyright (C) 2017 AT&T 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=========================================================
+###
+
+# this script now requires a release parameter.
+# the tool finds and sorts *.txt files within the
+# bundleconfig/etc/scriptdate/addmanualdata/$release directory containing
+# one resource to be added to the graph. The directory contains a second
+# file with the same name, but the extension is .json. This json file
+# is passed to the PutTool as the payload. The parameters passed to the
+# PutTool will have 412 failures ignored. After calling the PutTool, the
+# GetTool is called to include the object put into the graph.
+# this script is run at every installation, logging the manual data applied.
+
+# Returns 0 if the specified string contains the specified substring,
+# otherwise returns 1.
+contains() {
+ string="$1"
+ substring="$2"
+ if test "${string#*$substring}" != "$string"
+ then
+ return 0 # $substring is in $string
+ else
+ return 1 # $substring is not in $string
+ fi
+}
+
+. /etc/profile.d/aai.sh
+PROJECT_HOME=/opt/app/aai-resources
+
+PROGNAME=$(basename $0)
+OUTFILE=$PROJECT_HOME/logs/misc/${PROGNAME}.log.$(date +\%Y-\%m-\%d)
+#OUTFILE=/c/temp/${PROGNAME}.log.$(date +\%Y-\%m-\%d)
+
+TS=$(date "+%Y-%m-%d %H:%M:%S")
+
+CHECK_USER="aaiadmin"
+userid=$( id | cut -f2 -d"(" | cut -f1 -d")" )
+if [ "${userid}" != $CHECK_USER ]; then
+ echo "You must be $CHECK_USER to run $0. The id used $userid."
+ exit 1
+fi
+
+
+if [ "$#" -ne 1 ]; then
+ echo "Release or tenant_isolation parameter is required, e.g. 1610, 1702, tenant_isolation, etc"
+ echo "usage: $0 release"
+ exit 1
+fi
+
+error_exit () {
+ echo "${PROGNAME}: failed for ${1:-"Unknown error"} on cmd $2 in $3" 1>&2
+ echo "${PROGNAME}: failed for ${1:-"Unknown error"} on cmd $2 in $3" >> $OUTFILE
+# exit ${2:-"1"}
+}
+
+rel="/"$1"/"
+k=0
+
+if [ "$1" = "tenant_isolation" ]
+then
+ CR_TEXT_PATH=`find $PROJECT_HOME/bundleconfig/etc/scriptdata/addmanualdata/tenant_isolation/cloud-region -name "*.txt" -print | sort -f`
+ AZ_TEXT_PATH=`find $PROJECT_HOME/bundleconfig/etc/scriptdata/addmanualdata/tenant_isolation/availability-zone -name "*.txt" -print | sort -f`
+ COMPLEX_TEXT_PATH=`find $PROJECT_HOME/bundleconfig/etc/scriptdata/addmanualdata/tenant_isolation/complex -name "*.txt" -print | sort -f`
+ ZONE_TEXT_PATH=`find $PROJECT_HOME/bundleconfig/etc/scriptdata/addmanualdata/tenant_isolation/zone -name "*.txt" -print | sort -f`
+ PSERVER_TEXT_PATH=`find $PROJECT_HOME/bundleconfig/etc/scriptdata/addmanualdata/tenant_isolation/pserver -name "*.txt" -print | sort -f`
+ TEXT_PATH="${CR_TEXT_PATH} ${AZ_TEXT_PATH} ${COMPLEX_TEXT_PATH} ${ZONE_TEXT_PATH} ${PSERVER_TEXT_PATH}"
+ COMMAND=${TEXT_PATH}
+else
+ TEXT_PATH=$PROJECT_HOME/bundleconfig/etc/scriptdata/addmanualdata/*/*.txt
+ COMMAND=`ls ${TEXT_PATH} | sort -f`
+fi
+
+ls ${TEXT_PATH} >/dev/null 2>&1
+if [ $? -ne 0 ]
+then
+echo "No manual data to add for $1";
+exit 0;
+fi
+
+for filepath in ${COMMAND}
+do
+contains $filepath $rel
+if [ $? -eq 0 ]
+then
+jsonfile=${filepath%???}json
+j=0
+while IFS=\n read -r i
+do
+echo "##### Begin putTool for $i ##### from file $filepath" | tee -a $OUTFILE
+resource=`echo $i | tr -d '\r'`
+$PROJECT_HOME/scripts/putTool.sh $resource $jsonfile 1 0 na 1 >> $OUTFILE 2>&1 || error_exit "$resource" $j $filepath
+echo "##### End putTool for $resource #####" | tee -a $OUTFILE
+echo "Begin getTool for $resource" | tee -a $OUTFILE
+$PROJECT_HOME/scripts/getTool.sh $resource >> $OUTFILE 2>&1 || error_exit "$i" $j $filepath
+echo "End getTool for $resource" | tee -a $OUTFILE
+
+j=$(expr "$j" + 1)
+k=$(expr "$k" + 1)
+done < $filepath
+
+fi
+
+done
+if [ $k -eq 0 ]
+then
+echo "No manual data to add for release $1";
+exit 0;
+fi
+
+echo "See output and error file: $OUTFILE"
+
+exit 0
diff --git a/aai-resources/src/main/scripts/putTool.sh b/aai-resources/src/main/scripts/putTool.sh
index dfa9b37..b5ad862 100644
--- a/aai-resources/src/main/scripts/putTool.sh
+++ b/aai-resources/src/main/scripts/putTool.sh
@@ -46,9 +46,10 @@ display_usage() {
cat <<EOF
Usage: $0 [options]
- 1. Usage: putTool.sh <resource-path> <json payload file>
+ 1. Usage: putTool.sh <resource-path> <json payload file> <optional -display>
2. This script requires two arguments, a resource path and a file path to a json file containing the payload.
3. Example: resource-path and payload for a particular customer is: business/customers/customer/JohnDoe customerpayload.json
+ 4. Adding the optional "-display" argument will display all data returned from the request.
EOF
}
if [ $# -eq 0 ]; then
@@ -87,6 +88,13 @@ prop_file=$PROJECT_HOME/bundleconfig/etc/appprops/aaiconfig.properties
log_dir=$PROJECT_HOME/logs/misc
today=$(date +\%Y-\%m-\%d)
+RETURNRESPONSE=false
+if [ ${#} -ne 2 ]; then
+ if [ "$3" = "-display" ]; then
+ RETURNRESPONSE=true
+ fi
+fi
+
MISSING_PROP=false
RESTURL=`grep ^aai.server.url= $prop_file |cut -d'=' -f2 |tr -d "\015"`
if [ -z $RESTURL ]; then
@@ -117,10 +125,14 @@ if [ $MISSING_PROP = false ]; then
else
AUTHSTRING="-u $CURLUSER:$CURLPASSWORD"
fi
- result=`curl --request PUT -sL -w "%{http_code}" -o /dev/null -k $AUTHSTRING -H "X-FromAppId: $XFROMAPPID" -H "X-TransactionId: $XTRANSID" -H "Accept: application/json" -T $JSONFILE $RESTURL$RESOURCE`
- #echo "result is $result."
- RC=0;
- if [ $? -eq 0 ]; then
+ if [ $RETURNRESPONSE = true ]; then
+ curl --request PUT -sL -k $AUTHSTRING -H "X-FromAppId: $XFROMAPPID" -H "X-TransactionId: $XTRANSID" -H "Accept: application/json" -T $JSONFILE $RESTURL$RESOURCE | python -mjson.tool
+ RC=$?
+ else
+ result=`curl --request PUT -sL -w "%{http_code}" -o /dev/null -k $AUTHSTRING -H "X-FromAppId: $XFROMAPPID" -H "X-TransactionId: $XTRANSID" -H "Accept: application/json" -T $JSONFILE $RESTURL$RESOURCE`
+ #echo "result is $result."
+ RC=0;
+ if [ $? -eq 0 ]; then
case $result in
+([0-9])?)
if [[ "$result" -ge 200 && $result -lt 300 ]]
@@ -148,10 +160,11 @@ if [ $MISSING_PROP = false ]; then
;;
esac
- else
+ else
echo "FAILED to send request to $RESTURL"
RC=-1
- fi
+ fi
+ fi
else
echo "usage: $0 resource file [expected-failure-codes]"
RC=-1
diff --git a/aai-resources/src/main/scripts/run_Migrations.sh b/aai-resources/src/main/scripts/run_Migrations.sh
new file mode 100644
index 0000000..7f0ea08
--- /dev/null
+++ b/aai-resources/src/main/scripts/run_Migrations.sh
@@ -0,0 +1,76 @@
+#!/bin/ksh
+
+###
+# ============LICENSE_START=======================================================
+# org.onap.aai
+# ================================================================================
+# Copyright (C) 2017 AT&T 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=========================================================
+###
+
+echo
+echo $(date) " Starting $0"
+
+userid=$( id | cut -f2 -d"(" | cut -f1 -d")" )
+if [ "${userid}" != "aaiadmin" ]; then
+ echo "You must be aaiadmin to run $0. The id used $userid."
+ exit 1
+fi
+
+if [ -f "/etc/profile.d/aai.sh" ]; then
+ source /etc/profile.d/aai.sh
+else
+ echo "File not found: /etc/profile.d/aai.sh";
+ exit
+fi
+
+JAVA=$JAVA_HOME/bin/java
+PROJECT_HOME=/opt/app/aai-resources
+
+ARGS="-c ${PROJECT_HOME}/bundleconfig/etc/appprops/titan-realtime.properties $@"
+
+for JAR in $(ls $PROJECT_HOME/extJars/*.jar)
+do
+ CLASSPATH=$CLASSPATH:$JAR
+done
+
+UUID=$(uuidgen)
+
+unzip -o $PROJECT_HOME/lib/ajsc-runner-5.0.0-RC16.0.5.jar -d /tmp/ajsc-war-$UUID/ > /dev/null
+unzip -o /tmp/ajsc-war-$UUID/ajsc-war-5.0.0-RC16.0.5.war -d /tmp/ajsc-war-$UUID/ > /dev/null
+
+for JAR in $(ls /tmp/ajsc-war-$UUID/WEB-INF/lib/*.jar)
+do
+ if [[ ! "$JAR" =~ .*logback-classic-.*.jar ]];
+ then
+ CLASSPATH=$CLASSPATH:$JAR
+ fi
+done
+
+for JAR in $(ls /opt/app/swm/dme2/lib/*.jar)
+do
+ CLASSPATH=$CLASSPATH:$JAR
+done
+
+for JAR in $(ls $PROJECT_HOME/lib/*.jar)
+do
+ CLASSPATH=$CLASSPATH:$JAR
+done
+
+CLASSPATH=$CLASSPATH:${PROJECT_HOME}"/bundleconfig/etc/tmp-config/"
+
+$JAVA -Dhttps.protocols=TLSv1.1,TLSv1.2 -DAJSC_HOME=$PROJECT_HOME -Daai.home=$PROJECT_HOME -DBUNDLECONFIG_DIR="bundleconfig" -Dlogback.configurationFile=$PROJECT_HOME/bundleconfig/etc/appprops/migration-logback.xml -cp $CLASSPATH org.onap.aai.migration.MigrationController $ARGS
+
+rm -r /tmp/ajsc-war-$UUID/
diff --git a/aai-resources/src/main/scripts/updateTool.sh b/aai-resources/src/main/scripts/updateTool.sh
index f4e2941..05377d6 100644
--- a/aai-resources/src/main/scripts/updateTool.sh
+++ b/aai-resources/src/main/scripts/updateTool.sh
@@ -47,20 +47,15 @@ contains() {
display_usage() {
cat <<EOF
-Usage: $0 [options]
+Usage 1: updateTool.sh <node type> <update node URI> <property name>:<property value>
+[,<property name>:<property value]* | where update node uri is the URI path for that node
+for ex1: ./updateTool.sh pserver cloud-infrastructure/pservers/pserver/XXX prov-status:NEWSTATUS
+ex2:./updateTool.sh pserver cloud-infrastructure/pservers/pserver/XXX 'prov-status:NEWSTATUS with space'
+ex3:./updateTool.sh pserver cloud-infrastructure/pservers/pserver/XXX 'prov-status:NEWSTATUS,attribute2:value'
-1. This script needs a resource argument (resource-path), and either a JSON filepath, or directly the property you need to update
-2. Usage 1 (use a Json file): updateTool.sh <node type> <resource> <filepath> <optional arg to ignore HTTP failure codes>
-3. Usage 1 example: ./updateTool.sh customer business/customers/customer/customer-id-1 /tmp/updateTest.json
+Usage 2. using .json file for update: ./updateTool.sh <node type> <update node URI> /tmp/updatepayload.json
+Ex: ./updateTool.sh pserver cloud-infrastructure/pservers/pserver/XXX /tmp/testpayload.json
-4. Usage 2 (update a property directly): updateTool.sh <node type> <resource> '<key name>:<key value>,<property>:<property val>' <optional arg to ignore HTTP failure codes>
-5. Usage 2 example: ./updateTool.sh complex cloud-infrastructure/complexes/complex/complex-id 'physical-location-id:complex-id, city:New York'
-6. You could try without the <key name>:<key value> (only the property and its new value), but on some servers this did not work:
-7. ./updateTool.sh complex cloud-infrastructure/complexes/complex/complex-id 'city:New York'
-
-8. Usage 3 (update an attribute on an object that is embedded a level or two levels. Use the full path)
-9. ./updateTool.sh <node type> <embedded resource with full paths> <key name: key value>
-10. ./updateTool.sh p-interface network/pnfs/pnf/pnf-name-1/p-interfaces/p-interface/int-1 'interface-type:int-typei'
EOF
}
@@ -131,11 +126,10 @@ fi
#or
#'physical-location-id:complex-id, city:New York'
thirdarg=$3
-isjson = true
+isjson = false
if [[ "$thirdarg" == *json || "$thirdarg" == *JSON ]]; then
- echo "Usage 1(JSON) because the 2nd arg ends with json";
+ isjson = true
else
- echo "Usage 2(Comand Arg) because the 2nd arg does not end with json";
#For Usage 2, format input into JSON string format
JSONSTRING="{"
INPUT=$3