Skip to content

Commit 9cde40d

Browse files
committed
workflow: add ping-mesh workflow
1 parent 81dc1a1 commit 9cde40d

File tree

2 files changed

+103
-1
lines changed

2 files changed

+103
-1
lines changed

Diff for: statics/js/components/workflow.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Vue.component('item', {
1717
<div class="form-group">
1818
<div v-if="Type == 'string'" class="form-group">
1919
<label :for="Name">{{Description}}</label>
20-
<textarea:id="Name" v-model="formData[Name]"></textarea>
20+
<textarea :id="Name" v-model="formData[Name]" class="form-control input-sm"></textarea>
2121
</div>
2222
<div v-else-if="Type == 'date'" class="form-group">
2323
<label :for="Name">{{Description}}</label>

Diff for: statics/workflows/ping-mesh.yaml

+102
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
---
2+
UUID: "784c3329-0f47-449b-5c58-2d207bcfb501"
3+
Name: "Ping Mesh (ICMP/TCP/UDP)"
4+
Description: "Check Connectivity from Multiple Source to Single Destination"
5+
Parameters:
6+
- Name: protocol
7+
Description: Protocol
8+
Type: choice
9+
Default: icmp4
10+
Values:
11+
- Description: "Protocol : ICMPv4/Echo request"
12+
Value: icmp4
13+
- Description: "Protocol : TCP/IPv4"
14+
Value: tcp4
15+
- Description: "Protocol : UDP/IPv4"
16+
Value: udp4
17+
- Name: source
18+
Description: Source Nodes (Enter a Gremlin Query to select Source Nodes)
19+
Type: string
20+
- Name: destination
21+
Description: Destination Node (Select Destination Node)
22+
Type: node
23+
Source: |
24+
function PingMesh(protocol, src, dst) {
25+
var sources = [];
26+
var result = {};
27+
var pktform = {};
28+
client.gremlin.query(src).then(function(nodes) {
29+
nodes.forEach(function(node) {
30+
sources.push(node.Metadata.TID);
31+
});
32+
})
33+
var capture = new Capture();
34+
capture.GremlinQuery = "G.V().Has('TID', '" + dst + "')";
35+
var packetInjection = new PacketInjection();
36+
return client.captures.create(capture).then(function (c) {
37+
capture = c
38+
}).then(function () {
39+
return sleep(1000)
40+
}).then(function () {
41+
sources.forEach(function(s) {
42+
packetInjection.Src = "G.V().Has('TID', '" + s + "')"
43+
packetInjection.Dst = "G.V().Has('TID', '" + dst + "')"
44+
packetInjection.Count = 5
45+
return client.G.V().Has("TID", dst).then(
46+
function (nodes) {
47+
if (nodes[0].Metadata.Neutron && nodes[0].Metadata.Neutron.IPV4) {
48+
packetInjection.DstIP = nodes[0].Metadata.Neutron.IPV4[0]
49+
}
50+
if (nodes[0].Metadata.ExtID && nodes[0].Metadata.ExtID["attached-mac"]) {
51+
packetInjection.DstMAC = nodes[0].Metadata.ExtID["attached-mac"]
52+
}
53+
if (protocol == "icmp4") {
54+
packetInjection.Type = protocol;
55+
packetInjection.ICMPID = Math.floor(Math.random() * 65535);
56+
}
57+
if (protocol == "tcp4" || protocol == "udp4") {
58+
packetInjection.Type = protocol;
59+
packetInjection.SrcPort = 1024 + Math.floor(Math.random() * (65535-1024));
60+
packetInjection.DstPort = 1024 + Math.floor(Math.random() * (65535-1024));
61+
}
62+
}).then(function () {
63+
return client.G.V().Has("TID", s)
64+
}).then(function (nodes) {
65+
if (nodes[0].Metadata.Neutron && nodes[0].Metadata.Neutron.IPV4) {
66+
packetInjection.SrcIP = nodes[0].Metadata.Neutron.IPV4[0]
67+
}
68+
if (nodes[0].Metadata.ExtID && nodes[0].Metadata.ExtID["attached-mac"]) {
69+
packetInjection.SrcMAC = nodes[0].Metadata.ExtID["attached-mac"]
70+
} else {
71+
packetInjection.SrcIP = nodes[0].Metadata.IPV4[0]
72+
}
73+
pktform[s] = packetInjection;
74+
pktform[s].SrcIP = pktform[s].SrcIP.split("/")[0]
75+
return client.packetInjections.create(packetInjection)
76+
})
77+
});
78+
}).then(function () {
79+
return sleep(1000)
80+
}).then(function () {
81+
sources.forEach(function(s) {
82+
if (protocol == "icmp4") {
83+
client.G.Flows().Has("ICMP.ID", pktform[s].ICMPID, "Network.A", pktform[s].SrcIP).then(function(flows) {
84+
result[s] = {"Connected" : flows.length > 0 && flows[0].Metric.ABPackets > 0, "Replied" : flows.length > 0 && flows[0].Metric.BAPackets > 0};
85+
return result
86+
})
87+
} else {
88+
transport_protocol = protocol.toUpperCase().split(4)[0];
89+
client.G.Flows().Has("Transport.A", pktform[s].SrcPort, "Transport.B", pktform[s].DstPort, "Transport.Protocol", transport_protocol, "Network.A", pktform[s].SrcIP).then(function(flows) {
90+
result[s] = {"Connected" : flows.length > 0 && flows[0].Metric.ABPackets > 0, "Replied" : flows.length > 0 && flows[0].Metric.BAPackets > 0};
91+
return result
92+
})
93+
}
94+
});
95+
}).then(function () {
96+
return result
97+
}).finally(function () {
98+
return client.captures.delete(capture.UUID)
99+
}).catch(function () {
100+
return client.captures.delete(capture.UUID)
101+
});
102+
}

0 commit comments

Comments
 (0)