Skip to content

Commit dd8ba4a

Browse files
committed
workflow: add ping-mesh workflow
1 parent 6830dcb commit dd8ba4a

File tree

2 files changed

+107
-1
lines changed

2 files changed

+107
-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

+106
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
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+
return client.captures.create(capture).then(function (c) {
36+
capture = c
37+
}).then(function () {
38+
return sleep(1000)
39+
}).then(function () {
40+
sources.forEach(function(s) {
41+
if (s != dst) {
42+
var packetInjection = new PacketInjection();
43+
packetInjection.Src = "G.V().Has('TID', '" + s + "')"
44+
packetInjection.Dst = "G.V().Has('TID', '" + dst + "')"
45+
packetInjection.Count = 5
46+
return client.G.V().Has("TID", dst).then(
47+
function (nodes) {
48+
if (nodes[0].Metadata.Neutron && nodes[0].Metadata.Neutron.IPV4) {
49+
packetInjection.DstIP = nodes[0].Metadata.Neutron.IPV4[0]
50+
}
51+
if (nodes[0].Metadata.ExtID && nodes[0].Metadata.ExtID["attached-mac"]) {
52+
packetInjection.DstMAC = nodes[0].Metadata.ExtID["attached-mac"]
53+
}
54+
if (protocol == "icmp4") {
55+
packetInjection.Type = protocol;
56+
packetInjection.ICMPID = Math.floor(Math.random() * 65535);
57+
}
58+
if (protocol == "tcp4" || protocol == "udp4") {
59+
packetInjection.Type = protocol;
60+
packetInjection.SrcPort = 1024 + Math.floor(Math.random() * (65535-1024));
61+
packetInjection.DstPort = 1024 + Math.floor(Math.random() * (65535-1024));
62+
}
63+
}).then(function () {
64+
return client.G.V().Has("TID", s)
65+
}).then(function (nodes) {
66+
if (nodes[0].Metadata.Neutron && nodes[0].Metadata.Neutron.IPV4) {
67+
packetInjection.SrcIP = nodes[0].Metadata.Neutron.IPV4[0]
68+
}
69+
if (nodes[0].Metadata.ExtID && nodes[0].Metadata.ExtID["attached-mac"]) {
70+
packetInjection.SrcMAC = nodes[0].Metadata.ExtID["attached-mac"]
71+
} else {
72+
packetInjection.SrcIP = nodes[0].Metadata.IPV4[0]
73+
}
74+
pktform[s] = packetInjection;
75+
pktform[s].SrcIP = pktform[s].SrcIP.split("/")[0]
76+
return client.packetInjections.create(packetInjection)
77+
})
78+
}
79+
});
80+
}).then(function () {
81+
return sleep(1000)
82+
}).then(function () {
83+
sources.forEach(function(s) {
84+
if (s != dst) {
85+
if (protocol == "icmp4") {
86+
client.G.Flows().Has("ICMP.ID", pktform[s].ICMPID, "Network.A", pktform[s].SrcIP).then(function(flows) {
87+
result[s] = {"Connected" : flows.length > 0 && flows[0].Metric.ABPackets > 0, "Replied" : flows.length > 0 && flows[0].Metric.BAPackets > 0};
88+
return result
89+
})
90+
} else {
91+
transport_protocol = protocol.toUpperCase().split(4)[0];
92+
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) {
93+
result[s] = {"Connected" : flows.length > 0 && flows[0].Metric.ABPackets > 0, "Replied" : flows.length > 0 && flows[0].Metric.BAPackets > 0};
94+
return result
95+
})
96+
}
97+
}
98+
});
99+
}).then(function () {
100+
return result
101+
}).finally(function () {
102+
return client.captures.delete(capture.UUID)
103+
}).catch(function () {
104+
return client.captures.delete(capture.UUID)
105+
});
106+
}

0 commit comments

Comments
 (0)