summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--aai-traversal/bundleconfig-local/etc/query/stored-queries.properties35
-rw-r--r--aai-traversal/src/test/java/org/openecomp/aai/rest/search/LinkedDevices_ComplicatedGVtoGV.java78
-rw-r--r--aai-traversal/src/test/java/org/openecomp/aai/rest/search/LinkedDevices_NewvceVserverTest.java91
-rw-r--r--aai-traversal/src/test/java/org/openecomp/aai/rest/search/LinkedDevices_SimpleGVtoGVQueryTest.java66
-rw-r--r--aai-traversal/src/test/java/org/openecomp/aai/rest/search/VnfsFromPserverQueryTest.java90
5 files changed, 359 insertions, 1 deletions
diff --git a/aai-traversal/bundleconfig-local/etc/query/stored-queries.properties b/aai-traversal/bundleconfig-local/etc/query/stored-queries.properties
index f29518e..bf4753a 100644
--- a/aai-traversal/bundleconfig-local/etc/query/stored-queries.properties
+++ b/aai-traversal/bundleconfig-local/etc/query/stored-queries.properties
@@ -238,4 +238,37 @@ spaas-topology-fromServiceInstance=builder.createEdgeTraversal(EdgeType.COUSIN,
vnfs-fromServiceInstance=builder.createEdgeTraversal(EdgeType.COUSIN, 'service-instance', 'generic-vnf')\
.store('x').cap('x').unfold().dedup()
- \ No newline at end of file
+
+
+vnfs-fromPserver=builder.where(\
+ builder.newInstance().union(\
+ builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'pserver').getVerticesByProperty('hostname', hostname),\
+ builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'generic-vnf', 'vserver').createEdgeTraversal(EdgeType.COUSIN, 'vserver', 'pserver').getVerticesByProperty('hostname', hostname)\
+ )\
+ ).store('x').cap('x').unfold().dedup()
+
+linked-devices=builder.store('x').union(\
+ builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'generic-vnf', 'l-interface'),\
+ builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'generic-vnf', 'lag-interface'),\
+ builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'newvce', 'l-interface'),\
+ builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vserver', 'l-interface')\
+ ).dedup()\
+ .until(builder.newInstance().getVerticesByProperty('aai-node-type', new ArrayList<>(Arrays.asList('generic-vnf','newvce','vserver'))))\
+ .repeat(builder.newInstance()\
+ .union(\
+ builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'lag-interface', 'l-interface'),\
+ builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'lag-interface'),\
+ builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'vlan'),\
+ builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'vlan', 'l-interface'),\
+ builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'lag-interface', 'logical-link'),\
+ builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'logical-link', 'lag-interface'),\
+ builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'l-interface', 'logical-link'),\
+ builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'logical-link', 'l-interface'),\
+ builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'vlan', 'logical-link'),\
+ builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'logical-link', 'vlan'),\
+ builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'generic-vnf'),\
+ builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'lag-interface', 'generic-vnf'),\
+ builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'newvce'),\
+ builder.newInstance().createEdgeTraversal(EdgeType.TREE, 'l-interface', 'vserver')\
+ ).dedup().simplePath()\
+ ).store('x').cap('x').unfold().dedup()
diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/LinkedDevices_ComplicatedGVtoGV.java b/aai-traversal/src/test/java/org/openecomp/aai/rest/search/LinkedDevices_ComplicatedGVtoGV.java
new file mode 100644
index 0000000..656cd44
--- /dev/null
+++ b/aai-traversal/src/test/java/org/openecomp/aai/rest/search/LinkedDevices_ComplicatedGVtoGV.java
@@ -0,0 +1,78 @@
+package org.openecomp.aai.rest.search;
+
+import java.util.Map;
+
+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.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.openecomp.aai.exceptions.AAIException;
+import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class LinkedDevices_ComplicatedGVtoGV extends QueryTest {
+
+ public LinkedDevices_ComplicatedGVtoGV() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ Vertex gvnf1 = graph.addVertex(T.label, "generic-vnf", T.id, "00", "aai-node-type", "generic-vnf",
+ "vnf-id", "gvnf1", "vnf-name", "genvnfname1", "nf-type", "sample-nf-type");
+
+ Vertex lint1 = graph.addVertex(T.label, "l-interface", T.id, "10", "aai-node-type", "l-interface",
+ "interface-name", "lint1", "is-port-mirrored", "true", "in-maint", "true", "is-ip-unnumbered", "false");
+
+ Vertex loglink1 = graph.addVertex(T.label, "logical-link", T.id, "20", "aai-node-type", "logical-link",
+ "link-name", "loglink1", "in-maint", "false", "link-type", "sausage");
+
+ Vertex lint2 = graph.addVertex(T.label, "l-interface", T.id, "11", "aai-node-type", "l-interface",
+ "interface-name", "lint2", "is-port-mirrored", "true", "in-maint", "true", "is-ip-unnumbered", "false");
+
+ Vertex vlan = graph.addVertex(T.label, "vlan", T.id, "30", "aai-node-type", "vlan",
+ "vlan-interface", "vlan1");
+
+ Vertex loglink2 = graph.addVertex(T.label, "logical-link", T.id, "21", "aai-node-type", "logical-link",
+ "link-name", "loglink2", "in-maint", "false", "link-type", "sausage");
+
+ Vertex lagint = graph.addVertex(T.label, "lag-interface", T.id, "40", "aai-node-type", "lag-interface",
+ "interface-name", "lagint1");
+
+ Vertex gvnf2 = graph.addVertex(T.label, "generic-vnf", T.id, "01", "aai-node-type", "generic-vnf",
+ "vnf-id", "gvnf2", "vnf-name", "genvnfname2", "nf-type", "sample-nf-type");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addTreeEdge(g, gvnf1, lint1);
+ rules.addEdge(g, lint1, loglink1);
+ rules.addEdge(g, lint2, loglink1);
+ rules.addTreeEdge(g, lint2, vlan);
+ rules.addEdge(g, vlan, loglink2);
+ rules.addEdge(g, loglink2, lagint);
+ rules.addTreeEdge(g, gvnf2, lagint);
+
+ expectedResult.add(gvnf1);
+ expectedResult.add(gvnf2);
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "linked-devices";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "generic-vnf").has("vnf-id", "gvnf1");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ // n/a for this query
+ }
+
+}
diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/LinkedDevices_NewvceVserverTest.java b/aai-traversal/src/test/java/org/openecomp/aai/rest/search/LinkedDevices_NewvceVserverTest.java
new file mode 100644
index 0000000..e37bb5a
--- /dev/null
+++ b/aai-traversal/src/test/java/org/openecomp/aai/rest/search/LinkedDevices_NewvceVserverTest.java
@@ -0,0 +1,91 @@
+package org.openecomp.aai.rest.search;
+
+import static org.junit.Assert.*;
+
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.List;
+
+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.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.openecomp.aai.exceptions.AAIException;
+import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class LinkedDevices_NewvceVserverTest extends QueryTest {
+
+ public LinkedDevices_NewvceVserverTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ //Note: I don't know if this topology is realistic, but it doesn't really matter bc we're just testing functionality
+ Vertex newvce1 = graph.addVertex(T.label, "newvce", T.id, "00", "aai-node-type", "newvce",
+ "vnf-id2", "newvce1", "vnf-name", "bob", "vnf-type", "new");
+
+ Vertex lint1 = graph.addVertex(T.label, "l-interface", T.id, "10", "aai-node-type", "l-interface",
+ "interface-name", "lint1", "is-port-mirrored", "true", "in-maint", "true", "is-ip-unnumbered", "false");
+ Vertex loglink1 = graph.addVertex(T.label, "logical-link", T.id, "20", "aai-node-type", "logical-link",
+ "link-name", "loglink1", "in-maint", "false", "link-type", "sausage");
+ Vertex lint2 = graph.addVertex(T.label, "l-interface", T.id, "11", "aai-node-type", "l-interface",
+ "interface-name", "lint2", "is-port-mirrored", "true", "in-maint", "true", "is-ip-unnumbered", "false");
+ Vertex vlan = graph.addVertex(T.label, "vlan", T.id, "40", "aai-node-type", "vlan",
+ "vlan-interface", "vlan1");
+
+ Vertex newvce2 = graph.addVertex(T.label, "newvce", T.id, "01", "aai-node-type", "newvce",
+ "vnf-id2", "newvce2", "vnf-name", "bob", "vnf-type", "new");
+
+ Vertex loglink2 = graph.addVertex(T.label, "logical-link", T.id, "21", "aai-node-type", "logical-link",
+ "link-name", "loglink2", "in-maint", "false", "link-type", "sausage");
+ Vertex lint3 = graph.addVertex(T.label, "l-interface", T.id, "12", "aai-node-type", "l-interface",
+ "interface-name", "lint3", "is-port-mirrored", "true", "in-maint", "true", "is-ip-unnumbered", "false");
+
+ Vertex cloudregion = graph.addVertex(T.label, "cloud-region", T.id, "50", "aai-node-type", "cloud-region",
+ "cloud-owner", "att", "cloud-region-id", "crId");
+ Vertex tenant = graph.addVertex(T.label, "tenant", T.id, "60", "aai-node-type", "tenant",
+ "tenant-id", "tenId", "tenant-name", "verity");
+ Vertex vserver = graph.addVertex(T.label, "vserver", T.id, "30", "aai-node-type", "vserver",
+ "vserver-id", "vserv1", "vserver-name", "frank");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addTreeEdge(g, newvce1, lint1);
+ rules.addTreeEdge(g, lint1, vlan);
+ rules.addEdge(g, lint1, loglink1);
+ rules.addEdge(g, lint2, loglink1);
+
+ rules.addTreeEdge(g, cloudregion, tenant);
+ rules.addTreeEdge(g, tenant, vserver);
+ rules.addTreeEdge(g, vserver, lint2);
+
+ rules.addEdge(g, vlan, loglink2);
+ rules.addTreeEdge(g, newvce2, lint3);
+ rules.addEdge(g, loglink2, lint3);
+
+ expectedResult.add(newvce1);
+ expectedResult.add(newvce2);
+ expectedResult.add(vserver);
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "linked-devices";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type", "newvce").has("vnf-id2", "newvce1");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ // n/a for this query
+ }
+}
diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/LinkedDevices_SimpleGVtoGVQueryTest.java b/aai-traversal/src/test/java/org/openecomp/aai/rest/search/LinkedDevices_SimpleGVtoGVQueryTest.java
new file mode 100644
index 0000000..435878e
--- /dev/null
+++ b/aai-traversal/src/test/java/org/openecomp/aai/rest/search/LinkedDevices_SimpleGVtoGVQueryTest.java
@@ -0,0 +1,66 @@
+package org.openecomp.aai.rest.search;
+
+import java.util.Map;
+
+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.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+import org.openecomp.aai.exceptions.AAIException;
+import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class LinkedDevices_SimpleGVtoGVQueryTest extends QueryTest {
+
+ public LinkedDevices_SimpleGVtoGVQueryTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ Vertex gvnf1 = graph.addVertex(T.label, "generic-vnf", T.id, "00", "aai-node-type", "generic-vnf",
+ "vnf-id", "gvnf1", "vnf-name", "genvnfname1", "nf-type", "sample-nf-type");
+
+ Vertex lint1 = graph.addVertex(T.label, "l-interface", T.id, "10", "aai-node-type", "l-interface",
+ "interface-name", "lint1", "is-port-mirrored", "true", "in-maint", "true", "is-ip-unnumbered", "false");
+
+ Vertex loglink = graph.addVertex(T.label, "logical-link", T.id, "20", "aai-node-type", "logical-link",
+ "link-name", "loglink1", "in-maint", "false", "link-type", "sausage");
+
+ Vertex lint2 = graph.addVertex(T.label, "l-interface", T.id, "11", "aai-node-type", "l-interface",
+ "interface-name", "lint2", "is-port-mirrored", "true", "in-maint", "true", "is-ip-unnumbered", "false");
+
+ Vertex gvnf2 = graph.addVertex(T.label, "generic-vnf", T.id, "01", "aai-node-type", "generic-vnf",
+ "vnf-id", "gvnf2", "vnf-name", "genvnfname2", "nf-type", "sample-nf-type");
+
+ GraphTraversalSource g = graph.traversal();
+ rules.addTreeEdge(g, gvnf1, lint1);
+ rules.addTreeEdge(g, gvnf2, lint2);
+ rules.addEdge(g, lint1, loglink);
+ rules.addEdge(g, lint2, loglink);
+
+ expectedResult.add(gvnf1);
+ expectedResult.add(gvnf2);
+ }
+
+ @Override
+ protected String getQueryName() {
+ return "linked-devices";
+ }
+
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ g.has("aai-node-type","generic-vnf").has("vnf-id","gvnf1");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ // n/a for this test
+ }
+
+}
diff --git a/aai-traversal/src/test/java/org/openecomp/aai/rest/search/VnfsFromPserverQueryTest.java b/aai-traversal/src/test/java/org/openecomp/aai/rest/search/VnfsFromPserverQueryTest.java
new file mode 100644
index 0000000..fde3729
--- /dev/null
+++ b/aai-traversal/src/test/java/org/openecomp/aai/rest/search/VnfsFromPserverQueryTest.java
@@ -0,0 +1,90 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * org.openecomp.aai
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.aai.rest.search;
+
+import java.util.Map;
+
+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.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.Test;
+
+import org.openecomp.aai.exceptions.AAIException;
+import org.openecomp.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
+
+public class VnfsFromPserverQueryTest extends QueryTest {
+ public VnfsFromPserverQueryTest() throws AAIException, NoEdgeRuleFoundException {
+ super();
+ }
+
+ @Test
+ public void run() {
+ super.run();
+ }
+ @Override
+ protected void createGraph() throws AAIException, NoEdgeRuleFoundException {
+ //Set up the test graph
+
+ Vertex vnf1 = graph.addVertex(T.label, "generic-vnf", T.id, "1", "aai-node-type", "generic-vnf", "vnf-id", "vnfid1", "vnf-name", "sample");
+ Vertex pserver1 = graph.addVertex(T.label, "pserver", T.id, "2", "aai-node-type", "pserver", "hostname", "pservername1");
+
+ Vertex vnf2 = graph.addVertex(T.label, "generic-vnf", T.id, "3", "aai-node-type", "generic-vnf", "vnf-id", "vnfid2");
+ Vertex pserver2 = graph.addVertex(T.label, "pserver", T.id, "4", "aai-node-type", "pserver", "hostname", "pservername2");
+
+ Vertex pserver3 = graph.addVertex(T.label, "pserver", T.id, "5", "aai-node-type", "pserver", "hostname", "pservername3");
+ Vertex vserver = graph.addVertex(T.label, "vserver", T.id, "6", "aai-node-type", "vserver", "vserver-name", "vservername");
+ Vertex tenant = graph.addVertex(T.label, "tenant", T.id, "7", "aai-node-type", "tenant", "tenant-id", "tenantuuid", "tenant-name", "tenantname");
+ Vertex cloudregion = graph.addVertex(T.label, "cloud-region", T.id, "8", "aai-node-type", "cloud-region", "cloud-region-id", "clouduuid", "cloud-region-owner", "cloudOwnername");
+
+ Vertex vnf3 = graph.addVertex(T.label, "generic-vnf", T.id, "9", "aai-node-type", "generic-vnf", "vnf-id", "vnfid3", "vnf-name", "sample");
+
+ GraphTraversalSource g = graph.traversal();
+
+ rules.addEdge(g, pserver1, vnf1);
+ rules.addEdge(g, pserver1, vnf2);
+ rules.addEdge(g, pserver1, vnf3);
+
+ rules.addTreeEdge(g, tenant, cloudregion);
+ rules.addTreeEdge(g, vserver, tenant);
+ rules.addEdge(g, vserver, pserver3);
+ rules.addEdge(g, vserver, vnf2);
+
+ //expectedResult.add(vnf2);
+ expectedResult.add(vnf1);
+ //expectedResult.add(vnf3);
+
+ }
+ @Override
+ protected String getQueryName() {
+ return "vnfs-fromPserver";
+ }
+ @Override
+ protected void addStartNode(GraphTraversal<Vertex, Vertex> g) {
+ //g.has("vnf-id", "vnfid2");
+ g.has("aai-node-type","generic-vnf").has("vnf-id", "vnfid1").has("vnf-name", "sample");
+ }
+
+ @Override
+ protected void addParam(Map<String, Object> params) {
+ params.put("hostname", "pservername1");
+ }
+}