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-16 07:48:47 -0700
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
c65fa11ca2e9ed535af6c5cc3324489d23c1b3f3
c65fa11c
1 parent
8350ba51
Enahnced path list command to show JSON.
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
1 deletions
cli/src/main/java/org/onlab/onos/cli/net/LinksListCommand.java
cli/src/main/java/org/onlab/onos/cli/net/PathListCommand.java
cli/src/main/java/org/onlab/onos/cli/net/LinksListCommand.java
View file @
c65fa11
...
...
@@ -66,7 +66,7 @@ public class LinksListCommand extends AbstractShellCommand {
public
static
ObjectNode
json
(
ObjectMapper
mapper
,
Link
link
)
{
ObjectNode
result
=
mapper
.
createObjectNode
();
result
.
set
(
"src"
,
json
(
mapper
,
link
.
src
()));
result
.
set
(
"dst"
,
json
(
mapper
,
link
.
src
()));
result
.
set
(
"dst"
,
json
(
mapper
,
link
.
dst
()));
return
result
;
}
...
...
cli/src/main/java/org/onlab/onos/cli/net/PathListCommand.java
View file @
c65fa11
package
org
.
onlab
.
onos
.
cli
.
net
;
import
com.fasterxml.jackson.databind.JsonNode
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.node.ArrayNode
;
import
org.apache.karaf.shell.commands.Argument
;
import
org.apache.karaf.shell.commands.Command
;
import
org.onlab.onos.net.Link
;
...
...
@@ -32,10 +35,31 @@ public class PathListCommand extends TopologyCommand {
protected
void
execute
()
{
init
();
Set
<
Path
>
paths
=
service
.
getPaths
(
topology
,
deviceId
(
src
),
deviceId
(
dst
));
if
(
outputJson
())
{
print
(
"%s"
,
json
(
paths
));
}
else
{
for
(
Path
path
:
paths
)
{
print
(
pathString
(
path
));
}
}
}
/**
* Produces a JSON array containing the specified paths.
*
* @param paths collection of paths
* @return JSON array
*/
public
static
JsonNode
json
(
Iterable
<
Path
>
paths
)
{
ObjectMapper
mapper
=
new
ObjectMapper
();
ArrayNode
result
=
mapper
.
createArrayNode
();
for
(
Path
path
:
paths
)
{
result
.
add
(
LinksListCommand
.
json
(
mapper
,
path
)
.
put
(
"cost"
,
path
.
cost
())
.
set
(
"links"
,
LinksListCommand
.
json
(
path
.
links
())));
}
return
result
;
}
/**
* Produces a formatted string representing the specified path.
...
...
Please
register
or
login
to post a comment