diff --git a/statics/workflows/ping-mesh.yaml b/statics/workflows/ping-mesh.yaml new file mode 100644 index 0000000000..cf4337e181 --- /dev/null +++ b/statics/workflows/ping-mesh.yaml @@ -0,0 +1,109 @@ +--- +UUID: "5230f319-7ccb-4e92-5e55-23a75e474ee6" +name: "PingMesh(ICMP/TCP/UDP)" +description: "Check Connectivity from Multiple Source to Single Destination" +parameters: + - name: source + description: Source node + type: node + - name: destination + description: Destination node + type: node + - name: protocol + description: Protocol + type: choice + default: ICMPv4 + values: + - description: "Protocol : ICMPv4/Echo request" + value: ICMPv4 + - description: "Protocol : TCP/IPv4" + value: TCP + - description: "Protocol : UDP/IPv4" + value: UDP +source: | + function PingMesh(from, to, protocol) { + var dict = {}; + var From = {}; + var sources = []; + sources.push(from); + var capture = new Capture(); + capture.GremlinQuery = "G.V().Has('TID', '" + to + "')"; + var packetInjection = new PacketInjection(); + return client.captures.create(capture).then(function (c) { + capture = c + }).then(function () { + sources.forEach(function(source) { + packetInjection.Src = "G.V().Has('TID', '" + source + "')" + packetInjection.Dst = "G.V().Has('TID', '" + to + "')" + packetInjection.Count = 5 + return client.G.V().Has("TID", to).then( + function (nodes) { + if (nodes[0].Metadata.Neutron && nodes[0].Metadata.Neutron.IPV4) { + packetInjection.DstIP = nodes[0].Metadata.Neutron.IPV4[0] + } + if (nodes[0].Metadata.ExtID && nodes[0].Metadata.ExtID["attached-mac"]) { + packetInjection.DstMAC = nodes[0].Metadata.ExtID["attached-mac"] + } + if (protocol == "ICMPv4") { + packetInjection.Type = "icmp4" + packetInjection.ICMPID = Math.floor(Math.random() * 65535); + i += Math.floor(Math.random() * 1000); + } + if (protocol == "TCP") { + packetInjection.Type = "tcp4" + packetInjection.SrcPort = 1024 + Math.floor(Math.random() * (65535-1024)); + packetInjection.DstPort = 1024 + Math.floor(Math.random() * (65535-1024)); + } + if (protocol == "UDP") { + packetInjection.Type = "udp4" + packetInjection.SrcPort = 1024 + Math.floor(Math.random() * (65535-1024)); + packetInjection.DstPort = 1024 + Math.floor(Math.random() * (65535-1024)); + } + }).then(function () { + return client.G.V().Has("TID", source) + }).then(function (nodes) { + if (nodes[0].Metadata.Neutron && nodes[0].Metadata.Neutron.IPV4) { + packetInjection.SrcIP = nodes[0].Metadata.Neutron.IPV4[0] + } + if (nodes[0].Metadata.ExtID && nodes[0].Metadata.ExtID["attached-mac"]) { + packetInjection.SrcMAC = nodes[0].Metadata.ExtID["attached-mac"] + From[source] = packetInjection; + }else { + From[source] = packetInjection; + From[source].SrcIP = nodes[0].Metadata.IPV4[0] + From[source].SrcMAC = nodes[0].Metadata.MAC + } + From[source].SrcIP = From[source].SrcIP.split("/")[0] + return client.packetInjections.create(packetInjection) + }) + }); + }).then(function () { + return sleep(2000) + }).then(function () { + sources.forEach(function(source) { + if (protocol == "ICMPv4") { + return client.G.Flows().Has("ICMP.ID", From[source].ICMPID, "Link.A", From[source].SrcMAC, "Network.A", From[source].SrcIP).then( + function (flows) { + dict[source] = flows.length > 0; + }) + } + if (protocol == "TCP") { + return client.G.Flows().Has("Transport.A", From[source].SrcPort, "Transport.B", From[source].DstPort, "Transport.Protocol", "TCP", "Link.A", From[source].SrcMAC, "Network.A", From[source].SrcIP).then( + function (flows) { + dict[source] = flows.length > 0; + }) + } + if (protocol == "UDP") { + return client.G.Flows().Has("Transport.A", From[source].SrcPort, "Transport.B", From[source].DstPort, "Transport.Protocol", "UDP", "Link.A", From[source].SrcMAC, "Network.A", From[source].SrcIP).then( + function (flows) { + dict[source] = flows.length > 0; + }) + } + }); + return sleep(1000) + }).then(function () { + return dict + }).finally(function () { + client.captures.delete(capture.UUID) + }) + } \ No newline at end of file