*/
package org.onap.aai.schema;
-import java.util.List;
-import java.util.Optional;
-import java.util.Set;
-
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.janusgraph.core.JanusGraph;
import org.janusgraph.core.PropertyKey;
+import org.janusgraph.core.schema.JanusGraphIndex;
import org.janusgraph.core.schema.JanusGraphManagement;
import org.janusgraph.graphdb.database.StandardJanusGraph;
import org.janusgraph.graphdb.database.management.ManagementSystem;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Optional;
+import java.util.Set;
+
public class GenTester {
- private static Logger LOGGER;
- private static boolean historyEnabled;
- private static final String SCHEMA_INITIALIZED = "schema-initialized";
-
- /**
- * The main method.
- *
- * @param args the arguments
- */
- public static void main(String[] args) throws AAIException {
-
- try {
- createSchema(args);
- } catch (Exception e) {
- LOGGER.error("Failed to run schema creation", e);
- System.exit(1);
- }
-
- LOGGER.debug("All done, if the program does not exit, please kill it manually.");
- System.exit(0);
- }
-
- private static void createSchema(String[] args) throws AAIException {
- JanusGraph graph = null;
- System.setProperty("aai.service.name", GenTester.class.getSimpleName());
-
- LOGGER = LoggerFactory.getLogger(GenTester.class);
- boolean addDefaultCR = true;
-
- AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
- try {
- ctx.scan(
- "org.onap.aai");
- ctx.refresh();
- } catch (Exception e) {
- AAIException aai = ExceptionTranslator.schemaServiceExceptionTranslator(e);
- LOGGER.error("Problems running the tool " + aai.getMessage());
- ErrorLogHelper.logError(aai.getCode(), e.getMessage() + ", resolve and retry");
- throw aai;
- }
- historyEnabled = Boolean.parseBoolean(ctx.getEnvironment().getProperty("history.enabled", "false"));
- if (historyEnabled) {
- String amsg = "GenTester may only be used when history.enabled=false. ";
- System.out.println(amsg);
- LOGGER.debug(amsg);
- return;
- }
- try {
- LOGGER.debug("GenTester uses either cql jar or Cassandra jar");
-
- AAIConfig.init();
- if (args != null && args.length > 0) {
- if ("genDbRulesOnly".equals(args[0])) {
- ErrorLogHelper.logError("AAI_3100",
- " This option is no longer supported. What was in DbRules is now derived from the OXM files. ");
- return;
- } else if ("GEN_DB_WITH_NO_SCHEMA".equals(args[0])) {
- // Note this is done to create an empty DB with no Schema so that
- // an HBase copyTable can be used to set up a copy of the db.
- String imsg = " ---- NOTE --- about to load a graph without doing any schema processing (takes a little while) -------- ";
- System.out.println(imsg);
- LOGGER.debug(imsg);
- graph = AAIGraph.getInstance().getGraph();
-
- if (graph == null) {
- ErrorLogHelper.logError("AAI_5102", "Error creating JanusGraph graph.");
- return;
- } else {
- LOGGER.debug("Successfully loaded a JanusGraph graph without doing any schema work.");
- return;
- }
- } else if ("GEN_DB_WITH_NO_DEFAULT_CR".equals(args[0])) {
- addDefaultCR = false;
- } else {
- ErrorLogHelper.logError("AAI_3000",
- "Unrecognized argument passed to GenTester.java: [" + args[0] + "]. ");
-
- String emsg = "Unrecognized argument passed to GenTester.java: [" + args[0] + "]. ";
- System.out.println(emsg);
- LOGGER.error(emsg);
-
- emsg = "Either pass no argument for normal processing, or use 'GEN_DB_WITH_NO_SCHEMA'.";
- System.out.println(emsg);
- LOGGER.error(emsg);
-
- return;
- }
- }
-
- // AAIConfig.init();
- ErrorLogHelper.loadProperties();
-
- LOGGER.debug("about to open graph (takes a little while)");
- graph = AAIGraph.getInstance().getGraph();
-
- if (graph == null) {
- ErrorLogHelper.logError("AAI_5102", "Error creating JanusGraph graph. ");
- return;
- }
-
- Optional<Vertex> schemaInitializedVertex = graph.traversal().V()
- .or(
- __.has(SCHEMA_INITIALIZED, true),
- __.has(SCHEMA_INITIALIZED, false)
- )
- .tryNext();
-
- if (schemaInitializedVertex.isPresent()) {
- //Set schema-initialized vertex to false if such vertex is present in db
- setSchemaInitializedToFalse(graph, schemaInitializedVertex);
- } else {
- // Creating a new vertex as the vertex is not yet present in db
- createNewSchemaInitializedVertex(graph);
- }
-
- GraphAdminDBUtils.logConfigs(graph.configuration());
-
- LOGGER.debug("-- Loading new schema elements into JanusGraph --");
-
- boolean dbNotEmpty = (graph.traversal().V().limit(1).hasNext());
- LOGGER.info("DB is not empty. Newly created indexes will also be reindexed.");
- List<String> vertexesToReindex = SchemaGenerator.loadSchemaIntoJanusGraph(graph, null, dbNotEmpty);
- LOGGER.debug("-- committing transaction ");
- graph.tx().commit();
-
- boolean reindexingEnabled = false; // disable reindexing for now, since it's not working correctly
- if (reindexingEnabled && !vertexesToReindex.isEmpty()) {
- killTransactionsAndInstances(graph);
- LOGGER.info("Number of edge indexes to reindex: " + vertexesToReindex.size());
- SchemaGenerator.reindexEdgeIndexes(graph, vertexesToReindex);
- } else {
- if (vertexesToReindex.isEmpty()) {
- LOGGER.info("Nothing to reindex.");
- }
- }
-
- // Setting property schema-initialized to true
- LOGGER.debug("-- Updating vertex with property schema-initialized to true ");
- graph.traversal().V().has(SCHEMA_INITIALIZED , false).property(SCHEMA_INITIALIZED , true).next();
- LOGGER.debug("-- committing transaction ");
- graph.tx().commit();
-
- graph.close();
- LOGGER.info("Closed the graph");
-
- } catch (Exception ex) {
- ErrorLogHelper.logError("AAI_4000", ex.getMessage());
- System.exit(1);
- }
- }
-
- private static void setSchemaInitializedToFalse(JanusGraph graph, Optional<Vertex> schemaInitializedVertex) {
- Vertex vertex = schemaInitializedVertex.get();
- Object schemaInitializedValueObj = vertex.property(SCHEMA_INITIALIZED).value();
- Boolean schemaInitializedValue = schemaInitializedValueObj instanceof Boolean b ? b : Boolean.FALSE;
-
- //Setting schema-initialized vertex to False
- if (Boolean.TRUE.equals(schemaInitializedValue)) {
- // Update the property from true to false
- LOGGER.debug("-- Vertex with property 'schema-initialized' present in db and is true. Updating it to false");
- graph.traversal().V()
- .has(SCHEMA_INITIALIZED, true)
- .property(SCHEMA_INITIALIZED, false)
- .next();
- } else {
- // Property already false, no action needed
- LOGGER.debug("-- Vertex with property 'schema-initialized' present in db and is false. Keeping it false. Do Nothing");
- }
- }
-
- private static void createNewSchemaInitializedVertex(JanusGraph graph) throws Exception {
- LOGGER.debug("-- Adding a new vertex with property schema-initialized as false");
- JanusGraphManagement mgmt = graph.openManagement();
- try {
- // Creating an index
- createSchemaInitializedIndex(graph, mgmt);
- } catch (Exception e) {
- mgmt.rollback();
- LOGGER.error("Problems creating an index for schema-initialized vertex " + e.getMessage());
- throw e;
- }
- try {
- Vertex newVertex = graph.addVertex(SCHEMA_INITIALIZED , false);
- LOGGER.info("Created a new vertex with property '{}' set to '{}'", SCHEMA_INITIALIZED ,
- newVertex.property(SCHEMA_INITIALIZED ).value());
- } catch (Exception e) {
- LOGGER.error("Error creating a new vertex: {}", e.getMessage(), e);
- throw e;
- }
- }
-
- private static void createSchemaInitializedIndex(JanusGraph graph, JanusGraphManagement mgmt) throws InterruptedException {
- // creating a composite index
- boolean indexExists = mgmt.containsGraphIndex(SCHEMA_INITIALIZED);
- if(indexExists) {
- LOGGER.debug(SCHEMA_INITIALIZED + " index already exists. Skipping creation.");
- return;
- }
- LOGGER.debug("-- Building an index on property schema-initialized");
- PropertyKey schemaInitialized = mgmt.makePropertyKey(SCHEMA_INITIALIZED).dataType(Boolean.class).make();
- mgmt.buildIndex(SCHEMA_INITIALIZED, Vertex.class)
- .addKey(schemaInitialized)
- .buildCompositeIndex();
- mgmt.commit();
-
- // Wait for the index to become available
- ManagementSystem.awaitGraphIndexStatus(graph, SCHEMA_INITIALIZED).call();
- }
-
- /**
- * Radical approach to avoiding index update failures.
- * Indexes can get stuck in INSTALLED state, when there are stale transactions
- * or JanusGraph instances.
- * This is because a state change needs to be acknowledged by all instances
- * before transitioning.
- *
- * @param graph
- * @return
- */
- private static void killTransactionsAndInstances(JanusGraph graph) {
- graph.tx().rollback();
- final StandardJanusGraph janusGraph = (StandardJanusGraph) graph;
- janusGraph.getOpenTransactions().stream().forEach(transaction -> {
- LOGGER.debug("Closing open transaction [{}] before schema generation", transaction.toString());
- transaction.rollback();
- });
-
- final JanusGraphManagement graphMgtForClosing = graph.openManagement();
-
- Set<String> instances = graphMgtForClosing.getOpenInstances();
- LOGGER.info("Number of open instances: {}", instances.size());
- LOGGER.info("Currently open instances: [{}]", instances);
- instances.stream()
- .filter(instance -> !instance.contains("graphadmin")) // Potentially comment this out, should there be
- // issues with the schema creation job
- .filter(instance -> !instance.contains("(current)"))
- .forEach(instance -> {
- LOGGER.debug("Closing open JanusGraph instance [{}] before reindexing procedure", instance);
- graphMgtForClosing.forceCloseInstance(instance);
- });
- graphMgtForClosing.commit();
- }
+ private static Logger LOGGER;
+ private static boolean historyEnabled;
+ private static final String SCHEMA_INITIALIZED = "schema-initialized";
+ /**
+ * The main method.
+ *
+ * @param args the arguments
+ */
+ public static void main(String[] args) throws AAIException {
+ LOGGER = LoggerFactory.getLogger(GenTester.class);
+ try {
+ createSchema(args);
+ } catch (Exception e) {
+ LOGGER.error("Failed to run schema creation", e);
+ System.exit(1);
+ }
+
+ LOGGER.debug("All done, if the program does not exit, please kill it manually.");
+ System.exit(0);
+ }
+
+ private static void createSchema(String[] args) throws AAIException {
+ JanusGraph graph = null;
+ System.setProperty("aai.service.name", GenTester.class.getSimpleName());
+ boolean addDefaultCR = true;
+
+ AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
+ try {
+ ctx.scan(
+ "org.onap.aai");
+ ctx.refresh();
+ } catch (Exception e) {
+ LOGGER.error("Exception while loading context: " + e.getStackTrace());
+ AAIException aai = ExceptionTranslator.schemaServiceExceptionTranslator(e);
+ LOGGER.error("Problems running the tool " + aai.getStackTrace());
+ ErrorLogHelper.logError(aai.getCode(), e.getMessage() + ", resolve and retry");
+ throw aai;
+ }
+ historyEnabled = Boolean.parseBoolean(ctx.getEnvironment().getProperty("history.enabled", "false"));
+ if (historyEnabled) {
+ String amsg = "GenTester may only be used when history.enabled=false. ";
+ System.out.println(amsg);
+ LOGGER.debug(amsg);
+ return;
+ }
+ try {
+ LOGGER.debug("GenTester uses either cql jar or Cassandra jar");
+
+ AAIConfig.init();
+ if (args != null && args.length > 0) {
+ if ("genDbRulesOnly".equals(args[0])) {
+ ErrorLogHelper.logError("AAI_3100",
+ " This option is no longer supported. What was in DbRules is now derived from the OXM files. ");
+ return;
+ } else if ("GEN_DB_WITH_NO_SCHEMA".equals(args[0])) {
+ // Note this is done to create an empty DB with no Schema so that
+ // an HBase copyTable can be used to set up a copy of the db.
+ String imsg = " ---- NOTE --- about to load a graph without doing any schema processing (takes a little while) -------- ";
+ System.out.println(imsg);
+ LOGGER.debug(imsg);
+ graph = AAIGraph.getInstance().getGraph();
+
+ if (graph == null) {
+ ErrorLogHelper.logError("AAI_5102", "Error creating JanusGraph graph.");
+ return;
+ } else {
+ LOGGER.debug("Successfully loaded a JanusGraph graph without doing any schema work.");
+ return;
+ }
+ } else if ("GEN_DB_WITH_NO_DEFAULT_CR".equals(args[0])) {
+ addDefaultCR = false;
+ } else {
+ ErrorLogHelper.logError("AAI_3000",
+ "Unrecognized argument passed to GenTester.java: [" + args[0] + "]. ");
+
+ String emsg = "Unrecognized argument passed to GenTester.java: [" + args[0] + "]. ";
+ System.out.println(emsg);
+ LOGGER.error(emsg);
+
+ emsg = "Either pass no argument for normal processing, or use 'GEN_DB_WITH_NO_SCHEMA'.";
+ System.out.println(emsg);
+ LOGGER.error(emsg);
+
+ return;
+ }
+ }
+
+ // AAIConfig.init();
+ ErrorLogHelper.loadProperties();
+
+ LOGGER.debug("about to open graph (takes a little while)");
+ graph = AAIGraph.getInstance().getGraph();
+
+ if (graph == null) {
+ ErrorLogHelper.logError("AAI_5102", "Error creating JanusGraph graph. ");
+ return;
+ }
+ LOGGER.info("checking schemaInitializedVertex...");
+ Optional<Vertex> schemaInitializedVertex = graph.traversal().V()
+ .or(
+ __.has(SCHEMA_INITIALIZED, true),
+ __.has(SCHEMA_INITIALIZED, false)
+ )
+ .tryNext();
+
+ if (schemaInitializedVertex.isPresent()) {
+ //Set schema-initialized vertex to false if such vertex is present in db
+ setSchemaInitializedToFalse(graph, schemaInitializedVertex);
+ } else {
+ // Creating a new vertex as the vertex is not yet present in db
+ createNewSchemaInitializedVertex(graph);
+ }
+
+ GraphAdminDBUtils.logConfigs(graph.configuration());
+
+ LOGGER.debug("-- Loading new schema elements into JanusGraph --");
+
+ boolean dbNotEmpty = (graph.traversal().V().limit(1).hasNext());
+ LOGGER.info("DB is not empty. Newly created indexes will also be reindexed.");
+ List<String> vertexesToReindex = SchemaGenerator.loadSchemaIntoJanusGraph(graph, null, dbNotEmpty);
+ LOGGER.debug("-- committing transaction ");
+ graph.tx().commit();
+
+ boolean reindexingEnabled = false; // disable reindexing for now, since it's not working correctly
+ if (reindexingEnabled && !vertexesToReindex.isEmpty()) {
+ killTransactionsAndInstances(graph);
+ LOGGER.info("Number of edge indexes to reindex: " + vertexesToReindex.size());
+ SchemaGenerator.reindexEdgeIndexes(graph, vertexesToReindex);
+ } else {
+ if (vertexesToReindex.isEmpty()) {
+ LOGGER.info("Nothing to reindex.");
+ }
+ }
+
+ // Setting property schema-initialized to true
+ LOGGER.info("-- Updating vertex with property schema-initialized to true ");
+ graph.traversal().V().has(SCHEMA_INITIALIZED , false).property(SCHEMA_INITIALIZED , true).next();
+ LOGGER.debug("-- committing transaction ");
+ graph.tx().commit();
+ applyLockConsistency(graph);
+ graph.close();
+ LOGGER.info("Closed the graph");
+
+ } catch (Exception ex) {
+ ErrorLogHelper.logError("AAI_4000", ex.getMessage());
+ System.exit(1);
+ }
+ }
+
+ /**
+ * Enforces ConsistencyModifier.LOCK on all vertex composite indexes.
+ * This ensures index-level consistency after schema creation.
+ */
+ private static void applyLockConsistency(JanusGraph graph) {
+ // Read from environment variable injected by Helm
+ boolean lockEnabled = Boolean.parseBoolean(
+ Optional.ofNullable(System.getenv("AAI_INDEX_LOCK_ENABLED"))
+ .orElse("false")
+ );
+ LOGGER.info("=== Enforcing ConsistencyModifier.LOCK on all composite indexes === LOCK ENABLED: {}",lockEnabled);
+
+ JanusGraphManagement mgmt = graph.openManagement();
+ try {
+ Iterator<JanusGraphIndex> indexes = mgmt.getGraphIndexes(Vertex.class).iterator();
+ while (indexes.hasNext()) {
+ JanusGraphIndex index = indexes.next();
+
+ if (index.isCompositeIndex()) {
+ try {
+
+ if (lockEnabled) {
+ mgmt.setConsistency(index, org.janusgraph.core.schema.ConsistencyModifier.LOCK);
+ LOGGER.debug("Successfully set LOCK for index: {}", index.name());
+ }else{
+ mgmt.setConsistency(index, org.janusgraph.core.schema.ConsistencyModifier.DEFAULT);
+ LOGGER.debug("Successfully set DEFAULT for index: {}", index.name());
+ }
+ } catch (Exception e) {
+ LOGGER.warn("Failed to set LOCK for index {}: {}", index.name(), e.getMessage());
+ }
+ } else {
+ LOGGER.debug("Skipping non-composite index: {}", index.name());
+ }
+ }
+
+ mgmt.commit();
+ LOGGER.info("Committed LOCK consistency for all applicable indexes.");
+ } catch (Exception e) {
+ LOGGER.error("Error while applying ConsistencyModifier.LOCK: {}", e.getMessage(), e);
+ mgmt.rollback();
+ }
+ }
+
+
+
+ private static void setSchemaInitializedToFalse(JanusGraph graph, Optional<Vertex> schemaInitializedVertex) {
+ Vertex vertex = schemaInitializedVertex.get();
+ Object schemaInitializedValueObj = vertex.property(SCHEMA_INITIALIZED).value();
+ Boolean schemaInitializedValue = schemaInitializedValueObj instanceof Boolean b ? b : Boolean.FALSE;
+
+ //Setting schema-initialized vertex to False
+ if (Boolean.TRUE.equals(schemaInitializedValue)) {
+ // Update the property from true to false
+ LOGGER.debug("-- Vertex with property 'schema-initialized' present in db and is true. Updating it to false");
+ graph.traversal().V()
+ .has(SCHEMA_INITIALIZED, true)
+ .property(SCHEMA_INITIALIZED, false)
+ .next();
+ } else {
+ // Property already false, no action needed
+ LOGGER.debug("-- Vertex with property 'schema-initialized' present in db and is false. Keeping it false. Do Nothing");
+ }
+ }
+
+ private static void createNewSchemaInitializedVertex(JanusGraph graph) throws Exception {
+ LOGGER.debug("-- Adding a new vertex with property schema-initialized as false");
+ JanusGraphManagement mgmt = graph.openManagement();
+ try {
+ // Creating an index
+ createSchemaInitializedIndex(graph, mgmt);
+ } catch (Exception e) {
+ mgmt.rollback();
+ LOGGER.error("Problems creating an index for schema-initialized vertex " + e.getMessage());
+ throw e;
+ }
+ try {
+ Vertex newVertex = graph.addVertex(SCHEMA_INITIALIZED , false);
+ LOGGER.info("Created a new vertex with property '{}' set to '{}'", SCHEMA_INITIALIZED ,
+ newVertex.property(SCHEMA_INITIALIZED ).value());
+ } catch (Exception e) {
+ LOGGER.error("Error creating a new vertex: {}", e.getMessage(), e);
+ throw e;
+ }
+ }
+
+ private static void createSchemaInitializedIndex(JanusGraph graph, JanusGraphManagement mgmt) throws InterruptedException {
+ // creating a composite index
+ boolean indexExists = mgmt.containsGraphIndex(SCHEMA_INITIALIZED);
+ if(indexExists) {
+ LOGGER.debug(SCHEMA_INITIALIZED + " index already exists. Skipping creation.");
+ return;
+ }
+ LOGGER.debug("-- Building an index on property schema-initialized");
+ PropertyKey schemaInitialized = mgmt.makePropertyKey(SCHEMA_INITIALIZED).dataType(Boolean.class).make();
+ mgmt.buildIndex(SCHEMA_INITIALIZED, Vertex.class)
+ .addKey(schemaInitialized)
+ .buildCompositeIndex();
+ mgmt.commit();
+
+ // Wait for the index to become available
+ ManagementSystem.awaitGraphIndexStatus(graph, SCHEMA_INITIALIZED).call();
+ }
+
+ /**
+ * Radical approach to avoiding index update failures.
+ * Indexes can get stuck in INSTALLED state, when there are stale transactions
+ * or JanusGraph instances.
+ * This is because a state change needs to be acknowledged by all instances
+ * before transitioning.
+ *
+ * @param graph
+ * @return
+ */
+ private static void killTransactionsAndInstances(JanusGraph graph) {
+ graph.tx().rollback();
+ final StandardJanusGraph janusGraph = (StandardJanusGraph) graph;
+ janusGraph.getOpenTransactions().stream().forEach(transaction -> {
+ LOGGER.debug("Closing open transaction [{}] before schema generation", transaction.toString());
+ transaction.rollback();
+ });
+
+ final JanusGraphManagement graphMgtForClosing = graph.openManagement();
+
+ Set<String> instances = graphMgtForClosing.getOpenInstances();
+ LOGGER.info("Number of open instances: {}", instances.size());
+ LOGGER.info("Currently open instances: [{}]", instances);
+ instances.stream()
+ .filter(instance -> !instance.contains("graphadmin")) // Potentially comment this out, should there be
+ // issues with the schema creation job
+ .filter(instance -> !instance.contains("(current)"))
+ .forEach(instance -> {
+ LOGGER.debug("Closing open JanusGraph instance [{}] before reindexing procedure", instance);
+ graphMgtForClosing.forceCloseInstance(instance);
+ });
+ graphMgtForClosing.commit();
+ }
}
--- /dev/null
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 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.schema;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.janusgraph.core.JanusGraph;
+import org.janusgraph.core.JanusGraphTransaction;
+import org.onap.aai.db.props.AAIProperties;
+import org.onap.aai.dbmap.AAIGraph;
+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.ExceptionTranslator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+
+import java.io.*;
+import java.nio.charset.StandardCharsets;
+import java.util.*;
+
+/*
+* Class SDCRootModelLoader loads the root models (model invariant-ids and model-version-ids ) through
+* Artifact-Generator.properties file in to AAI DB
+*/
+public class SDCRootModelLoader {
+ private static Logger LOGGER;
+
+ public static void main(String[] args) throws AAIException {
+ LOGGER = LoggerFactory.getLogger(SDCRootModelLoader.class);
+ try {
+ loadRootModels();
+ } catch (Exception e) {
+ AAIException aai = ExceptionTranslator.schemaServiceExceptionTranslator(e);
+ LOGGER.error("Problems during loading root models " + aai.getStackTrace());
+ throw aai;
+ }
+ LOGGER.debug("All done, if the program does not exit, please kill it manually.");
+ System.exit(0);
+ }
+
+ private static void loadRootModels() throws AAIException {
+ JanusGraph graph = AAIGraph.getInstance().getGraph();
+ if (graph == null) {
+ ErrorLogHelper.logError("AAI_5102", "Error creating JanusGraph graph. ");
+ return;
+ }
+ if (checkDBContainsModelData(graph)) {
+ LOGGER.info("Model data already present in DB, skipping root model loading.");
+ return;
+ }
+
+ long startTime = System.currentTimeMillis();
+ // This file with the root model details is referenced & taken from SDC under
+ // below repository path
+ // https://gerrit.onap.org/r/gitweb?p=sdc.git;a=blob;f=catalog-be/src/main/resources/config/Artifact-Generator.properties
+ String filePath = AAIConstants.AAI_HOME_ETC_APP_PROPERTIES + "artifact-generator.properties";
+
+ Map<String, Map<String, String>> modelData = loadModelProperties(filePath);
+ final int BATCH_SIZE = 100;
+ int counter = 0;
+ int totalInserted = 0;
+
+ JanusGraphTransaction tx = graph.newTransaction();
+ final GraphTraversalSource g = tx.traversal();
+
+ try {
+ Vertex rootModel = g.V()
+ .has("aai-node-type", "service-design-and-creation")
+ .tryNext()
+ .orElseGet(() -> g.addV("service-design-and-creation")
+ .property("aai-node-type", "service-design-and-creation")
+ .next());
+
+ for (Map.Entry<String, Map<String, String>> entry : modelData.entrySet()) {
+
+ String modelName = entry.getKey();
+ Map<String, String> ids = entry.getValue();
+ // loading single model data (invariant-id, version-id)
+ loadSingleModelEntry(g, tx, rootModel, modelName, ids);
+
+ counter++;
+ totalInserted++;
+ if (counter >= BATCH_SIZE) {
+ tx.commit();
+ LOGGER.info("Committed batch of {} models ({} total so far)", counter, totalInserted);
+ counter = 0;
+ }
+ }
+
+ tx.commit();
+ LOGGER.info("Final commit — total models inserted/updated: {}", totalInserted);
+
+ } catch (Exception e) {
+ LOGGER.error("Error inserting/updating model data", e);
+ if (tx != null && tx.isOpen())
+ tx.rollback();
+ } finally {
+ if (tx != null && tx.isOpen())
+ tx.close();
+ }
+ graph.close();
+ long elapsed = System.currentTimeMillis() - startTime;
+ LOGGER.info("Model data loading completed in {} ms, total models inserted: {}", elapsed, totalInserted);
+ }
+
+ private static void loadSingleModelEntry(GraphTraversalSource g, JanusGraphTransaction tx, Vertex rootModel,
+ String modelName, Map<String, String> ids) {
+
+ String modelInvariantId = ids.get("model-invariant-id");
+ String modelVersionId = ids.get("model-version-id");
+ String modelType = ids.getOrDefault("model-type", "widget");
+
+ if (modelInvariantId == null || modelVersionId == null) {
+ LOGGER.warn("Skipping {} — missing model IDs", modelName);
+ return;
+ }
+
+ // --- Create or fetch model vertex ---
+ Vertex modelVertex = g.V()
+ .has("aai-node-type", "model")
+ .has("model-invariant-id", modelInvariantId)
+ .tryNext()
+ .orElseGet(() -> {
+ long currentTimeModelInvariant = System.currentTimeMillis();
+ Vertex v = g.addV("model")
+ .property("aai-node-type", "model")
+ .property("model-invariant-id", modelInvariantId)
+ .property("model-type", modelType)
+ .property("aai-uuid", UUID.randomUUID().toString())
+ .property("model-name", modelName)
+ .property("source-of-truth", "ModelLoaderTool")
+ .property("last-mod-source-of-truth", "ModelLoaderTool")
+ .property("aai-created-ts", currentTimeModelInvariant)
+ .property("aai-last-mod-ts", currentTimeModelInvariant)
+ .property("aai-uri", String.format(
+ "/service-design-and-creation/models/model/%s", modelInvariantId))
+ .property(AAIProperties.RESOURCE_VERSION, String.valueOf(currentTimeModelInvariant))
+ .next();
+ LOGGER.info("Created model vertex for invariantId: {}", modelInvariantId);
+ return v;
+ });
+
+ // --- Create or fetch model-version vertex ---
+ Vertex modelVerVertex = g.V()
+ .has("aai-node-type", "model-ver")
+ .has("model-version-id", modelVersionId)
+ .tryNext()
+ .orElseGet(() -> {
+ long currentTimeModelVersion = System.currentTimeMillis();
+ Vertex v = g.addV("model-ver")
+ .property("aai-node-type", "model-ver")
+ .property("model-version-id", modelVersionId)
+ .property("model-name", modelName)
+ .property("aai-uuid", UUID.randomUUID().toString())
+ .property("source-of-truth", "ModelLoaderTool")
+ .property("last-mod-source-of-truth", "ModelLoaderTool")
+ .property("aai-created-ts", currentTimeModelVersion)
+ .property("model-version", "2.0")
+ .property("aai-last-mod-ts", currentTimeModelVersion)
+ .property("aai-uri", String.format(
+ "/service-design-and-creation/models/model/%s/model-vers/model-ver/%s",
+ modelInvariantId, modelVersionId))
+ .property(AAIProperties.RESOURCE_VERSION, String.valueOf(currentTimeModelVersion))
+ .next();
+ LOGGER.info("Created model-version vertex: {}", modelVersionId);
+ return v;
+ });
+
+ if (!g.V(rootModel).out("models").has("model-invariant-id", modelInvariantId).hasNext()) {
+ g.addE("models").from(rootModel).to(modelVertex).next();
+ LOGGER.info("Linked rootModel → model {}", modelInvariantId);
+ }
+ if (!g.V(modelVertex).out("model-vers").has("model-version-id", modelVersionId).hasNext()) {
+ g.addE("model-vers").from(modelVertex).to(modelVerVertex).next();
+ LOGGER.info("Linked model → model-ver {}", modelVersionId);
+ }
+ }
+
+ private static boolean checkDBContainsModelData(JanusGraph graph) throws AAIException {
+ try (JanusGraphTransaction tx = graph.newTransaction()) {
+ GraphTraversalSource g = tx.traversal();
+ boolean hasWidgetModel = g.V()
+ .has("aai-node-type", "model")
+ .has("model-type", "widget")
+ .hasNext();
+ tx.commit();
+ return hasWidgetModel;
+ } catch (Exception e) {
+ LOGGER.error("Error during model data loading", e);
+ return false;
+ }
+ }
+
+ private static Map<String, Map<String, String>> loadModelProperties(String filePath) throws AAIException {
+ Map<String, Map<String, String>> modelData = new LinkedHashMap<>();
+ Properties props = new Properties();
+
+ try (BufferedReader reader = new BufferedReader(new FileReader(filePath))) {
+ StringBuilder cleanContent = new StringBuilder();
+ String line;
+ boolean insideCommentBlock = false;
+
+ while ((line = reader.readLine()) != null) {
+ line = line.trim();
+
+ if (line.startsWith("{{/*")) {
+ insideCommentBlock = true;
+ continue;
+ } else if (line.endsWith("*/}}")) {
+ insideCommentBlock = false;
+ continue;
+ }
+
+ if (insideCommentBlock || line.isEmpty() || line.startsWith("#")) {
+ continue;
+ }
+ cleanContent.append(line).append(System.lineSeparator());
+ }
+
+ try (InputStream is = new ByteArrayInputStream(cleanContent.toString().getBytes(StandardCharsets.UTF_8))) {
+ props.load(is);
+ }
+
+ } catch (IOException e) {
+ LOGGER.error("Error reading properties file: {}", filePath, e);
+ return Collections.emptyMap();
+ }
+
+ // Parse AAI model properties: e.g. AAI.model-version-id.action=UUID
+ for (String key : props.stringPropertyNames()) {
+ String value = props.getProperty(key).trim();
+ String[] parts = key.split("\\.");
+
+ if (parts.length == 3) {
+ String idType = parts[1];
+ String nodeType = parts[2];
+ modelData.computeIfAbsent(nodeType, k -> new HashMap<>())
+ .put(idType, value);
+ } else {
+ LOGGER.warn("Skipping invalid key: {}", key);
+ }
+ }
+
+ LOGGER.info("Loaded {} model entries from {}", modelData.size(), filePath);
+ for (Map.Entry<String, Map<String, String>> entry : modelData.entrySet()) {
+ LOGGER.debug("→ nodeType={}, model-invariant-id={}, model-version-id={}",
+ entry.getKey(),
+ entry.getValue().get("model-invariant-id"),
+ entry.getValue().get("model-version-id"));
+ }
+
+ return modelData;
+ }
+}
--- /dev/null
+{{/*
+# Copyright © 2018 Amdocs, Bell Canada, AT&T
+#
+# 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.
+
+
+# action widget details from SDC
+# This file with the root model details is referenced & taken from SDC under
+# below repository path
+# https://gerrit.onap.org/r/gitweb?p=sdc.git;a=blob;f=catalog-be/src/main/resources/config/Artifact-Generator.properties
+*/}}
+
+#action widget details
+AAI.model-version-id.action=fd7fb09e-d930-41b9-b83f-cfde9df48640
+AAI.model-invariant-id.action=af593b4b-490e-4665-ad74-2f6351c0a7ce
+#action-data widget details
+AAI.model-invariant-id.action-data=9551346c-7d8b-4daf-9926-b93e96e2344a
+AAI.model-version-id.action-data=2f80c596-27e5-4ca9-b5bb-e03a7fd4c0fd
+#allotted-resource widget details
+AAI.model-invariant-id.allotted-resource=f6d6a23d-a1a9-48ff-8419-b6530da2d381
+AAI.model-version-id.allotted-resource=7ad0915f-25c0-4a70-b9bc-185a75f87564
+#availability-zone widget details
+AAI.model-version-id.availability-zone=6c092fb1-21b2-456b-9e01-67fb4de1896e
+AAI.model-invariant-id.availability-zone=61b88c01-d819-41c0-8e21-7fd7ba47148e
+#az-and-dvs-switches widget details
+AAI.model-version-id.az-and-dvs-switches=b2dea88d-78a0-49bf-95c9-5819df08e966
+AAI.model-invariant-id.az-and-dvs-switches=53dc00d4-e6d9-48ec-b6cc-3d3797e9b896
+#class-of-service widget details
+AAI.model-version-id.class-of-service=d2fb27cc-15eb-4c4e-828e-71d41aaecc5b
+AAI.model-invariant-id.class-of-service=18094b19-d16d-4822-8acf-e92c6aefa178
+#cloud-region widget details
+AAI.model-version-id.cloud-region=2a160989-b202-47dd-874b-4a0f275998f7
+AAI.model-invariant-id.cloud-region=425b2158-e51d-4509-9945-dad4556474a3
+#complex widget details
+AAI.model-invariant-id.complex=af91c2f7-35fc-43cf-a13d-443f385b2353
+AAI.model-version-id.complex=3a8ab1ee-9220-4fe8-b89c-9251d160ddc2
+#connector widget details
+AAI.model-version-id.connector=22104c9f-29fd-462f-be07-96cd6b46dd33
+AAI.model-invariant-id.connector=4c01c948-7607-4d66-8a6c-99c2c2717936
+#constrained-element-set widget details
+AAI.model-invariant-id.constrained-element-set=c0292b4f-ee97-40cc-8c2e-f967c48f5701
+AAI.model-version-id.constrained-element-set=01102126-9c04-4a89-945b-b131e61e95d7
+#ctag-assignment widget details
+AAI.model-version-id.ctag-assignment=44e5cb1f-0938-41aa-b766-d4595109fe89
+AAI.model-invariant-id.ctag-assignment=fcb8d46b-b656-4ad6-8fa4-22cef74b443f
+#ctag-pool widget details
+AAI.model-invariant-id.ctag-pool=46c51d4e-d67e-4a9c-b1f5-49b1e9c6fcaa
+AAI.model-version-id.ctag-pool=2056c41f-23b9-4de7-9f50-819adad37d76
+#customer widget details
+AAI.model-invariant-id.customer=c1d4305f-cdbd-4bbe-9069-a2f4978fd89e
+AAI.model-version-id.customer=d4df5c27-98a1-4812-a8aa-c17f055b7a3f
+#cvlan-tag-entry widget details
+AAI.model-version-id.cvlan-tag-entry=c3878ffb-8d85-4114-bee6-e4074a9db10b
+AAI.model-invariant-id.cvlan-tag-entry=245cf4b0-7cc5-4eea-bbd9-753e939adcab
+#dvs-switch widget details
+AAI.model-invariant-id.dvs-switch=98fbb471-1f86-428e-bd8a-c8a25de6fa23
+AAI.model-version-id.dvs-switch=4cb44ae8-e3ab-452a-9f95-bcc8a44c55ea
+#edge-prop-names widget details
+AAI.model-invariant-id.edge-prop-names=7a08cad4-8759-46a5-8245-095d1ba57ac6
+AAI.model-version-id.edge-prop-names=f0442326-8201-4d0e-857c-74b4ddcbfc9f
+#element-choice-set widget details
+AAI.model-invariant-id.element-choice-set=9a011958-7165-47a3-b872-00951d1f09ae
+AAI.model-version-id.element-choice-set=af27fbfd-598d-44da-aeae-0f9d3a5fcd6a
+#entitlement widget details
+AAI.model-version-id.entitlement=7e27ba2e-b7db-4e13-9fae-d142152ef98a
+AAI.model-invariant-id.entitlement=ae75b5a0-d5e1-4f3a-b8fb-37626a753da3
+#flavor widget details
+AAI.model-invariant-id.flavor=bace8d1c-a261-4041-9e37-823117415d0f
+AAI.model-version-id.flavor=36200fb5-f251-4f5d-a520-7c5ad5c2cd4b
+#generic-vnf widget details
+AAI.model-version-id.generic-vnf=93a6166f-b3d5-4f06-b4ba-aed48d009ad9
+AAI.model-invariant-id.generic-vnf=acc6edd8-a8d4-4b93-afaa-0994068be14c
+#group-assignment widget details
+AAI.model-invariant-id.group-assignment=7cc05f25-7ba2-42b7-a237-c5662a1689e1
+AAI.model-version-id.group-assignment=fe578080-ce19-4604-8760-fc264fbb2565
+#image widget details
+AAI.model-version-id.image=f6a038c2-820c-42ba-8c2b-375e24e8f932
+AAI.model-invariant-id.image=3f4c7204-739b-4bbb-87a7-8a6856439c90
+#include-node-filter widget details
+AAI.model-invariant-id.include-node-filter=2a2d8ad2-af0a-4e1f-9982-0c899e7dc827
+AAI.model-version-id.include-node-filter=f05f804d-7057-4ffe-bdc5-39f2f0c9c9fd
+#instance-group widget details
+AAI.model-version-id.instance-group=8e6ee9dc-9017-444a-83b3-219edb018128
+AAI.model-invariant-id.instance-group=3bf1e610-45f7-4ad6-b833-ca4c5ee6a3fd
+#inventory-item widget details
+AAI.model-invariant-id.inventory-item=cd57d844-9017-4078-aa19-926935a3d77c
+AAI.model-version-id.inventory-item=69957f4a-2155-4b95-8d72-d6dd9b88b27b
+#inventory-item-data widget details
+AAI.model-version-id.inventory-item-data=0e54bb87-bd6e-4a2b-ad1c-6d935b87ae51
+AAI.model-invariant-id.inventory-item-data=87a383ae-cf03-432e-a9de-04e6a622d0fd
+#ipsec-configuration widget details
+AAI.model-invariant-id.ipsec-configuration=aca4c310-cb45-42bd-9f88-73e40ba7b962
+AAI.model-version-id.ipsec-configuration=d949fd10-36bf-408a-ac7a-cad5004d2e0d
+#key-data widget details
+AAI.model-version-id.key-data=c23ea04d-1a3b-453d-bc49-a6c783a5e92b
+AAI.model-invariant-id.key-data=f5faa464-c2f2-4cc3-89d2-a90452dc3a07
+#l3-interface-ipv4-address-list widget details
+AAI.model-version-id.l3-interface-ipv4-address-list=41e76b6f-1e06-4fd4-82cd-81c50fc4574b
+AAI.model-invariant-id.l3-interface-ipv4-address-list=aad85df2-09be-40fa-b867-16415e4e10e2
+#l3-interface-ipv6-address-list widget details
+AAI.model-invariant-id.l3-interface-ipv6-address-list=82966045-43ee-4982-8307-7e9610866140
+AAI.model-version-id.l3-interface-ipv6-address-list=d040621d-541a-477b-bb1b-a2b61b14e295
+#l3-network widget details
+AAI.model-version-id.l3-network=9111f20f-e680-4001-b83f-19a2fc23bfc1
+AAI.model-invariant-id.l3-network=3d560d81-57d0-438b-a2a1-5334dba0651a
+#lag-interface widget details
+AAI.model-version-id.lag-interface=ce95f7c3-b61b-4758-ae9e-7e943b1c103d
+AAI.model-invariant-id.lag-interface=e0ee9bde-c1fc-4651-a95d-8e0597bf7d70
+#lag-link widget details
+AAI.model-version-id.lag-link=d29a087a-af59-4053-a3f8-0f95a92faa75
+AAI.model-invariant-id.lag-link=86ffe6e5-4d0e-4cec-80b5-5c38aa3eff98
+#license widget details
+AAI.model-invariant-id.license=b9a9b337-1f86-42d3-b9f9-f987a089507c
+AAI.model-version-id.license=6889274b-a1dc-40ab-9090-93677e13e2e6
+#license-key-resource widget details
+AAI.model-invariant-id.license-key-resource=9022ebfe-b54f-4911-a6b2-8c3f5ec189b7
+AAI.model-version-id.license-key-resource=24b25f8c-b8bd-4c62-9421-87c12667aac9
+#l-interface widget details
+AAI.model-version-id.l-interface=a32613fd-18b9-459e-aab8-fffb3912966a
+AAI.model-invariant-id.l-interface=cea0a982-8d55-4093-921e-418fbccf7060
+#logical-link widget details
+AAI.model-version-id.logical-link=a1481a38-f8ba-4ae4-bdf1-06c2c6af4c54
+AAI.model-invariant-id.logical-link=fe012535-2c31-4a39-a739-612374c638a0
+#metadatum widget details
+AAI.model-invariant-id.metadatum=86dbb63a-265e-4614-993f-6771c30b56a5
+AAI.model-version-id.metadatum=6bae950e-8939-41d3-a6a7-251b03e4c1fc
+#model widget details
+AAI.model-invariant-id.model=06d1418a-5faa-452d-a94b-a2829df5f67b
+AAI.model-version-id.model=1f51c05c-b164-4c27-9c03-5cbb239fd6be
+#model-constraint widget details
+AAI.model-invariant-id.model-constraint=c28966f3-e758-4483-b37b-a90b05d3dd33
+AAI.model-version-id.model-constraint=ad70dd19-f156-4fb5-a865-97b5563b0d37
+#model-element widget details
+AAI.model-invariant-id.model-element=2076e726-3577-477a-a300-7fa65cd4df11
+AAI.model-version-id.model-element=753e813a-ba9e-4a1d-ab34-b2f6dc6eec0c
+#multicast-configuration widget details
+AAI.model-invariant-id.multicast-configuration=ea78c9e3-514d-4a0a-9162-13837fa54c35
+AAI.model-version-id.multicast-configuration=666a06ee-4b57-46df-bacf-908da8f10c3f
+#named-query widget details
+AAI.model-version-id.named-query=5c3b7c33-afa3-4be5-8da7-1a5ac6f99896
+AAI.model-invariant-id.named-query=80b712fd-0ad3-4180-a99c-8c995cf1cc32
+#named-query-element widget details
+AAI.model-version-id.named-query-element=204c641a-3494-48c8-979a-86856f5fd32a
+AAI.model-invariant-id.named-query-element=3c504d40-b847-424c-9d25-4fb7e0a3e994
+#network-policy widget details
+AAI.model-invariant-id.network-policy=6aa05779-94d7-4d8b-9bee-59ef2ab0c246
+AAI.model-version-id.network-policy=a0ccd9dc-7062-4940-9bcc-e91dd28af510
+#network-profile widget details
+AAI.model-version-id.network-profile=01f45471-4240-498c-a9e1-235dc0b8b4a6
+AAI.model-invariant-id.network-profile=2734b44a-b8a2-40f6-957d-6256589e5d00
+#newvce widget details
+AAI.model-version-id.newvce=7c79e11f-a408-4593-aa86-ba948a1236af
+AAI.model-invariant-id.newvce=4b05ec9c-c55d-4987-83ff-e08d6ddb694f
+#oam-network widget details
+AAI.model-invariant-id.oam-network=2851cf01-9c40-4064-87d4-6184a6fcff35
+AAI.model-version-id.oam-network=f4fb34f3-fd6e-4a8f-a3fb-4ab61a343b79
+#physical-link widget details
+AAI.model-invariant-id.physical-link=c822d81f-822f-4304-9623-1025b53da568
+AAI.model-version-id.physical-link=9c523936-95b4-4d7f-9f53-6bdfe0cf2c05
+#p-interface widget details
+AAI.model-invariant-id.p-interface=94043c37-4e73-439c-a790-0fdd697924cd
+AAI.model-version-id.p-interface=d2cdb2d0-fc1f-4a57-a89e-591b1c4e3754
+#pnf widget details
+AAI.model-version-id.pnf=e9f1fa7d-c839-418a-9601-03dc0d2ad687
+AAI.model-invariant-id.pnf=862b25a1-262a-4961-bdaa-cdc55d69785a
+#port-group widget details
+AAI.model-version-id.port-group=03e8bb6b-b48a-46ae-b5d4-e5af577e6844
+AAI.model-invariant-id.port-group=8ce940fb-55d7-4230-9e7f-a56cc2741f77
+#property-constraint widget details
+AAI.model-version-id.property-constraint=81706bbd-981e-4362-ae20-995cbcb2d995
+AAI.model-invariant-id.property-constraint=f4a863c3-6886-470a-a6ae-05723837ea45
+#pserver widget details
+AAI.model-invariant-id.pserver=6d932c8f-463b-4e76-83fb-87acfbaa2e2d
+AAI.model-version-id.pserver=72f0d495-bc27-4653-9e1a-eef76bd34bc9
+#related-lookup widget details
+AAI.model-invariant-id.related-lookup=468f6f5b-2996-41bb-b2a3-7cf9613ebb9b
+AAI.model-version-id.related-lookup=0988bab5-bf4f-4938-a419-ab249867d12a
+#reserved-prop-names widget details
+AAI.model-invariant-id.reserved-prop-names=0c3e0ba3-618c-498d-9127-c8d42b00170f
+AAI.model-version-id.reserved-prop-names=ac49d26d-9163-430e-934a-13b738a04f5c
+#result-data widget details
+AAI.model-version-id.result-data=4e9b50aa-5227-4f6f-b489-62e6bbc03c79
+AAI.model-invariant-id.result-data=ff656f23-6185-406f-9006-4b26834f3e1c
+#route-table-reference widget details
+AAI.model-version-id.route-table-reference=fed7e326-03a7-45ff-a3f2-471470d268c4
+AAI.model-invariant-id.route-table-reference=a8614b63-2636-4c4f-98df-fd448c4241db
+#routing-instance widget details
+AAI.model-invariant-id.routing-instance=1c2ded4f-8b01-4193-829c-966847dfec3e
+AAI.model-version-id.routing-instance=3ccbcbc7-d19e-44d5-a52f-7e18aa8d69fa
+#secondary-filter widget details
+AAI.model-version-id.secondary-filter=1380619d-dd1a-4cec-b755-c6407833e065
+AAI.model-invariant-id.secondary-filter=738ff299-6290-4c00-8998-bd0e96a07b93
+#segmentation-assignment widget details
+AAI.model-invariant-id.segmentation-assignment=6e814aee-46e1-4583-a9d4-0049bfd2b59b
+AAI.model-version-id.segmentation-assignment=c5171ae0-44fb-4c04-b482-d56702241a44
+#service widget details
+AAI.model-version-id.service=ecce2c42-3957-4ae0-9442-54bc6afe27b6
+AAI.model-invariant-id.service=07a3a60b-1b6c-4367-8173-8014386f89e3
+#service-capability widget details
+AAI.model-invariant-id.service-capability=b1a7cc05-d19d-443b-a5d1-733e325c4232
+AAI.model-version-id.service-capability=f9cfec1b-18da-4bba-bd83-4b26cca115cd
+#service-instance widget details
+AAI.model-invariant-id.service-instance=82194af1-3c2c-485a-8f44-420e22a9eaa4
+AAI.model-version-id.service-instance=46b92144-923a-4d20-b85a-3cbd847668a9
+#service-subscription widget details
+AAI.model-invariant-id.service-subscription=2e1a602a-acd8-4f78-94ff-618b802a303b
+AAI.model-version-id.service-subscription=5e68299a-79f2-4bfb-8fbc-2bae877a2459
+#site-pair widget details
+AAI.model-version-id.site-pair=7106bc02-6552-4fc3-8a56-4f3df9034531
+AAI.model-invariant-id.site-pair=db63f3e6-f8d1-484e-8d5e-191600b7914b
+#site-pair-set widget details
+AAI.model-invariant-id.site-pair-set=5d4dae3e-b402-4bfd-909e-ece12ff75d26
+AAI.model-version-id.site-pair-set=a5c6c1bc-dc38-468e-9459-bb08f87247df
+#snapshot widget details
+AAI.model-version-id.snapshot=962a7c8b-687f-4d32-a775-fe098e214bcd
+AAI.model-invariant-id.snapshot=24de00ef-aead-4b52-995b-0adf8d4bd90d
+#sriov-vf widget details
+AAI.model-version-id.sriov-vf=1e8b331f-3d4a-4160-b7aa-f4d5a8916625
+AAI.model-invariant-id.sriov-vf=04b2935f-33c4-40a9-8af0-8b52690042dc
+#start-node-filter widget details
+AAI.model-version-id.start-node-filter=aad96fd3-e75f-42fc-9777-3450c36f1168
+AAI.model-invariant-id.start-node-filter=083093a3-e407-447a-ba5d-7583e4d23e1d
+#subnet widget details
+AAI.model-version-id.subnet=f902a6bc-6be4-4fe5-8458-a6ec0056b374
+AAI.model-invariant-id.subnet=1b2c9ba7-e449-4831-ba15-3073672f5ef2
+#tagged-inventory-item-list widget details
+AAI.model-invariant-id.tagged-inventory-item-list=e78a7eaa-f65d-4919-9c2b-5b258c8c4d7e
+AAI.model-version-id.tagged-inventory-item-list=c246f6e2-e3a1-4697-94c0-5672a7fbbf04
+#tenant widget details
+AAI.model-invariant-id.tenant=97c26c99-6870-44c1-8a07-1d900d3f4ce6
+AAI.model-version-id.tenant=abcc54bc-bb74-49dc-9043-7f7171707545
+#tunnel-xconnect widget details
+AAI.model-invariant-id.tunnel-xconnect=50b9e2fa-005c-4bbe-b651-3251dece4cd8
+AAI.model-version-id.tunnel-xconnect=e7cb4ca8-e1a5-4487-a716-4ae0bcd8aef5
+#update-node-key widget details
+AAI.model-version-id.update-node-key=6004cfa6-eb6d-4062-971f-b1fde6b74aa0
+AAI.model-invariant-id.update-node-key=fe81c801-f65d-408a-b2b7-a729a18f8154
+#vce widget details
+AAI.model-version-id.vce=b6cf54b5-ec45-43e1-be64-97b4e1513333
+AAI.model-invariant-id.vce=bab6dceb-e7e6-4301-a5e0-a7399b48d792
+#vf-module widget details
+AAI.model-invariant-id.vf-module=ef86f9c5-2165-44f3-8fc3-96018b609ea5
+AAI.model-version-id.vf-module=c00563ae-812b-4e62-8330-7c4d0f47088a
+#vig-server widget details
+AAI.model-version-id.vig-server=8e8c22f1-fbdf-48ea-844c-8bdeb44e7b16
+AAI.model-invariant-id.vig-server=bed7c3b7-35d0-4cd9-abde-41b20e68b28e
+#virtual-data-center widget details
+AAI.model-invariant-id.virtual-data-center=5150abcf-0c5f-4593-9afe-a19c48fc4824
+AAI.model-version-id.virtual-data-center=6dd43ced-d789-47af-a759-d3abc14e3ac1
+#vlan widget details
+AAI.model-version-id.vlan=257d88a5-a269-4c35-944f-aca04fbdb791
+AAI.model-invariant-id.vlan=d2b1eaf1-ae59-4116-9ee4-aa0179faa4f8
+#vnfc widget details
+AAI.model-invariant-id.vnfc=96129eb9-f0de-4e05-8af2-73146473f766
+AAI.model-version-id.vnfc=5761e0a7-c6df-4d8a-9ebd-b8f445054dec
+#vnf-image widget details
+AAI.model-invariant-id.vnf-image=f9a628ff-7aa0-40e2-a93d-02d91c950982
+AAI.model-version-id.vnf-image=c4d3e747-ba4a-4b17-9896-94c6f18c19d3
+#volume widget details
+AAI.model-version-id.volume=0fbe2e8f-4d91-4415-a772-88387049b38d
+AAI.model-invariant-id.volume=ddd739b4-2b25-46c4-affc-41a32af5cc42
+#volume-group widget details
+AAI.model-invariant-id.volume-group=fcec1b02-b2d0-4834-aef8-d71be04717dd
+AAI.model-version-id.volume-group=99d44c90-1f61-4418-b9a6-56586bf38c79
+#vpe widget details
+AAI.model-invariant-id.vpe=053ec3a7-5b72-492d-b54d-123805a9b967
+AAI.model-version-id.vpe=203817d3-829c-42d4-942d-2a935478e993
+#vpls-pe widget details
+AAI.model-version-id.vpls-pe=b1566228-6785-4ce1-aea2-053736f80341
+AAI.model-invariant-id.vpls-pe=457ba89b-334c-4fbd-acc4-160ac0e0cdc0
+#vpn-binding widget details
+AAI.model-invariant-id.vpn-binding=9e23b675-db2b-488b-b459-57aa9857baa0
+AAI.model-version-id.vpn-binding=21a146e5-9901-448c-9197-723076770119
+#vserver widget details
+AAI.model-invariant-id.vserver=ff69d4e0-a8e8-4108-bdb0-dd63217e63c7
+AAI.model-version-id.vserver=8ecb2c5d-7176-4317-a255-26274edfdd53
\ No newline at end of file
</encoder>
</appender>
<!-- CreateDBSchema logs ended -->
+
+ <!-- SdcRootModelLoader logs started -->
+ <appender name="sdcRootModelLoader" class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
+ <level>WARN</level>
+ </filter>
+ <File>${logDirectory}/sdcRootModelLoader/error.log</File>
+ <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+ <fileNamePattern>${logDirectory}/sdcRootModelLoader/error.log.%d{yyyy-MM-dd}</fileNamePattern>
+ <maxHistory>${maxHistory}</maxHistory>
+ <totalSizeCap>${totalSizeCap}</totalSizeCap>
+ </rollingPolicy>
+ <encoder>
+ <pattern>${errorPattern}</pattern>
+ </encoder>
+ </appender>
+
+ <appender name="sdcRootModelLoaderdebug" class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <filter class="ch.qos.logback.classic.filter.LevelFilter">
+ <level>DEBUG</level>
+ <onMatch>ACCEPT</onMatch>
+ <onMismatch>DENY</onMismatch>
+ </filter>
+ <File>${logDirectory}/sdcRootModelLoader/debug.log</File>
+ <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+ <fileNamePattern>${logDirectory}/sdcRootModelLoader/debug.log.%d{yyyy-MM-dd}</fileNamePattern>
+ <maxHistory>${maxHistory}</maxHistory>
+ <totalSizeCap>${totalSizeCap}</totalSizeCap>
+ </rollingPolicy>
+ <encoder>
+ <pattern>${debugPattern}</pattern>
+ </encoder>
+ </appender>
+
+ <appender name="sdcRootModelLoadermetric" class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <filter class="ch.qos.logback.classic.filter.LevelFilter">
+ <level>INFO</level>
+ <onMatch>ACCEPT</onMatch>
+ <onMismatch>DENY</onMismatch>
+ </filter>
+ <File>${logDirectory}/sdcRootModelLoader/metrics.log</File>
+ <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+ <fileNamePattern>${logDirectory}/sdcRootModelLoader/metrics.log.%d{yyyy-MM-dd}</fileNamePattern>
+ <maxHistory>${maxHistory}</maxHistory>
+ <totalSizeCap>${totalSizeCap}</totalSizeCap>
+ </rollingPolicy>
+ <encoder>
+ <pattern>${metricPattern}</pattern>
+ </encoder>
+ </appender>
+ <!-- SdcRootModelLoader logs ended -->
<!-- DataCleanupTasks logs started -->
<appender name="dataCleanuperror" class="ch.qos.logback.core.rolling.RollingFileAppender">
<appender-ref ref="createDBSchemametric"/>
<appender-ref ref="STDOUT"/>
</logger>
+
+ <logger name="org.onap.aai.schema" level="DEBUG" additivity="false">
+ <appender-ref ref="sdcRootModelLoader"/>
+ <appender-ref ref="sdcRootModelLoaderdebug"/>
+ <appender-ref ref="sdcRootModelLoadermetric"/>
+ <appender-ref ref="STDOUT"/>
+ </logger>
<logger name="org.onap.aai.dbgen.DupeTool" level="DEBUG" additivity="false">
<appender-ref ref="dupeTooldebug" />
--- /dev/null
+#!/bin/sh
+#
+# ============LICENSE_START=======================================================
+# org.onap.aai
+# ================================================================================
+# Copyright © 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=========================================================
+#
+# ECOMP is a trademark and service mark of AT&T Intellectual Property.
+# The script invokes GenTester java class to create the DB schema
+#
+# NOTE: you can pass an option GEN_DB_WITH_NO_SCHEMA if you want it to create an instance of
+# the graph - but with no schema (this is useful when using the Hbase copyTable to
+# copy our database to different environments).
+# Ie. createDbSchema.sh GEN_DB_WITH_NO_SCHEMA
+#
+#
+#
+#
+
+set -x;
+COMMON_ENV_PATH=$( cd "$(dirname "$0")" ; pwd -P )
+. ${COMMON_ENV_PATH}/common_functions.sh
+start_date;
+source_profile;
+if [ -z "$1" ]; then
+ execute_spring_jar org.onap.aai.schema.SDCRootModelLoader ${PROJECT_HOME}/resources/logback.xml
+else
+ execute_spring_jar org.onap.aai.schema.SDCRootModelLoader ${PROJECT_HOME}/resources/logback.xml "$1"
+fi;
+end_date;
+exit 0