diff --git a/statics/workflows/traceroute.yaml b/statics/workflows/traceroute.yaml new file mode 100644 index 0000000000..cc663ff22c --- /dev/null +++ b/statics/workflows/traceroute.yaml @@ -0,0 +1,110 @@ +UUID: "9b598b28-b52e-488f-7b1c-402ac07e59b5" +name: "Traceroute" +description: "Traceroute" +parameters: + - name: protocol + description: Protocol + type: choice + default: icmp4 + values: + - description: "Protocol : ICMPv4/Echo request" + value: icmp4 + - description: "Protocol : TCP/IPv4" + value: tcp4 + - name: source + description: Source Node + type: node + - name: destination + description: Destination Node + type: node +source: | + function Traceroute(protocol, from, to) { + var sources = []; + var result = {}; + var From = {}; + var G = client.gremlin.G() + G.V().Has('TID', from).ShortestPathTo(Metadata('TID', to)).then(function(nodes) { + for (var i in nodes) { + if (nodes[0][i].Metadata && nodes[0][i].Metadata.IPV4 && nodes[0][i].Metadata.MAC != null) { + sources.push(nodes[0][i].Metadata); + }else { + if ((nodes[0][i].Metadata && nodes[0][i].Metadata.Neutron && nodes[0][i].Metadata.Neutron.IPV4 != null) && (nodes[0][i].Metadata && nodes[0][i].Metadata.ExtID && nodes[0][i].Metadata.ExtID["attached-mac"] != null)) { + sources.push(nodes[0][i].Metadata); + } + } + } + }) + var capture = new Capture(); + capture.GremlinQuery = "G.V().Has('TID', '" + from + "')"; + var packetInjection = new PacketInjection(); + return client.captures.create(capture).then(function (c) { + capture = c + }).then(function () { + return sleep(1000) + }).then(function () { + for (i=0, j=1; i+1 0 && flows[0].Metric.ABPackets > 0 && flows[0].Metric.BAPackets > 0) { + result[flows[0].Network.A + " -- " + flows[0].Network.B] = {"Connected" : true, "RTT" : (flows[0].RTT / 1000000).toFixed(3) + " ms" }; + } + return result + }) + } else { + client.G.Flows().Has("Transport.A", From[sources[j].TID].SrcPort, "Transport.B", From[sources[j].TID].DstPort, "Transport.Protocol", "TCP", "Network.A", From[sources[j].TID].SrcIP, "Network.B", From[sources[j].TID].DstIP).then(function(flows) { + if (flows.length > 0 && flows[0].Metric.ABPackets > 0 && flows[0].Metric.BAPackets > 0) { + result[flows[0].Network.A + " -- " + flows[0].Network.B] = {"Connected" : true, "RTT" : (flows[0].RTT / 1000000).toFixed(3) + " ms" }; + } + return result + }) + } + } + return result + }).then(function () { + return { + "Trace Route" : sources[0].IPV4[0] + " To " + sources[sources.length - 1].IPV4[0], + "Path" : result + } + }).finally(function () { + return client.captures.delete(capture.UUID) + }).catch(function () { + return client.captures.delete(capture.UUID) + }); + }