Toggle navigation
Toggle navigation
This project
Loading...
Sign in
홍길동
/
onos
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
tom
2014-10-04 12:06:02 -0700
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
0511a52140055670abcd9ff4a2fed5223e8019bc
0511a521
1 parent
958d381a
Added an intent completer to the command-line.
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
12 deletions
apps/ifwd/src/main/java/org/onlab/onos/ifwd/IntentReactiveForwarding.java
cli/src/main/java/org/onlab/onos/cli/net/IntentIdCompleter.java
cli/src/main/resources/OSGI-INF/blueprint/shell-config.xml
tools/dev/bash_profile
apps/ifwd/src/main/java/org/onlab/onos/ifwd/IntentReactiveForwarding.java
View file @
0511a52
package
org
.
onlab
.
onos
.
ifwd
;
import
static
org
.
slf4j
.
LoggerFactory
.
getLogger
;
import
org.apache.felix.scr.annotations.Activate
;
import
org.apache.felix.scr.annotations.Component
;
import
org.apache.felix.scr.annotations.Deactivate
;
import
org.apache.felix.scr.annotations.Reference
;
import
org.apache.felix.scr.annotations.ReferenceCardinality
;
import
org.onlab.onos.ApplicationId
;
import
org.onlab.onos.net.Host
;
import
org.onlab.onos.net.HostId
;
import
org.onlab.onos.net.PortNumber
;
...
...
@@ -29,6 +26,8 @@ import org.onlab.onos.net.topology.TopologyService;
import
org.onlab.packet.Ethernet
;
import
org.slf4j.Logger
;
import
static
org
.
slf4j
.
LoggerFactory
.
getLogger
;
/**
* WORK-IN-PROGRESS: Sample reactive forwarding application using intent framework.
*/
...
...
@@ -51,14 +50,12 @@ public class IntentReactiveForwarding {
private
ReactivePacketProcessor
processor
=
new
ReactivePacketProcessor
();
private
ApplicationId
appId
;
private
static
long
intentId
=
1
;
@Activate
public
void
activate
()
{
appId
=
ApplicationId
.
getAppId
();
packetService
.
addProcessor
(
processor
,
PacketProcessor
.
ADVISOR_MAX
+
2
);
log
.
info
(
"Started
with Application ID {}"
,
appId
.
id
()
);
log
.
info
(
"Started
"
);
}
@Deactivate
...
...
@@ -68,7 +65,6 @@ public class IntentReactiveForwarding {
log
.
info
(
"Stopped"
);
}
/**
* Packet processor responsible for forwarding packets along their paths.
*/
...
...
@@ -138,5 +134,3 @@ public class IntentReactiveForwarding {
}
}
...
...
cli/src/main/java/org/onlab/onos/cli/net/IntentIdCompleter.java
0 → 100644
View file @
0511a52
package
org
.
onlab
.
onos
.
cli
.
net
;
import
org.apache.karaf.shell.console.Completer
;
import
org.apache.karaf.shell.console.completer.StringsCompleter
;
import
org.onlab.onos.cli.AbstractShellCommand
;
import
org.onlab.onos.net.intent.Intent
;
import
org.onlab.onos.net.intent.IntentService
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.SortedSet
;
/**
* Intent ID completer.
*/
public
class
IntentIdCompleter
implements
Completer
{
@Override
public
int
complete
(
String
buffer
,
int
cursor
,
List
<
String
>
candidates
)
{
// Delegate string completer
StringsCompleter
delegate
=
new
StringsCompleter
();
// Fetch our service and feed it's offerings to the string completer
IntentService
service
=
AbstractShellCommand
.
get
(
IntentService
.
class
);
Iterator
<
Intent
>
it
=
service
.
getIntents
().
iterator
();
SortedSet
<
String
>
strings
=
delegate
.
getStrings
();
while
(
it
.
hasNext
())
{
strings
.
add
(
it
.
next
().
getId
().
toString
());
}
// Now let the completer do the work for figuring out what to offer.
return
delegate
.
complete
(
buffer
,
cursor
,
candidates
);
}
}
cli/src/main/resources/OSGI-INF/blueprint/shell-config.xml
View file @
0511a52
...
...
@@ -58,6 +58,9 @@
</command>
<command>
<action
class=
"org.onlab.onos.cli.net.IntentsListCommand"
/>
</command>
<command>
<action
class=
"org.onlab.onos.cli.net.AddHostToHostIntentCommand"
/>
<completers>
<ref
component-id=
"hostIdCompleter"
/>
...
...
@@ -65,9 +68,9 @@
</command>
<command>
<action
class=
"org.onlab.onos.cli.net.RemoveHostToHostIntentCommand"
/>
</command
>
<command
>
<
action
class=
"org.onlab.onos.cli.net.IntentsListCommand"
/
>
<completers
>
<ref
component-id=
"intentIdCompleter"
/
>
<
/completers
>
</command>
<command>
...
...
@@ -108,6 +111,7 @@
<bean
id=
"clusterIdCompleter"
class=
"org.onlab.onos.cli.net.ClusterIdCompleter"
/>
<bean
id=
"roleCompleter"
class=
"org.onlab.onos.cli.net.RoleCompleter"
/>
<bean
id=
"hostIdCompleter"
class=
"org.onlab.onos.cli.net.HostIdCompleter"
/>
<bean
id=
"intentIdCompleter"
class=
"org.onlab.onos.cli.net.IntentIdCompleter"
/>
<bean
id=
"flowRuleStatusCompleter"
class=
"org.onlab.onos.cli.net.FlowRuleStatusCompleter"
/>
</blueprint>
...
...
tools/dev/bash_profile
View file @
0511a52
...
...
@@ -32,6 +32,7 @@ alias ob='onos-build'
alias
obs
=
'onos-build-selective'
alias
op
=
'onos-package'
alias
ot
=
'onos-test'
alias
ol
=
'onos-log'
# Short-hand for tailing the ONOS (karaf) log
alias
tl
=
'$ONOS_ROOT/tools/dev/bin/onos-local-log'
...
...
Please
register
or
login
to post a comment