// to the SchemaGenerator needs the bean and during the constructor
// the Spring Context is not yet initialized
-
AAIGraph.getInstance();
System.setProperty("org.onap.aai.graphadmin.started", "true");
public static void loadDefaultProps(){
+ /*
+ * Required for DB connection name
+ */
+ System.setProperty("aai.service.name", GraphAdminApp.class.getSimpleName());
if(System.getProperty("AJSC_HOME") == null){
System.setProperty("AJSC_HOME", ".");
}
HashMap<String, Vertex> orphanNodeHash ;
HashMap<String, Vertex> missingAaiNtNodeHash ;
+ HashMap<String, Vertex> badUriNodeHash ;
+ HashMap<String, Vertex> badIndexNodeHash ;
HashMap<String, Edge> oneArmedEdgeHash ;
HashMap<String, Vertex> ghostNodeHash ;
ArrayList<String> dupeGroups;
JanusGraph graph2 = null;
deleteCount = 0;
int dummyUpdCount = 0;
+ int indexUpdCount = 0;
boolean executeFinalCommit = false;
deleteCandidateList = new LinkedHashSet<>();
Set<String> processedVertices = new LinkedHashSet<>();
HashMap<String, String> misMatchedHash = new HashMap<String, String>();
orphanNodeHash = new HashMap<String, Vertex>();
missingAaiNtNodeHash = new HashMap<String, Vertex>();
+ badUriNodeHash = new HashMap<String, Vertex>();
+ badIndexNodeHash = new HashMap<String, Vertex>();
oneArmedEdgeHash = new HashMap<String, Edge>();
HashMap<String, String> emptyVertexHash = new HashMap<String, String>();
ghostNodeHash = new HashMap<String, Vertex>();
&& depNodeOk){
aaiKeysOk = false;
}
-
- if( (!aaiKeysOk || !aaiUriOk)
- && !deleteCandidateList.contains(thisVid)
- && !skipIndexUpdateFix ){
- // Either the aaiKeys or aaiUri was bad. This may
- // be a problem with the indexes so we'll try to reset
- // them since this node is not on the delete list from
- // a previous run.
- tryToReSetIndexedProps(thisVtx, thisVid, indexedProps);
- }
-
- if( !aaiKeysOk || !aaiUriOk ){
- // We could not get the node back using it's own key info or aai-uri.
+
+ boolean bothKeysAreBad = false;
+ if( !aaiKeysOk && !aaiUriOk ) {
+ bothKeysAreBad = true;
+ }
+ else if ( !aaiKeysOk ){
+ // Just the key-index is bad
+ // We will not be putting this on the Auto-Delete list, just logging it (AAI-16252)
+ badIndexNodeHash.put(thisVid, thisVtx);
+ }
+ else if ( !aaiUriOk ){
+ // Just the aai-uri is bad
+ // We will not be putting this on the Auto-Delete list, just logging it (AAI-16252)
+ badUriNodeHash.put(thisVid, thisVtx);
+ }
+
+ if( bothKeysAreBad ){
+ // Neither the aai-uri nor key info could retrieve this node - BOTH are bad.
// So, it's a PHANTOM
if (deleteCandidateList.contains(thisVid)) {
ArrayList<Vertex> vertList = new ArrayList<>();
Iterator<Vertex> vItor3 = g.traversal().V();
- // Gotta hold these in a List - or else HBase times out as you cycle
+ // Gotta hold these in a List - or else the DB times out as you cycle
// through these
while (vItor3.hasNext()) {
Vertex v = vItor3.next();
continue;
}
if (ghostNodeHash.containsKey(thisVertId)) {
- // This is a phantom node, so don't try to use it
+ // We already know that this is a phantom node, so don't bother checking it
LOGGER.info(" >> Skipping edge check for edges from vertexId = "
+ thisVertId
+ ", since that guy is a Phantom Node");
deleteCount = deleteCount + dupeGrpsDeleted;
- if (deleteCount > 0 || dummyUpdCount > 0){
+ if (deleteCount > 0 || dummyUpdCount > 0 || indexUpdCount > 0){
executeFinalCommit = true;
}
int orphanNodeCount = orphanNodeHash.size();
int oneArmedEdgeCount = oneArmedEdgeHash.size();
int missingAaiNtNodeCount = missingAaiNtNodeHash.size();
+ int badUriNodeCount = badUriNodeHash.size();
+ int badIndexNodeCount = badIndexNodeHash.size();
int dupeCount = dupeGroups.size();
deleteCount = deleteCount + dupeGrpsDeleted;
+ "\n");
bw.write("Dummy-index-update to delete candidates = " + dummyUpdCount
+ "\n");
+ bw.write("index-update-Fix Attempts to phantom nodes = " + indexUpdCount
+ + "\n");
bw.write("Total number of nodes looked at = " + totalNodeCount
+ "\n");
bw.write("Ghost Nodes identified = " + ghostNodeCount + "\n");
bw.write("Orphan Nodes identified = " + orphanNodeCount + "\n");
bw.write("Missing aai-node-type Nodes identified = " + missingAaiNtNodeCount + "\n");
bw.write("Bad Edges identified = " + oneArmedEdgeCount + "\n");
+ bw.write("Bad aai-uri property Nodes identified = " + badUriNodeCount + "\n");
+ bw.write("Bad index property Nodes identified = " + badIndexNodeCount + "\n");
bw.write("Duplicate Groups count = " + dupeCount + "\n");
bw.write("MisMatching Label/aai-node-type count = "
+ misMatchedHash.size() + "\n");
bw.write("DeleteCandidate: Bad EDGE Edge-id = [" + eid + "]\n");
cleanupCandidateCount++;
}
+
+
bw.write("\n-- NOTE - To see DeleteCandidates for Duplicates, you need to look in the Duplicates Detail section below.\n");
}
}
- bw.write("\n ------------- Missing aai-node-type NODES - detail: ");
+ bw.write("\n ------------- Missing aai-node-type NODES - detail ");
for (Map.Entry<String, Vertex> entry : missingAaiNtNodeHash
.entrySet()) {
try {
LOGGER.error("error trying to print detail info for a node missing its aai-node-type " + LogFormatTools.getStackTop(dex));
}
}
+
+ bw.write("\n ------------- Nodes where aai-uri property is bad - detail ");
+ for (Map.Entry<String, Vertex> entry : badUriNodeHash
+ .entrySet()) {
+ try {
+ String vid = entry.getKey();
+ bw.write("\n> Has Bad aai-uri - Vid = " + vid + "\n");
+ ArrayList<String> retArr = showPropertiesForNode(
+ TRANSID, FROMAPPID, entry.getValue());
+ for (String info : retArr) {
+ bw.write(info + "\n");
+ }
+
+ retArr = showAllEdgesForNode(TRANSID, FROMAPPID,
+ entry.getValue());
+ for (String info : retArr) {
+ bw.write(info + "\n");
+ }
+ } catch (Exception dex) {
+ LoggingContext.statusCode(StatusCode.ERROR);
+ LoggingContext.responseCode(LoggingContext.DATA_ERROR);
+ LOGGER.error("error trying to print detail info for a node with a bad aai-uri " + LogFormatTools.getStackTop(dex));
+ }
+ }
+
+ bw.write("\n ------------- Nodes where an indexed property is bad - detail: ");
+ for (Map.Entry<String, Vertex> entry : badIndexNodeHash
+ .entrySet()) {
+ try {
+ String vid = entry.getKey();
+ bw.write("\n> Node with bad index - Vid = " + vid + "\n");
+ ArrayList<String> retArr = showPropertiesForNode(
+ TRANSID, FROMAPPID, entry.getValue());
+ for (String info : retArr) {
+ bw.write(info + "\n");
+ }
+
+ retArr = showAllEdgesForNode(TRANSID, FROMAPPID,
+ entry.getValue());
+ for (String info : retArr) {
+ bw.write(info + "\n");
+ }
+ } catch (Exception dex) {
+ LoggingContext.statusCode(StatusCode.ERROR);
+ LoggingContext.responseCode(LoggingContext.DATA_ERROR);
+ LOGGER.error("error trying to print detail info for a node with bad index " + LogFormatTools.getStackTop(dex));
+ }
+ }
bw.write("\n ------------- Missing Dependent Edge ORPHAN NODES - detail: ");
for (Map.Entry<String, Vertex> entry : orphanNodeHash
LOGGER.info("\n ------------- Done doing all the checks ------------ ");
LOGGER.info("Output will be written to " + fullOutputFileName);
- if (cleanupCandidateCount > 0) {
+ if (cleanupCandidateCount > 0 || badUriNodeCount > 0 || badIndexNodeCount > 0) {
// Technically, this is not an error -- but we're throwing this
// error so that hopefully a
// monitoring system will pick it up and do something with it.
// We will only deal with properties that are indexed and have a value - and for those,
// we will re-set them to the same value they already have, so that hopefully if their
// index was broken, it may get re-set.
+
+ // NOTE -- as of 1902-P2, this is deprecated --------------
LOGGER.info(" We will try to re-set the indexed properties for this node without changing any property values. VID = " + thisVidStr );
// These reserved-prop-names are all indexed for all nodes
public int getMissingAaiNtNodeCount(){
return getMissingAaiNtNodeHash().size();
}
+
+ public HashMap<String, Vertex> getBadUriNodeHash() {
+ return badUriNodeHash;
+ }
+ public void setBadUriNodeHash(HashMap<String, Vertex> badUriNodeHash) {
+ this.badUriNodeHash = badUriNodeHash;
+ }
+
+ public int getBadUriNodeCount(){
+ return getBadUriNodeHash().size();
+ }
+
+ public HashMap<String, Vertex> getBadIndexNodeHash() {
+ return badIndexNodeHash;
+ }
+
+ public void setBadIndexNodeHash(HashMap<String, Vertex> badIndexNodeHash) {
+ this.badIndexNodeHash = badIndexNodeHash;
+ }
+
+ public int getBadIndexNodeCount(){
+ return getBadIndexNodeHash().size();
+ }
+
public HashMap<String, Edge> getOneArmedEdgeHash() {
return oneArmedEdgeHash;
}
append("enabledupecheckoff" , AAIConfig.get("aai.datagrooming.enabledupecheckoff"), dataGroomingFlagMap);
append("enableghost2checkoff" , AAIConfig.get("aai.datagrooming.enableghost2checkoff"), dataGroomingFlagMap);
append("enableghost2fixon" , AAIConfig.get("aai.datagrooming.enableghost2fixon"), dataGroomingFlagMap);
+ append("enableskipindexupdatefix" , AAIConfig.get("aai.datagrooming.enableskipindexupdatefix"), dataGroomingFlagMap);
append("enablef" , AAIConfig.get("aai.datagrooming.enablef"), dataGroomingFlagMap);
append("fvalue" , AAIConfig.get("aai.datagrooming.fvalue"), dataGroomingFlagMap);
append("timewindowminutesvalue" , AAIConfig.get("aai.datagrooming.timewindowminutesvalue"), dataGroomingFlagMap);
if("true".equals(dataGroomingFlagMap.get("enableghost2fixon"))){
paramsArray.add("-ghost2FixOn");
}
+ if("true".equals(dataGroomingFlagMap.get("enableskipindexupdatefix"))){
+ paramsArray.add("-skipIndexUpdateFix");
+ }
if("true".equals(dataGroomingFlagMap.get("enablef"))) {
paramsArray.add("-f");
public void execute(String[] args){
- String defVersion = "v15";
+ String defVersion = "v16";
try {
defVersion = AAIConfig.get(AAIConstants.AAI_DEFAULT_API_VERSION_PROP);
} catch (AAIException ae) {
* https://github.com/JanusGraph/janusgraph/wiki/Indexing
*/
-@Enabled
+//@Enabled
@MigrationPriority(500)
@MigrationDangerRating(1000)
import java.util.*;
import java.util.stream.Collectors;
-@Enabled
+//@Enabled
@MigrationPriority(1000)
@MigrationDangerRating(1000)
import org.onap.aai.setup.SchemaVersions;
-@Enabled
+//@Enabled
@MigrationPriority(20)
@MigrationDangerRating(100)
public class MigrateBadWidgetModelsPartOne extends EdgeSwingMigrator {
import org.onap.aai.setup.SchemaVersions;
-@Enabled
+//@Enabled
@MigrationPriority(21)
@MigrationDangerRating(100)
public class MigrateBadWidgetModelsPartTwo extends EdgeSwingMigrator {
@MigrationPriority(10)
@MigrationDangerRating(100)
-@Enabled
+//@Enabled
public class MigrateEdgesBetweenVnfcAndVfModule extends EdgeMigrator {
public MigrateEdgesBetweenVnfcAndVfModule(TransactionalGraphEngine engine, LoaderFactory loaderFactory, EdgeIngestor edgeIngestor, EdgeSerializer edgeSerializer, SchemaVersions schemaVersions) {
@MigrationPriority(26)
@MigrationDangerRating(100)
-@Enabled
+//@Enabled
public class MigrateForwarderEvcCircuitId extends Migrator {
private final String PNF_NODE_TYPE = "pnf";
@MigrationPriority(19)
@MigrationDangerRating(2)
-@Enabled
+//@Enabled
public class MigrateInstanceGroupModelInvariantId extends PropertyMigrator {
private static final String INSTANCE_GROUP_NODE_TYPE = "instance-group";
@MigrationPriority(19)
@MigrationDangerRating(2)
-@Enabled
+//@Enabled
public class MigrateInstanceGroupModelVersionId extends PropertyMigrator {
private static final String INSTANCE_GROUP_NODE_TYPE = "instance-group";
@MigrationPriority(20)
@MigrationDangerRating(2)
-@Enabled
+//@Enabled
public class MigrateInstanceGroupSubType extends PropertyMigrator{
protected static final String SUB_TYPE_PROPERTY = "sub-type";
@MigrationPriority(20)
@MigrationDangerRating(2)
-@Enabled
+//@Enabled
public class MigrateInstanceGroupType extends PropertyMigrator{
protected static final String TYPE_PROPERTY = "type";
-/**\r
- * ============LICENSE_START=======================================================\r
- * org.onap.aai\r
- * ================================================================================\r
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.\r
- * ================================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ============LICENSE_END=========================================================\r
- */\r
-package org.onap.aai.migration.v13;\r
-import java.util.List;\r
-import java.util.Optional;\r
-\r
-import org.apache.tinkerpop.gremlin.structure.Vertex;\r
-import org.onap.aai.db.props.AAIProperties;\r
-import org.onap.aai.edges.EdgeIngestor;\r
-import org.onap.aai.introspection.LoaderFactory;\r
-import org.onap.aai.migration.Enabled;\r
-import org.onap.aai.migration.MigrationDangerRating;\r
-import org.onap.aai.migration.MigrationPriority;\r
-import org.onap.aai.migration.Migrator;\r
-import org.onap.aai.migration.Status;\r
-import org.onap.aai.serialization.db.EdgeSerializer;\r
-import org.onap.aai.serialization.engines.TransactionalGraphEngine;\r
-import org.onap.aai.setup.SchemaVersions;\r
-\r
-@MigrationPriority(20)\r
-@MigrationDangerRating(2)\r
-@Enabled\r
-public class MigratePserverAndPnfEquipType extends Migrator{\r
-\r
- protected static final String EQUIP_TYPE_PROPERTY = "equip-type";\r
- protected static final String HOSTNAME_PROPERTY = "hostname";\r
- protected static final String PNF_NAME_PROPERTY = "pnf-name";\r
- protected static final String PNF_NODE_TYPE = "pnf";\r
- protected static final String PSERVER_NODE_TYPE = "pserver";\r
- private boolean success = true;\r
-\r
- public MigratePserverAndPnfEquipType(TransactionalGraphEngine engine, LoaderFactory loaderFactory, EdgeIngestor edgeIngestor, EdgeSerializer edgeSerializer, SchemaVersions schemaVersions) {\r
- super(engine, loaderFactory, edgeIngestor, edgeSerializer, schemaVersions);\r
- }\r
-\r
-\r
-\r
- @Override\r
- public void run() {\r
- int pserverCount = 0;\r
- int pnfCount = 0;\r
- int pserverErrorCount = 0;\r
- int pnfErrorCount = 0;\r
- logger.info("---------- Start Updating equip-type for Pserver and Pnf ----------");\r
-\r
- List<Vertex> pserverList = this.engine.asAdmin().getTraversalSource().V().has(AAIProperties.NODE_TYPE, PSERVER_NODE_TYPE).toList();\r
- List<Vertex> pnfList = this.engine.asAdmin().getTraversalSource().V().has(AAIProperties.NODE_TYPE, PNF_NODE_TYPE).toList();\r
-\r
- for (Vertex vertex : pserverList) {\r
- String currentValueOfEquipType = null;\r
- String hostName = null;\r
- try {\r
- currentValueOfEquipType = getEquipTypeNodeValue(vertex);\r
- hostName = getHostNameNodeValue(vertex);\r
- if("Server".equals(currentValueOfEquipType) ||"server".equals(currentValueOfEquipType) ){\r
- vertex.property(EQUIP_TYPE_PROPERTY, "SERVER");\r
- this.touchVertexProperties(vertex, false);\r
- logger.info("changed Pserver equip-type from " + currentValueOfEquipType + " to SERVER having hostname : " + hostName);\r
- pserverCount++;\r
- }\r
- } catch (Exception e) {\r
- success = false;\r
- pserverErrorCount++;\r
- logger.error(MIGRATION_ERROR + "encountered exception for equip-type:" + currentValueOfEquipType + " having hostName :" + hostName, e);\r
- }\r
- }\r
- \r
- for (Vertex vertex : pnfList) {\r
- String currentValueOfEquipType = null;\r
- String pnfName = null;\r
- try {\r
- currentValueOfEquipType = getEquipTypeNodeValue(vertex);\r
- pnfName = getPnfNameNodeValue(vertex);\r
- if("Switch".equals(currentValueOfEquipType)||"switch".equals(currentValueOfEquipType)){\r
- vertex.property(EQUIP_TYPE_PROPERTY, "SWITCH");\r
- this.touchVertexProperties(vertex, false);\r
- logger.info("changed Pnf equip-type from "+ currentValueOfEquipType +" to SWITCH having pnf-name :" + pnfName);\r
- pnfCount++;\r
- }\r
-\r
- } catch (Exception e) {\r
- success = false;\r
- pnfErrorCount++;\r
- logger.error(MIGRATION_ERROR + "encountered exception for equip-type:" + currentValueOfEquipType +" having pnf-name : "+ pnfName , e);\r
- }\r
- }\r
- \r
- logger.info ("\n \n ******* Final Summary Updated equip-type for Pserver and Pnf Migration ********* \n");\r
- logger.info(MIGRATION_SUMMARY_COUNT+"Number of Pservers updated: "+ pserverCount +"\n");\r
- logger.info(MIGRATION_SUMMARY_COUNT+"Number of Pservers failed to update due to error : "+ pserverErrorCount +"\n");\r
- \r
- logger.info(MIGRATION_SUMMARY_COUNT+"Number of Pnf updated: "+ pnfCount +"\n");\r
- logger.info(MIGRATION_SUMMARY_COUNT+"Number of Pnf failed to update due to error : "+ pnfErrorCount +"\n");\r
-\r
- }\r
-\r
- private String getEquipTypeNodeValue(Vertex vertex) {\r
- String propertyValue = "";\r
- if(vertex != null && vertex.property(EQUIP_TYPE_PROPERTY).isPresent()){\r
- propertyValue = vertex.property(EQUIP_TYPE_PROPERTY).value().toString();\r
- }\r
- return propertyValue;\r
- }\r
- \r
- private String getHostNameNodeValue(Vertex vertex) {\r
- String propertyValue = "";\r
- if(vertex != null && vertex.property(HOSTNAME_PROPERTY).isPresent()){\r
- propertyValue = vertex.property(HOSTNAME_PROPERTY).value().toString();\r
- }\r
- return propertyValue;\r
- }\r
- \r
- private String getPnfNameNodeValue(Vertex vertex) {\r
- String propertyValue = "";\r
- if(vertex != null && vertex.property(PNF_NAME_PROPERTY).isPresent()){\r
- propertyValue = vertex.property(PNF_NAME_PROPERTY).value().toString();\r
- }\r
- return propertyValue;\r
- }\r
- \r
- @Override\r
- public Status getStatus() {\r
- if (success) {\r
- return Status.SUCCESS;\r
- } else {\r
- return Status.FAILURE;\r
- }\r
- }\r
- \r
- @Override\r
- public Optional<String[]> getAffectedNodeTypes() {\r
- return Optional.of(new String[]{PSERVER_NODE_TYPE,PNF_NODE_TYPE});\r
- }\r
-\r
- @Override\r
- public String getMigrationName() {\r
- return "MigratePserverAndPnfEquipType";\r
- }\r
-\r
-}\r
+/**
+ * ============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.migration.v13;
+import java.util.List;
+import java.util.Optional;
+
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.onap.aai.db.props.AAIProperties;
+import org.onap.aai.edges.EdgeIngestor;
+import org.onap.aai.introspection.LoaderFactory;
+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.EdgeSerializer;
+import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+import org.onap.aai.setup.SchemaVersions;
+
+@MigrationPriority(20)
+@MigrationDangerRating(2)
+//@Enabled
+public class MigratePserverAndPnfEquipType extends Migrator{
+
+ protected static final String EQUIP_TYPE_PROPERTY = "equip-type";
+ protected static final String HOSTNAME_PROPERTY = "hostname";
+ protected static final String PNF_NAME_PROPERTY = "pnf-name";
+ protected static final String PNF_NODE_TYPE = "pnf";
+ protected static final String PSERVER_NODE_TYPE = "pserver";
+ private boolean success = true;
+
+ public MigratePserverAndPnfEquipType(TransactionalGraphEngine engine, LoaderFactory loaderFactory, EdgeIngestor edgeIngestor, EdgeSerializer edgeSerializer, SchemaVersions schemaVersions) {
+ super(engine, loaderFactory, edgeIngestor, edgeSerializer, schemaVersions);
+ }
+
+
+
+ @Override
+ public void run() {
+ int pserverCount = 0;
+ int pnfCount = 0;
+ int pserverErrorCount = 0;
+ int pnfErrorCount = 0;
+ logger.info("---------- Start Updating equip-type for Pserver and Pnf ----------");
+
+ List<Vertex> pserverList = this.engine.asAdmin().getTraversalSource().V().has(AAIProperties.NODE_TYPE, PSERVER_NODE_TYPE).toList();
+ List<Vertex> pnfList = this.engine.asAdmin().getTraversalSource().V().has(AAIProperties.NODE_TYPE, PNF_NODE_TYPE).toList();
+
+ for (Vertex vertex : pserverList) {
+ String currentValueOfEquipType = null;
+ String hostName = null;
+ try {
+ currentValueOfEquipType = getEquipTypeNodeValue(vertex);
+ hostName = getHostNameNodeValue(vertex);
+ if("Server".equals(currentValueOfEquipType) ||"server".equals(currentValueOfEquipType) ){
+ vertex.property(EQUIP_TYPE_PROPERTY, "SERVER");
+ this.touchVertexProperties(vertex, false);
+ logger.info("changed Pserver equip-type from " + currentValueOfEquipType + " to SERVER having hostname : " + hostName);
+ pserverCount++;
+ }
+ } catch (Exception e) {
+ success = false;
+ pserverErrorCount++;
+ logger.error(MIGRATION_ERROR + "encountered exception for equip-type:" + currentValueOfEquipType + " having hostName :" + hostName, e);
+ }
+ }
+
+ for (Vertex vertex : pnfList) {
+ String currentValueOfEquipType = null;
+ String pnfName = null;
+ try {
+ currentValueOfEquipType = getEquipTypeNodeValue(vertex);
+ pnfName = getPnfNameNodeValue(vertex);
+ if("Switch".equals(currentValueOfEquipType)||"switch".equals(currentValueOfEquipType)){
+ vertex.property(EQUIP_TYPE_PROPERTY, "SWITCH");
+ this.touchVertexProperties(vertex, false);
+ logger.info("changed Pnf equip-type from "+ currentValueOfEquipType +" to SWITCH having pnf-name :" + pnfName);
+ pnfCount++;
+ }
+
+ } catch (Exception e) {
+ success = false;
+ pnfErrorCount++;
+ logger.error(MIGRATION_ERROR + "encountered exception for equip-type:" + currentValueOfEquipType +" having pnf-name : "+ pnfName , e);
+ }
+ }
+
+ logger.info ("\n \n ******* Final Summary Updated equip-type for Pserver and Pnf Migration ********* \n");
+ logger.info(MIGRATION_SUMMARY_COUNT+"Number of Pservers updated: "+ pserverCount +"\n");
+ logger.info(MIGRATION_SUMMARY_COUNT+"Number of Pservers failed to update due to error : "+ pserverErrorCount +"\n");
+
+ logger.info(MIGRATION_SUMMARY_COUNT+"Number of Pnf updated: "+ pnfCount +"\n");
+ logger.info(MIGRATION_SUMMARY_COUNT+"Number of Pnf failed to update due to error : "+ pnfErrorCount +"\n");
+
+ }
+
+ private String getEquipTypeNodeValue(Vertex vertex) {
+ String propertyValue = "";
+ if(vertex != null && vertex.property(EQUIP_TYPE_PROPERTY).isPresent()){
+ propertyValue = vertex.property(EQUIP_TYPE_PROPERTY).value().toString();
+ }
+ return propertyValue;
+ }
+
+ private String getHostNameNodeValue(Vertex vertex) {
+ String propertyValue = "";
+ if(vertex != null && vertex.property(HOSTNAME_PROPERTY).isPresent()){
+ propertyValue = vertex.property(HOSTNAME_PROPERTY).value().toString();
+ }
+ return propertyValue;
+ }
+
+ private String getPnfNameNodeValue(Vertex vertex) {
+ String propertyValue = "";
+ if(vertex != null && vertex.property(PNF_NAME_PROPERTY).isPresent()){
+ propertyValue = vertex.property(PNF_NAME_PROPERTY).value().toString();
+ }
+ return propertyValue;
+ }
+
+ @Override
+ public Status getStatus() {
+ if (success) {
+ return Status.SUCCESS;
+ } else {
+ return Status.FAILURE;
+ }
+ }
+
+ @Override
+ public Optional<String[]> getAffectedNodeTypes() {
+ return Optional.of(new String[]{PSERVER_NODE_TYPE,PNF_NODE_TYPE});
+ }
+
+ @Override
+ public String getMigrationName() {
+ return "MigratePserverAndPnfEquipType";
+ }
+
+}
* ============LICENSE_END=========================================================
*/
package org.onap.aai.migration.v13;
-/*-
- * ============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.janusgraph.core.Cardinality;
import org.onap.aai.edges.EdgeIngestor;
* ============LICENSE_END=========================================================
*/
package org.onap.aai.migration.v13;
-/*-
- * ============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.Optional;
import org.janusgraph.core.Cardinality;
@MigrationPriority(19)
@MigrationDangerRating(2)
-@Enabled
+//@Enabled
public class MigrateVnfcModelVersionId extends PropertyMigrator {
private static final String VNFC_NODE_TYPE = "vnfc";
-/**\r
- * ============LICENSE_START=======================================================\r
- * org.onap.aai\r
- * ================================================================================\r
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.\r
- * ================================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ============LICENSE_END=========================================================\r
- */\r
-package org.onap.aai.migration.v14;\r
-\r
-import java.util.ArrayList;\r
-import java.util.HashMap;\r
-import java.util.List;\r
-import java.util.Map;\r
-import java.util.Optional;\r
-\r
-import org.onap.aai.edges.EdgeIngestor;\r
-import org.onap.aai.introspection.LoaderFactory;\r
-import org.onap.aai.migration.MigrationDangerRating;\r
-import org.onap.aai.migration.MigrationPriority;\r
-import org.onap.aai.migration.Status;\r
-import org.onap.aai.migration.ValueMigrator;\r
-import org.onap.aai.migration.Enabled;\r
-import org.onap.aai.serialization.db.EdgeSerializer;\r
-import org.onap.aai.serialization.engines.TransactionalGraphEngine;\r
-import org.onap.aai.setup.SchemaVersions;\r
-\r
-\r
-@MigrationPriority(1)\r
-@MigrationDangerRating(1)\r
-@Enabled\r
-public class MigrateGenericVnfMgmtOptions extends ValueMigrator {\r
-\r
- protected static final String VNF_NODE_TYPE = "generic-vnf";\r
- \r
- \r
- private static Map<String, Map> map;\r
- private static Map<String, String> pair1;\r
- private static Map<String, List<String>> conditionsMap;\r
- \r
- public MigrateGenericVnfMgmtOptions(TransactionalGraphEngine engine, LoaderFactory loaderFactory, EdgeIngestor edgeIngestor, EdgeSerializer edgeSerializer, SchemaVersions schemaVersions) {\r
- super(engine, loaderFactory, edgeIngestor, edgeSerializer, schemaVersions, setMgmtOptions(), setConditionsMap(), false);\r
- \r
- }\r
- \r
- private static Map<String, Map> setMgmtOptions(){\r
- map = new HashMap<>();\r
- pair1 = new HashMap<>(); \r
-\r
- pair1.put("management-option", "AT&T Managed-Basic"); \r
- map.put("generic-vnf", pair1);\r
- \r
- return map;\r
- }\r
- \r
- \r
-\r
- public static Map<String, List<String>> setConditionsMap() {\r
- List<String> conditionsList = new ArrayList<String>();\r
- conditionsMap = new HashMap<>();\r
- \r
- conditionsList.add("HN");\r
- conditionsList.add("HP");\r
- conditionsList.add("HG");\r
- \r
- conditionsMap.put("vnf-type", conditionsList);\r
- \r
- return conditionsMap;\r
- }\r
-\r
- @Override\r
- public Status getStatus() {\r
- return Status.SUCCESS;\r
- }\r
-\r
- @Override\r
- public Optional<String[]> getAffectedNodeTypes() {\r
- return Optional.of(new String[]{VNF_NODE_TYPE});\r
- }\r
-\r
- @Override\r
- public String getMigrationName() {\r
- return "MigrateGenericVnfMgmtOptions";\r
- }\r
- \r
- @Override\r
- public boolean isUpdateDmaap(){\r
- return true;\r
- }\r
- \r
-\r
-}\r
+/**
+ * ============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.migration.v14;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+
+import org.onap.aai.edges.EdgeIngestor;
+import org.onap.aai.introspection.LoaderFactory;
+import org.onap.aai.migration.MigrationDangerRating;
+import org.onap.aai.migration.MigrationPriority;
+import org.onap.aai.migration.Status;
+import org.onap.aai.migration.ValueMigrator;
+import org.onap.aai.migration.Enabled;
+import org.onap.aai.serialization.db.EdgeSerializer;
+import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+import org.onap.aai.setup.SchemaVersions;
+
+
+@MigrationPriority(1)
+@MigrationDangerRating(1)
+//@Enabled
+public class MigrateGenericVnfMgmtOptions extends ValueMigrator {
+
+ protected static final String VNF_NODE_TYPE = "generic-vnf";
+
+
+ private static Map<String, Map> map;
+ private static Map<String, String> pair1;
+ private static Map<String, List<String>> conditionsMap;
+
+ public MigrateGenericVnfMgmtOptions(TransactionalGraphEngine engine, LoaderFactory loaderFactory, EdgeIngestor edgeIngestor, EdgeSerializer edgeSerializer, SchemaVersions schemaVersions) {
+ super(engine, loaderFactory, edgeIngestor, edgeSerializer, schemaVersions, setMgmtOptions(), setConditionsMap(), false);
+
+ }
+
+ private static Map<String, Map> setMgmtOptions(){
+ map = new HashMap<>();
+ pair1 = new HashMap<>();
+
+ pair1.put("management-option", "AT&T Managed-Basic");
+ map.put("generic-vnf", pair1);
+
+ return map;
+ }
+
+
+
+ public static Map<String, List<String>> setConditionsMap() {
+ List<String> conditionsList = new ArrayList<String>();
+ conditionsMap = new HashMap<>();
+
+ conditionsList.add("HN");
+ conditionsList.add("HP");
+ conditionsList.add("HG");
+
+ conditionsMap.put("vnf-type", conditionsList);
+
+ return conditionsMap;
+ }
+
+ @Override
+ public Status getStatus() {
+ return Status.SUCCESS;
+ }
+
+ @Override
+ public Optional<String[]> getAffectedNodeTypes() {
+ return Optional.of(new String[]{VNF_NODE_TYPE});
+ }
+
+ @Override
+ public String getMigrationName() {
+ return "MigrateGenericVnfMgmtOptions";
+ }
+
+ @Override
+ public boolean isUpdateDmaap(){
+ return true;
+ }
+
+
+}
@MigrationPriority(20)
@MigrationDangerRating(2)
-@Enabled
+//@Enabled
public class MigrateNetworkTechToCloudRegion extends Migrator{
protected static final String CLOUDREGION_NODETYPE = "cloud-region";
import java.util.*;
import java.util.stream.Collectors;
-@Enabled
+//@Enabled
@MigrationPriority(5)
@MigrationDangerRating(100)
public class MigrateSameSourcedRCTROPserverData extends EdgeSwingMigrator {
-/**\r
- * ============LICENSE_START=======================================================\r
- * org.onap.aai\r
- * ================================================================================\r
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.\r
- * ================================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ============LICENSE_END=========================================================\r
- */\r
-package org.onap.aai.migration.v14;\r
-\r
-import java.io.FileNotFoundException;\r
-import java.io.IOException;\r
-import java.nio.file.Files;\r
-import java.nio.file.NoSuchFileException;\r
-import java.nio.file.Paths;\r
-import java.util.ArrayList;\r
-import java.util.HashMap;\r
-import java.util.Iterator;\r
-import java.util.List;\r
-import java.util.Map;\r
-import java.util.Optional;\r
-\r
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;\r
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;\r
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;\r
-import org.apache.tinkerpop.gremlin.structure.Vertex;\r
-import org.onap.aai.db.props.AAIProperties;\r
-import org.onap.aai.edges.EdgeIngestor;\r
-import org.onap.aai.introspection.LoaderFactory;\r
-import org.onap.aai.migration.Enabled;\r
-import org.onap.aai.migration.MigrationDangerRating;\r
-import org.onap.aai.migration.MigrationPriority;\r
-import org.onap.aai.migration.Migrator;\r
-import org.onap.aai.migration.Status;\r
-import org.onap.aai.serialization.db.EdgeSerializer;\r
-import org.onap.aai.serialization.engines.TransactionalGraphEngine;\r
-import org.onap.aai.setup.SchemaVersions;\r
-\r
-@MigrationPriority(100)\r
-@MigrationDangerRating(1)\r
-@Enabled\r
-public class MigrateSdnaIvlanData extends Migrator {\r
- \r
- private final String CONFIGURATION_NODE_TYPE = "configuration";\r
- private final String EVC_NODE_TYPE = "evc";\r
- private final String FORWARDER_NODE_TYPE = "forwarder";\r
- private final String FORWRDER_EVC_NODE_TYPE = "forwarder-evc"; \r
- private final String FORWARDING_PATH_NODE_TYPE = "forwarding-path";\r
- private final String PNF_NODE_TYPE = "pnf";\r
- private final String P_INTERFACE_NODE_TYPE = "p-interface";\r
- private final String LAG_INTERFACE_NODE_TYPE = "lag-interface";\r
- private final String SAREA_GLOBAL_CUSTOMER_ID = "8a00890a-e6ae-446b-9dbe-b828dbeb38bd";\r
- \r
- GraphTraversal<Vertex, Vertex> serviceSubscriptionGt;\r
- \r
- private static GraphTraversalSource g = null;\r
- private static boolean success = true;\r
- private static boolean checkLog = false;\r
- private int headerLength;\r
- private int migrationSuccess = 0;\r
- private int migrationFailure = 0;\r
- private int invalidPInterfaceCount = 0;\r
- private int invalidLagInterfaceCount = 0;\r
- \r
- \r
- private static List<String> dmaapMsgList = new ArrayList<String>();\r
- private static final String homeDir = System.getProperty("AJSC_HOME");\r
- \r
- private static List<String> validPnfList = new ArrayList<String>();\r
- private static List<String> invalidPnfList = new ArrayList<String>();\r
- \r
- private static Map<String, List<String>> validInterfaceMap = new HashMap<String, List<String>>();\r
- private static Map<String, List<String>> invalidInterfaceMap = new HashMap<String, List<String>>();\r
- \r
- protected class SdnaIvlanFileData{\r
- String evcName;\r
- String pnfName;\r
- String interfaceAID;\r
- int ivlanValue;\r
- \r
- public String getEvcName() {\r
- return evcName;\r
- }\r
- public void setEvcName(String evcName) {\r
- this.evcName = evcName;\r
- }\r
- \r
- public String getPnfName() {\r
- return pnfName;\r
- }\r
- public void setPnfName(String pnfName) {\r
- this.pnfName = pnfName;\r
- }\r
- public String getInterfaceAID() {\r
- return interfaceAID;\r
- }\r
- public void setInterfaceAID(String interfaceAID) {\r
- this.interfaceAID = interfaceAID;\r
- }\r
- \r
- public int getIvlanValue() {\r
- return ivlanValue;\r
- }\r
- public void setIvlanValue(int ivlanValue) {\r
- this.ivlanValue = ivlanValue;\r
- }\r
- \r
- }\r
- \r
- private static ArrayList<SdnaIvlanFileData> ivlanList = new ArrayList<SdnaIvlanFileData>();\r
- \r
- public MigrateSdnaIvlanData(TransactionalGraphEngine engine, LoaderFactory loaderFactory, EdgeIngestor edgeIngestor, EdgeSerializer edgeSerializer, SchemaVersions schemaVersions) {\r
- super(engine, loaderFactory, edgeIngestor, edgeSerializer, schemaVersions);\r
- \r
- this.g = this.engine.asAdmin().getTraversalSource();\r
- this.serviceSubscriptionGt = g.V().has("global-customer-id", SAREA_GLOBAL_CUSTOMER_ID).in("org.onap.relationships.inventory.BelongsTo").has("service-type", "SAREA");\r
- }\r
-\r
- @Override\r
- public void run() {\r
- logger.info("---------- Start migration ----------");\r
- String configDir = System.getProperty("BUNDLECONFIG_DIR");\r
- if (homeDir == null) {\r
- logger.info(this.MIGRATION_ERROR + "ERROR: Could not find sys prop AJSC_HOME");\r
- success = false;\r
- return;\r
- }\r
- if (configDir == null) {\r
- success = false;\r
- return;\r
- }\r
- \r
- String feedDir = homeDir + "/" + configDir + "/" + "migration-input-files/sarea-inventory/";\r
-\r
- int fileLineCounter = 0;\r
-\r
- String fileName = feedDir+ "ivlanData.csv";\r
- logger.info(fileName);\r
- logger.info("---------- Processing Entries from file ----------");\r
- \r
- \r
- try {\r
- List<String> lines = Files.readAllLines(Paths.get(fileName));\r
- Iterator<String> lineItr = lines.iterator();\r
- while (lineItr.hasNext()){\r
- String line = lineItr.next().trim();\r
- if (!line.isEmpty()) {\r
- if (fileLineCounter != 0) {\r
- \r
- try{\r
- String[] colList = line.split(",", -1); \r
- SdnaIvlanFileData lineData = new SdnaIvlanFileData();\r
- lineData.setEvcName(colList[0].trim());\r
- lineData.setPnfName(colList[1].trim());\r
- lineData.setInterfaceAID(colList[2].trim());\r
- lineData.setIvlanValue(Integer.valueOf(colList[3].trim()));\r
- ivlanList.add(lineData);\r
- \r
- } catch (Exception e){\r
- logger.info(this.MIGRATION_ERROR + " ERROR: Record Format is invalid. Expecting Numeric value for Forwarder_Id and Ivlan_Value. Skipping Record: " + line);\r
- this.migrationFailure++;\r
- }\r
- \r
- } else {\r
- this.headerLength = line.split(",", -1).length;\r
- if (this.headerLength < 4){\r
- logger.info(this.MIGRATION_ERROR + "ERROR: Input file should have atleast 4 columns");\r
- this.success = false;\r
- return;\r
- }\r
- }\r
- }\r
- fileLineCounter++;\r
- }\r
- \r
- processSdnaIvlan();\r
- \r
- int invalidInterfacesCount = getInvalidInterfaceCount();\r
- \r
- logger.info ("\n \n ******* Final Summary for SDN-A IVLAN Migration ********* \n");\r
- logger.info(this.MIGRATION_SUMMARY_COUNT + "SDN-A forward-evcs: IVLANs updated: "+ migrationSuccess);\r
- logger.info(this.MIGRATION_SUMMARY_COUNT + "Total File Record Count: "+(fileLineCounter - 1));\r
- logger.info(this.MIGRATION_SUMMARY_COUNT + "Unprocessed SDNA File Records : "+ migrationFailure);\r
- logger.info(this.MIGRATION_SUMMARY_COUNT + "PNFs from Input File not found : "+ Integer.toString(invalidPnfList.size()) + "\n");\r
- \r
- \r
- logger.info(this.MIGRATION_SUMMARY_COUNT + "Total PNF + P-INTERFACEs from Input File not found : " + Integer.toString(invalidPInterfaceCount));\r
- logger.info(this.MIGRATION_SUMMARY_COUNT + "Total PNF + LAG-INTERFACEs from Input File not found : " + Integer.toString(invalidLagInterfaceCount));\r
- logger.info(this.MIGRATION_SUMMARY_COUNT + "Total PNF/INTERFACEs from Input File not found : " + Integer.toString(invalidInterfacesCount));\r
-\r
- } catch (FileNotFoundException e) {\r
- logger.info(this.MIGRATION_ERROR + "ERROR: Could not find file " + fileName, e.getMessage());\r
- success = false;\r
- checkLog = true; \r
- } catch (NoSuchFileException e) {\r
- logger.info(this.MIGRATION_ERROR + "ERROR: Could not find file " + fileName, e.getMessage());\r
- success = false;\r
- checkLog = true; \r
- } catch (IOException e) {\r
- logger.info(this.MIGRATION_ERROR + "ERROR: Issue reading file " + fileName, e);\r
- success = false;\r
- } catch (Exception e) {\r
- logger.info(this.MIGRATION_ERROR + "encountered exception", e);\r
- e.printStackTrace();\r
- success = false;\r
- } \r
-\r
- }\r
- private void processSdnaIvlan() {\r
-\r
- for(int i = 0; i < ivlanList.size(); i ++) {\r
- String evc = ivlanList.get(i).getEvcName();\r
- String pnf = ivlanList.get(i).getPnfName();\r
- String interfaceId = ivlanList.get(i).getInterfaceAID();\r
- String ivlanValue = Integer.toString(ivlanList.get(i).getIvlanValue());\r
- \r
- Boolean pnfExists = pnfExists(pnf);\r
- GraphTraversal<Vertex, Vertex> forwarderEvcGT;\r
- Vertex forwarderEvcVtx = null;\r
- String interfaceNodeType;\r
- String forwarderEvcId = null;\r
- \r
- if (!pnfExists){\r
- migrationFailure++;\r
- }else{\r
- \r
- if (interfaceId.contains(".")){\r
- interfaceNodeType = P_INTERFACE_NODE_TYPE; \r
- }else{\r
- interfaceNodeType = LAG_INTERFACE_NODE_TYPE; \r
- }\r
- \r
- validateInterface(pnf, interfaceNodeType, interfaceId);\r
-\r
- forwarderEvcGT = g.V()\r
- .has("pnf-name", pnf).has(AAIProperties.NODE_TYPE, PNF_NODE_TYPE)\r
- .in("tosca.relationships.network.BindsTo")\r
- .has(AAIProperties.NODE_TYPE, interfaceNodeType).has("interface-name", interfaceId)\r
- .in("org.onap.relationships.inventory.ForwardsTo")\r
- .where(__.out("org.onap.relationships.inventory.BelongsTo").has("forwarding-path-id", evc))\r
- .out("org.onap.relationships.inventory.Uses")\r
- .in("org.onap.relationships.inventory.BelongsTo"); \r
- \r
- // fwd-evc not found for pnf + interface\r
- if(!forwarderEvcGT.hasNext()){\r
- forwarderEvcId = pnf + " " + evc;\r
- migrationError(PNF_NODE_TYPE + "/" + EVC_NODE_TYPE, forwarderEvcId, "ivlan", ivlanValue);\r
- \r
- }\r
- \r
- while(forwarderEvcGT.hasNext()){\r
- forwarderEvcVtx = forwarderEvcGT.next();\r
- \r
- // fwd-evc vertex is null \r
- if(forwarderEvcVtx == null){\r
- forwarderEvcId = pnf + " " + evc;\r
- migrationError(PNF_NODE_TYPE + "/" + EVC_NODE_TYPE, forwarderEvcId, "ivlan", ivlanValue);\r
- }\r
- // update fwd-evc with ivlan value\r
- else{\r
- \r
- forwarderEvcId = forwarderEvcVtx.property("forwarder-evc-id").value().toString();\r
- try{\r
- forwarderEvcVtx.property("ivlan", ivlanValue);\r
- logger.info(String.format("Updating Node Type forwarder-evc Property ivlan value %s", ivlanValue.toString()));\r
- this.touchVertexProperties(forwarderEvcVtx, false);\r
- updateDmaapList(forwarderEvcVtx);\r
- migrationSuccess++; \r
- \r
- }catch (Exception e){\r
- logger.info(e.toString());\r
- migrationError(FORWRDER_EVC_NODE_TYPE, forwarderEvcId, "ivlan", ivlanValue);\r
- } \r
- }\r
- } \r
- }\r
- \r
- }\r
- }\r
- \r
- /** \r
- * Description: Validate if pnf node exists in Graph\r
- * @param pnf \r
- * @return boolean\r
- */\r
- private boolean pnfExists(String pnf){\r
- if (invalidPnfList.contains(pnf)){\r
- logger.info(this.MIGRATION_ERROR + "ERROR: PNF value " + pnf + " does not exist.");\r
- return false;\r
- }\r
- if (validPnfList.contains(pnf)){\r
- return true;\r
- }\r
- \r
- GraphTraversal<Vertex, Vertex> pnfGT = g.V()\r
- .has("pnf-name", pnf).has(AAIProperties.NODE_TYPE, PNF_NODE_TYPE);\r
- \r
- if(pnfGT.hasNext()){\r
- validPnfList.add(pnf);\r
- return true;\r
- }\r
- else{\r
- logger.info(this.MIGRATION_ERROR + "ERROR: PNF value " + pnf + " does not exist.");\r
- invalidPnfList.add(pnf);\r
- return false;\r
- }\r
-\r
- }\r
- \r
- /**\r
- * Description: Validate if p-interface or lag-interface node exists in Graph\r
- * @param pnf\r
- * @param interfaceNodeType\r
- * @param interfaceName\r
- */\r
- private void validateInterface(String pnf, String interfaceNodeType, String interfaceName){\r
- \r
- List <String> validInterfaceList;\r
- List <String> invalidInterfaceList;\r
- \r
- if(!validInterfaceMap.containsKey(pnf) ){\r
- validInterfaceList = new ArrayList<String>();\r
- }else{\r
- validInterfaceList = validInterfaceMap.get(pnf); \r
- }\r
- \r
- if(!invalidInterfaceMap.containsKey(pnf)){\r
- invalidInterfaceList = new ArrayList<String>();\r
- }else{\r
- invalidInterfaceList = invalidInterfaceMap.get(pnf); \r
- }\r
- \r
- if(invalidInterfaceList.contains(interfaceName)){\r
- logger.info(this.MIGRATION_ERROR + "ERROR PNF " + pnf + " with a " + interfaceNodeType + " of " + interfaceName + " does not exist.");\r
- return;\r
- }\r
- if(validInterfaceList.contains(interfaceName)){\r
- return;\r
- }\r
- \r
- GraphTraversal<Vertex, Vertex> interfaceGT = g.V()\r
- .has("pnf-name", pnf).has(AAIProperties.NODE_TYPE, PNF_NODE_TYPE)\r
- .in("tosca.relationships.network.BindsTo")\r
- .has("interface-name", interfaceName).has(AAIProperties.NODE_TYPE, interfaceNodeType);\r
- \r
- if(interfaceGT.hasNext()){\r
- validInterfaceList.add(interfaceName); \r
- validInterfaceMap.put(pnf, validInterfaceList);\r
- }\r
- else{\r
- logger.info(this.MIGRATION_ERROR + "ERROR PNF " + pnf + " with a " + interfaceNodeType + " of " + interfaceName + " does not exist.");\r
- invalidInterfaceList.add(interfaceName); \r
- invalidInterfaceMap.put(pnf, invalidInterfaceList);\r
- }\r
- }\r
- \r
- \r
- /**\r
- * Description: Error Routine if graph is not updated by input file record\r
- * @param nodeType\r
- * @param nodeId\r
- * @param property\r
- * @param propertyValue\r
- */\r
- private void migrationError(String nodeType, String nodeId, String property, String propertyValue){\r
- logger.info(this.MIGRATION_ERROR + "ERROR: Failure to update " \r
- + nodeType + " ID " + nodeId + ", " + property + " to value " + propertyValue \r
- + ". Node Not Found \n");\r
- migrationFailure++;\r
- }\r
- \r
- private int getInvalidInterfaceCount(){\r
- int interfaceCount = 0;\r
-\r
- for (Map.Entry<String, List<String>> entry: invalidInterfaceMap.entrySet()){\r
- String key = entry.getKey();\r
- List <String> invalidList = invalidInterfaceMap.get(key);\r
- \r
- for (int i = 0; i < invalidList.size(); i++){\r
- if(invalidList.get(i).contains(".")){\r
- invalidPInterfaceCount++;\r
- }else{\r
- invalidLagInterfaceCount++;\r
- }\r
- \r
- } \r
- interfaceCount = interfaceCount + invalidInterfaceMap.get(key).size(); \r
- } \r
- return interfaceCount;\r
- }\r
- \r
- /**\r
- * Description: Dmaap Routine\r
- * @param v\r
- */\r
- private void updateDmaapList(Vertex v){\r
- String dmaapMsg = System.nanoTime() + "_" + v.id().toString() + "_" + v.value("resource-version").toString();\r
- dmaapMsgList.add(dmaapMsg);\r
- logger.info("\tAdding Updated Vertex " + v.id().toString() + " to dmaapMsgList....");\r
- }\r
- \r
- @Override\r
- public Status getStatus() {\r
- if (checkLog) {\r
- return Status.CHECK_LOGS;\r
- }\r
- else if (success) {\r
- return Status.SUCCESS;\r
- }\r
- else {\r
- return Status.FAILURE;\r
- }\r
- }\r
- \r
- @Override\r
- public void commit() {\r
- engine.commit();\r
- createDmaapFiles(dmaapMsgList);\r
- }\r
-\r
- @Override\r
- public Optional<String[]> getAffectedNodeTypes() {\r
- return Optional.of(new String[]{this.FORWRDER_EVC_NODE_TYPE});\r
- }\r
-\r
-\r
- @Override\r
- public String getMigrationName() {\r
- return "MigrateSdnaIvlanData";\r
- }\r
-\r
-}\r
+/**
+ * ============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.migration.v14;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.NoSuchFileException;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.onap.aai.db.props.AAIProperties;
+import org.onap.aai.edges.EdgeIngestor;
+import org.onap.aai.introspection.LoaderFactory;
+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.EdgeSerializer;
+import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+import org.onap.aai.setup.SchemaVersions;
+
+@MigrationPriority(100)
+@MigrationDangerRating(1)
+//@Enabled
+public class MigrateSdnaIvlanData extends Migrator {
+
+ private final String CONFIGURATION_NODE_TYPE = "configuration";
+ private final String EVC_NODE_TYPE = "evc";
+ private final String FORWARDER_NODE_TYPE = "forwarder";
+ private final String FORWRDER_EVC_NODE_TYPE = "forwarder-evc";
+ private final String FORWARDING_PATH_NODE_TYPE = "forwarding-path";
+ private final String PNF_NODE_TYPE = "pnf";
+ private final String P_INTERFACE_NODE_TYPE = "p-interface";
+ private final String LAG_INTERFACE_NODE_TYPE = "lag-interface";
+ private final String SAREA_GLOBAL_CUSTOMER_ID = "8a00890a-e6ae-446b-9dbe-b828dbeb38bd";
+
+ GraphTraversal<Vertex, Vertex> serviceSubscriptionGt;
+
+ private static GraphTraversalSource g = null;
+ private static boolean success = true;
+ private static boolean checkLog = false;
+ private int headerLength;
+ private int migrationSuccess = 0;
+ private int migrationFailure = 0;
+ private int invalidPInterfaceCount = 0;
+ private int invalidLagInterfaceCount = 0;
+
+
+ private static List<String> dmaapMsgList = new ArrayList<String>();
+ private static final String homeDir = System.getProperty("AJSC_HOME");
+
+ private static List<String> validPnfList = new ArrayList<String>();
+ private static List<String> invalidPnfList = new ArrayList<String>();
+
+ private static Map<String, List<String>> validInterfaceMap = new HashMap<String, List<String>>();
+ private static Map<String, List<String>> invalidInterfaceMap = new HashMap<String, List<String>>();
+
+ protected class SdnaIvlanFileData{
+ String evcName;
+ String pnfName;
+ String interfaceAID;
+ int ivlanValue;
+
+ public String getEvcName() {
+ return evcName;
+ }
+ public void setEvcName(String evcName) {
+ this.evcName = evcName;
+ }
+
+ public String getPnfName() {
+ return pnfName;
+ }
+ public void setPnfName(String pnfName) {
+ this.pnfName = pnfName;
+ }
+ public String getInterfaceAID() {
+ return interfaceAID;
+ }
+ public void setInterfaceAID(String interfaceAID) {
+ this.interfaceAID = interfaceAID;
+ }
+
+ public int getIvlanValue() {
+ return ivlanValue;
+ }
+ public void setIvlanValue(int ivlanValue) {
+ this.ivlanValue = ivlanValue;
+ }
+
+ }
+
+ private static ArrayList<SdnaIvlanFileData> ivlanList = new ArrayList<SdnaIvlanFileData>();
+
+ public MigrateSdnaIvlanData(TransactionalGraphEngine engine, LoaderFactory loaderFactory, EdgeIngestor edgeIngestor, EdgeSerializer edgeSerializer, SchemaVersions schemaVersions) {
+ super(engine, loaderFactory, edgeIngestor, edgeSerializer, schemaVersions);
+
+ this.g = this.engine.asAdmin().getTraversalSource();
+ this.serviceSubscriptionGt = g.V().has("global-customer-id", SAREA_GLOBAL_CUSTOMER_ID).in("org.onap.relationships.inventory.BelongsTo").has("service-type", "SAREA");
+ }
+
+ @Override
+ public void run() {
+ logger.info("---------- Start migration ----------");
+ String configDir = System.getProperty("BUNDLECONFIG_DIR");
+ if (homeDir == null) {
+ logger.info(this.MIGRATION_ERROR + "ERROR: Could not find sys prop AJSC_HOME");
+ success = false;
+ return;
+ }
+ if (configDir == null) {
+ success = false;
+ return;
+ }
+
+ String feedDir = homeDir + "/" + configDir + "/" + "migration-input-files/sarea-inventory/";
+
+ int fileLineCounter = 0;
+
+ String fileName = feedDir+ "ivlanData.csv";
+ logger.info(fileName);
+ logger.info("---------- Processing Entries from file ----------");
+
+
+ try {
+ List<String> lines = Files.readAllLines(Paths.get(fileName));
+ Iterator<String> lineItr = lines.iterator();
+ while (lineItr.hasNext()){
+ String line = lineItr.next().trim();
+ if (!line.isEmpty()) {
+ if (fileLineCounter != 0) {
+
+ try{
+ String[] colList = line.split(",", -1);
+ SdnaIvlanFileData lineData = new SdnaIvlanFileData();
+ lineData.setEvcName(colList[0].trim());
+ lineData.setPnfName(colList[1].trim());
+ lineData.setInterfaceAID(colList[2].trim());
+ lineData.setIvlanValue(Integer.valueOf(colList[3].trim()));
+ ivlanList.add(lineData);
+
+ } catch (Exception e){
+ logger.info(this.MIGRATION_ERROR + " ERROR: Record Format is invalid. Expecting Numeric value for Forwarder_Id and Ivlan_Value. Skipping Record: " + line);
+ this.migrationFailure++;
+ }
+
+ } else {
+ this.headerLength = line.split(",", -1).length;
+ if (this.headerLength < 4){
+ logger.info(this.MIGRATION_ERROR + "ERROR: Input file should have atleast 4 columns");
+ this.success = false;
+ return;
+ }
+ }
+ }
+ fileLineCounter++;
+ }
+
+ processSdnaIvlan();
+
+ int invalidInterfacesCount = getInvalidInterfaceCount();
+
+ logger.info ("\n \n ******* Final Summary for SDN-A IVLAN Migration ********* \n");
+ logger.info(this.MIGRATION_SUMMARY_COUNT + "SDN-A forward-evcs: IVLANs updated: "+ migrationSuccess);
+ logger.info(this.MIGRATION_SUMMARY_COUNT + "Total File Record Count: "+(fileLineCounter - 1));
+ logger.info(this.MIGRATION_SUMMARY_COUNT + "Unprocessed SDNA File Records : "+ migrationFailure);
+ logger.info(this.MIGRATION_SUMMARY_COUNT + "PNFs from Input File not found : "+ Integer.toString(invalidPnfList.size()) + "\n");
+
+
+ logger.info(this.MIGRATION_SUMMARY_COUNT + "Total PNF + P-INTERFACEs from Input File not found : " + Integer.toString(invalidPInterfaceCount));
+ logger.info(this.MIGRATION_SUMMARY_COUNT + "Total PNF + LAG-INTERFACEs from Input File not found : " + Integer.toString(invalidLagInterfaceCount));
+ logger.info(this.MIGRATION_SUMMARY_COUNT + "Total PNF/INTERFACEs from Input File not found : " + Integer.toString(invalidInterfacesCount));
+
+ } catch (FileNotFoundException e) {
+ logger.info(this.MIGRATION_ERROR + "ERROR: Could not find file " + fileName, e.getMessage());
+ success = false;
+ checkLog = true;
+ } catch (NoSuchFileException e) {
+ logger.info(this.MIGRATION_ERROR + "ERROR: Could not find file " + fileName, e.getMessage());
+ success = false;
+ checkLog = true;
+ } catch (IOException e) {
+ logger.info(this.MIGRATION_ERROR + "ERROR: Issue reading file " + fileName, e);
+ success = false;
+ } catch (Exception e) {
+ logger.info(this.MIGRATION_ERROR + "encountered exception", e);
+ e.printStackTrace();
+ success = false;
+ }
+
+ }
+ private void processSdnaIvlan() {
+
+ for(int i = 0; i < ivlanList.size(); i ++) {
+ String evc = ivlanList.get(i).getEvcName();
+ String pnf = ivlanList.get(i).getPnfName();
+ String interfaceId = ivlanList.get(i).getInterfaceAID();
+ String ivlanValue = Integer.toString(ivlanList.get(i).getIvlanValue());
+
+ Boolean pnfExists = pnfExists(pnf);
+ GraphTraversal<Vertex, Vertex> forwarderEvcGT;
+ Vertex forwarderEvcVtx = null;
+ String interfaceNodeType;
+ String forwarderEvcId = null;
+
+ if (!pnfExists){
+ migrationFailure++;
+ }else{
+
+ if (interfaceId.contains(".")){
+ interfaceNodeType = P_INTERFACE_NODE_TYPE;
+ }else{
+ interfaceNodeType = LAG_INTERFACE_NODE_TYPE;
+ }
+
+ validateInterface(pnf, interfaceNodeType, interfaceId);
+
+ forwarderEvcGT = g.V()
+ .has("pnf-name", pnf).has(AAIProperties.NODE_TYPE, PNF_NODE_TYPE)
+ .in("tosca.relationships.network.BindsTo")
+ .has(AAIProperties.NODE_TYPE, interfaceNodeType).has("interface-name", interfaceId)
+ .in("org.onap.relationships.inventory.ForwardsTo")
+ .where(__.out("org.onap.relationships.inventory.BelongsTo").has("forwarding-path-id", evc))
+ .out("org.onap.relationships.inventory.Uses")
+ .in("org.onap.relationships.inventory.BelongsTo");
+
+ // fwd-evc not found for pnf + interface
+ if(!forwarderEvcGT.hasNext()){
+ forwarderEvcId = pnf + " " + evc;
+ migrationError(PNF_NODE_TYPE + "/" + EVC_NODE_TYPE, forwarderEvcId, "ivlan", ivlanValue);
+
+ }
+
+ while(forwarderEvcGT.hasNext()){
+ forwarderEvcVtx = forwarderEvcGT.next();
+
+ // fwd-evc vertex is null
+ if(forwarderEvcVtx == null){
+ forwarderEvcId = pnf + " " + evc;
+ migrationError(PNF_NODE_TYPE + "/" + EVC_NODE_TYPE, forwarderEvcId, "ivlan", ivlanValue);
+ }
+ // update fwd-evc with ivlan value
+ else{
+
+ forwarderEvcId = forwarderEvcVtx.property("forwarder-evc-id").value().toString();
+ try{
+ forwarderEvcVtx.property("ivlan", ivlanValue);
+ logger.info(String.format("Updating Node Type forwarder-evc Property ivlan value %s", ivlanValue.toString()));
+ this.touchVertexProperties(forwarderEvcVtx, false);
+ updateDmaapList(forwarderEvcVtx);
+ migrationSuccess++;
+
+ }catch (Exception e){
+ logger.info(e.toString());
+ migrationError(FORWRDER_EVC_NODE_TYPE, forwarderEvcId, "ivlan", ivlanValue);
+ }
+ }
+ }
+ }
+
+ }
+ }
+
+ /**
+ * Description: Validate if pnf node exists in Graph
+ * @param pnf
+ * @return boolean
+ */
+ private boolean pnfExists(String pnf){
+ if (invalidPnfList.contains(pnf)){
+ logger.info(this.MIGRATION_ERROR + "ERROR: PNF value " + pnf + " does not exist.");
+ return false;
+ }
+ if (validPnfList.contains(pnf)){
+ return true;
+ }
+
+ GraphTraversal<Vertex, Vertex> pnfGT = g.V()
+ .has("pnf-name", pnf).has(AAIProperties.NODE_TYPE, PNF_NODE_TYPE);
+
+ if(pnfGT.hasNext()){
+ validPnfList.add(pnf);
+ return true;
+ }
+ else{
+ logger.info(this.MIGRATION_ERROR + "ERROR: PNF value " + pnf + " does not exist.");
+ invalidPnfList.add(pnf);
+ return false;
+ }
+
+ }
+
+ /**
+ * Description: Validate if p-interface or lag-interface node exists in Graph
+ * @param pnf
+ * @param interfaceNodeType
+ * @param interfaceName
+ */
+ private void validateInterface(String pnf, String interfaceNodeType, String interfaceName){
+
+ List <String> validInterfaceList;
+ List <String> invalidInterfaceList;
+
+ if(!validInterfaceMap.containsKey(pnf) ){
+ validInterfaceList = new ArrayList<String>();
+ }else{
+ validInterfaceList = validInterfaceMap.get(pnf);
+ }
+
+ if(!invalidInterfaceMap.containsKey(pnf)){
+ invalidInterfaceList = new ArrayList<String>();
+ }else{
+ invalidInterfaceList = invalidInterfaceMap.get(pnf);
+ }
+
+ if(invalidInterfaceList.contains(interfaceName)){
+ logger.info(this.MIGRATION_ERROR + "ERROR PNF " + pnf + " with a " + interfaceNodeType + " of " + interfaceName + " does not exist.");
+ return;
+ }
+ if(validInterfaceList.contains(interfaceName)){
+ return;
+ }
+
+ GraphTraversal<Vertex, Vertex> interfaceGT = g.V()
+ .has("pnf-name", pnf).has(AAIProperties.NODE_TYPE, PNF_NODE_TYPE)
+ .in("tosca.relationships.network.BindsTo")
+ .has("interface-name", interfaceName).has(AAIProperties.NODE_TYPE, interfaceNodeType);
+
+ if(interfaceGT.hasNext()){
+ validInterfaceList.add(interfaceName);
+ validInterfaceMap.put(pnf, validInterfaceList);
+ }
+ else{
+ logger.info(this.MIGRATION_ERROR + "ERROR PNF " + pnf + " with a " + interfaceNodeType + " of " + interfaceName + " does not exist.");
+ invalidInterfaceList.add(interfaceName);
+ invalidInterfaceMap.put(pnf, invalidInterfaceList);
+ }
+ }
+
+
+ /**
+ * Description: Error Routine if graph is not updated by input file record
+ * @param nodeType
+ * @param nodeId
+ * @param property
+ * @param propertyValue
+ */
+ private void migrationError(String nodeType, String nodeId, String property, String propertyValue){
+ logger.info(this.MIGRATION_ERROR + "ERROR: Failure to update "
+ + nodeType + " ID " + nodeId + ", " + property + " to value " + propertyValue
+ + ". Node Not Found \n");
+ migrationFailure++;
+ }
+
+ private int getInvalidInterfaceCount(){
+ int interfaceCount = 0;
+
+ for (Map.Entry<String, List<String>> entry: invalidInterfaceMap.entrySet()){
+ String key = entry.getKey();
+ List <String> invalidList = invalidInterfaceMap.get(key);
+
+ for (int i = 0; i < invalidList.size(); i++){
+ if(invalidList.get(i).contains(".")){
+ invalidPInterfaceCount++;
+ }else{
+ invalidLagInterfaceCount++;
+ }
+
+ }
+ interfaceCount = interfaceCount + invalidInterfaceMap.get(key).size();
+ }
+ return interfaceCount;
+ }
+
+ /**
+ * Description: Dmaap Routine
+ * @param v
+ */
+ private void updateDmaapList(Vertex v){
+ String dmaapMsg = System.nanoTime() + "_" + v.id().toString() + "_" + v.value("resource-version").toString();
+ dmaapMsgList.add(dmaapMsg);
+ logger.info("\tAdding Updated Vertex " + v.id().toString() + " to dmaapMsgList....");
+ }
+
+ @Override
+ public Status getStatus() {
+ if (checkLog) {
+ return Status.CHECK_LOGS;
+ }
+ else if (success) {
+ return Status.SUCCESS;
+ }
+ else {
+ return Status.FAILURE;
+ }
+ }
+
+ @Override
+ public void commit() {
+ engine.commit();
+ createDmaapFiles(dmaapMsgList);
+ }
+
+ @Override
+ public Optional<String[]> getAffectedNodeTypes() {
+ return Optional.of(new String[]{this.FORWRDER_EVC_NODE_TYPE});
+ }
+
+
+ @Override
+ public String getMigrationName() {
+ return "MigrateSdnaIvlanData";
+ }
+
+}
import org.onap.aai.setup.SchemaVersions;
import org.onap.aai.introspection.Introspector;
-@Enabled
+//@Enabled
@MigrationPriority(10)
@MigrationDangerRating(100)
public class PserverDedupWithDifferentSourcesOfTruth extends EdgeSwingMigrator {
return;
}
+ GraphAdminDBUtils.logConfigs(graph.configuration());
+
// Load the propertyKeys, indexes and edge-Labels into the DB
JanusGraphManagement graphMgt = graph.openManagement();
- imsg = "-- Loading new schema elements into JanusGraph --";
- System.out.println(imsg);
- LOGGER.info(imsg);
- SchemaGenerator.loadSchemaIntoJanusGraph(graph, graphMgt, null);
- if( graph != null ){
- imsg = "-- graph commit";
- System.out.println(imsg);
- LOGGER.info(imsg);
- graph.tx().commit();
-
- imsg = "-- graph shutdown ";
- System.out.println(imsg);
- LOGGER.info(imsg);
- graph.close();
- }
+ imsg = "-- Loading new schema elements into JanusGraph --";
+ System.out.println(imsg);
+ LOGGER.info(imsg);
+ SchemaGenerator.loadSchemaIntoJanusGraph(graph, graphMgt, null);
} catch(Exception ex) {
- ErrorLogHelper.logError("AAI_4000", ex.getMessage());
- System.exit(1);
+ ErrorLogHelper.logError("AAI_4000", ex.getMessage());
}
+
+
+ if( graph != null ){
+ String imsg = "-- graph commit";
+ System.out.println(imsg);
+ LOGGER.info(imsg);
+ graph.tx().commit();
+ imsg = "-- graph shutdown ";
+ System.out.println(imsg);
+ LOGGER.info(imsg);
+ graph.close();
+ }
+
LOGGER.auditEvent("-- all done, if program does not exit, please kill.");
System.exit(0);
}
+
+
+
}
aai.datagrooming.enableghost2checkoff=false
aai.datagrooming.enableghost2fixon=false
aai.datagrooming.enablef=false
+aai.datagrooming.enableskipindexupdatefix=true
# used by the dataGrooming to set values
aai.datagrooming.timewindowminutesvalue=10500
# Retired patterns specifying that a version is retired
retired.api.pattern.list=\
- ^/aai/v[2-6]+/.*$
+ ^/aai/v[2-7]+/.*$
# Retired patterns specifying that all versions of the api are retired
retired.api.all.versions=
\ No newline at end of file
Vertex cloudRegionVertexBadNode = g.addV().property("aai-node-type", "cloud-region")
.property("aai-uri", "aai-uriX06")
.property("cloud-owner", "test-owner-noregionId").property("source-of-truth", "JUNIT").next();
-
Vertex cloudRegionVertexBadNode2 = g.addV().property("aai-node-type", "cloud-region")
.property("aai-uri", "aai-uriX07")
/*
* 2 GhostNodes - CloudRegions 1 OrphaNode - tenant
*/
- assertThat(dataGrooming.getGhostNodeCount(), is(5));
+ assertThat(dataGrooming.getGhostNodeCount(), is(0));
+ assertThat(dataGrooming.getBadIndexNodeCount(), is(5));
+ assertThat(dataGrooming.getBadUriNodeCount(), is(0));
assertThat(dataGrooming.getOrphanNodeCount(), is(5));
assertThat(dataGrooming.getMissingAaiNtNodeCount(), is(1));
- assertThat(dataGrooming.getOneArmedEdgeHashCount(), is(3));
+ assertThat(dataGrooming.getOneArmedEdgeHashCount(), is(4));
}
};
dataGrooming.execute(args);
- assertThat(dataGrooming.getGhostNodeCount(), is(5));
+ assertThat(dataGrooming.getGhostNodeCount(), is(0));
+ assertThat(dataGrooming.getBadIndexNodeCount(), is(5));
+ assertThat(dataGrooming.getBadUriNodeCount(), is(0));
assertThat(dataGrooming.getOrphanNodeCount(), is(5));
assertThat(dataGrooming.getMissingAaiNtNodeCount(), is(1));
- assertThat(dataGrooming.getOneArmedEdgeHashCount(), is(3));
+ assertThat(dataGrooming.getOneArmedEdgeHashCount(), is(4));
assertThat(dataGrooming.getDeleteCandidateList().size(), is(0));
assertThat(dataGrooming.getDeleteCount(), is(0));
}
String[] args = { "-autoFix ", "-sleepMinutes", "1"};
dataGrooming.execute(args);
- assertThat(dataGrooming.getDeleteCandidateList().size(), is(14));
+ assertThat(dataGrooming.getDeleteCandidateList().size(), is(10));
}
String[] args = { "-autoFix ", "-sleepMinutes", "1", "-neverUseCache", "-singleNodeType", "cloud-region"};
dataGrooming.execute(args);
- assertThat(dataGrooming.getDeleteCandidateList().size(), is(8));
-
+ assertThat(dataGrooming.getDeleteCandidateList().size(), is(4));
+ assertThat(dataGrooming.getBadIndexNodeCount(), is(4));
+ assertThat(dataGrooming.getBadUriNodeCount(), is(0));
}
System.setOut(oldOutputStream);
}
+ @Ignore
@Test
public void testRunDisabledExcludeAndCommit() throws Exception {
assertThat("rebuildAllEdges shouldn't have enabled annotation", !RebuildAllEdges.class.isAnnotationPresent(Enabled.class));
import org.janusgraph.core.JanusGraphTransaction;
import org.junit.After;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.onap.aai.AAISetup;
import org.onap.aai.dbmap.DBConnectionType;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
-
+@Ignore
public class DeletePInterfaceTest extends AAISetup {
private final static ModelType introspectorFactoryType = ModelType.MOXY;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.junit.After;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.onap.aai.AAISetup;
import org.onap.aai.dbmap.DBConnectionType;
import org.onap.aai.serialization.engines.QueryStyle;
import org.onap.aai.serialization.engines.JanusGraphDBEngine;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
-
+@Ignore
public class MigrateModelVerDistributionStatusPropertyTest extends AAISetup{
private final static ModelType introspectorFactoryType = ModelType.MOXY;
assertNotNull(migrationName);
assertEquals("MigratePATHPhysicalInventory", migrationName);
}
-}
+}
\ No newline at end of file
import org.janusgraph.core.JanusGraphFactory;
import org.janusgraph.core.JanusGraph;
import org.janusgraph.core.JanusGraphTransaction;
-
+@Ignore
public class MigrateServiceInstanceToConfigurationTest extends AAISetup {
private final static ModelType introspectorFactoryType = ModelType.MOXY;
-/**\r
- * ============LICENSE_START=======================================================\r
- * org.onap.aai\r
- * ================================================================================\r
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.\r
- * ================================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ============LICENSE_END=========================================================\r
- */\r
-package org.onap.aai.migration.v13;\r
-\r
-import static org.junit.Assert.assertEquals;\r
-import static org.mockito.Mockito.spy;\r
-import static org.mockito.Mockito.when;\r
-\r
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;\r
-import org.apache.tinkerpop.gremlin.structure.Vertex;\r
-import org.junit.After;\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.onap.aai.AAISetup;\r
-import org.onap.aai.dbmap.DBConnectionType;\r
-import org.onap.aai.introspection.Loader;\r
-import org.onap.aai.introspection.LoaderFactory;\r
-import org.onap.aai.introspection.ModelType;\r
-import org.onap.aai.setup.SchemaVersions;\r
-import org.onap.aai.setup.SchemaVersion;\r
-import org.onap.aai.serialization.engines.QueryStyle;\r
-import org.onap.aai.serialization.engines.JanusGraphDBEngine;\r
-import org.onap.aai.serialization.engines.TransactionalGraphEngine;\r
-\r
-import org.janusgraph.core.JanusGraphFactory;\r
-import org.janusgraph.core.JanusGraph;\r
-import org.janusgraph.core.JanusGraphTransaction;\r
-\r
-\r
-public class MigratePServerAndPnfEquipTypeTest extends AAISetup{\r
-\r
- private final static ModelType introspectorFactoryType = ModelType.MOXY;\r
- private final static QueryStyle queryStyle = QueryStyle.TRAVERSAL;\r
- private final static DBConnectionType type = DBConnectionType.REALTIME;\r
- private Loader loader;\r
- private TransactionalGraphEngine dbEngine;\r
- private JanusGraph graph;\r
- private MigratePserverAndPnfEquipType migration;\r
- private GraphTraversalSource g;\r
- private JanusGraphTransaction tx;\r
- Vertex pserver1;\r
- Vertex pserver2;\r
- Vertex pnf1;\r
- Vertex pserver3;\r
- Vertex pnf2;\r
- Vertex pnf22;\r
-\r
-\r
- @Before\r
- public void setUp() throws Exception {\r
- graph = JanusGraphFactory.build().set("storage.backend", "inmemory").open();\r
- tx = graph.newTransaction();\r
- g = tx.traversal();\r
- loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, schemaVersions.getDefaultVersion());\r
- dbEngine = new JanusGraphDBEngine(\r
- queryStyle,\r
- type,\r
- loader);\r
- pserver1 = g.addV().property("aai-node-type", MigratePserverAndPnfEquipType.PSERVER_NODE_TYPE)\r
- .property( MigratePserverAndPnfEquipType.EQUIP_TYPE_PROPERTY, "Server")\r
- .next();\r
- \r
- pserver2 = g.addV().property("aai-node-type", MigratePserverAndPnfEquipType.PSERVER_NODE_TYPE)\r
- .property( MigratePserverAndPnfEquipType.EQUIP_TYPE_PROPERTY, "server")\r
- .next();\r
- \r
- pnf1 = g.addV().property("aai-node-type", MigratePserverAndPnfEquipType.PNF_NODE_TYPE)\r
- .property( MigratePserverAndPnfEquipType.EQUIP_TYPE_PROPERTY, "Switch")\r
- .next();\r
- pnf22 = g.addV().property("aai-node-type", MigratePserverAndPnfEquipType.PNF_NODE_TYPE)\r
- .property( MigratePserverAndPnfEquipType.EQUIP_TYPE_PROPERTY, "switch")\r
- .next();\r
-\r
- pserver3 = g.addV().property("aai-node-type", MigratePserverAndPnfEquipType.PSERVER_NODE_TYPE)\r
- .property( MigratePserverAndPnfEquipType.EQUIP_TYPE_PROPERTY, "server1")\r
- .next();\r
- \r
- pnf2 = g.addV().property("aai-node-type", MigratePserverAndPnfEquipType.PNF_NODE_TYPE)\r
- .property( MigratePserverAndPnfEquipType.EQUIP_TYPE_PROPERTY, "Switch1")\r
- .next();\r
-\r
- TransactionalGraphEngine spy = spy(dbEngine);\r
- TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());\r
- GraphTraversalSource traversal = g;\r
- when(spy.asAdmin()).thenReturn(adminSpy);\r
- when(adminSpy.getTraversalSource()).thenReturn(traversal);\r
- migration = new MigratePserverAndPnfEquipType(spy, loaderFactory, edgeIngestor, edgeSerializer, schemaVersions);\r
- migration.run();\r
- }\r
-\r
- @After\r
- public void cleanUp() {\r
- tx.rollback();\r
- graph.close();\r
- }\r
-\r
-\r
- /***\r
- * checks if the Equip Type value was changed\r
- */\r
-\r
- @Test\r
- public void confirmEquipTypeChanged() {\r
-\r
- assertEquals("SERVER",pserver1.property(MigratePserverAndPnfEquipType.EQUIP_TYPE_PROPERTY).value());\r
- assertEquals("SERVER",pserver2.property(MigratePserverAndPnfEquipType.EQUIP_TYPE_PROPERTY).value());\r
- assertEquals("SWITCH",pnf1.property(MigratePserverAndPnfEquipType.EQUIP_TYPE_PROPERTY).value());\r
- assertEquals("SWITCH",pnf22.property(MigratePserverAndPnfEquipType.EQUIP_TYPE_PROPERTY).value());\r
- }\r
- \r
- @Test\r
- public void verifyEquipTypeIsNotChanged() {\r
- assertEquals("server1",pserver3.property(MigratePserverAndPnfEquipType.EQUIP_TYPE_PROPERTY).value());\r
- assertEquals("Switch1",pnf2.property(MigratePserverAndPnfEquipType.EQUIP_TYPE_PROPERTY).value());\r
- }\r
- \r
- \r
- \r
-\r
-\r
+/**
+ * ============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.migration.v13;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.aai.AAISetup;
+import org.onap.aai.dbmap.DBConnectionType;
+import org.onap.aai.introspection.Loader;
+import org.onap.aai.introspection.LoaderFactory;
+import org.onap.aai.introspection.ModelType;
+import org.onap.aai.setup.SchemaVersions;
+import org.onap.aai.setup.SchemaVersion;
+import org.onap.aai.serialization.engines.QueryStyle;
+import org.onap.aai.serialization.engines.JanusGraphDBEngine;
+import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+
+import org.janusgraph.core.JanusGraphFactory;
+import org.janusgraph.core.JanusGraph;
+import org.janusgraph.core.JanusGraphTransaction;
+
+
+public class MigratePServerAndPnfEquipTypeTest extends AAISetup{
+
+ private final static ModelType introspectorFactoryType = ModelType.MOXY;
+ private final static QueryStyle queryStyle = QueryStyle.TRAVERSAL;
+ private final static DBConnectionType type = DBConnectionType.REALTIME;
+ private Loader loader;
+ private TransactionalGraphEngine dbEngine;
+ private JanusGraph graph;
+ private MigratePserverAndPnfEquipType migration;
+ private GraphTraversalSource g;
+ private JanusGraphTransaction tx;
+ Vertex pserver1;
+ Vertex pserver2;
+ Vertex pnf1;
+ Vertex pserver3;
+ Vertex pnf2;
+ Vertex pnf22;
+
+
+ @Before
+ public void setUp() throws Exception {
+ graph = JanusGraphFactory.build().set("storage.backend", "inmemory").open();
+ tx = graph.newTransaction();
+ g = tx.traversal();
+ loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, schemaVersions.getDefaultVersion());
+ dbEngine = new JanusGraphDBEngine(
+ queryStyle,
+ type,
+ loader);
+ pserver1 = g.addV().property("aai-node-type", MigratePserverAndPnfEquipType.PSERVER_NODE_TYPE)
+ .property( MigratePserverAndPnfEquipType.EQUIP_TYPE_PROPERTY, "Server")
+ .next();
+
+ pserver2 = g.addV().property("aai-node-type", MigratePserverAndPnfEquipType.PSERVER_NODE_TYPE)
+ .property( MigratePserverAndPnfEquipType.EQUIP_TYPE_PROPERTY, "server")
+ .next();
+
+ pnf1 = g.addV().property("aai-node-type", MigratePserverAndPnfEquipType.PNF_NODE_TYPE)
+ .property( MigratePserverAndPnfEquipType.EQUIP_TYPE_PROPERTY, "Switch")
+ .next();
+ pnf22 = g.addV().property("aai-node-type", MigratePserverAndPnfEquipType.PNF_NODE_TYPE)
+ .property( MigratePserverAndPnfEquipType.EQUIP_TYPE_PROPERTY, "switch")
+ .next();
+
+ pserver3 = g.addV().property("aai-node-type", MigratePserverAndPnfEquipType.PSERVER_NODE_TYPE)
+ .property( MigratePserverAndPnfEquipType.EQUIP_TYPE_PROPERTY, "server1")
+ .next();
+
+ pnf2 = g.addV().property("aai-node-type", MigratePserverAndPnfEquipType.PNF_NODE_TYPE)
+ .property( MigratePserverAndPnfEquipType.EQUIP_TYPE_PROPERTY, "Switch1")
+ .next();
+
+ TransactionalGraphEngine spy = spy(dbEngine);
+ TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
+ GraphTraversalSource traversal = g;
+ when(spy.asAdmin()).thenReturn(adminSpy);
+ when(adminSpy.getTraversalSource()).thenReturn(traversal);
+ migration = new MigratePserverAndPnfEquipType(spy, loaderFactory, edgeIngestor, edgeSerializer, schemaVersions);
+ migration.run();
+ }
+
+ @After
+ public void cleanUp() {
+ tx.rollback();
+ graph.close();
+ }
+
+
+ /***
+ * checks if the Equip Type value was changed
+ */
+
+ @Test
+ public void confirmEquipTypeChanged() {
+
+ assertEquals("SERVER",pserver1.property(MigratePserverAndPnfEquipType.EQUIP_TYPE_PROPERTY).value());
+ assertEquals("SERVER",pserver2.property(MigratePserverAndPnfEquipType.EQUIP_TYPE_PROPERTY).value());
+ assertEquals("SWITCH",pnf1.property(MigratePserverAndPnfEquipType.EQUIP_TYPE_PROPERTY).value());
+ assertEquals("SWITCH",pnf22.property(MigratePserverAndPnfEquipType.EQUIP_TYPE_PROPERTY).value());
+ }
+
+ @Test
+ public void verifyEquipTypeIsNotChanged() {
+ assertEquals("server1",pserver3.property(MigratePserverAndPnfEquipType.EQUIP_TYPE_PROPERTY).value());
+ assertEquals("Switch1",pnf2.property(MigratePserverAndPnfEquipType.EQUIP_TYPE_PROPERTY).value());
+ }
+
+
+
+
+
}
\ No newline at end of file
-/**\r
- * ============LICENSE_START=======================================================\r
- * org.onap.aai\r
- * ================================================================================\r
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.\r
- * ================================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ============LICENSE_END=========================================================\r
- */\r
-package org.onap.aai.migration.v14;\r
-\r
-import org.onap.aai.AAISetup;\r
-import org.onap.aai.edges.EdgeIngestor;\r
-import org.onap.aai.introspection.LoaderFactory;\r
-import org.onap.aai.serialization.db.EdgeSerializer;\r
-import org.onap.aai.serialization.engines.TransactionalGraphEngine;\r
-\r
-\r
-import org.janusgraph.core.JanusGraph;\r
-import org.janusgraph.core.JanusGraphFactory;\r
-import org.janusgraph.core.JanusGraphTransaction;\r
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.onap.aai.dbmap.DBConnectionType;\r
-import org.onap.aai.introspection.Loader;\r
-import org.onap.aai.introspection.ModelType;\r
-import org.onap.aai.setup.SchemaVersions;\r
-import org.onap.aai.setup.SchemaVersion;\r
-import org.onap.aai.migration.Status;\r
-import org.onap.aai.serialization.engines.QueryStyle;\r
-import org.onap.aai.serialization.engines.JanusGraphDBEngine;\r
-\r
-import static org.mockito.Mockito.spy;\r
-import static org.mockito.Mockito.when;\r
-\r
-import java.util.Optional;\r
-\r
-import javax.validation.constraints.AssertFalse;\r
-\r
-import static org.junit.Assert.assertTrue;\r
-\r
-public class MigrateGenericVnfMgmtOptionsTest extends AAISetup {\r
- \r
- protected static final String VNF_NODE_TYPE = "generic-vnf";\r
-\r
- public static class MigrateVnfType extends MigrateGenericVnfMgmtOptions {\r
- public MigrateVnfType(TransactionalGraphEngine engine, LoaderFactory loaderFactory, EdgeIngestor edgeIngestor, EdgeSerializer edgeSerializer, SchemaVersions schemaVersions){\r
- super(engine, loaderFactory, edgeIngestor, edgeSerializer, schemaVersions);\r
- }\r
- @Override\r
- public Status getStatus() {\r
- return Status.SUCCESS;\r
- }\r
- @Override\r
- public Optional<String[]> getAffectedNodeTypes() {\r
- return Optional.of(new String[]{VNF_NODE_TYPE});\r
- }\r
- @Override\r
- public String getMigrationName() {\r
- return "MockMigrateVnfType";\r
- }\r
- }\r
-\r
- private final static ModelType introspectorFactoryType = ModelType.MOXY;\r
- private final static QueryStyle queryStyle = QueryStyle.TRAVERSAL;\r
- private final static DBConnectionType type = DBConnectionType.REALTIME;\r
- private Loader loader;\r
- private TransactionalGraphEngine dbEngine;\r
- private MigrateVnfType migration;\r
- private GraphTraversalSource g;\r
-\r
- @Before\r
- public void setup() throws Exception{\r
- g = tx.traversal();\r
- loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, schemaVersions.getDefaultVersion());\r
- dbEngine = new JanusGraphDBEngine(\r
- queryStyle,\r
- type,\r
- loader);\r
-\r
- //generic-vnf\r
- g.addV().property("aai-node-type", "generic-vnf")\r
- .property("vnf-id", "generic-vnf0")\r
- .property("vnf-type", "HN")\r
- .next();\r
- g.addV().property("aai-node-type", "generic-vnf")\r
- .property("vnf-id", "generic-vnf1")\r
- .property("vnf-type", "HN")\r
- .property("management-option", "")\r
- .next();\r
- g.addV().property("aai-node-type", "generic-vnf")\r
- .property("vnf-id", "generic-vnf2")\r
- .property("vnf-type", "HN")\r
- .property("management-option", "existingOption")\r
- .next();\r
- \r
- g.addV().property("aai-node-type", "generic-vnf")\r
- .property("vnf-id", "generic-vnf10")\r
- .property("vnf-type", "HP")\r
- .next();\r
- g.addV().property("aai-node-type", "generic-vnf")\r
- .property("vnf-id", "generic-vnf11")\r
- .property("vnf-type", "HP")\r
- .property("management-option", "")\r
- .next();\r
- g.addV().property("aai-node-type", "generic-vnf")\r
- .property("vnf-id", "generic-vnf12")\r
- .property("vnf-type", "HP")\r
- .property("management-option", "existingOption")\r
- .next();\r
- \r
- g.addV().property("aai-node-type", "generic-vnf")\r
- .property("vnf-id", "generic-vnf20")\r
- .property("vnf-type", "HG")\r
- .next();\r
- g.addV().property("aai-node-type", "generic-vnf")\r
- .property("vnf-id", "generic-vnf21")\r
- .property("vnf-type", "HG")\r
- .property("management-option", "")\r
- .next();\r
- g.addV().property("aai-node-type", "generic-vnf")\r
- .property("vnf-id", "generic-vnf22")\r
- .property("vnf-type", "HG")\r
- .property("management-option", "existingOption")\r
- .next(); \r
- \r
- // Non-eligible migration conditions - vnf-type = XX\r
- g.addV().property("aai-node-type", "generic-vnf")\r
- .property("vnf-id", "generic-vnf30")\r
- .property("vnf-type", "XX")\r
- .next();\r
- g.addV().property("aai-node-type", "generic-vnf")\r
- .property("vnf-id", "generic-vnf31")\r
- .property("vnf-type", "XX")\r
- .property("management-option", "")\r
- .next();\r
- g.addV().property("aai-node-type", "generic-vnf")\r
- .property("vnf-id", "generic-vnf32")\r
- .property("vnf-type", "XX")\r
- .property("management-option", "existingOption")\r
- .next(); \r
- // Non-eligible migration conditions - vnf-type = missing\r
- g.addV().property("aai-node-type", "generic-vnf")\r
- .property("vnf-id", "generic-vnf40")\r
- .next();\r
- g.addV().property("aai-node-type", "generic-vnf")\r
- .property("vnf-id", "generic-vnf41")\r
- .property("management-option", "")\r
- .next();\r
- g.addV().property("aai-node-type", "generic-vnf")\r
- .property("vnf-id", "generic-vnf42")\r
- .property("management-option", "existingOption")\r
- .next(); \r
- \r
- TransactionalGraphEngine spy = spy(dbEngine);\r
- TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());\r
- GraphTraversalSource traversal = g;\r
- when(spy.asAdmin()).thenReturn(adminSpy);\r
- when(adminSpy.getTraversalSource()).thenReturn(traversal);\r
- migration = new MigrateVnfType(spy, loaderFactory, edgeIngestor, edgeSerializer, schemaVersions);\r
- migration.run();\r
- \r
- }\r
-\r
- @Test\r
- public void testMissingProperty(){\r
- //management-option\r
- assertTrue("Value of generic-vnf should be updated since the property management-option doesn't exist",\r
- g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "generic-vnf0").has("management-option", "AT&T Managed-Basic").hasNext()); \r
- assertTrue("Value of generic-vnf should be updated since the property management-option doesn't exist",\r
- g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "generic-vnf10").has("management-option", "AT&T Managed-Basic").hasNext());\r
- assertTrue("Value of generic-vnf should be updated since the property management-option doesn't exist",\r
- g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "generic-vnf20").has("management-option", "AT&T Managed-Basic").hasNext()); \r
- }\r
-\r
- @Test\r
- public void testEmptyValue() { \r
- //management-option\r
- assertTrue("Value of generic-vnf should be updated since the value for management-option is an empty string",\r
- g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "generic-vnf1").has("management-option", "AT&T Managed-Basic").hasNext());\r
- assertTrue("Value of generic-vnf should be updated since the value for management-option is an empty string",\r
- g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "generic-vnf11").has("management-option", "AT&T Managed-Basic").hasNext());\r
- assertTrue("Value of generic-vnf should be updated since the value for management-option is an empty string",\r
- g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "generic-vnf21").has("management-option", "AT&T Managed-Basic").hasNext());\r
- \r
- }\r
- \r
- @Test\r
- public void testExistingValues() {\r
- //management-option\r
- assertTrue("Value of generic-vnf shouldn't be updated since management-option already exists",\r
- !g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "generic-vnf2").has("management-option", "AT&T Managed-Basic").hasNext());\r
- assertTrue("Value of generic-vnf shouldn't be updated since management-option already exists",\r
- !g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "generic-vnf12").has("management-option", "AT&T Managed-Basic").hasNext());\r
- assertTrue("Value of generic-vnf shouldn't be updated since management-option already exists",\r
- !g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "generic-vnf22").has("management-option", "AT&T Managed-Basic").hasNext());\r
- \r
- \r
- }\r
- \r
- @Test\r
- public void testExistingVnfsNotMigrated() {\r
- //management-option\r
- assertTrue("Value of generic-vnf shouldn't be updated since vnf-type is not affected",\r
- !g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "generic-vnf30").has("management-option", "AT&T Managed-Basic").hasNext());\r
- assertTrue("Value of generic-vnf shouldn't be updated since vnf-type is not affected",\r
- !g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "generic-vnf31").has("management-option", "AT&T Managed-Basic").hasNext());\r
- assertTrue("Value of generic-vnf shouldn't be updated since vnf-type is not affected and management-option already exists",\r
- !g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "generic-vnf32").has("management-option", "AT&T Managed-Basic").hasNext());\r
- \r
- assertTrue("Value of generic-vnf shouldn't be updated since vnf-type is not present",\r
- !g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "generic-vnf40").has("management-option", "AT&T Managed-Basic").hasNext());\r
- assertTrue("Value of generic-vnf shouldn't be updated since vnf-type is not present",\r
- !g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "generic-vnf41").has("management-option", "AT&T Managed-Basic").hasNext());\r
- assertTrue("Value of generic-vnf shouldn't be updated since vnf-type is not present and management-option already exists",\r
- !g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "generic-vnf42").has("management-option", "AT&T Managed-Basic").hasNext());\r
- \r
- } \r
+/**
+ * ============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.migration.v14;
+
+import org.onap.aai.AAISetup;
+import org.onap.aai.edges.EdgeIngestor;
+import org.onap.aai.introspection.LoaderFactory;
+import org.onap.aai.serialization.db.EdgeSerializer;
+import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+
+
+import org.janusgraph.core.JanusGraph;
+import org.janusgraph.core.JanusGraphFactory;
+import org.janusgraph.core.JanusGraphTransaction;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.aai.dbmap.DBConnectionType;
+import org.onap.aai.introspection.Loader;
+import org.onap.aai.introspection.ModelType;
+import org.onap.aai.setup.SchemaVersions;
+import org.onap.aai.setup.SchemaVersion;
+import org.onap.aai.migration.Status;
+import org.onap.aai.serialization.engines.QueryStyle;
+import org.onap.aai.serialization.engines.JanusGraphDBEngine;
+
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import java.util.Optional;
+
+import javax.validation.constraints.AssertFalse;
+
+import static org.junit.Assert.assertTrue;
+
+public class MigrateGenericVnfMgmtOptionsTest extends AAISetup {
+
+ protected static final String VNF_NODE_TYPE = "generic-vnf";
+
+ public static class MigrateVnfType extends MigrateGenericVnfMgmtOptions {
+ public MigrateVnfType(TransactionalGraphEngine engine, LoaderFactory loaderFactory, EdgeIngestor edgeIngestor, EdgeSerializer edgeSerializer, SchemaVersions schemaVersions){
+ super(engine, loaderFactory, edgeIngestor, edgeSerializer, schemaVersions);
+ }
+ @Override
+ public Status getStatus() {
+ return Status.SUCCESS;
+ }
+ @Override
+ public Optional<String[]> getAffectedNodeTypes() {
+ return Optional.of(new String[]{VNF_NODE_TYPE});
+ }
+ @Override
+ public String getMigrationName() {
+ return "MockMigrateVnfType";
+ }
+ }
+
+ private final static ModelType introspectorFactoryType = ModelType.MOXY;
+ private final static QueryStyle queryStyle = QueryStyle.TRAVERSAL;
+ private final static DBConnectionType type = DBConnectionType.REALTIME;
+ private Loader loader;
+ private TransactionalGraphEngine dbEngine;
+ private MigrateVnfType migration;
+ private GraphTraversalSource g;
+
+ @Before
+ public void setup() throws Exception{
+ g = tx.traversal();
+ loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, schemaVersions.getDefaultVersion());
+ dbEngine = new JanusGraphDBEngine(
+ queryStyle,
+ type,
+ loader);
+
+ //generic-vnf
+ g.addV().property("aai-node-type", "generic-vnf")
+ .property("vnf-id", "generic-vnf0")
+ .property("vnf-type", "HN")
+ .next();
+ g.addV().property("aai-node-type", "generic-vnf")
+ .property("vnf-id", "generic-vnf1")
+ .property("vnf-type", "HN")
+ .property("management-option", "")
+ .next();
+ g.addV().property("aai-node-type", "generic-vnf")
+ .property("vnf-id", "generic-vnf2")
+ .property("vnf-type", "HN")
+ .property("management-option", "existingOption")
+ .next();
+
+ g.addV().property("aai-node-type", "generic-vnf")
+ .property("vnf-id", "generic-vnf10")
+ .property("vnf-type", "HP")
+ .next();
+ g.addV().property("aai-node-type", "generic-vnf")
+ .property("vnf-id", "generic-vnf11")
+ .property("vnf-type", "HP")
+ .property("management-option", "")
+ .next();
+ g.addV().property("aai-node-type", "generic-vnf")
+ .property("vnf-id", "generic-vnf12")
+ .property("vnf-type", "HP")
+ .property("management-option", "existingOption")
+ .next();
+
+ g.addV().property("aai-node-type", "generic-vnf")
+ .property("vnf-id", "generic-vnf20")
+ .property("vnf-type", "HG")
+ .next();
+ g.addV().property("aai-node-type", "generic-vnf")
+ .property("vnf-id", "generic-vnf21")
+ .property("vnf-type", "HG")
+ .property("management-option", "")
+ .next();
+ g.addV().property("aai-node-type", "generic-vnf")
+ .property("vnf-id", "generic-vnf22")
+ .property("vnf-type", "HG")
+ .property("management-option", "existingOption")
+ .next();
+
+ // Non-eligible migration conditions - vnf-type = XX
+ g.addV().property("aai-node-type", "generic-vnf")
+ .property("vnf-id", "generic-vnf30")
+ .property("vnf-type", "XX")
+ .next();
+ g.addV().property("aai-node-type", "generic-vnf")
+ .property("vnf-id", "generic-vnf31")
+ .property("vnf-type", "XX")
+ .property("management-option", "")
+ .next();
+ g.addV().property("aai-node-type", "generic-vnf")
+ .property("vnf-id", "generic-vnf32")
+ .property("vnf-type", "XX")
+ .property("management-option", "existingOption")
+ .next();
+ // Non-eligible migration conditions - vnf-type = missing
+ g.addV().property("aai-node-type", "generic-vnf")
+ .property("vnf-id", "generic-vnf40")
+ .next();
+ g.addV().property("aai-node-type", "generic-vnf")
+ .property("vnf-id", "generic-vnf41")
+ .property("management-option", "")
+ .next();
+ g.addV().property("aai-node-type", "generic-vnf")
+ .property("vnf-id", "generic-vnf42")
+ .property("management-option", "existingOption")
+ .next();
+
+ TransactionalGraphEngine spy = spy(dbEngine);
+ TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
+ GraphTraversalSource traversal = g;
+ when(spy.asAdmin()).thenReturn(adminSpy);
+ when(adminSpy.getTraversalSource()).thenReturn(traversal);
+ migration = new MigrateVnfType(spy, loaderFactory, edgeIngestor, edgeSerializer, schemaVersions);
+ migration.run();
+
+ }
+
+ @Test
+ public void testMissingProperty(){
+ //management-option
+ assertTrue("Value of generic-vnf should be updated since the property management-option doesn't exist",
+ g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "generic-vnf0").has("management-option", "AT&T Managed-Basic").hasNext());
+ assertTrue("Value of generic-vnf should be updated since the property management-option doesn't exist",
+ g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "generic-vnf10").has("management-option", "AT&T Managed-Basic").hasNext());
+ assertTrue("Value of generic-vnf should be updated since the property management-option doesn't exist",
+ g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "generic-vnf20").has("management-option", "AT&T Managed-Basic").hasNext());
+ }
+
+ @Test
+ public void testEmptyValue() {
+ //management-option
+ assertTrue("Value of generic-vnf should be updated since the value for management-option is an empty string",
+ g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "generic-vnf1").has("management-option", "AT&T Managed-Basic").hasNext());
+ assertTrue("Value of generic-vnf should be updated since the value for management-option is an empty string",
+ g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "generic-vnf11").has("management-option", "AT&T Managed-Basic").hasNext());
+ assertTrue("Value of generic-vnf should be updated since the value for management-option is an empty string",
+ g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "generic-vnf21").has("management-option", "AT&T Managed-Basic").hasNext());
+
+ }
+
+ @Test
+ public void testExistingValues() {
+ //management-option
+ assertTrue("Value of generic-vnf shouldn't be updated since management-option already exists",
+ !g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "generic-vnf2").has("management-option", "AT&T Managed-Basic").hasNext());
+ assertTrue("Value of generic-vnf shouldn't be updated since management-option already exists",
+ !g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "generic-vnf12").has("management-option", "AT&T Managed-Basic").hasNext());
+ assertTrue("Value of generic-vnf shouldn't be updated since management-option already exists",
+ !g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "generic-vnf22").has("management-option", "AT&T Managed-Basic").hasNext());
+
+
+ }
+
+ @Test
+ public void testExistingVnfsNotMigrated() {
+ //management-option
+ assertTrue("Value of generic-vnf shouldn't be updated since vnf-type is not affected",
+ !g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "generic-vnf30").has("management-option", "AT&T Managed-Basic").hasNext());
+ assertTrue("Value of generic-vnf shouldn't be updated since vnf-type is not affected",
+ !g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "generic-vnf31").has("management-option", "AT&T Managed-Basic").hasNext());
+ assertTrue("Value of generic-vnf shouldn't be updated since vnf-type is not affected and management-option already exists",
+ !g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "generic-vnf32").has("management-option", "AT&T Managed-Basic").hasNext());
+
+ assertTrue("Value of generic-vnf shouldn't be updated since vnf-type is not present",
+ !g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "generic-vnf40").has("management-option", "AT&T Managed-Basic").hasNext());
+ assertTrue("Value of generic-vnf shouldn't be updated since vnf-type is not present",
+ !g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "generic-vnf41").has("management-option", "AT&T Managed-Basic").hasNext());
+ assertTrue("Value of generic-vnf shouldn't be updated since vnf-type is not present and management-option already exists",
+ !g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "generic-vnf42").has("management-option", "AT&T Managed-Basic").hasNext());
+
+ }
}
\ No newline at end of file