Showing
4 changed files
with
46 additions
and
13 deletions
| 1 | package org.onlab.onos.ifwd; | 1 | package org.onlab.onos.ifwd; |
| 2 | 2 | ||
| 3 | -import static org.slf4j.LoggerFactory.getLogger; | ||
| 4 | - | ||
| 5 | import org.apache.felix.scr.annotations.Activate; | 3 | import org.apache.felix.scr.annotations.Activate; |
| 6 | import org.apache.felix.scr.annotations.Component; | 4 | import org.apache.felix.scr.annotations.Component; |
| 7 | import org.apache.felix.scr.annotations.Deactivate; | 5 | import org.apache.felix.scr.annotations.Deactivate; |
| 8 | import org.apache.felix.scr.annotations.Reference; | 6 | import org.apache.felix.scr.annotations.Reference; |
| 9 | import org.apache.felix.scr.annotations.ReferenceCardinality; | 7 | import org.apache.felix.scr.annotations.ReferenceCardinality; |
| 10 | -import org.onlab.onos.ApplicationId; | ||
| 11 | import org.onlab.onos.net.Host; | 8 | import org.onlab.onos.net.Host; |
| 12 | import org.onlab.onos.net.HostId; | 9 | import org.onlab.onos.net.HostId; |
| 13 | import org.onlab.onos.net.PortNumber; | 10 | import org.onlab.onos.net.PortNumber; |
| ... | @@ -29,6 +26,8 @@ import org.onlab.onos.net.topology.TopologyService; | ... | @@ -29,6 +26,8 @@ import org.onlab.onos.net.topology.TopologyService; |
| 29 | import org.onlab.packet.Ethernet; | 26 | import org.onlab.packet.Ethernet; |
| 30 | import org.slf4j.Logger; | 27 | import org.slf4j.Logger; |
| 31 | 28 | ||
| 29 | +import static org.slf4j.LoggerFactory.getLogger; | ||
| 30 | + | ||
| 32 | /** | 31 | /** |
| 33 | * WORK-IN-PROGRESS: Sample reactive forwarding application using intent framework. | 32 | * WORK-IN-PROGRESS: Sample reactive forwarding application using intent framework. |
| 34 | */ | 33 | */ |
| ... | @@ -51,14 +50,12 @@ public class IntentReactiveForwarding { | ... | @@ -51,14 +50,12 @@ public class IntentReactiveForwarding { |
| 51 | 50 | ||
| 52 | private ReactivePacketProcessor processor = new ReactivePacketProcessor(); | 51 | private ReactivePacketProcessor processor = new ReactivePacketProcessor(); |
| 53 | 52 | ||
| 54 | - private ApplicationId appId; | ||
| 55 | private static long intentId = 1; | 53 | private static long intentId = 1; |
| 56 | 54 | ||
| 57 | @Activate | 55 | @Activate |
| 58 | public void activate() { | 56 | public void activate() { |
| 59 | - appId = ApplicationId.getAppId(); | ||
| 60 | packetService.addProcessor(processor, PacketProcessor.ADVISOR_MAX + 2); | 57 | packetService.addProcessor(processor, PacketProcessor.ADVISOR_MAX + 2); |
| 61 | - log.info("Started with Application ID {}", appId.id()); | 58 | + log.info("Started"); |
| 62 | } | 59 | } |
| 63 | 60 | ||
| 64 | @Deactivate | 61 | @Deactivate |
| ... | @@ -68,7 +65,6 @@ public class IntentReactiveForwarding { | ... | @@ -68,7 +65,6 @@ public class IntentReactiveForwarding { |
| 68 | log.info("Stopped"); | 65 | log.info("Stopped"); |
| 69 | } | 66 | } |
| 70 | 67 | ||
| 71 | - | ||
| 72 | /** | 68 | /** |
| 73 | * Packet processor responsible for forwarding packets along their paths. | 69 | * Packet processor responsible for forwarding packets along their paths. |
| 74 | */ | 70 | */ |
| ... | @@ -120,7 +116,7 @@ public class IntentReactiveForwarding { | ... | @@ -120,7 +116,7 @@ public class IntentReactiveForwarding { |
| 120 | private void forwardPacketToDst(PacketContext context, Host dst) { | 116 | private void forwardPacketToDst(PacketContext context, Host dst) { |
| 121 | TrafficTreatment treatment = DefaultTrafficTreatment.builder().setOutput(dst.location().port()).build(); | 117 | TrafficTreatment treatment = DefaultTrafficTreatment.builder().setOutput(dst.location().port()).build(); |
| 122 | OutboundPacket packet = new DefaultOutboundPacket(dst.location().deviceId(), | 118 | OutboundPacket packet = new DefaultOutboundPacket(dst.location().deviceId(), |
| 123 | - treatment, context.inPacket().unparsed()); | 119 | + treatment, context.inPacket().unparsed()); |
| 124 | packetService.emit(packet); | 120 | packetService.emit(packet); |
| 125 | log.info("sending packet: {}", packet); | 121 | log.info("sending packet: {}", packet); |
| 126 | } | 122 | } |
| ... | @@ -138,5 +134,3 @@ public class IntentReactiveForwarding { | ... | @@ -138,5 +134,3 @@ public class IntentReactiveForwarding { |
| 138 | } | 134 | } |
| 139 | 135 | ||
| 140 | } | 136 | } |
| 141 | - | ||
| 142 | - | ... | ... |
| 1 | +package org.onlab.onos.cli.net; | ||
| 2 | + | ||
| 3 | +import org.apache.karaf.shell.console.Completer; | ||
| 4 | +import org.apache.karaf.shell.console.completer.StringsCompleter; | ||
| 5 | +import org.onlab.onos.cli.AbstractShellCommand; | ||
| 6 | +import org.onlab.onos.net.intent.Intent; | ||
| 7 | +import org.onlab.onos.net.intent.IntentService; | ||
| 8 | + | ||
| 9 | +import java.util.Iterator; | ||
| 10 | +import java.util.List; | ||
| 11 | +import java.util.SortedSet; | ||
| 12 | + | ||
| 13 | +/** | ||
| 14 | + * Intent ID completer. | ||
| 15 | + */ | ||
| 16 | +public class IntentIdCompleter implements Completer { | ||
| 17 | + @Override | ||
| 18 | + public int complete(String buffer, int cursor, List<String> candidates) { | ||
| 19 | + // Delegate string completer | ||
| 20 | + StringsCompleter delegate = new StringsCompleter(); | ||
| 21 | + | ||
| 22 | + // Fetch our service and feed it's offerings to the string completer | ||
| 23 | + IntentService service = AbstractShellCommand.get(IntentService.class); | ||
| 24 | + Iterator<Intent> it = service.getIntents().iterator(); | ||
| 25 | + SortedSet<String> strings = delegate.getStrings(); | ||
| 26 | + while (it.hasNext()) { | ||
| 27 | + strings.add(it.next().getId().toString()); | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | + // Now let the completer do the work for figuring out what to offer. | ||
| 31 | + return delegate.complete(buffer, cursor, candidates); | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | +} |
| ... | @@ -58,6 +58,9 @@ | ... | @@ -58,6 +58,9 @@ |
| 58 | </command> | 58 | </command> |
| 59 | 59 | ||
| 60 | <command> | 60 | <command> |
| 61 | + <action class="org.onlab.onos.cli.net.IntentsListCommand"/> | ||
| 62 | + </command> | ||
| 63 | + <command> | ||
| 61 | <action class="org.onlab.onos.cli.net.AddHostToHostIntentCommand"/> | 64 | <action class="org.onlab.onos.cli.net.AddHostToHostIntentCommand"/> |
| 62 | <completers> | 65 | <completers> |
| 63 | <ref component-id="hostIdCompleter"/> | 66 | <ref component-id="hostIdCompleter"/> |
| ... | @@ -65,9 +68,9 @@ | ... | @@ -65,9 +68,9 @@ |
| 65 | </command> | 68 | </command> |
| 66 | <command> | 69 | <command> |
| 67 | <action class="org.onlab.onos.cli.net.RemoveHostToHostIntentCommand"/> | 70 | <action class="org.onlab.onos.cli.net.RemoveHostToHostIntentCommand"/> |
| 68 | - </command> | 71 | + <completers> |
| 69 | - <command> | 72 | + <ref component-id="intentIdCompleter"/> |
| 70 | - <action class="org.onlab.onos.cli.net.IntentsListCommand"/> | 73 | + </completers> |
| 71 | </command> | 74 | </command> |
| 72 | 75 | ||
| 73 | <command> | 76 | <command> |
| ... | @@ -108,6 +111,7 @@ | ... | @@ -108,6 +111,7 @@ |
| 108 | <bean id="clusterIdCompleter" class="org.onlab.onos.cli.net.ClusterIdCompleter"/> | 111 | <bean id="clusterIdCompleter" class="org.onlab.onos.cli.net.ClusterIdCompleter"/> |
| 109 | <bean id="roleCompleter" class="org.onlab.onos.cli.net.RoleCompleter"/> | 112 | <bean id="roleCompleter" class="org.onlab.onos.cli.net.RoleCompleter"/> |
| 110 | <bean id="hostIdCompleter" class="org.onlab.onos.cli.net.HostIdCompleter"/> | 113 | <bean id="hostIdCompleter" class="org.onlab.onos.cli.net.HostIdCompleter"/> |
| 114 | + <bean id="intentIdCompleter" class="org.onlab.onos.cli.net.IntentIdCompleter"/> | ||
| 111 | <bean id="flowRuleStatusCompleter" class="org.onlab.onos.cli.net.FlowRuleStatusCompleter"/> | 115 | <bean id="flowRuleStatusCompleter" class="org.onlab.onos.cli.net.FlowRuleStatusCompleter"/> |
| 112 | 116 | ||
| 113 | </blueprint> | 117 | </blueprint> | ... | ... |
| ... | @@ -32,6 +32,7 @@ alias ob='onos-build' | ... | @@ -32,6 +32,7 @@ alias ob='onos-build' |
| 32 | alias obs='onos-build-selective' | 32 | alias obs='onos-build-selective' |
| 33 | alias op='onos-package' | 33 | alias op='onos-package' |
| 34 | alias ot='onos-test' | 34 | alias ot='onos-test' |
| 35 | +alias ol='onos-log' | ||
| 35 | 36 | ||
| 36 | # Short-hand for tailing the ONOS (karaf) log | 37 | # Short-hand for tailing the ONOS (karaf) log |
| 37 | alias tl='$ONOS_ROOT/tools/dev/bin/onos-local-log' | 38 | alias tl='$ONOS_ROOT/tools/dev/bin/onos-local-log' | ... | ... |
-
Please register or login to post a comment