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
alshabib
2014-09-22 11:58:17 -0700
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
9290eeaf11c9ae00d893c19b26f7e2fbf4eb69c6
9290eeaf
1 parent
9c835412
small fix to flowid
Change-Id: I7ba950cf3fe874a094ddd3f93a8d72df0cba89c0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
80 additions
and
2 deletions
cli/src/main/java/org/onlab/onos/cli/net/FlowsListCommand.java
core/api/src/main/java/org/onlab/onos/net/flow/DefaultFlowRule.java
core/api/src/main/java/org/onlab/onos/net/flow/FlowId.java
cli/src/main/java/org/onlab/onos/cli/net/FlowsListCommand.java
0 → 100644
View file @
9290eea
package
org
.
onlab
.
onos
.
cli
.
net
;
import
static
com
.
google
.
common
.
collect
.
Lists
.
newArrayList
;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.List
;
import
java.util.Map
;
import
org.apache.karaf.shell.commands.Command
;
import
org.onlab.onos.cli.AbstractShellCommand
;
import
org.onlab.onos.net.Device
;
import
org.onlab.onos.net.device.DeviceService
;
import
org.onlab.onos.net.flow.FlowRule
;
import
org.onlab.onos.net.flow.FlowRuleService
;
import
com.google.common.collect.Maps
;
/**
* Lists all currently-known hosts.
*/
@Command
(
scope
=
"onos"
,
name
=
"flows"
,
description
=
"Lists all currently-known flows."
)
public
class
FlowsListCommand
extends
AbstractShellCommand
{
private
static
final
String
FMT
=
" id=%s, selector=%s, treatment=%s, state=%s"
;
protected
static
final
Comparator
<
FlowRule
>
ID_COMPARATOR
=
new
Comparator
<
FlowRule
>()
{
@Override
public
int
compare
(
FlowRule
f1
,
FlowRule
f2
)
{
return
Long
.
valueOf
(
f1
.
id
().
value
()).
compareTo
(
f2
.
id
().
value
());
}
};
@Override
protected
Object
doExecute
()
throws
Exception
{
DeviceService
deviceService
=
getService
(
DeviceService
.
class
);
FlowRuleService
service
=
getService
(
FlowRuleService
.
class
);
Map
<
Device
,
List
<
FlowRule
>>
flows
=
getSortedFlows
(
deviceService
,
service
);
for
(
Device
d
:
deviceService
.
getDevices
())
{
printFlows
(
d
,
flows
.
get
(
d
));
}
return
null
;
}
/**
* Returns the list of devices sorted using the device ID URIs.
*
* @param service device service
* @return sorted device list
*/
protected
Map
<
Device
,
List
<
FlowRule
>>
getSortedFlows
(
DeviceService
deviceService
,
FlowRuleService
service
)
{
Map
<
Device
,
List
<
FlowRule
>>
flows
=
Maps
.
newHashMap
();
List
<
FlowRule
>
rules
;
for
(
Device
d
:
deviceService
.
getDevices
())
{
rules
=
newArrayList
(
service
.
getFlowEntries
(
d
.
id
()));
Collections
.
sort
(
rules
,
ID_COMPARATOR
);
flows
.
put
(
d
,
rules
);
}
return
flows
;
}
/**
* Prints flows.
* @param d the device
* @param flows the set of flows for that device.
*/
protected
void
printFlows
(
Device
d
,
List
<
FlowRule
>
flows
)
{
print
(
"Device: "
+
d
.
id
());
for
(
FlowRule
f
:
flows
)
{
print
(
FMT
,
f
.
id
().
value
(),
f
.
selector
(),
f
.
treatment
(),
f
.
state
());
}
}
}
\ No newline at end of file
core/api/src/main/java/org/onlab/onos/net/flow/DefaultFlowRule.java
View file @
9290eea
...
...
@@ -37,7 +37,7 @@ public class DefaultFlowRule implements FlowRule {
public
DefaultFlowRule
(
DeviceId
deviceId
,
TrafficSelector
selector
,
TrafficTreatment
treatment
,
int
priority
,
FlowRuleState
state
,
long
life
,
long
packets
,
long
bytes
,
Integer
flowId
)
{
long
life
,
long
packets
,
long
bytes
,
long
flowId
)
{
this
.
deviceId
=
deviceId
;
this
.
priority
=
priority
;
this
.
selector
=
selector
;
...
...
core/api/src/main/java/org/onlab/onos/net/flow/FlowId.java
View file @
9290eea
...
...
@@ -13,7 +13,7 @@ public final class FlowId {
this
.
flowid
=
id
;
}
public
static
FlowId
valueOf
(
int
id
)
{
public
static
FlowId
valueOf
(
long
id
)
{
return
new
FlowId
(
id
);
}
...
...
Please
register
or
login
to post a comment