Committed by
Gerrit Code Review
Added ui-cache-regions CLI command.
Change-Id: I196543792c85e40e582f9456e4e50dd33bedf111
Showing
8 changed files
with
118 additions
and
1 deletions
... | @@ -149,6 +149,16 @@ public class UiTopology extends UiElement { | ... | @@ -149,6 +149,16 @@ public class UiTopology extends UiElement { |
149 | return cnodeLookup.size(); | 149 | return cnodeLookup.size(); |
150 | } | 150 | } |
151 | 151 | ||
152 | + | ||
153 | + /** | ||
154 | + * Returns all regions in the model. | ||
155 | + * | ||
156 | + * @return all regions | ||
157 | + */ | ||
158 | + public Set<UiRegion> allRegions() { | ||
159 | + return new HashSet<>(regionLookup.values()); | ||
160 | + } | ||
161 | + | ||
152 | /** | 162 | /** |
153 | * Returns a reference to the null-region. That is, the container for | 163 | * Returns a reference to the null-region. That is, the container for |
154 | * devices, hosts, and links that belong to no region. | 164 | * devices, hosts, and links that belong to no region. | ... | ... |
... | @@ -5,6 +5,8 @@ COMPILE_DEPS = [ | ... | @@ -5,6 +5,8 @@ COMPILE_DEPS = [ |
5 | '//lib:jetty-websocket', | 5 | '//lib:jetty-websocket', |
6 | '//lib:jetty-util', | 6 | '//lib:jetty-util', |
7 | '//lib:jersey-media-multipart', | 7 | '//lib:jersey-media-multipart', |
8 | + '//lib:org.apache.karaf.shell.console', | ||
9 | + '//cli:onos-cli', | ||
8 | '//incubator/api:onos-incubator-api', | 10 | '//incubator/api:onos-incubator-api', |
9 | '//incubator/net:onos-incubator-net', | 11 | '//incubator/net:onos-incubator-net', |
10 | '//utils/rest:onlab-rest', | 12 | '//utils/rest:onlab-rest', | ... | ... |
... | @@ -64,6 +64,15 @@ | ... | @@ -64,6 +64,15 @@ |
64 | <groupId>org.glassfish.jersey.media</groupId> | 64 | <groupId>org.glassfish.jersey.media</groupId> |
65 | <artifactId>jersey-media-multipart</artifactId> | 65 | <artifactId>jersey-media-multipart</artifactId> |
66 | </dependency> | 66 | </dependency> |
67 | + <dependency> | ||
68 | + <groupId>org.onosproject</groupId> | ||
69 | + <artifactId>onos-cli</artifactId> | ||
70 | + <version>${project.version}</version> | ||
71 | + </dependency> | ||
72 | + <dependency> | ||
73 | + <groupId>org.apache.karaf.shell</groupId> | ||
74 | + <artifactId>org.apache.karaf.shell.console</artifactId> | ||
75 | + </dependency> | ||
67 | </dependencies> | 76 | </dependencies> |
68 | 77 | ||
69 | <build> | 78 | <build> | ... | ... |
1 | +/* | ||
2 | + * Copyright 2016-present Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | + | ||
17 | +package org.onosproject.ui.impl.topo.cli; | ||
18 | + | ||
19 | +import org.apache.karaf.shell.commands.Command; | ||
20 | +import org.onosproject.cli.AbstractShellCommand; | ||
21 | +import org.onosproject.ui.impl.topo.model.UiSharedTopologyModel; | ||
22 | + | ||
23 | +/** | ||
24 | + * CLI command to list the UiRegions stored in the ModelCache. | ||
25 | + */ | ||
26 | +@Command(scope = "onos", name = "ui-cache-regions", | ||
27 | + description = "Lists UiRegions in the Model Cache") | ||
28 | +public class ListRegions extends AbstractShellCommand { | ||
29 | + | ||
30 | + @Override | ||
31 | + protected void execute() { | ||
32 | + UiSharedTopologyModel model = get(UiSharedTopologyModel.class); | ||
33 | + model.getRegions().forEach(r -> print("%s", r)); | ||
34 | + } | ||
35 | +} |
1 | +/* | ||
2 | + * Copyright 2016-present Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | + | ||
17 | +/** | ||
18 | + * Topology View Model Cache CLI commands. | ||
19 | + */ | ||
20 | +package org.onosproject.ui.impl.topo.cli; |
... | @@ -68,6 +68,7 @@ import org.slf4j.Logger; | ... | @@ -68,6 +68,7 @@ import org.slf4j.Logger; |
68 | import org.slf4j.LoggerFactory; | 68 | import org.slf4j.LoggerFactory; |
69 | 69 | ||
70 | import java.util.List; | 70 | import java.util.List; |
71 | +import java.util.Set; | ||
71 | import java.util.concurrent.ExecutorService; | 72 | import java.util.concurrent.ExecutorService; |
72 | import java.util.concurrent.Executors; | 73 | import java.util.concurrent.Executors; |
73 | 74 | ||
... | @@ -196,7 +197,7 @@ public final class UiSharedTopologyModel | ... | @@ -196,7 +197,7 @@ public final class UiSharedTopologyModel |
196 | 197 | ||
197 | 198 | ||
198 | // ======================================================================= | 199 | // ======================================================================= |
199 | - // methods that the topo session will use to extract information from us | 200 | + // Methods for topo session (or CLI) to use to get information from us |
200 | 201 | ||
201 | /** | 202 | /** |
202 | * Returns the list of cluster members stored in our model cache. | 203 | * Returns the list of cluster members stored in our model cache. |
... | @@ -208,6 +209,15 @@ public final class UiSharedTopologyModel | ... | @@ -208,6 +209,15 @@ public final class UiSharedTopologyModel |
208 | } | 209 | } |
209 | 210 | ||
210 | /** | 211 | /** |
212 | + * Returns the set of regions stored in our model cache. | ||
213 | + * | ||
214 | + * @return set of regions | ||
215 | + */ | ||
216 | + public Set<UiRegion> getRegions() { | ||
217 | + return cache.getAllRegions(); | ||
218 | + } | ||
219 | + | ||
220 | + /** | ||
211 | * Returns the region for the given identifier. | 221 | * Returns the region for the given identifier. |
212 | * | 222 | * |
213 | * @param id region identifier | 223 | * @param id region identifier | ... | ... |
1 | +<!-- | ||
2 | + ~ Copyright 2016-present Open Networking Laboratory | ||
3 | + ~ | ||
4 | + ~ Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + ~ you may not use this file except in compliance with the License. | ||
6 | + ~ You may obtain a copy of the License at | ||
7 | + ~ | ||
8 | + ~ http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + ~ | ||
10 | + ~ Unless required by applicable law or agreed to in writing, software | ||
11 | + ~ distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + ~ See the License for the specific language governing permissions and | ||
14 | + ~ limitations under the License. | ||
15 | + --> | ||
16 | + | ||
17 | +<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"> | ||
18 | + | ||
19 | + <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.1.0"> | ||
20 | + <command> | ||
21 | + <action class="org.onosproject.ui.impl.topo.cli.ListRegions"/> | ||
22 | + </command> | ||
23 | + </command-bundle> | ||
24 | + | ||
25 | + <!--<bean id="macIDCompleter" class="org.onosproject.dhcp.cli.MacIdCompleter"/>--> | ||
26 | + | ||
27 | +</blueprint> | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
-
Please register or login to post a comment