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 14:27:13 -0700
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
c290a12541bee350b3e5aaa01186e48059528a5a
c290a125
1 parent
d79f7ec6
Enhanced the CLIs.
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
58 additions
and
23 deletions
cli/src/main/java/org/onlab/onos/cli/net/DevicePortsListCommand.java
cli/src/main/java/org/onlab/onos/cli/net/DeviceRemoveCommand.java
cli/src/main/java/org/onlab/onos/cli/net/DevicesListCommand.java
cli/src/main/java/org/onlab/onos/cli/net/LinksListCommand.java
cli/src/main/resources/OSGI-INF/blueprint/shell-config.xml
cli/src/main/java/org/onlab/onos/cli/net/DevicePortsListCommand.java
View file @
c290a12
...
...
@@ -14,15 +14,15 @@ import java.util.List;
import
static
org
.
onlab
.
onos
.
net
.
DeviceId
.
deviceId
;
/**
* Lists all
infrastructure links
.
* Lists all
ports or all ports of a device
.
*/
@Command
(
scope
=
"onos"
,
name
=
"ports"
,
description
=
"Lists all ports of a device"
)
description
=
"Lists all ports o
r all ports o
f a device"
)
public
class
DevicePortsListCommand
extends
DevicesListCommand
{
private
static
final
String
FMT
=
" port=%s, state=%s"
;
@Argument
(
index
=
0
,
name
=
"
deviceId
"
,
description
=
"Device ID"
,
@Argument
(
index
=
0
,
name
=
"
uri
"
,
description
=
"Device ID"
,
required
=
false
,
multiValued
=
false
)
String
uri
=
null
;
...
...
@@ -39,18 +39,19 @@ public class DevicePortsListCommand extends DevicesListCommand {
DeviceService
service
=
getService
(
DeviceService
.
class
);
if
(
uri
==
null
)
{
for
(
Device
device
:
getSortedDevices
(
service
))
{
printDevice
Ports
(
service
,
device
);
printDevice
(
service
,
device
);
}
}
else
{
printDevice
Ports
(
service
,
service
.
getDevice
(
deviceId
(
uri
)));
printDevice
(
service
,
service
.
getDevice
(
deviceId
(
uri
)));
}
return
null
;
}
private
void
printDevicePorts
(
DeviceService
service
,
Device
device
)
{
@Override
protected
void
printDevice
(
DeviceService
service
,
Device
device
)
{
super
.
printDevice
(
service
,
device
);
List
<
Port
>
ports
=
new
ArrayList
<>(
service
.
getPorts
(
device
.
id
()));
Collections
.
sort
(
ports
,
PORT_COMPARATOR
);
printDevice
(
device
,
service
.
isAvailable
(
device
.
id
()));
for
(
Port
port
:
ports
)
{
print
(
FMT
,
port
.
number
(),
port
.
isEnabled
()
?
"enabled"
:
"disabled"
);
}
...
...
cli/src/main/java/org/onlab/onos/cli/net/DeviceRemoveCommand.java
0 → 100644
View file @
c290a12
package
org
.
onlab
.
onos
.
cli
.
net
;
import
org.apache.karaf.shell.commands.Argument
;
import
org.apache.karaf.shell.commands.Command
;
import
org.onlab.onos.cli.AbstractShellCommand
;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.net.device.DeviceAdminService
;
/**
* Removes an infrastructure device.
*/
@Command
(
scope
=
"onos"
,
name
=
"device-remove"
,
description
=
"Removes an infrastructure device"
)
public
class
DeviceRemoveCommand
extends
AbstractShellCommand
{
@Argument
(
index
=
0
,
name
=
"uri"
,
description
=
"Device ID"
,
required
=
true
,
multiValued
=
false
)
String
uri
=
null
;
@Override
protected
Object
doExecute
()
throws
Exception
{
getService
(
DeviceAdminService
.
class
).
removeDevice
(
DeviceId
.
deviceId
(
uri
));
return
null
;
}
}
cli/src/main/java/org/onlab/onos/cli/net/DevicesListCommand.java
View file @
c290a12
...
...
@@ -19,7 +19,7 @@ import static com.google.common.collect.Lists.newArrayList;
public
class
DevicesListCommand
extends
AbstractShellCommand
{
private
static
final
String
FMT
=
"id=%s, available=%s, type=%s, mfr=%s, hw=%s, sw=%s, serial=%s"
;
"id=%s, available=%s,
role=%s,
type=%s, mfr=%s, hw=%s, sw=%s, serial=%s"
;
protected
static
final
Comparator
<
Device
>
ID_COMPARATOR
=
new
Comparator
<
Device
>()
{
@Override
...
...
@@ -32,7 +32,7 @@ public class DevicesListCommand extends AbstractShellCommand {
protected
Object
doExecute
()
throws
Exception
{
DeviceService
service
=
getService
(
DeviceService
.
class
);
for
(
Device
device
:
getSortedDevices
(
service
))
{
printDevice
(
device
,
service
.
isAvailable
(
device
.
id
())
);
printDevice
(
service
,
device
);
}
return
null
;
}
...
...
@@ -52,11 +52,12 @@ public class DevicesListCommand extends AbstractShellCommand {
/**
* Prints information about the specified device.
*
* @param
device infrastructure de
vice
* @param
isAvailable true of device is availabl
e
* @param
service device ser
vice
* @param
device infrastructure devic
e
*/
protected
void
printDevice
(
Device
device
,
boolean
isAvailable
)
{
print
(
FMT
,
device
.
id
(),
isAvailable
,
device
.
type
(),
protected
void
printDevice
(
DeviceService
service
,
Device
device
)
{
print
(
FMT
,
device
.
id
(),
service
.
isAvailable
(
device
.
id
()),
service
.
getRole
(
device
.
id
()),
device
.
type
(),
device
.
manufacturer
(),
device
.
hwVersion
(),
device
.
swVersion
(),
device
.
serialNumber
());
}
...
...
cli/src/main/java/org/onlab/onos/cli/net/LinksListCommand.java
View file @
c290a12
...
...
@@ -17,15 +17,15 @@ public class LinksListCommand extends AbstractShellCommand {
private
static
final
String
FMT
=
"src=%s/%s, dst=%s/%s, type=%s"
;
@Argument
(
index
=
0
,
name
=
"
deviceId
"
,
description
=
"Device ID"
,
@Argument
(
index
=
0
,
name
=
"
uri
"
,
description
=
"Device ID"
,
required
=
false
,
multiValued
=
false
)
String
deviceId
=
null
;
String
uri
=
null
;
@Override
protected
Object
doExecute
()
throws
Exception
{
LinkService
service
=
getService
(
LinkService
.
class
);
Iterable
<
Link
>
links
=
deviceId
!=
null
?
service
.
getDeviceLinks
(
deviceId
(
deviceId
))
:
service
.
getLinks
();
Iterable
<
Link
>
links
=
uri
!=
null
?
service
.
getDeviceLinks
(
deviceId
(
uri
))
:
service
.
getLinks
();
for
(
Link
link
:
links
)
{
print
(
FMT
,
link
.
src
().
deviceId
(),
link
.
src
().
port
(),
link
.
dst
().
deviceId
(),
link
.
dst
().
port
(),
link
.
type
());
...
...
cli/src/main/resources/OSGI-INF/blueprint/shell-config.xml
View file @
c290a12
...
...
@@ -11,18 +11,25 @@
</completers>
</command>
<command>
<action
class=
"org.onlab.onos.cli.net.DeviceRemoveCommand"
/>
<completers>
<ref
component-id=
"deviceIdCompleter"
/>
</completers>
</command>
<command>
<action
class=
"org.onlab.onos.cli.net.LinksListCommand"
/>
<completers>
<ref
component-id=
"deviceIdCompleter"
/>
</completers>
</command>
<
!--<command>--
>
<
!--<action class="org.onlab.onos.cli.GreetCommand"/>--
>
<
!--<completers>--
>
<
!--<ref component-id="nameCompleter"/>--
>
<
!--</completers>--
>
<
!--</command>--
>
<
command
>
<
action
class=
"org.onlab.onos.cli.GreetCommand"
/
>
<
completers
>
<
ref
component-id=
"nameCompleter"
/
>
<
/completers
>
<
/command
>
</command-bundle>
<bean
id=
"deviceIdCompleter"
class=
"org.onlab.onos.cli.net.DeviceIdCompleter"
/>
...
...
Please
register
or
login
to post a comment