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
Thomas Vachuska
2014-10-21 12:47:26 -0700
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
10d4abcf36021e8dad8bc1c3616658b2e487932b
10d4abcf
1 parent
d87aeca6
Adding JSON output for intent list command.
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
5 deletions
cli/src/main/java/org/onlab/onos/cli/net/IntentsListCommand.java
core/api/src/main/java/org/onlab/onos/net/intent/IntentService.java
core/api/src/test/java/org/onlab/onos/net/intent/FakeIntentManager.java
core/net/src/main/java/org/onlab/onos/net/intent/impl/IntentManager.java
cli/src/main/java/org/onlab/onos/cli/net/IntentsListCommand.java
View file @
10d4abc
...
...
@@ -19,6 +19,7 @@ import org.onlab.onos.net.intent.PathIntent;
import
org.onlab.onos.net.intent.PointToPointIntent
;
import
org.onlab.onos.net.intent.SinglePointToMultiPointIntent
;
import
java.util.List
;
import
java.util.Set
;
/**
...
...
@@ -39,19 +40,23 @@ public class IntentsListCommand extends AbstractShellCommand {
print
(
"id=%s, state=%s, type=%s, appId=%s"
,
intent
.
id
(),
state
,
intent
.
getClass
().
getSimpleName
(),
intent
.
appId
().
name
());
printDetails
(
intent
);
printDetails
(
service
,
intent
);
}
}
}
private
void
printDetails
(
Intent
intent
)
{
private
void
printDetails
(
Intent
Service
service
,
Intent
intent
)
{
if
(
intent
.
resources
()
!=
null
&&
!
intent
.
resources
().
isEmpty
())
{
print
(
" resources=%s"
,
intent
.
resources
());
}
if
(
intent
instanceof
ConnectivityIntent
)
{
ConnectivityIntent
ci
=
(
ConnectivityIntent
)
intent
;
print
(
" selector=%s"
,
ci
.
selector
().
criteria
());
print
(
" treatment=%s"
,
ci
.
treatment
().
instructions
());
if
(!
ci
.
selector
().
criteria
().
isEmpty
())
{
print
(
" selector=%s"
,
ci
.
selector
().
criteria
());
}
if
(!
ci
.
treatment
().
instructions
().
isEmpty
())
{
print
(
" treatment=%s"
,
ci
.
treatment
().
instructions
());
}
}
if
(
intent
instanceof
PointToPointIntent
)
{
...
...
@@ -71,6 +76,11 @@ public class IntentsListCommand extends AbstractShellCommand {
print
(
" links=%s"
,
li
.
links
());
print
(
" egress=%s"
,
li
.
egressPoint
());
}
List
<
Intent
>
installable
=
service
.
getInstallableIntents
(
intent
.
id
());
if
(
installable
!=
null
&&
!
installable
.
isEmpty
())
{
print
(
" installable=%s"
,
installable
);
}
}
// Produces JSON array of the specified intents.
...
...
@@ -86,10 +96,14 @@ public class IntentsListCommand extends AbstractShellCommand {
private
JsonNode
json
(
IntentService
service
,
ObjectMapper
mapper
,
Intent
intent
)
{
ObjectNode
result
=
mapper
.
createObjectNode
()
.
put
(
"id"
,
intent
.
id
().
toString
())
.
put
(
"state"
,
service
.
getIntentState
(
intent
.
id
()).
toString
())
.
put
(
"type"
,
intent
.
getClass
().
getSimpleName
())
.
put
(
"appId"
,
intent
.
appId
().
name
());
IntentState
state
=
service
.
getIntentState
(
intent
.
id
());
if
(
state
!=
null
)
{
result
.
put
(
"state"
,
state
.
toString
());
}
if
(
intent
.
resources
()
!=
null
&&
!
intent
.
resources
().
isEmpty
())
{
ArrayNode
rnode
=
mapper
.
createArrayNode
();
for
(
NetworkResource
resource
:
intent
.
resources
())
{
...
...
@@ -136,6 +150,10 @@ public class IntentsListCommand extends AbstractShellCommand {
result
.
set
(
"links"
,
LinksListCommand
.
json
(
li
.
links
()));
}
List
<
Intent
>
installable
=
service
.
getInstallableIntents
(
intent
.
id
());
if
(
installable
!=
null
&&
!
installable
.
isEmpty
())
{
result
.
set
(
"installable"
,
json
(
service
,
installable
));
}
return
result
;
}
...
...
core/api/src/main/java/org/onlab/onos/net/intent/IntentService.java
View file @
10d4abc
package
org
.
onlab
.
onos
.
net
.
intent
;
import
java.util.List
;
/**
* Service for application submitting or withdrawing their intents.
*/
...
...
@@ -68,6 +70,15 @@ public interface IntentService {
IntentState
getIntentState
(
IntentId
id
);
/**
* Returns the list of the installable events associated with the specified
* top-level intent.
*
* @param intentId top-level intent identifier
* @return compiled installable intents
*/
List
<
Intent
>
getInstallableIntents
(
IntentId
intentId
);
/**
* Adds the specified listener for intent events.
*
* @param listener listener to be added
...
...
core/api/src/test/java/org/onlab/onos/net/intent/FakeIntentManager.java
View file @
10d4abc
...
...
@@ -196,6 +196,11 @@ public class FakeIntentManager implements TestableIntentService {
}
@Override
public
List
<
Intent
>
getInstallableIntents
(
IntentId
intentId
)
{
return
installables
.
get
(
intentId
);
}
@Override
public
void
addListener
(
IntentListener
listener
)
{
listeners
.
add
(
listener
);
}
...
...
core/net/src/main/java/org/onlab/onos/net/intent/impl/IntentManager.java
View file @
10d4abc
...
...
@@ -153,6 +153,12 @@ public class IntentManager
}
@Override
public
List
<
Intent
>
getInstallableIntents
(
IntentId
intentId
)
{
checkNotNull
(
intentId
,
INTENT_ID_NULL
);
return
store
.
getInstallableIntents
(
intentId
);
}
@Override
public
void
addListener
(
IntentListener
listener
)
{
listenerRegistry
.
addListener
(
listener
);
}
...
...
Please
register
or
login
to post a comment