Committed by
Gerrit Code Review
Adding enhancements to the GUI server-side.
Fixing a few intent-related glitches for the optical use-case. Fixing lat/lng information in the optical config. Change-Id: I6a1dd1ee69c2db2f0e351d191627bba468a3c49c
Showing
10 changed files
with
279 additions
and
77 deletions
... | @@ -15,8 +15,6 @@ | ... | @@ -15,8 +15,6 @@ |
15 | */ | 15 | */ |
16 | package org.onlab.onos.cli.net; | 16 | package org.onlab.onos.cli.net; |
17 | 17 | ||
18 | -import java.util.List; | ||
19 | - | ||
20 | import org.apache.karaf.shell.commands.Argument; | 18 | import org.apache.karaf.shell.commands.Argument; |
21 | import org.apache.karaf.shell.commands.Command; | 19 | import org.apache.karaf.shell.commands.Command; |
22 | import org.onlab.onos.net.HostId; | 20 | import org.onlab.onos.net.HostId; |
... | @@ -28,6 +26,8 @@ import org.onlab.onos.net.intent.Constraint; | ... | @@ -28,6 +26,8 @@ import org.onlab.onos.net.intent.Constraint; |
28 | import org.onlab.onos.net.intent.HostToHostIntent; | 26 | import org.onlab.onos.net.intent.HostToHostIntent; |
29 | import org.onlab.onos.net.intent.IntentService; | 27 | import org.onlab.onos.net.intent.IntentService; |
30 | 28 | ||
29 | +import java.util.List; | ||
30 | + | ||
31 | /** | 31 | /** |
32 | * Installs host-to-host connectivity intent. | 32 | * Installs host-to-host connectivity intent. |
33 | */ | 33 | */ | ... | ... |
... | @@ -20,11 +20,13 @@ import java.util.List; | ... | @@ -20,11 +20,13 @@ import java.util.List; |
20 | 20 | ||
21 | import org.apache.karaf.shell.commands.Option; | 21 | import org.apache.karaf.shell.commands.Option; |
22 | import org.onlab.onos.cli.AbstractShellCommand; | 22 | import org.onlab.onos.cli.AbstractShellCommand; |
23 | +import org.onlab.onos.net.Link; | ||
23 | import org.onlab.onos.net.flow.DefaultTrafficSelector; | 24 | import org.onlab.onos.net.flow.DefaultTrafficSelector; |
24 | import org.onlab.onos.net.flow.TrafficSelector; | 25 | import org.onlab.onos.net.flow.TrafficSelector; |
25 | import org.onlab.onos.net.intent.Constraint; | 26 | import org.onlab.onos.net.intent.Constraint; |
26 | import org.onlab.onos.net.intent.constraint.BandwidthConstraint; | 27 | import org.onlab.onos.net.intent.constraint.BandwidthConstraint; |
27 | import org.onlab.onos.net.intent.constraint.LambdaConstraint; | 28 | import org.onlab.onos.net.intent.constraint.LambdaConstraint; |
29 | +import org.onlab.onos.net.intent.constraint.LinkTypeConstraint; | ||
28 | import org.onlab.onos.net.resource.Bandwidth; | 30 | import org.onlab.onos.net.resource.Bandwidth; |
29 | import org.onlab.packet.Ethernet; | 31 | import org.onlab.packet.Ethernet; |
30 | import org.onlab.packet.IpPrefix; | 32 | import org.onlab.packet.IpPrefix; |
... | @@ -142,6 +144,7 @@ public abstract class ConnectivityIntentCommand extends AbstractShellCommand { | ... | @@ -142,6 +144,7 @@ public abstract class ConnectivityIntentCommand extends AbstractShellCommand { |
142 | if (lambda) { | 144 | if (lambda) { |
143 | constraints.add(new LambdaConstraint(null)); | 145 | constraints.add(new LambdaConstraint(null)); |
144 | } | 146 | } |
147 | + constraints.add(new LinkTypeConstraint(lambda, Link.Type.OPTICAL)); | ||
145 | 148 | ||
146 | return constraints; | 149 | return constraints; |
147 | } | 150 | } | ... | ... |
... | @@ -16,12 +16,14 @@ | ... | @@ -16,12 +16,14 @@ |
16 | package org.onlab.onos.net.intent; | 16 | package org.onlab.onos.net.intent; |
17 | 17 | ||
18 | import com.google.common.base.MoreObjects; | 18 | import com.google.common.base.MoreObjects; |
19 | +import com.google.common.collect.ImmutableList; | ||
19 | import org.onlab.onos.core.ApplicationId; | 20 | import org.onlab.onos.core.ApplicationId; |
20 | import org.onlab.onos.net.HostId; | 21 | import org.onlab.onos.net.HostId; |
22 | +import org.onlab.onos.net.Link; | ||
21 | import org.onlab.onos.net.flow.TrafficSelector; | 23 | import org.onlab.onos.net.flow.TrafficSelector; |
22 | import org.onlab.onos.net.flow.TrafficTreatment; | 24 | import org.onlab.onos.net.flow.TrafficTreatment; |
25 | +import org.onlab.onos.net.intent.constraint.LinkTypeConstraint; | ||
23 | 26 | ||
24 | -import java.util.Collections; | ||
25 | import java.util.List; | 27 | import java.util.List; |
26 | 28 | ||
27 | import static com.google.common.base.Preconditions.checkNotNull; | 29 | import static com.google.common.base.Preconditions.checkNotNull; |
... | @@ -47,7 +49,8 @@ public final class HostToHostIntent extends ConnectivityIntent { | ... | @@ -47,7 +49,8 @@ public final class HostToHostIntent extends ConnectivityIntent { |
47 | public HostToHostIntent(ApplicationId appId, HostId one, HostId two, | 49 | public HostToHostIntent(ApplicationId appId, HostId one, HostId two, |
48 | TrafficSelector selector, | 50 | TrafficSelector selector, |
49 | TrafficTreatment treatment) { | 51 | TrafficTreatment treatment) { |
50 | - this(appId, one, two, selector, treatment, Collections.emptyList()); | 52 | + this(appId, one, two, selector, treatment, |
53 | + ImmutableList.of(new LinkTypeConstraint(false, Link.Type.OPTICAL))); | ||
51 | } | 54 | } |
52 | 55 | ||
53 | /** | 56 | /** | ... | ... |
... | @@ -3,32 +3,32 @@ | ... | @@ -3,32 +3,32 @@ |
3 | { | 3 | { |
4 | "uri": "of:0000ffffffffff01", "mac": "ffffffffffff01", "type": "ROADM", | 4 | "uri": "of:0000ffffffffff01", "mac": "ffffffffffff01", "type": "ROADM", |
5 | "mfr": "Linc", "hw": "OE", "sw": "?", "serial": "?", "name": "ROADM1", | 5 | "mfr": "Linc", "hw": "OE", "sw": "?", "serial": "?", "name": "ROADM1", |
6 | - "annotations": { "latitude": 37.6, "longitude": 122.3, "optical.regens": 0 }, | 6 | + "annotations": { "latitude": 37.6, "longitude": -122.3, "optical.regens": 0 }, |
7 | "ports": [ { "port": 10, "speed": 100000, "type": "FIBER" }, { "port": 20, "speed": 0, "type": "FIBER" } ] | 7 | "ports": [ { "port": 10, "speed": 100000, "type": "FIBER" }, { "port": 20, "speed": 0, "type": "FIBER" } ] |
8 | }, | 8 | }, |
9 | { | 9 | { |
10 | "uri": "of:0000ffffffffff02", "mac": "ffffffffffff02", "type": "ROADM", | 10 | "uri": "of:0000ffffffffff02", "mac": "ffffffffffff02", "type": "ROADM", |
11 | "mfr": "Linc", "hw": "OE", "sw": "?", "serial": "?", "name": "ROADM2", | 11 | "mfr": "Linc", "hw": "OE", "sw": "?", "serial": "?", "name": "ROADM2", |
12 | - "annotations": { "latitude": 37.3, "longitude": 121.9, "optical.regens": 0 }, | 12 | + "annotations": { "latitude": 37.3, "longitude": -121.9, "optical.regens": 0 }, |
13 | "ports": [ { "port": 11, "speed": 100000, "type": "FIBER" }, { "port": 21, "speed": 0, "type": "FIBER" } ] | 13 | "ports": [ { "port": 11, "speed": 100000, "type": "FIBER" }, { "port": 21, "speed": 0, "type": "FIBER" } ] |
14 | }, | 14 | }, |
15 | { | 15 | { |
16 | "uri": "of:0000ffffffffff03", "mac": "ffffffffffff03", "type": "ROADM", | 16 | "uri": "of:0000ffffffffff03", "mac": "ffffffffffff03", "type": "ROADM", |
17 | "mfr": "Linc", "hw": "OE", "sw": "?", "serial": "?", "name": "ROADM3", | 17 | "mfr": "Linc", "hw": "OE", "sw": "?", "serial": "?", "name": "ROADM3", |
18 | - "annotations": { "latitude": 33.9, "longitude": 118.4, "optical.regens": 2 }, | 18 | + "annotations": { "latitude": 33.9, "longitude": -118.4, "optical.regens": 2 }, |
19 | "ports": [ { "port": 30, "speed": 0, "type": "FIBER" }, { "port": 31, "speed": 0, "type": "FIBER" } ] | 19 | "ports": [ { "port": 30, "speed": 0, "type": "FIBER" }, { "port": 31, "speed": 0, "type": "FIBER" } ] |
20 | }, | 20 | }, |
21 | 21 | ||
22 | { | 22 | { |
23 | "uri": "of:0000ffffffff0001", "mac": "ffffffffff0001", "type": "SWITCH", | 23 | "uri": "of:0000ffffffff0001", "mac": "ffffffffff0001", "type": "SWITCH", |
24 | "mfr": "Linc", "hw": "PK", "sw": "?", "serial": "?", "name": "ROUTER1", | 24 | "mfr": "Linc", "hw": "PK", "sw": "?", "serial": "?", "name": "ROUTER1", |
25 | - "annotations": { "latitude": 37.6, "longitude": 122.3 }, | 25 | + "annotations": { "latitude": 37.6, "longitude": -122.3 }, |
26 | "ports": [ { "port": 1, "speed": 10000, "type": "COPPER" }, { "port": 2, "speed": 100000, "type": "FIBER" } ] | 26 | "ports": [ { "port": 1, "speed": 10000, "type": "COPPER" }, { "port": 2, "speed": 100000, "type": "FIBER" } ] |
27 | }, | 27 | }, |
28 | { | 28 | { |
29 | "uri": "of:0000ffffffff0002", "mac": "ffffffffff0002", "type": "SWITCH", | 29 | "uri": "of:0000ffffffff0002", "mac": "ffffffffff0002", "type": "SWITCH", |
30 | "mfr": "Linc", "hw": "PK", "sw": "?", "serial": "?", "name": "ROUTER2", | 30 | "mfr": "Linc", "hw": "PK", "sw": "?", "serial": "?", "name": "ROUTER2", |
31 | - "annotations": { "latitude": 37.3, "longitude": 121.9 }, | 31 | + "annotations": { "latitude": 37.3, "longitude": -121.9 }, |
32 | "ports": [ { "port": 1, "speed": 10000, "type": "COPPER" }, { "port": 2, "speed": 100000, "type": "FIBER" } ] | 32 | "ports": [ { "port": 1, "speed": 10000, "type": "COPPER" }, { "port": 2, "speed": 100000, "type": "FIBER" } ] |
33 | } | 33 | } |
34 | ], | 34 | ], | ... | ... |
... | @@ -3,7 +3,7 @@ | ... | @@ -3,7 +3,7 @@ |
3 | { | 3 | { |
4 | "uri": "of:0000ffffffffff01", "mac": "ffffffffffff01", "type": "ROADM", | 4 | "uri": "of:0000ffffffffff01", "mac": "ffffffffffff01", "type": "ROADM", |
5 | "mfr": "Linc", "hw": "OE", "sw": "?", "serial": "?", "name": "SFO-W10", | 5 | "mfr": "Linc", "hw": "OE", "sw": "?", "serial": "?", "name": "SFO-W10", |
6 | - "annotations": { "latitude": 37.6, "longitude": 122.3, "optical.regens": 0 }, | 6 | + "annotations": { "latitude": 37.6, "longitude": -122.3, "optical.regens": 0 }, |
7 | "ports": [ { "port": 10, "speed": 100000, "type": "FIBER" }, | 7 | "ports": [ { "port": 10, "speed": 100000, "type": "FIBER" }, |
8 | { "port": 20, "speed": 0, "type": "FIBER" }, | 8 | { "port": 20, "speed": 0, "type": "FIBER" }, |
9 | { "port": 50, "speed":100000, "type": "FIBER" } ] | 9 | { "port": 50, "speed":100000, "type": "FIBER" } ] |
... | @@ -11,7 +11,7 @@ | ... | @@ -11,7 +11,7 @@ |
11 | { | 11 | { |
12 | "uri": "of:0000ffffffffff02", "mac": "ffffffffffff02", "type": "ROADM", | 12 | "uri": "of:0000ffffffffff02", "mac": "ffffffffffff02", "type": "ROADM", |
13 | "mfr": "Linc", "hw": "OE", "sw": "?", "serial": "?", "name": "SJC-W10", | 13 | "mfr": "Linc", "hw": "OE", "sw": "?", "serial": "?", "name": "SJC-W10", |
14 | - "annotations": { "latitude": 37.3, "longitude": 121.9, "optical.regens": 0 }, | 14 | + "annotations": { "latitude": 37.3, "longitude": -121.9, "optical.regens": 0 }, |
15 | "ports": [ { "port": 20, "speed": 100000, "type": "FIBER" }, | 15 | "ports": [ { "port": 20, "speed": 100000, "type": "FIBER" }, |
16 | { "port": 30, "speed": 0, "type": "FIBER" }, | 16 | { "port": 30, "speed": 0, "type": "FIBER" }, |
17 | { "port": 50, "speed": 0, "type": "FIBER" } ] | 17 | { "port": 50, "speed": 0, "type": "FIBER" } ] |
... | @@ -19,7 +19,7 @@ | ... | @@ -19,7 +19,7 @@ |
19 | { | 19 | { |
20 | "uri": "of:0000ffffffffff03", "mac": "ffffffffffff03", "type": "ROADM", | 20 | "uri": "of:0000ffffffffff03", "mac": "ffffffffffff03", "type": "ROADM", |
21 | "mfr": "Linc", "hw": "OE", "sw": "?", "serial": "?", "name": "LAX-W10", | 21 | "mfr": "Linc", "hw": "OE", "sw": "?", "serial": "?", "name": "LAX-W10", |
22 | - "annotations": { "latitude": 33.9, "longitude": 118.4, "optical.regens": 0 }, | 22 | + "annotations": { "latitude": 33.9, "longitude": -118.4, "optical.regens": 0 }, |
23 | "ports": [ { "port": 30, "speed": 0, "type": "FIBER" }, | 23 | "ports": [ { "port": 30, "speed": 0, "type": "FIBER" }, |
24 | { "port": 50, "speed": 0, "type": "FIBER" }, | 24 | { "port": 50, "speed": 0, "type": "FIBER" }, |
25 | { "port": 20, "speed": 0, "type": "FIBER" } ] | 25 | { "port": 20, "speed": 0, "type": "FIBER" } ] |
... | @@ -27,7 +27,7 @@ | ... | @@ -27,7 +27,7 @@ |
27 | { | 27 | { |
28 | "uri": "of:0000ffffffffff04", "mac": "ffffffffffff04", "type": "ROADM", | 28 | "uri": "of:0000ffffffffff04", "mac": "ffffffffffff04", "type": "ROADM", |
29 | "mfr": "Linc", "hw": "OE", "sw": "?", "serial": "?", "name": "SDG-W10", | 29 | "mfr": "Linc", "hw": "OE", "sw": "?", "serial": "?", "name": "SDG-W10", |
30 | - "annotations": { "latitude": 32.8, "longitude": 117.1, "optical.regens": 3 }, | 30 | + "annotations": { "latitude": 32.8, "longitude": -117.1, "optical.regens": 3 }, |
31 | "ports": [ { "port": 30, "speed": 0, "type": "FIBER" }, | 31 | "ports": [ { "port": 30, "speed": 0, "type": "FIBER" }, |
32 | { "port":50, "speed": 0, "type": "FIBER" }, | 32 | { "port":50, "speed": 0, "type": "FIBER" }, |
33 | { "port":20, "speed": 0, "type": "FIBER" }] | 33 | { "port":20, "speed": 0, "type": "FIBER" }] |
... | @@ -35,7 +35,7 @@ | ... | @@ -35,7 +35,7 @@ |
35 | { | 35 | { |
36 | "uri": "of:0000ffffffffff05", "mac": "ffffffffffff05", "type": "ROADM", | 36 | "uri": "of:0000ffffffffff05", "mac": "ffffffffffff05", "type": "ROADM", |
37 | "mfr": "Linc", "hw": "OE", "sw": "?", "serial": "?", "name": "MSP-M10", | 37 | "mfr": "Linc", "hw": "OE", "sw": "?", "serial": "?", "name": "MSP-M10", |
38 | - "annotations": { "latitude": 44.8, "longitude": 93.1, "optical.regens": 3 }, | 38 | + "annotations": { "latitude": 44.8, "longitude": -93.1, "optical.regens": 3 }, |
39 | "ports": [ { "port": 20, "speed": 0, "type": "FIBER" }, | 39 | "ports": [ { "port": 20, "speed": 0, "type": "FIBER" }, |
40 | { "port": 30, "speed": 0, "type": "FIBER" }, | 40 | { "port": 30, "speed": 0, "type": "FIBER" }, |
41 | { "port": 40, "speed": 0, "type": "FIBER" }, | 41 | { "port": 40, "speed": 0, "type": "FIBER" }, |
... | @@ -44,7 +44,7 @@ | ... | @@ -44,7 +44,7 @@ |
44 | { | 44 | { |
45 | "uri": "of:0000ffffffffff06", "mac": "ffffffffffff06", "type": "ROADM", | 45 | "uri": "of:0000ffffffffff06", "mac": "ffffffffffff06", "type": "ROADM", |
46 | "mfr": "Linc", "hw": "OE", "sw": "?", "serial": "?", "name": "DFW-M10", | 46 | "mfr": "Linc", "hw": "OE", "sw": "?", "serial": "?", "name": "DFW-M10", |
47 | - "annotations": { "latitude": 32.8, "longitude": 97.1, "optical.regens": 3 }, | 47 | + "annotations": { "latitude": 32.8, "longitude": -97.1, "optical.regens": 3 }, |
48 | "ports": [ { "port": 10, "speed": 0, "type": "FIBER" }, | 48 | "ports": [ { "port": 10, "speed": 0, "type": "FIBER" }, |
49 | { "port": 20, "speed": 0, "type": "FIBER" }, | 49 | { "port": 20, "speed": 0, "type": "FIBER" }, |
50 | { "port": 30, "speed": 0, "type": "FIBER" }, | 50 | { "port": 30, "speed": 0, "type": "FIBER" }, |
... | @@ -54,7 +54,7 @@ | ... | @@ -54,7 +54,7 @@ |
54 | { | 54 | { |
55 | "uri": "of:0000ffffffffff07", "mac": "ffffffffffff07", "type": "ROADM", | 55 | "uri": "of:0000ffffffffff07", "mac": "ffffffffffff07", "type": "ROADM", |
56 | "mfr": "Linc", "hw": "OE", "sw": "?", "serial": "?", "name": "CHG-N10", | 56 | "mfr": "Linc", "hw": "OE", "sw": "?", "serial": "?", "name": "CHG-N10", |
57 | - "annotations": { "latitude": 41.8, "longitude": 120.1, "optical.regens": 3 }, | 57 | + "annotations": { "latitude": 41.8, "longitude": -120.1, "optical.regens": 3 }, |
58 | "ports": [ { "port": 10, "speed": 0, "type": "FIBER" }, | 58 | "ports": [ { "port": 10, "speed": 0, "type": "FIBER" }, |
59 | { "port": 20, "speed": 0, "type": "FIBER" }, | 59 | { "port": 20, "speed": 0, "type": "FIBER" }, |
60 | { "port": 30, "speed": 0, "type": "FIBER" }, | 60 | { "port": 30, "speed": 0, "type": "FIBER" }, |
... | @@ -63,7 +63,7 @@ | ... | @@ -63,7 +63,7 @@ |
63 | { | 63 | { |
64 | "uri": "of:0000ffffffffff08", "mac": "ffffffffffff08", "type": "ROADM", | 64 | "uri": "of:0000ffffffffff08", "mac": "ffffffffffff08", "type": "ROADM", |
65 | "mfr": "Linc", "hw": "OE", "sw": "?", "serial": "?", "name": "IAD-M10", | 65 | "mfr": "Linc", "hw": "OE", "sw": "?", "serial": "?", "name": "IAD-M10", |
66 | - "annotations": { "latitude": 38.8, "longitude": 77.1, "optical.regens": 3 }, | 66 | + "annotations": { "latitude": 38.8, "longitude": -77.1, "optical.regens": 3 }, |
67 | "ports": [ { "port": 20, "speed": 0, "type": "FIBER" }, | 67 | "ports": [ { "port": 20, "speed": 0, "type": "FIBER" }, |
68 | { "port": 30, "speed": 0, "type": "FIBER" }, | 68 | { "port": 30, "speed": 0, "type": "FIBER" }, |
69 | { "port": 50, "speed": 0, "type": "FIBER" }] | 69 | { "port": 50, "speed": 0, "type": "FIBER" }] |
... | @@ -71,7 +71,7 @@ | ... | @@ -71,7 +71,7 @@ |
71 | { | 71 | { |
72 | "uri": "of:0000ffffffffff09", "mac": "ffffffffffff09", "type": "ROADM", | 72 | "uri": "of:0000ffffffffff09", "mac": "ffffffffffff09", "type": "ROADM", |
73 | "mfr": "Linc", "hw": "OE", "sw": "?", "serial": "?", "name": "JFK-M10", | 73 | "mfr": "Linc", "hw": "OE", "sw": "?", "serial": "?", "name": "JFK-M10", |
74 | - "annotations": { "latitude": 40.8, "longitude": 73.1, "optical.regens": 0 }, | 74 | + "annotations": { "latitude": 40.8, "longitude": -73.1, "optical.regens": 0 }, |
75 | "ports": [ { "port": 10, "speed": 0, "type": "FIBER" }, | 75 | "ports": [ { "port": 10, "speed": 0, "type": "FIBER" }, |
76 | { "port": 20, "speed": 0, "type": "FIBER" }, | 76 | { "port": 20, "speed": 0, "type": "FIBER" }, |
77 | { "port": 50, "speed": 0, "type": "FIBER" }] | 77 | { "port": 50, "speed": 0, "type": "FIBER" }] |
... | @@ -79,7 +79,7 @@ | ... | @@ -79,7 +79,7 @@ |
79 | { | 79 | { |
80 | "uri": "of:0000ffffffffff0A", "mac": "ffffffffffff0A", "type": "ROADM", | 80 | "uri": "of:0000ffffffffff0A", "mac": "ffffffffffff0A", "type": "ROADM", |
81 | "mfr": "Linc", "hw": "OE", "sw": "?", "serial": "?", "name": "ATL-S10", | 81 | "mfr": "Linc", "hw": "OE", "sw": "?", "serial": "?", "name": "ATL-S10", |
82 | - "annotations": { "latitude": 33.8, "longitude": 84.1, "optical.regens": 0 }, | 82 | + "annotations": { "latitude": 33.8, "longitude": -84.1, "optical.regens": 0 }, |
83 | "ports": [ { "port": 10, "speed": 0, "type": "FIBER" }, | 83 | "ports": [ { "port": 10, "speed": 0, "type": "FIBER" }, |
84 | { "port": 20, "speed": 0, "type": "FIBER" }, | 84 | { "port": 20, "speed": 0, "type": "FIBER" }, |
85 | { "port": 50, "speed": 0, "type": "FIBER" }] | 85 | { "port": 50, "speed": 0, "type": "FIBER" }] |
... | @@ -87,37 +87,37 @@ | ... | @@ -87,37 +87,37 @@ |
87 | { | 87 | { |
88 | "uri": "of:0000ffffffff0001", "mac": "ffffffffff0001", "type": "SWITCH", | 88 | "uri": "of:0000ffffffff0001", "mac": "ffffffffff0001", "type": "SWITCH", |
89 | "mfr": "Linc", "hw": "PK", "sw": "?", "serial": "?", "name": "SFO-R10", | 89 | "mfr": "Linc", "hw": "PK", "sw": "?", "serial": "?", "name": "SFO-R10", |
90 | - "annotations": { "latitude": 37.6, "longitude": 122.3 }, | 90 | + "annotations": { "latitude": 37.6, "longitude": -122.3 }, |
91 | "ports": [ { "port": 1, "speed": 10000, "type": "COPPER" }, { "port": 2, "speed": 100000, "type": "FIBER" } ] | 91 | "ports": [ { "port": 1, "speed": 10000, "type": "COPPER" }, { "port": 2, "speed": 100000, "type": "FIBER" } ] |
92 | }, | 92 | }, |
93 | { | 93 | { |
94 | "uri": "of:0000ffffffff0002", "mac": "ffffffffff0003", "type": "SWITCH", | 94 | "uri": "of:0000ffffffff0002", "mac": "ffffffffff0003", "type": "SWITCH", |
95 | "mfr": "Linc", "hw": "PK", "sw": "?", "serial": "?", "name": "LAX-R10", | 95 | "mfr": "Linc", "hw": "PK", "sw": "?", "serial": "?", "name": "LAX-R10", |
96 | - "annotations": { "latitude": 33.9, "longitude": 118.4 }, | 96 | + "annotations": { "latitude": 33.9, "longitude": -118.4 }, |
97 | "ports": [ { "port": 1, "speed": 10000, "type": "COPPER" }, { "port": 2, "speed": 100000, "type": "FIBER" } ] | 97 | "ports": [ { "port": 1, "speed": 10000, "type": "COPPER" }, { "port": 2, "speed": 100000, "type": "FIBER" } ] |
98 | }, | 98 | }, |
99 | { | 99 | { |
100 | "uri": "of:0000ffffffff0003", "mac": "ffffffffff0004", "type": "SWITCH", | 100 | "uri": "of:0000ffffffff0003", "mac": "ffffffffff0004", "type": "SWITCH", |
101 | "mfr": "Linc", "hw": "PK", "sw": "?", "serial": "?", "name": "SDG-R10", | 101 | "mfr": "Linc", "hw": "PK", "sw": "?", "serial": "?", "name": "SDG-R10", |
102 | - "annotations": { "latitude": 32.8, "longitude": 117.1 }, | 102 | + "annotations": { "latitude": 32.8, "longitude": -117.1 }, |
103 | "ports": [ { "port": 1, "speed": 10000, "type": "COPPER" }, { "port": 2, "speed": 100000, "type": "FIBER" } ] | 103 | "ports": [ { "port": 1, "speed": 10000, "type": "COPPER" }, { "port": 2, "speed": 100000, "type": "FIBER" } ] |
104 | }, | 104 | }, |
105 | { | 105 | { |
106 | "uri": "of:0000ffffffff0004", "mac": "ffffffffff0007", "type": "SWITCH", | 106 | "uri": "of:0000ffffffff0004", "mac": "ffffffffff0007", "type": "SWITCH", |
107 | "mfr": "Linc", "hw": "PK", "sw": "?", "serial": "?", "name": "CHG-R10", | 107 | "mfr": "Linc", "hw": "PK", "sw": "?", "serial": "?", "name": "CHG-R10", |
108 | - "annotations": { "latitude": 41.8, "longitude": 120.1 }, | 108 | + "annotations": { "latitude": 41.8, "longitude": -120.1 }, |
109 | "ports": [ { "port": 1, "speed": 10000, "type": "COPPER" }, { "port": 2, "speed": 100000, "type": "FIBER" } ] | 109 | "ports": [ { "port": 1, "speed": 10000, "type": "COPPER" }, { "port": 2, "speed": 100000, "type": "FIBER" } ] |
110 | }, | 110 | }, |
111 | { | 111 | { |
112 | "uri": "of:0000ffffffff0005", "mac": "ffffffffff0009", "type": "SWITCH", | 112 | "uri": "of:0000ffffffff0005", "mac": "ffffffffff0009", "type": "SWITCH", |
113 | "mfr": "Linc", "hw": "PK", "sw": "?", "serial": "?", "name": "JFK-R10", | 113 | "mfr": "Linc", "hw": "PK", "sw": "?", "serial": "?", "name": "JFK-R10", |
114 | - "annotations": { "latitude": 40.8, "longitude": 73.1 }, | 114 | + "annotations": { "latitude": 40.8, "longitude": -73.1 }, |
115 | "ports": [ { "port": 1, "speed": 10000, "type": "COPPER" }, { "port": 2, "speed": 100000, "type": "FIBER" } ] | 115 | "ports": [ { "port": 1, "speed": 10000, "type": "COPPER" }, { "port": 2, "speed": 100000, "type": "FIBER" } ] |
116 | }, | 116 | }, |
117 | { | 117 | { |
118 | "uri": "of:0000ffffffff0006", "mac": "ffffffffff000A", "type": "SWITCH", | 118 | "uri": "of:0000ffffffff0006", "mac": "ffffffffff000A", "type": "SWITCH", |
119 | "mfr": "Linc", "hw": "PK", "sw": "?", "serial": "?", "name": "ATL-R10", | 119 | "mfr": "Linc", "hw": "PK", "sw": "?", "serial": "?", "name": "ATL-R10", |
120 | - "annotations": { "latitude": 33.8, "longitude": 84.1 }, | 120 | + "annotations": { "latitude": 33.8, "longitude": -84.1 }, |
121 | "ports": [ { "port": 1, "speed": 10000, "type": "COPPER" }, { "port": 2, "speed": 100000, "type": "FIBER" } ] | 121 | "ports": [ { "port": 1, "speed": 10000, "type": "COPPER" }, { "port": 2, "speed": 100000, "type": "FIBER" } ] |
122 | } | 122 | } |
123 | 123 | ... | ... |
... | @@ -3,37 +3,37 @@ | ... | @@ -3,37 +3,37 @@ |
3 | { | 3 | { |
4 | "uri": "of:0000ffffffffff01", "mac": "ffffffffffff01", "type": "ROADM", | 4 | "uri": "of:0000ffffffffff01", "mac": "ffffffffffff01", "type": "ROADM", |
5 | "mfr": "Linc", "hw": "OE", "sw": "?", "serial": "?", "name": "ROADM1", | 5 | "mfr": "Linc", "hw": "OE", "sw": "?", "serial": "?", "name": "ROADM1", |
6 | - "annotations": { "latitude": 37.6, "longitude": 122.3, "optical.regens": 0 }, | 6 | + "annotations": { "latitude": 37.6, "longitude": -122.3, "optical.regens": 0 }, |
7 | - "ports": [ { "port": 10, "speed": 100000, "type": "FIBER" }, { "port": 20, "speed": 0, "type": "FIBER" }, { "port": 22, "speed": 0, "type": "FIBER" }] | 7 | + "ports": [ { "port": 10, "speed": 100000, "type": "FIBER" }, { "port": 20, "speed": 0, "type": "FIBER" }, { "port": 22, "speed": 0, "type": "FIBER" } ] |
8 | }, | 8 | }, |
9 | { | 9 | { |
10 | "uri": "of:0000ffffffffff02", "mac": "ffffffffffff02", "type": "ROADM", | 10 | "uri": "of:0000ffffffffff02", "mac": "ffffffffffff02", "type": "ROADM", |
11 | "mfr": "Linc", "hw": "OE", "sw": "?", "serial": "?", "name": "ROADM2", | 11 | "mfr": "Linc", "hw": "OE", "sw": "?", "serial": "?", "name": "ROADM2", |
12 | - "annotations": { "latitude": 37.3, "longitude": 121.9, "optical.regens": 0 }, | 12 | + "annotations": { "latitude": 37.3, "longitude": -121.9, "optical.regens": 0 }, |
13 | - "ports": [ { "port": 11, "speed": 100000, "type": "FIBER" }, { "port": 21, "speed": 0, "type": "FIBER" }, { "port": 22, "speed": 0, "type": "FIBER" }] | 13 | + "ports": [ { "port": 11, "speed": 100000, "type": "FIBER" }, { "port": 21, "speed": 0, "type": "FIBER" }, { "port": 22, "speed": 0, "type": "FIBER" } ] |
14 | }, | 14 | }, |
15 | { | 15 | { |
16 | "uri": "of:0000ffffffffff03", "mac": "ffffffffffff03", "type": "ROADM", | 16 | "uri": "of:0000ffffffffff03", "mac": "ffffffffffff03", "type": "ROADM", |
17 | "mfr": "Linc", "hw": "OE", "sw": "?", "serial": "?", "name": "ROADM3", | 17 | "mfr": "Linc", "hw": "OE", "sw": "?", "serial": "?", "name": "ROADM3", |
18 | - "annotations": { "latitude": 33.9, "longitude": 118.4, "optical.regens": 2 }, | 18 | + "annotations": { "latitude": 33.9, "longitude": -118.4, "optical.regens": 2 }, |
19 | - "ports": [ { "port": 30, "speed": 0, "type": "FIBER" }, { "port": 31, "speed": 0, "type": "FIBER" }] | 19 | + "ports": [ { "port": 30, "speed": 0, "type": "FIBER" }, { "port": 31, "speed": 0, "type": "FIBER" } ] |
20 | }, | 20 | }, |
21 | - { | 21 | + { |
22 | "uri": "of:0000ffffffffff04", "mac": "ffffffffffff04", "type":"ROADM", | 22 | "uri": "of:0000ffffffffff04", "mac": "ffffffffffff04", "type":"ROADM", |
23 | "mfr": "Linc", "hw": "OE", "sw": "?", "serial": "?", "name": "ROADM4", | 23 | "mfr": "Linc", "hw": "OE", "sw": "?", "serial": "?", "name": "ROADM4", |
24 | - "annotations": { "latitude": 39.9, "longitude": 119.4, "optical.regens": 2 }, | 24 | + "annotations": { "latitude": 39.9, "longitude": -119.4, "optical.regens": 2 }, |
25 | - "ports": [ { "port": 30, "speed": 0, "type": "FIBER" }, { "port": 31, "speed": 0, "type": "FIBER" }] | 25 | + "ports": [ { "port": 30, "speed": 0, "type": "FIBER" }, { "port": 31, "speed": 0, "type": "FIBER" } ] |
26 | }, | 26 | }, |
27 | { | 27 | { |
28 | "uri": "of:0000ffffffff0001", "mac": "ffffffffff0001", "type": "SWITCH", | 28 | "uri": "of:0000ffffffff0001", "mac": "ffffffffff0001", "type": "SWITCH", |
29 | "mfr": "Linc", "hw": "PK", "sw": "?", "serial": "?", "name": "ROUTER1", | 29 | "mfr": "Linc", "hw": "PK", "sw": "?", "serial": "?", "name": "ROUTER1", |
30 | - "annotations": { "latitude": 37.6, "longitude": 122.3 }, | 30 | + "annotations": { "latitude": 37.6, "longitude": -122.3 }, |
31 | "ports": [ { "port": 1, "speed": 10000, "type": "COPPER" }, { "port": 2, "speed": 100000, "type": "FIBER" } ] | 31 | "ports": [ { "port": 1, "speed": 10000, "type": "COPPER" }, { "port": 2, "speed": 100000, "type": "FIBER" } ] |
32 | }, | 32 | }, |
33 | { | 33 | { |
34 | "uri": "of:0000ffffffff0002", "mac": "ffffffffff0002", "type": "SWITCH", | 34 | "uri": "of:0000ffffffff0002", "mac": "ffffffffff0002", "type": "SWITCH", |
35 | "mfr": "Linc", "hw": "PK", "sw": "?", "serial": "?", "name": "ROUTER2", | 35 | "mfr": "Linc", "hw": "PK", "sw": "?", "serial": "?", "name": "ROUTER2", |
36 | - "annotations": { "latitude": 37.3, "longitude": 121.9 }, | 36 | + "annotations": { "latitude": 37.3, "longitude": -121.9 }, |
37 | "ports": [ { "port": 1, "speed": 10000, "type": "COPPER" }, { "port": 2, "speed": 100000, "type": "FIBER" } ] | 37 | "ports": [ { "port": 1, "speed": 10000, "type": "COPPER" }, { "port": 2, "speed": 100000, "type": "FIBER" } ] |
38 | } | 38 | } |
39 | ], | 39 | ], |
... | @@ -49,3 +49,4 @@ | ... | @@ -49,3 +49,4 @@ |
49 | ] | 49 | ] |
50 | 50 | ||
51 | } | 51 | } |
52 | + | ... | ... |
... | @@ -21,6 +21,8 @@ import org.onlab.onos.net.device.DeviceProviderRegistry; | ... | @@ -21,6 +21,8 @@ import org.onlab.onos.net.device.DeviceProviderRegistry; |
21 | import org.onlab.onos.net.host.HostProviderRegistry; | 21 | import org.onlab.onos.net.host.HostProviderRegistry; |
22 | import org.onlab.onos.net.link.LinkProviderRegistry; | 22 | import org.onlab.onos.net.link.LinkProviderRegistry; |
23 | import org.onlab.rest.BaseResource; | 23 | import org.onlab.rest.BaseResource; |
24 | +import org.slf4j.Logger; | ||
25 | +import org.slf4j.LoggerFactory; | ||
24 | 26 | ||
25 | import javax.ws.rs.Consumes; | 27 | import javax.ws.rs.Consumes; |
26 | import javax.ws.rs.POST; | 28 | import javax.ws.rs.POST; |
... | @@ -31,6 +33,8 @@ import javax.ws.rs.core.Response; | ... | @@ -31,6 +33,8 @@ import javax.ws.rs.core.Response; |
31 | import java.io.IOException; | 33 | import java.io.IOException; |
32 | import java.io.InputStream; | 34 | import java.io.InputStream; |
33 | 35 | ||
36 | +import static javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR; | ||
37 | + | ||
34 | /** | 38 | /** |
35 | * Resource that acts as an ancillary provider for uploading pre-configured | 39 | * Resource that acts as an ancillary provider for uploading pre-configured |
36 | * devices, ports and links. | 40 | * devices, ports and links. |
... | @@ -38,17 +42,24 @@ import java.io.InputStream; | ... | @@ -38,17 +42,24 @@ import java.io.InputStream; |
38 | @Path("config") | 42 | @Path("config") |
39 | public class ConfigResource extends BaseResource { | 43 | public class ConfigResource extends BaseResource { |
40 | 44 | ||
45 | + private static Logger log = LoggerFactory.getLogger(ConfigResource.class); | ||
46 | + | ||
41 | @POST | 47 | @POST |
42 | @Path("topology") | 48 | @Path("topology") |
43 | @Consumes(MediaType.APPLICATION_JSON) | 49 | @Consumes(MediaType.APPLICATION_JSON) |
44 | @Produces(MediaType.APPLICATION_JSON) | 50 | @Produces(MediaType.APPLICATION_JSON) |
45 | public Response topology(InputStream input) throws IOException { | 51 | public Response topology(InputStream input) throws IOException { |
46 | - ObjectMapper mapper = new ObjectMapper(); | 52 | + try { |
47 | - JsonNode cfg = mapper.readTree(input); | 53 | + ObjectMapper mapper = new ObjectMapper(); |
48 | - new ConfigProvider(cfg, get(DeviceProviderRegistry.class), | 54 | + JsonNode cfg = mapper.readTree(input); |
49 | - get(LinkProviderRegistry.class), | 55 | + new ConfigProvider(cfg, get(DeviceProviderRegistry.class), |
50 | - get(HostProviderRegistry.class)).parse(); | 56 | + get(LinkProviderRegistry.class), |
51 | - return Response.ok(mapper.createObjectNode().toString()).build(); | 57 | + get(HostProviderRegistry.class)).parse(); |
58 | + return Response.ok(mapper.createObjectNode().toString()).build(); | ||
59 | + } catch (Exception e) { | ||
60 | + log.error("Unable to parse topology configuration", e); | ||
61 | + return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString()).build(); | ||
62 | + } | ||
52 | } | 63 | } |
53 | 64 | ||
54 | } | 65 | } | ... | ... |
... | @@ -40,7 +40,12 @@ import org.onlab.onos.net.device.DeviceEvent; | ... | @@ -40,7 +40,12 @@ import org.onlab.onos.net.device.DeviceEvent; |
40 | import org.onlab.onos.net.device.DeviceService; | 40 | import org.onlab.onos.net.device.DeviceService; |
41 | import org.onlab.onos.net.host.HostEvent; | 41 | import org.onlab.onos.net.host.HostEvent; |
42 | import org.onlab.onos.net.host.HostService; | 42 | import org.onlab.onos.net.host.HostService; |
43 | +import org.onlab.onos.net.intent.ConnectivityIntent; | ||
44 | +import org.onlab.onos.net.intent.Intent; | ||
43 | import org.onlab.onos.net.intent.IntentService; | 45 | import org.onlab.onos.net.intent.IntentService; |
46 | +import org.onlab.onos.net.intent.IntentState; | ||
47 | +import org.onlab.onos.net.intent.LinkCollectionIntent; | ||
48 | +import org.onlab.onos.net.intent.PathIntent; | ||
44 | import org.onlab.onos.net.link.LinkEvent; | 49 | import org.onlab.onos.net.link.LinkEvent; |
45 | import org.onlab.onos.net.link.LinkService; | 50 | import org.onlab.onos.net.link.LinkService; |
46 | import org.onlab.onos.net.provider.ProviderId; | 51 | import org.onlab.onos.net.provider.ProviderId; |
... | @@ -50,6 +55,7 @@ import org.slf4j.Logger; | ... | @@ -50,6 +55,7 @@ import org.slf4j.Logger; |
50 | import org.slf4j.LoggerFactory; | 55 | import org.slf4j.LoggerFactory; |
51 | 56 | ||
52 | import java.util.Iterator; | 57 | import java.util.Iterator; |
58 | +import java.util.List; | ||
53 | import java.util.Map; | 59 | import java.util.Map; |
54 | import java.util.Set; | 60 | import java.util.Set; |
55 | import java.util.concurrent.ConcurrentHashMap; | 61 | import java.util.concurrent.ConcurrentHashMap; |
... | @@ -350,7 +356,7 @@ public abstract class TopologyMessages { | ... | @@ -350,7 +356,7 @@ public abstract class TopologyMessages { |
350 | new Prop("Longitude", annot.value("longitude")))); | 356 | new Prop("Longitude", annot.value("longitude")))); |
351 | } | 357 | } |
352 | 358 | ||
353 | - // Produces a path message to the client. | 359 | + // Produces a path payload to the client. |
354 | protected ObjectNode pathMessage(Path path, String type) { | 360 | protected ObjectNode pathMessage(Path path, String type) { |
355 | ObjectNode payload = mapper.createObjectNode(); | 361 | ObjectNode payload = mapper.createObjectNode(); |
356 | ArrayNode links = mapper.createArrayNode(); | 362 | ArrayNode links = mapper.createArrayNode(); |
... | @@ -362,6 +368,50 @@ public abstract class TopologyMessages { | ... | @@ -362,6 +368,50 @@ public abstract class TopologyMessages { |
362 | return payload; | 368 | return payload; |
363 | } | 369 | } |
364 | 370 | ||
371 | + | ||
372 | + // Produces JSON message to trigger traffic visualization | ||
373 | + protected ObjectNode trafficMessage(Set<Intent> intents, long sid) { | ||
374 | + ObjectNode payload = mapper.createObjectNode(); | ||
375 | + ArrayNode paths = mapper.createArrayNode(); | ||
376 | + payload.set("paths", paths); | ||
377 | + | ||
378 | + for (Intent intent : intents) { | ||
379 | + List<Intent> installables = intentService.getInstallableIntents(intent.id()); | ||
380 | + IntentState state = intentService.getIntentState(intent.id()); | ||
381 | + String type = state == IntentState.FAILED ? "inactive" : "active"; | ||
382 | + for (Intent installable : installables) { | ||
383 | + if (installable instanceof ConnectivityIntent) { | ||
384 | + addPathTraffic(paths, type, (ConnectivityIntent) installable); | ||
385 | + } | ||
386 | + } | ||
387 | + } | ||
388 | + | ||
389 | + return envelope("showTraffic", sid, payload); | ||
390 | + } | ||
391 | + | ||
392 | + // Adds the link segments (path or tree) associated with the specified | ||
393 | + // connectivity intent | ||
394 | + protected void addPathTraffic(ArrayNode paths, String type, | ||
395 | + ConnectivityIntent installable) { | ||
396 | + ObjectNode pathNode = mapper.createObjectNode(); | ||
397 | + ArrayNode linksNode = mapper.createArrayNode(); | ||
398 | + | ||
399 | + Iterable<Link> links; | ||
400 | + if (installable instanceof PathIntent) { | ||
401 | + links = ((PathIntent) installable).path().links(); | ||
402 | + } else if (installable instanceof LinkCollectionIntent) { | ||
403 | + links = ((LinkCollectionIntent) installable).links(); | ||
404 | + } else { | ||
405 | + return; | ||
406 | + } | ||
407 | + | ||
408 | + for (Link link : links) { | ||
409 | + linksNode.add(compactLinkString(link)); | ||
410 | + } | ||
411 | + pathNode.put("type", type).set("links", linksNode); | ||
412 | + paths.add(pathNode); | ||
413 | + } | ||
414 | + | ||
365 | // Produces compact string representation of a link. | 415 | // Produces compact string representation of a link. |
366 | private static String compactLinkString(Link link) { | 416 | private static String compactLinkString(Link link) { |
367 | return String.format(COMPACT, link.src().elementId(), link.src().port(), | 417 | return String.format(COMPACT, link.src().elementId(), link.src().port(), | ... | ... |
... | @@ -15,6 +15,8 @@ | ... | @@ -15,6 +15,8 @@ |
15 | */ | 15 | */ |
16 | package org.onlab.onos.gui; | 16 | package org.onlab.onos.gui; |
17 | 17 | ||
18 | +import com.fasterxml.jackson.databind.JsonNode; | ||
19 | +import com.fasterxml.jackson.databind.node.ArrayNode; | ||
18 | import com.fasterxml.jackson.databind.node.ObjectNode; | 20 | import com.fasterxml.jackson.databind.node.ObjectNode; |
19 | import org.eclipse.jetty.websocket.WebSocket; | 21 | import org.eclipse.jetty.websocket.WebSocket; |
20 | import org.onlab.onos.cluster.ClusterEvent; | 22 | import org.onlab.onos.cluster.ClusterEvent; |
... | @@ -24,6 +26,7 @@ import org.onlab.onos.core.ApplicationId; | ... | @@ -24,6 +26,7 @@ import org.onlab.onos.core.ApplicationId; |
24 | import org.onlab.onos.core.CoreService; | 26 | import org.onlab.onos.core.CoreService; |
25 | import org.onlab.onos.mastership.MastershipEvent; | 27 | import org.onlab.onos.mastership.MastershipEvent; |
26 | import org.onlab.onos.mastership.MastershipListener; | 28 | import org.onlab.onos.mastership.MastershipListener; |
29 | +import org.onlab.onos.net.ConnectPoint; | ||
27 | import org.onlab.onos.net.Device; | 30 | import org.onlab.onos.net.Device; |
28 | import org.onlab.onos.net.Host; | 31 | import org.onlab.onos.net.Host; |
29 | import org.onlab.onos.net.HostId; | 32 | import org.onlab.onos.net.HostId; |
... | @@ -38,16 +41,19 @@ import org.onlab.onos.net.host.HostListener; | ... | @@ -38,16 +41,19 @@ import org.onlab.onos.net.host.HostListener; |
38 | import org.onlab.onos.net.intent.HostToHostIntent; | 41 | import org.onlab.onos.net.intent.HostToHostIntent; |
39 | import org.onlab.onos.net.intent.Intent; | 42 | import org.onlab.onos.net.intent.Intent; |
40 | import org.onlab.onos.net.intent.IntentEvent; | 43 | import org.onlab.onos.net.intent.IntentEvent; |
41 | -import org.onlab.onos.net.intent.IntentId; | ||
42 | import org.onlab.onos.net.intent.IntentListener; | 44 | import org.onlab.onos.net.intent.IntentListener; |
45 | +import org.onlab.onos.net.intent.MultiPointToSinglePointIntent; | ||
43 | import org.onlab.onos.net.intent.PathIntent; | 46 | import org.onlab.onos.net.intent.PathIntent; |
47 | +import org.onlab.onos.net.intent.PointToPointIntent; | ||
44 | import org.onlab.onos.net.link.LinkEvent; | 48 | import org.onlab.onos.net.link.LinkEvent; |
45 | import org.onlab.onos.net.link.LinkListener; | 49 | import org.onlab.onos.net.link.LinkListener; |
46 | import org.onlab.osgi.ServiceDirectory; | 50 | import org.onlab.osgi.ServiceDirectory; |
47 | 51 | ||
48 | import java.io.IOException; | 52 | import java.io.IOException; |
53 | +import java.util.HashSet; | ||
49 | import java.util.List; | 54 | import java.util.List; |
50 | import java.util.Map; | 55 | import java.util.Map; |
56 | +import java.util.Set; | ||
51 | import java.util.concurrent.ConcurrentHashMap; | 57 | import java.util.concurrent.ConcurrentHashMap; |
52 | 58 | ||
53 | import static org.onlab.onos.cluster.ClusterEvent.Type.INSTANCE_ADDED; | 59 | import static org.onlab.onos.cluster.ClusterEvent.Type.INSTANCE_ADDED; |
... | @@ -85,9 +91,10 @@ public class TopologyWebSocket | ... | @@ -85,9 +91,10 @@ public class TopologyWebSocket |
85 | private final IntentListener intentListener = new InternalIntentListener(); | 91 | private final IntentListener intentListener = new InternalIntentListener(); |
86 | 92 | ||
87 | // Intents that are being monitored for the GUI | 93 | // Intents that are being monitored for the GUI |
88 | - private static Map<IntentId, Long> intentsToMonitor = new ConcurrentHashMap<>(); | 94 | + private static Map<Intent, Long> intentsToMonitor = new ConcurrentHashMap<>(); |
89 | 95 | ||
90 | private long lastActive = System.currentTimeMillis(); | 96 | private long lastActive = System.currentTimeMillis(); |
97 | + private boolean listenersRemoved = false; | ||
91 | 98 | ||
92 | /** | 99 | /** |
93 | * Creates a new web-socket for serving data to GUI topology view. | 100 | * Creates a new web-socket for serving data to GUI topology view. |
... | @@ -103,8 +110,8 @@ public class TopologyWebSocket | ... | @@ -103,8 +110,8 @@ public class TopologyWebSocket |
103 | * Issues a close on the connection. | 110 | * Issues a close on the connection. |
104 | */ | 111 | */ |
105 | synchronized void close() { | 112 | synchronized void close() { |
113 | + removeListeners(); | ||
106 | if (connection.isOpen()) { | 114 | if (connection.isOpen()) { |
107 | - removeListeners(); | ||
108 | connection.close(); | 115 | connection.close(); |
109 | } | 116 | } |
110 | } | 117 | } |
... | @@ -140,9 +147,7 @@ public class TopologyWebSocket | ... | @@ -140,9 +147,7 @@ public class TopologyWebSocket |
140 | 147 | ||
141 | @Override | 148 | @Override |
142 | public synchronized void onClose(int closeCode, String message) { | 149 | public synchronized void onClose(int closeCode, String message) { |
143 | - if (connection.isOpen()) { | 150 | + removeListeners(); |
144 | - removeListeners(); | ||
145 | - } | ||
146 | log.info("GUI client disconnected"); | 151 | log.info("GUI client disconnected"); |
147 | } | 152 | } |
148 | 153 | ||
... | @@ -165,7 +170,7 @@ public class TopologyWebSocket | ... | @@ -165,7 +170,7 @@ public class TopologyWebSocket |
165 | } else if (type.equals("requestPath")) { | 170 | } else if (type.equals("requestPath")) { |
166 | createHostIntent(event); | 171 | createHostIntent(event); |
167 | } else if (type.equals("requestTraffic")) { | 172 | } else if (type.equals("requestTraffic")) { |
168 | - sendTraffic(event); | 173 | + requestTraffic(event); |
169 | } else if (type.equals("cancelTraffic")) { | 174 | } else if (type.equals("cancelTraffic")) { |
170 | cancelTraffic(event); | 175 | cancelTraffic(event); |
171 | } | 176 | } |
... | @@ -217,12 +222,12 @@ public class TopologyWebSocket | ... | @@ -217,12 +222,12 @@ public class TopologyWebSocket |
217 | private void requestDetails(ObjectNode event) { | 222 | private void requestDetails(ObjectNode event) { |
218 | ObjectNode payload = payload(event); | 223 | ObjectNode payload = payload(event); |
219 | String type = string(payload, "class", "unknown"); | 224 | String type = string(payload, "class", "unknown"); |
225 | + long sid = number(event, "sid"); | ||
226 | + | ||
220 | if (type.equals("device")) { | 227 | if (type.equals("device")) { |
221 | - sendMessage(deviceDetails(deviceId(string(payload, "id")), | 228 | + sendMessage(deviceDetails(deviceId(string(payload, "id")), sid)); |
222 | - number(event, "sid"))); | ||
223 | } else if (type.equals("host")) { | 229 | } else if (type.equals("host")) { |
224 | - sendMessage(hostDetails(hostId(string(payload, "id")), | 230 | + sendMessage(hostDetails(hostId(string(payload, "id")), sid)); |
225 | - number(event, "sid"))); | ||
226 | } | 231 | } |
227 | } | 232 | } |
228 | 233 | ||
... | @@ -237,27 +242,137 @@ public class TopologyWebSocket | ... | @@ -237,27 +242,137 @@ public class TopologyWebSocket |
237 | HostToHostIntent hostIntent = new HostToHostIntent(appId, one, two, | 242 | HostToHostIntent hostIntent = new HostToHostIntent(appId, one, two, |
238 | DefaultTrafficSelector.builder().build(), | 243 | DefaultTrafficSelector.builder().build(), |
239 | DefaultTrafficTreatment.builder().build()); | 244 | DefaultTrafficTreatment.builder().build()); |
240 | - intentsToMonitor.put(hostIntent.id(), number(event, "sid")); | 245 | + intentsToMonitor.put(hostIntent, number(event, "sid")); |
241 | intentService.submit(hostIntent); | 246 | intentService.submit(hostIntent); |
242 | } | 247 | } |
243 | 248 | ||
244 | // Sends traffic message. | 249 | // Sends traffic message. |
245 | - private void sendTraffic(ObjectNode event) { | 250 | + private void requestTraffic(ObjectNode event) { |
246 | ObjectNode payload = payload(event); | 251 | ObjectNode payload = payload(event); |
247 | - long id = number(event, "sid"); | 252 | + long sid = number(event, "sid"); |
248 | - IntentId intentId = IntentId.valueOf(payload.path("intentId").asLong()); | 253 | + Set<Intent> intents = findPathIntents(payload); |
249 | 254 | ||
250 | - if (payload != null) { | 255 | + // Add all those intents to the list of monitored intents & flows. |
251 | - payload.put("traffic", true); | 256 | + intentsToMonitor.clear(); |
252 | - sendMessage(envelope("showPath", id, payload)); | 257 | + for (Intent intent : intents) { |
253 | - } else { | 258 | + intentsToMonitor.put(intent, sid); |
254 | - sendMessage(warning(id, "No path found")); | ||
255 | } | 259 | } |
260 | + | ||
261 | + // Send an initial message to highlight all links of all monitored intents. | ||
262 | + sendMessage(trafficMessage(intents, sid)); | ||
256 | } | 263 | } |
257 | 264 | ||
258 | // Cancels sending traffic messages. | 265 | // Cancels sending traffic messages. |
259 | private void cancelTraffic(ObjectNode event) { | 266 | private void cancelTraffic(ObjectNode event) { |
260 | - // TODO: implement this | 267 | + ObjectNode payload = payload(event); |
268 | + long sid = number(event, "sid"); | ||
269 | + Set<Intent> intents = findPathIntents(payload); | ||
270 | + | ||
271 | + // Remove all those intents from the list of monitored intents & flows. | ||
272 | + intentsToMonitor.clear(); // TODO: remove when ready | ||
273 | + for (Intent intent : intents) { | ||
274 | + intentsToMonitor.remove(intent.id()); | ||
275 | + } | ||
276 | + sendMessage(trafficMessage(intents, sid)); | ||
277 | + } | ||
278 | + | ||
279 | + // Finds all path (host-to-host or point-to-point) intents that pertains | ||
280 | + // to the hosts indicated in the given event payload. | ||
281 | + private Set<Intent> findPathIntents(ObjectNode payload) { | ||
282 | + // Get the list of selected hosts. | ||
283 | + Set<Host> hosts = getHosts((ArrayNode) payload.path("ids")); | ||
284 | + | ||
285 | + // Derive from this the set of edge connect points. | ||
286 | + Set<ConnectPoint> edgePoints = getEdgePoints(hosts); | ||
287 | + | ||
288 | + // Iterate over all intents and produce a set that contains only those | ||
289 | + // intents that target all selected hosts or derived edge connect points. | ||
290 | + return getIntents(hosts, edgePoints); | ||
291 | + } | ||
292 | + | ||
293 | + // Produces a set of intents that target all selected hosts or connect points. | ||
294 | + private Set<Intent> getIntents(Set<Host> hosts, Set<ConnectPoint> edgePoints) { | ||
295 | + Set<Intent> intents = new HashSet<>(); | ||
296 | + for (Intent intent : intentService.getIntents()) { | ||
297 | + boolean isRelevant = false; | ||
298 | + if (intent instanceof HostToHostIntent) { | ||
299 | + isRelevant = isIntentRelevant((HostToHostIntent) intent, hosts); | ||
300 | + } else if (intent instanceof PointToPointIntent) { | ||
301 | + isRelevant = isIntentRelevant((PointToPointIntent) intent, edgePoints); | ||
302 | + } else if (intent instanceof MultiPointToSinglePointIntent) { | ||
303 | + isRelevant = isIntentRelevant((MultiPointToSinglePointIntent) intent, edgePoints); | ||
304 | + } | ||
305 | + // TODO: add other intents, e.g. SinglePointToMultiPointIntent | ||
306 | + | ||
307 | + if (isRelevant) { | ||
308 | + intents.add(intent); | ||
309 | + } | ||
310 | + } | ||
311 | + return intents; | ||
312 | + } | ||
313 | + | ||
314 | + // Indicates whether the specified intent involves all of the given hosts. | ||
315 | + private boolean isIntentRelevant(HostToHostIntent intent, Set<Host> hosts) { | ||
316 | + for (Host host : hosts) { | ||
317 | + HostId id = host.id(); | ||
318 | + // Bail if intent does not involve this host. | ||
319 | + if (!id.equals(intent.one()) && !id.equals(intent.two())) { | ||
320 | + return false; | ||
321 | + } | ||
322 | + } | ||
323 | + return true; | ||
324 | + } | ||
325 | + | ||
326 | + // Indicates whether the specified intent involves all of the given edge points. | ||
327 | + private boolean isIntentRelevant(PointToPointIntent intent, | ||
328 | + Set<ConnectPoint> edgePoints) { | ||
329 | + for (ConnectPoint point : edgePoints) { | ||
330 | + // Bail if intent does not involve this edge point. | ||
331 | + if (!point.equals(intent.egressPoint()) && | ||
332 | + !point.equals(intent.ingressPoint())) { | ||
333 | + return false; | ||
334 | + } | ||
335 | + } | ||
336 | + return true; | ||
337 | + } | ||
338 | + | ||
339 | + // Indicates whether the specified intent involves all of the given edge points. | ||
340 | + private boolean isIntentRelevant(MultiPointToSinglePointIntent intent, | ||
341 | + Set<ConnectPoint> edgePoints) { | ||
342 | + for (ConnectPoint point : edgePoints) { | ||
343 | + // Bail if intent does not involve this edge point. | ||
344 | + if (!point.equals(intent.egressPoint()) && | ||
345 | + !intent.ingressPoints().contains(point)) { | ||
346 | + return false; | ||
347 | + } | ||
348 | + } | ||
349 | + return true; | ||
350 | + } | ||
351 | + | ||
352 | + | ||
353 | + // Produces a set of all host ids listed in the specified JSON array. | ||
354 | + private Set<Host> getHosts(ArrayNode array) { | ||
355 | + Set<Host> hosts = new HashSet<>(); | ||
356 | + for (JsonNode node : array) { | ||
357 | + try { | ||
358 | + Host host = hostService.getHost(hostId(node.asText())); | ||
359 | + if (host != null) { | ||
360 | + hosts.add(host); | ||
361 | + } | ||
362 | + } catch (IllegalArgumentException e) { | ||
363 | + log.debug("Skipping ID {}", node.asText()); | ||
364 | + } | ||
365 | + } | ||
366 | + return hosts; | ||
367 | + } | ||
368 | + | ||
369 | + // Produces a set of edge points from the specified set of hosts. | ||
370 | + private Set<ConnectPoint> getEdgePoints(Set<Host> hosts) { | ||
371 | + Set<ConnectPoint> edgePoints = new HashSet<>(); | ||
372 | + for (Host host : hosts) { | ||
373 | + edgePoints.add(host.location()); | ||
374 | + } | ||
375 | + return edgePoints; | ||
261 | } | 376 | } |
262 | 377 | ||
263 | 378 | ||
... | @@ -272,13 +387,16 @@ public class TopologyWebSocket | ... | @@ -272,13 +387,16 @@ public class TopologyWebSocket |
272 | } | 387 | } |
273 | 388 | ||
274 | // Removes all internal listeners. | 389 | // Removes all internal listeners. |
275 | - private void removeListeners() { | 390 | + private synchronized void removeListeners() { |
276 | - clusterService.removeListener(clusterListener); | 391 | + if (!listenersRemoved) { |
277 | - deviceService.removeListener(deviceListener); | 392 | + listenersRemoved = true; |
278 | - linkService.removeListener(linkListener); | 393 | + clusterService.removeListener(clusterListener); |
279 | - hostService.removeListener(hostListener); | 394 | + deviceService.removeListener(deviceListener); |
280 | - mastershipService.removeListener(mastershipListener); | 395 | + linkService.removeListener(linkListener); |
281 | - intentService.removeListener(intentListener); | 396 | + hostService.removeListener(hostListener); |
397 | + mastershipService.removeListener(mastershipListener); | ||
398 | + intentService.removeListener(intentListener); | ||
399 | + } | ||
282 | } | 400 | } |
283 | 401 | ||
284 | // Cluster event listener. | 402 | // Cluster event listener. |
... | @@ -327,7 +445,7 @@ public class TopologyWebSocket | ... | @@ -327,7 +445,7 @@ public class TopologyWebSocket |
327 | @Override | 445 | @Override |
328 | public void event(IntentEvent event) { | 446 | public void event(IntentEvent event) { |
329 | Intent intent = event.subject(); | 447 | Intent intent = event.subject(); |
330 | - Long sid = intentsToMonitor.get(intent.id()); | 448 | + Long sid = intentsToMonitor.get(intent); |
331 | if (sid != null) { | 449 | if (sid != null) { |
332 | List<Intent> installable = intentService.getInstallableIntents(intent.id()); | 450 | List<Intent> installable = intentService.getInstallableIntents(intent.id()); |
333 | if (installable != null && !installable.isEmpty()) { | 451 | if (installable != null && !installable.isEmpty()) { | ... | ... |
... | @@ -130,8 +130,8 @@ | ... | @@ -130,8 +130,8 @@ |
130 | U: unpin, | 130 | U: unpin, |
131 | 131 | ||
132 | W: requestTraffic, // bag of selections | 132 | W: requestTraffic, // bag of selections |
133 | - Z: requestPath, // host-to-host intent (and monitor) | 133 | + X: cancelTraffic, |
134 | - X: cancelMonitor | 134 | + Z: requestPath // host-to-host intent (and monitor) |
135 | }; | 135 | }; |
136 | 136 | ||
137 | // state variables | 137 | // state variables |
... | @@ -496,7 +496,23 @@ | ... | @@ -496,7 +496,23 @@ |
496 | } | 496 | } |
497 | 497 | ||
498 | function showTraffic(data) { | 498 | function showTraffic(data) { |
499 | - network.view.alert("showTraffic() -- TODO") | 499 | + fnTrace('showTraffic', data.payload.id); |
500 | + data.payload.paths.forEach(function () { | ||
501 | + var links = data.payload.links, | ||
502 | + s = [ data.event + "\n" + links.length ]; | ||
503 | + links.forEach(function (d, i) { | ||
504 | + s.push(d); | ||
505 | + }); | ||
506 | + network.view.alert(s.join('\n')); | ||
507 | + | ||
508 | + links.forEach(function (d, i) { | ||
509 | + var link = network.lookup[d]; | ||
510 | + if (link) { | ||
511 | + link.el.classed('showPath', true); | ||
512 | + } | ||
513 | + }); | ||
514 | + }); | ||
515 | + //network.view.alert("showTraffic() -- TODO") | ||
500 | } | 516 | } |
501 | 517 | ||
502 | // ............................... | 518 | // ............................... |
... | @@ -566,9 +582,9 @@ | ... | @@ -566,9 +582,9 @@ |
566 | } | 582 | } |
567 | } | 583 | } |
568 | 584 | ||
569 | - function cancelMonitor() { | 585 | + function cancelTraffic() { |
570 | // FIXME: from where do we get the intent id(s) to send to the server? | 586 | // FIXME: from where do we get the intent id(s) to send to the server? |
571 | - sendMessage('cancelMonitor', { | 587 | + sendMessage('cancelTraffic', { |
572 | ids: ["need_the_intent_id"] | 588 | ids: ["need_the_intent_id"] |
573 | }); | 589 | }); |
574 | } | 590 | } | ... | ... |
-
Please register or login to post a comment