diff --git a/core/api/src/main/java/org/onosproject/ui/model/topo/UiTopology.java b/core/api/src/main/java/org/onosproject/ui/model/topo/UiTopology.java index dd601eb3b5..b4eabe9134 100644 --- a/core/api/src/main/java/org/onosproject/ui/model/topo/UiTopology.java +++ b/core/api/src/main/java/org/onosproject/ui/model/topo/UiTopology.java @@ -149,6 +149,16 @@ public class UiTopology extends UiElement { return cnodeLookup.size(); } + + /** + * Returns all regions in the model. + * + * @return all regions + */ + public Set allRegions() { + return new HashSet<>(regionLookup.values()); + } + /** * Returns a reference to the null-region. That is, the container for * devices, hosts, and links that belong to no region. diff --git a/web/gui/BUCK b/web/gui/BUCK index 4b48069a6d..adf99ef3d4 100644 --- a/web/gui/BUCK +++ b/web/gui/BUCK @@ -5,6 +5,8 @@ COMPILE_DEPS = [ '//lib:jetty-websocket', '//lib:jetty-util', '//lib:jersey-media-multipart', + '//lib:org.apache.karaf.shell.console', + '//cli:onos-cli', '//incubator/api:onos-incubator-api', '//incubator/net:onos-incubator-net', '//utils/rest:onlab-rest', diff --git a/web/gui/pom.xml b/web/gui/pom.xml index c4c4ba05dd..ce301f6f8e 100644 --- a/web/gui/pom.xml +++ b/web/gui/pom.xml @@ -64,6 +64,15 @@ org.glassfish.jersey.media jersey-media-multipart + + org.onosproject + onos-cli + ${project.version} + + + org.apache.karaf.shell + org.apache.karaf.shell.console + diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/topo/cli/ListRegions.java b/web/gui/src/main/java/org/onosproject/ui/impl/topo/cli/ListRegions.java new file mode 100644 index 0000000000..f7c797230b --- /dev/null +++ b/web/gui/src/main/java/org/onosproject/ui/impl/topo/cli/ListRegions.java @@ -0,0 +1,35 @@ +/* + * Copyright 2016-present Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onosproject.ui.impl.topo.cli; + +import org.apache.karaf.shell.commands.Command; +import org.onosproject.cli.AbstractShellCommand; +import org.onosproject.ui.impl.topo.model.UiSharedTopologyModel; + +/** + * CLI command to list the UiRegions stored in the ModelCache. + */ +@Command(scope = "onos", name = "ui-cache-regions", + description = "Lists UiRegions in the Model Cache") +public class ListRegions extends AbstractShellCommand { + + @Override + protected void execute() { + UiSharedTopologyModel model = get(UiSharedTopologyModel.class); + model.getRegions().forEach(r -> print("%s", r)); + } +} diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/topo/cli/package-info.java b/web/gui/src/main/java/org/onosproject/ui/impl/topo/cli/package-info.java new file mode 100644 index 0000000000..bdb21b3d12 --- /dev/null +++ b/web/gui/src/main/java/org/onosproject/ui/impl/topo/cli/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2016-present Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Topology View Model Cache CLI commands. + */ +package org.onosproject.ui.impl.topo.cli; diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/topo/model/ModelCache.java b/web/gui/src/main/java/org/onosproject/ui/impl/topo/model/ModelCache.java index 8647c59317..e3fedd1fff 100644 --- a/web/gui/src/main/java/org/onosproject/ui/impl/topo/model/ModelCache.java +++ b/web/gui/src/main/java/org/onosproject/ui/impl/topo/model/ModelCache.java @@ -240,6 +240,10 @@ class ModelCache { } } + Set getAllRegions() { + return uiTopology.allRegions(); + } + // === DEVICES diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/topo/model/UiSharedTopologyModel.java b/web/gui/src/main/java/org/onosproject/ui/impl/topo/model/UiSharedTopologyModel.java index 4fbf707fd9..52eea69c30 100644 --- a/web/gui/src/main/java/org/onosproject/ui/impl/topo/model/UiSharedTopologyModel.java +++ b/web/gui/src/main/java/org/onosproject/ui/impl/topo/model/UiSharedTopologyModel.java @@ -68,6 +68,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.List; +import java.util.Set; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -196,7 +197,7 @@ public final class UiSharedTopologyModel // ======================================================================= - // methods that the topo session will use to extract information from us + // Methods for topo session (or CLI) to use to get information from us /** * Returns the list of cluster members stored in our model cache. @@ -207,6 +208,15 @@ public final class UiSharedTopologyModel return cache.getAllClusterMembers(); } + /** + * Returns the set of regions stored in our model cache. + * + * @return set of regions + */ + public Set getRegions() { + return cache.getAllRegions(); + } + /** * Returns the region for the given identifier. * diff --git a/web/gui/src/main/resources/OSGI-INF/blueprint/shell-config.xml b/web/gui/src/main/resources/OSGI-INF/blueprint/shell-config.xml new file mode 100644 index 0000000000..4d1abe3619 --- /dev/null +++ b/web/gui/src/main/resources/OSGI-INF/blueprint/shell-config.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + \ No newline at end of file