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-09-08 13:29:18 -0700
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
d79f7ec608d173ac0a85ad446c3b9e23a79b6fe9
d79f7ec6
1 parent
ff7eb7cc
Enhanced the CLIs.
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
2 deletions
cli/src/main/java/org/onlab/onos/cli/net/DevicePortsListCommand.java
cli/src/main/java/org/onlab/onos/cli/net/DevicesListCommand.java
cli/src/main/java/org/onlab/onos/cli/net/DevicePortsListCommand.java
View file @
d79f7ec
...
...
@@ -38,7 +38,7 @@ public class DevicePortsListCommand extends DevicesListCommand {
protected
Object
doExecute
()
throws
Exception
{
DeviceService
service
=
getService
(
DeviceService
.
class
);
if
(
uri
==
null
)
{
for
(
Device
device
:
service
.
getDevices
(
))
{
for
(
Device
device
:
getSortedDevices
(
service
))
{
printDevicePorts
(
service
,
device
);
}
}
else
{
...
...
cli/src/main/java/org/onlab/onos/cli/net/DevicesListCommand.java
View file @
d79f7ec
...
...
@@ -5,6 +5,12 @@ import org.onlab.onos.cli.AbstractShellCommand;
import
org.onlab.onos.net.Device
;
import
org.onlab.onos.net.device.DeviceService
;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.List
;
import
static
com
.
google
.
common
.
collect
.
Lists
.
newArrayList
;
/**
* Lists all infrastructure devices.
*/
...
...
@@ -15,16 +21,35 @@ public class DevicesListCommand extends AbstractShellCommand {
private
static
final
String
FMT
=
"id=%s, available=%s, type=%s, mfr=%s, hw=%s, sw=%s, serial=%s"
;
protected
static
final
Comparator
<
Device
>
ID_COMPARATOR
=
new
Comparator
<
Device
>()
{
@Override
public
int
compare
(
Device
d1
,
Device
d2
)
{
return
d1
.
id
().
uri
().
toString
().
compareTo
(
d2
.
id
().
uri
().
toString
());
}
};
@Override
protected
Object
doExecute
()
throws
Exception
{
DeviceService
service
=
getService
(
DeviceService
.
class
);
for
(
Device
device
:
service
.
getDevices
(
))
{
for
(
Device
device
:
getSortedDevices
(
service
))
{
printDevice
(
device
,
service
.
isAvailable
(
device
.
id
()));
}
return
null
;
}
/**
* Returns the list of devices sorted using the device ID URIs.
*
* @param service device service
* @return sorted device list
*/
protected
List
<
Device
>
getSortedDevices
(
DeviceService
service
)
{
List
<
Device
>
devices
=
newArrayList
(
service
.
getDevices
());
Collections
.
sort
(
devices
,
ID_COMPARATOR
);
return
devices
;
}
/**
* Prints information about the specified device.
*
* @param device infrastructure device
...
...
Please
register
or
login
to post a comment