Added missing CLI output of HostToHostIntent-specific info
for the "intents" CLI command. Change-Id: Icb150b570e8b4c0a52186489d408842d4327b387
Showing
2 changed files
with
31 additions
and
5 deletions
... | @@ -26,6 +26,7 @@ import org.onosproject.net.ConnectPoint; | ... | @@ -26,6 +26,7 @@ import org.onosproject.net.ConnectPoint; |
26 | import org.onosproject.net.Link; | 26 | import org.onosproject.net.Link; |
27 | import org.onosproject.net.NetworkResource; | 27 | import org.onosproject.net.NetworkResource; |
28 | import org.onosproject.net.intent.ConnectivityIntent; | 28 | import org.onosproject.net.intent.ConnectivityIntent; |
29 | +import org.onosproject.net.intent.HostToHostIntent; | ||
29 | import org.onosproject.net.intent.Intent; | 30 | import org.onosproject.net.intent.Intent; |
30 | import org.onosproject.net.intent.IntentService; | 31 | import org.onosproject.net.intent.IntentService; |
31 | import org.onosproject.net.intent.IntentState; | 32 | import org.onosproject.net.intent.IntentState; |
... | @@ -92,6 +93,7 @@ public class IntentsListCommand extends AbstractShellCommand { | ... | @@ -92,6 +93,7 @@ public class IntentsListCommand extends AbstractShellCommand { |
92 | private class IntentSummaries { | 93 | private class IntentSummaries { |
93 | private IntentSummary summaryAll; | 94 | private IntentSummary summaryAll; |
94 | private IntentSummary summaryConnectivity; | 95 | private IntentSummary summaryConnectivity; |
96 | + private IntentSummary summaryHostToHost; | ||
95 | private IntentSummary summaryPointToPoint; | 97 | private IntentSummary summaryPointToPoint; |
96 | private IntentSummary summaryMultiPointToSinglePoint; | 98 | private IntentSummary summaryMultiPointToSinglePoint; |
97 | private IntentSummary summarySinglePointToMultiPoint; | 99 | private IntentSummary summarySinglePointToMultiPoint; |
... | @@ -105,6 +107,7 @@ public class IntentsListCommand extends AbstractShellCommand { | ... | @@ -105,6 +107,7 @@ public class IntentsListCommand extends AbstractShellCommand { |
105 | private void init() { | 107 | private void init() { |
106 | summaryAll = new IntentSummary("All"); | 108 | summaryAll = new IntentSummary("All"); |
107 | summaryConnectivity = new IntentSummary("Connectivity"); | 109 | summaryConnectivity = new IntentSummary("Connectivity"); |
110 | + summaryHostToHost = new IntentSummary("HostToHost"); | ||
108 | summaryPointToPoint = new IntentSummary("PointToPoint"); | 111 | summaryPointToPoint = new IntentSummary("PointToPoint"); |
109 | summaryMultiPointToSinglePoint = | 112 | summaryMultiPointToSinglePoint = |
110 | new IntentSummary("MultiPointToSinglePoint"); | 113 | new IntentSummary("MultiPointToSinglePoint"); |
... | @@ -140,6 +143,10 @@ public class IntentsListCommand extends AbstractShellCommand { | ... | @@ -140,6 +143,10 @@ public class IntentsListCommand extends AbstractShellCommand { |
140 | // NOTE: ConnectivityIntent is a base type Intent | 143 | // NOTE: ConnectivityIntent is a base type Intent |
141 | // continue; | 144 | // continue; |
142 | } | 145 | } |
146 | + if (intent instanceof HostToHostIntent) { | ||
147 | + summaryHostToHost.update(intentState); | ||
148 | + continue; | ||
149 | + } | ||
143 | if (intent instanceof PointToPointIntent) { | 150 | if (intent instanceof PointToPointIntent) { |
144 | summaryPointToPoint.update(intentState); | 151 | summaryPointToPoint.update(intentState); |
145 | continue; | 152 | continue; |
... | @@ -174,6 +181,7 @@ public class IntentsListCommand extends AbstractShellCommand { | ... | @@ -174,6 +181,7 @@ public class IntentsListCommand extends AbstractShellCommand { |
174 | ObjectMapper mapper = new ObjectMapper(); | 181 | ObjectMapper mapper = new ObjectMapper(); |
175 | ObjectNode result = mapper.createObjectNode(); | 182 | ObjectNode result = mapper.createObjectNode(); |
176 | result.put("connectivity", summaryConnectivity.json(mapper)); | 183 | result.put("connectivity", summaryConnectivity.json(mapper)); |
184 | + result.put("hostToHost", summaryHostToHost.json(mapper)); | ||
177 | result.put("pointToPoint", summaryPointToPoint.json(mapper)); | 185 | result.put("pointToPoint", summaryPointToPoint.json(mapper)); |
178 | result.put("multiPointToSinglePoint", | 186 | result.put("multiPointToSinglePoint", |
179 | summaryMultiPointToSinglePoint.json(mapper)); | 187 | summaryMultiPointToSinglePoint.json(mapper)); |
... | @@ -191,6 +199,7 @@ public class IntentsListCommand extends AbstractShellCommand { | ... | @@ -191,6 +199,7 @@ public class IntentsListCommand extends AbstractShellCommand { |
191 | */ | 199 | */ |
192 | private void printSummary() { | 200 | private void printSummary() { |
193 | summaryConnectivity.printState(); | 201 | summaryConnectivity.printState(); |
202 | + summaryHostToHost.printState(); | ||
194 | summaryPointToPoint.printState(); | 203 | summaryPointToPoint.printState(); |
195 | summaryMultiPointToSinglePoint.printState(); | 204 | summaryMultiPointToSinglePoint.printState(); |
196 | summarySinglePointToMultiPoint.printState(); | 205 | summarySinglePointToMultiPoint.printState(); |
... | @@ -335,7 +344,10 @@ public class IntentsListCommand extends AbstractShellCommand { | ... | @@ -335,7 +344,10 @@ public class IntentsListCommand extends AbstractShellCommand { |
335 | } | 344 | } |
336 | } | 345 | } |
337 | 346 | ||
338 | - if (intent instanceof PointToPointIntent) { | 347 | + if (intent instanceof HostToHostIntent) { |
348 | + HostToHostIntent pi = (HostToHostIntent) intent; | ||
349 | + print(" host1=%s, host2=%s", pi.one(), pi.two()); | ||
350 | + } else if (intent instanceof PointToPointIntent) { | ||
339 | PointToPointIntent pi = (PointToPointIntent) intent; | 351 | PointToPointIntent pi = (PointToPointIntent) intent; |
340 | print(" ingress=%s, egress=%s", pi.ingressPoint(), pi.egressPoint()); | 352 | print(" ingress=%s, egress=%s", pi.ingressPoint(), pi.egressPoint()); |
341 | } else if (intent instanceof MultiPointToSinglePointIntent) { | 353 | } else if (intent instanceof MultiPointToSinglePointIntent) { |
... | @@ -405,22 +417,22 @@ public class IntentsListCommand extends AbstractShellCommand { | ... | @@ -405,22 +417,22 @@ public class IntentsListCommand extends AbstractShellCommand { |
405 | pnode.add(link.toString()); | 417 | pnode.add(link.toString()); |
406 | } | 418 | } |
407 | result.set("path", pnode); | 419 | result.set("path", pnode); |
408 | - | 420 | + } else if (intent instanceof HostToHostIntent) { |
421 | + HostToHostIntent pi = (HostToHostIntent) intent; | ||
422 | + result.set("host1", LinksListCommand.json(mapper, pi.one())); | ||
423 | + result.set("host2", LinksListCommand.json(mapper, pi.two())); | ||
409 | } else if (intent instanceof PointToPointIntent) { | 424 | } else if (intent instanceof PointToPointIntent) { |
410 | PointToPointIntent pi = (PointToPointIntent) intent; | 425 | PointToPointIntent pi = (PointToPointIntent) intent; |
411 | result.set("ingress", LinksListCommand.json(mapper, pi.ingressPoint())); | 426 | result.set("ingress", LinksListCommand.json(mapper, pi.ingressPoint())); |
412 | result.set("egress", LinksListCommand.json(mapper, pi.egressPoint())); | 427 | result.set("egress", LinksListCommand.json(mapper, pi.egressPoint())); |
413 | - | ||
414 | } else if (intent instanceof MultiPointToSinglePointIntent) { | 428 | } else if (intent instanceof MultiPointToSinglePointIntent) { |
415 | MultiPointToSinglePointIntent pi = (MultiPointToSinglePointIntent) intent; | 429 | MultiPointToSinglePointIntent pi = (MultiPointToSinglePointIntent) intent; |
416 | result.set("ingress", json(mapper, pi.ingressPoints())); | 430 | result.set("ingress", json(mapper, pi.ingressPoints())); |
417 | result.set("egress", LinksListCommand.json(mapper, pi.egressPoint())); | 431 | result.set("egress", LinksListCommand.json(mapper, pi.egressPoint())); |
418 | - | ||
419 | } else if (intent instanceof SinglePointToMultiPointIntent) { | 432 | } else if (intent instanceof SinglePointToMultiPointIntent) { |
420 | SinglePointToMultiPointIntent pi = (SinglePointToMultiPointIntent) intent; | 433 | SinglePointToMultiPointIntent pi = (SinglePointToMultiPointIntent) intent; |
421 | result.set("ingress", LinksListCommand.json(mapper, pi.ingressPoint())); | 434 | result.set("ingress", LinksListCommand.json(mapper, pi.ingressPoint())); |
422 | result.set("egress", json(mapper, pi.egressPoints())); | 435 | result.set("egress", json(mapper, pi.egressPoints())); |
423 | - | ||
424 | } else if (intent instanceof LinkCollectionIntent) { | 436 | } else if (intent instanceof LinkCollectionIntent) { |
425 | LinkCollectionIntent li = (LinkCollectionIntent) intent; | 437 | LinkCollectionIntent li = (LinkCollectionIntent) intent; |
426 | result.set("links", LinksListCommand.json(li.links())); | 438 | result.set("links", LinksListCommand.json(li.links())); | ... | ... |
... | @@ -23,6 +23,7 @@ import org.apache.karaf.shell.commands.Argument; | ... | @@ -23,6 +23,7 @@ import org.apache.karaf.shell.commands.Argument; |
23 | import org.apache.karaf.shell.commands.Command; | 23 | import org.apache.karaf.shell.commands.Command; |
24 | import org.onosproject.cli.AbstractShellCommand; | 24 | import org.onosproject.cli.AbstractShellCommand; |
25 | import org.onosproject.net.ConnectPoint; | 25 | import org.onosproject.net.ConnectPoint; |
26 | +import org.onosproject.net.HostId; | ||
26 | import org.onosproject.net.Link; | 27 | import org.onosproject.net.Link; |
27 | import org.onosproject.net.link.LinkService; | 28 | import org.onosproject.net.link.LinkService; |
28 | 29 | ||
... | @@ -89,6 +90,19 @@ public class LinksListCommand extends AbstractShellCommand { | ... | @@ -89,6 +90,19 @@ public class LinksListCommand extends AbstractShellCommand { |
89 | } | 90 | } |
90 | 91 | ||
91 | /** | 92 | /** |
93 | + * Produces a JSON object for the specified host ID. | ||
94 | + * | ||
95 | + * @param mapper object mapper | ||
96 | + * @param hostId host ID to encode | ||
97 | + * @return JSON object | ||
98 | + */ | ||
99 | + public static ObjectNode json(ObjectMapper mapper, HostId hostId) { | ||
100 | + return mapper.createObjectNode() | ||
101 | + .put("mac", hostId.mac().toString()) | ||
102 | + .put("vlanId", hostId.vlanId().toString()); | ||
103 | + } | ||
104 | + | ||
105 | + /** | ||
92 | * Produces a JSON object for the specified connect point. | 106 | * Produces a JSON object for the specified connect point. |
93 | * | 107 | * |
94 | * @param mapper object mapper | 108 | * @param mapper object mapper | ... | ... |
-
Please register or login to post a comment