diff options
author | Ashlee Young <ashlee@onosfw.com> | 2015-10-09 18:32:44 -0700 |
---|---|---|
committer | Ashlee Young <ashlee@onosfw.com> | 2015-10-09 18:32:44 -0700 |
commit | 6a07d2d622eaa06953f3353e39c080984076e8de (patch) | |
tree | bfb50a2090fce186c2cc545a400c969bf2ea702b /framework/src/onos/tools | |
parent | e6d71622143ff9b2421a1abbe8434b954b5b1099 (diff) |
Updated master to commit id 6ee8aa3e67ce89908a8c93aa9445c6f71a18f986
Change-Id: I94b055ee2f298daf71e2ec794fd0f2495bd8081f
Diffstat (limited to 'framework/src/onos/tools')
67 files changed, 2326 insertions, 219 deletions
diff --git a/framework/src/onos/tools/build/conf/pom.xml b/framework/src/onos/tools/build/conf/pom.xml index e4f8e9dc..29e4dea0 100644 --- a/framework/src/onos/tools/build/conf/pom.xml +++ b/framework/src/onos/tools/build/conf/pom.xml @@ -27,7 +27,7 @@ <groupId>org.onosproject</groupId> <artifactId>onos-build-conf</artifactId> - <version>1.0</version> + <version>1.1</version> <description>Various ONOS build settings</description> <properties> diff --git a/framework/src/onos/tools/build/conf/src/main/resources/onos/checkstyle.xml b/framework/src/onos/tools/build/conf/src/main/resources/onos/checkstyle.xml index 2908c891..1bb3b0bf 100644 --- a/framework/src/onos/tools/build/conf/src/main/resources/onos/checkstyle.xml +++ b/framework/src/onos/tools/build/conf/src/main/resources/onos/checkstyle.xml @@ -229,7 +229,10 @@ <!-- ONOS alows declarations inside of switch case blocks --> <property name="allowInSwitchCase" value="true"/> </module> - <module name="EmptyBlock"/> + <module name="EmptyBlock"> + <!-- allow empty block, as long as there's some comment --> + <property name="option" value="text"/> + </module> <module name="LeftCurly"/> <module name="NeedBraces"/> <module name="RightCurly"/> diff --git a/framework/src/onos/tools/build/docker/Dockerfile b/framework/src/onos/tools/build/docker/Dockerfile index fd61ad86..ee9666ab 100644 --- a/framework/src/onos/tools/build/docker/Dockerfile +++ b/framework/src/onos/tools/build/docker/Dockerfile @@ -45,11 +45,11 @@ RUN mkdir onos && \ # Ports -# 6633 - OpenFlow +# 6653 - OpenFlow # 8181 - GUI # 8101 - ONOS CLI # 9876 - ONOS CLUSTER COMMUNICATION -EXPOSE 6633 8181 8101 9876 +EXPOSE 6653 8181 8101 9876 # Get ready to run command WORKDIR /root/onos diff --git a/framework/src/onos/tools/build/onos-package b/framework/src/onos/tools/build/onos-package index 32794457..5566e60d 100755 --- a/framework/src/onos/tools/build/onos-package +++ b/framework/src/onos/tools/build/onos-package @@ -28,6 +28,10 @@ function build_stage_dir() { [ -f $KARAF_TAR ] && tar zxf $KARAF_TAR && rm -rf $ONOS_STAGE/$KARAF_DIST/demos mkdir bin + # Patch the log-file size in place to increase it to 10 MB + perl -pi.old -e "s/maxFileSize=1MB/maxFileSize=10MB/g" \ + $ONOS_STAGE/$KARAF_DIST/etc/org.ops4j.pax.logging.cfg + # Stage the ONOS admin scripts and patch in Karaf service wrapper extras cp -r $ONOS_ROOT/tools/package/bin . cp -r $ONOS_ROOT/tools/package/init $ONOS_STAGE/init diff --git a/framework/src/onos/tools/dev/bash_profile b/framework/src/onos/tools/dev/bash_profile index 5e161ccd..f39c2ce1 100644 --- a/framework/src/onos/tools/dev/bash_profile +++ b/framework/src/onos/tools/dev/bash_profile @@ -148,41 +148,41 @@ function nuke { spy "$@" | cut -c7-11 | xargs kill } -# Edit a cell file by providing a cell name. Opens the cell file in $EDITOR. -function vicell() { - local apply=false - local create=false - local cdf="" - local cpath="${ONOS_ROOT}/tools/test/cells/" - - if [ -z "$1" ] || [ "$1" = "-h" ] ; then - printf "usage: vicell [file] [options]\n\noptions:\n" - printf "\t-a: apply the cell after editing\n" - printf "\t-e: [editor] set EDITOR to [editor] (default *vi*)\n" - printf "\t-c: create cell file if none exist\n\n" - return 1 - fi - - while [ $# -gt 0 ]; do - case "$1" in - -a) apply=true ;; - -e) EDITOR=$2; shift ;; - -c) create=true ;; - *) cdf="$1" ;; - esac - shift - done - - if [ ! -e "${cpath}${cdf}" ] && [ "$create" = "false" ]; then - printf "${cdf} : no such cell\n" && return 1 - fi - - if [ -z "${EDITOR}" ] || [ -x "$(which ${EDITOR})" ]; then - unset EDITOR && vi ${cpath}${cdf} - else - $EDITOR ${cpath}${cdf} - fi - ($apply) && cell ${cdf} +# Edit a cell file by providing a cell name; opens the cell file in $EDITOR. +function vicell { + local apply=false + local create=false + local cdf="" + local cpath="${ONOS_ROOT}/tools/test/cells/" + + if [ -z "$1" ] || [ "$1" = "-h" ] ; then + printf "usage: vicell [file] [options]\n\noptions:\n" + printf "\t-a: apply the cell after editing\n" + printf "\t-e: [editor] set EDITOR to [editor] (default *vi*)\n" + printf "\t-c: create cell file if none exist\n\n" + return 1 + fi + + while [ $# -gt 0 ]; do + case "$1" in + -a) apply=true ;; + -e) EDITOR=$2; shift ;; + -c) create=true ;; + *) cdf="$1" ;; + esac + shift + done + + if [ ! -e "${cpath}${cdf}" ] && [ "$create" = "false" ]; then + printf "${cdf} : no such cell\n" && return 1 + fi + + if [ -z "${EDITOR}" ] || [ -x "$(which ${EDITOR})" ]; then + unset EDITOR && vi ${cpath}${cdf} + else + $EDITOR ${cpath}${cdf} + fi + ($apply) && cell ${cdf} } # autocomplete for certain utilities diff --git a/framework/src/onos/tools/dev/bin/onos-create-app b/framework/src/onos/tools/dev/bin/onos-create-app index 65b00b65..454bcd6e 100755 --- a/framework/src/onos/tools/dev/bin/onos-create-app +++ b/framework/src/onos/tools/dev/bin/onos-create-app @@ -11,7 +11,7 @@ type=${1:-bundle} [ $type = app ] && archetype=bundle || archetype=$type if [ "$1" = "-?" -o "$1" = "-h" -o "$1" = "--help" ]; then - echo "usage: $(basename $0) {app|bundle|ui|cli|api} groupId artifactId version package mvn-options" + echo "usage: $(basename $0) {app|bundle|ui|uitab|uitopo|cli|api} groupId artifactId version package mvn-options" echo " All arguments are optional" exit 1 fi diff --git a/framework/src/onos/tools/dev/header.txt b/framework/src/onos/tools/dev/header.txt index 6c18c92c..5b9dcb84 100644 --- a/framework/src/onos/tools/dev/header.txt +++ b/framework/src/onos/tools/dev/header.txt @@ -1,4 +1,4 @@ -Copyright $today.year Open Networking Laboratory +Copyright 2014-$today.year 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. diff --git a/framework/src/onos/tools/package/archetypes/pom.xml b/framework/src/onos/tools/package/archetypes/pom.xml index 525a2f68..12a23229 100644 --- a/framework/src/onos/tools/package/archetypes/pom.xml +++ b/framework/src/onos/tools/package/archetypes/pom.xml @@ -38,6 +38,8 @@ <module>bundle</module> <module>cli</module> <module>ui</module> + <module>uitab</module> + <module>uitopo</module> </modules> <build> diff --git a/framework/src/onos/tools/package/archetypes/ui/pom.xml b/framework/src/onos/tools/package/archetypes/ui/pom.xml index 8dd3a8e0..9bebe9da 100644 --- a/framework/src/onos/tools/package/archetypes/ui/pom.xml +++ b/framework/src/onos/tools/package/archetypes/ui/pom.xml @@ -26,6 +26,6 @@ <artifactId>onos-ui-archetype</artifactId> <packaging>maven-archetype</packaging> - <description>ONOS UI overlay archetype</description> + <description>ONOS UI Custom-View overlay archetype</description> </project> diff --git a/framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/pom.xml b/framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/pom.xml index 2e1f091e..d67c181a 100644 --- a/framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/pom.xml +++ b/framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/pom.xml @@ -22,7 +22,7 @@ <version>${version}</version> <packaging>bundle</packaging> - <description>ONOS OSGi UI bundle archetype</description> + <description>ONOS OSGi UI Custom-View bundle archetype</description> <url>http://onosproject.org</url> <properties> diff --git a/framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/java/AppUiComponent.java b/framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/java/AppUiComponent.java index f40bcb5f..e44b34d5 100644 --- a/framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/java/AppUiComponent.java +++ b/framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/java/AppUiComponent.java @@ -34,11 +34,14 @@ import org.slf4j.LoggerFactory; import java.util.List; /** - * Skeletal ONOS UI application component. + * Skeletal ONOS UI Custom-View application component. */ @Component(immediate = true) public class AppUiComponent { + private static final String VIEW_ID = "sampleCustom"; + private static final String VIEW_TEXT = "Sample Custom"; + private final Logger log = LoggerFactory.getLogger(getClass()); @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) @@ -46,7 +49,7 @@ public class AppUiComponent { // List of application views private final List<UiView> uiViews = ImmutableList.of( - new UiView(UiView.Category.OTHER, "sample", "Sample") + new UiView(UiView.Category.OTHER, VIEW_ID, VIEW_TEXT) ); // Factory for UI message handlers diff --git a/framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/java/AppUiMessageHandler.java b/framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/java/AppUiMessageHandler.java index d9d68b53..d6486328 100644 --- a/framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/java/AppUiMessageHandler.java +++ b/framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/java/AppUiMessageHandler.java @@ -22,168 +22,56 @@ import com.fasterxml.jackson.databind.node.ObjectNode; import com.google.common.collect.ImmutableSet; import org.onosproject.ui.RequestHandler; import org.onosproject.ui.UiMessageHandler; -import org.onosproject.ui.table.TableModel; -import org.onosproject.ui.table.TableRequestHandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.lang.Override; -import java.util.ArrayList; import java.util.Collection; -import java.util.List; /** - * Skeletal ONOS UI message handler. - * <p> - * This example specifically supporting a "table" view. + * Skeletal ONOS UI Custom-View message handler. */ public class AppUiMessageHandler extends UiMessageHandler { - private static final String SAMPLE_DATA_REQ = "sampleDataRequest"; - private static final String SAMPLE_DATA_RESP = "sampleDataResponse"; - private static final String SAMPLES = "samples"; + private static final String SAMPLE_CUSTOM_DATA_REQ = "sampleCustomDataRequest"; + private static final String SAMPLE_CUSTOM_DATA_RESP = "sampleCustomDataResponse"; - private static final String SAMPLE_DETAIL_REQ = "sampleDetailsRequest"; - private static final String SAMPLE_DETAIL_RESP = "sampleDetailsResponse"; - private static final String DETAILS = "details"; - - private static final String ID = "id"; - private static final String LABEL = "label"; - private static final String CODE = "code"; - private static final String COMMENT = "comment"; - private static final String RESULT = "result"; - - private static final String[] COLUMN_IDS = { ID, LABEL, CODE }; + private static final String NUMBER = "number"; + private static final String SQUARE = "square"; + private static final String CUBE = "cube"; + private static final String MESSAGE = "message"; + private static final String MSG_FORMAT = "Next incrememt is %d units"; private final Logger log = LoggerFactory.getLogger(getClass()); + private long someNumber = 1; + private long someIncrement = 1; @Override protected Collection<RequestHandler> createRequestHandlers() { return ImmutableSet.of( - new SampleDataRequestHandler(), - new SampleDetailRequestHandler() + new SampleCustomDataRequestHandler() ); } - // handler for sample table requests - private final class SampleDataRequestHandler extends TableRequestHandler { - - private SampleDataRequestHandler() { - super(SAMPLE_DATA_REQ, SAMPLE_DATA_RESP, SAMPLES); - } - - // if necessary, override defaultColumnId() -- if it isn't "id" + // handler for sample data requests + private final class SampleCustomDataRequestHandler extends RequestHandler { - @Override - protected String[] getColumnIds() { - return COLUMN_IDS; - } - - @Override - protected void populateTable(TableModel tm, ObjectNode payload) { - // === set custom column cell formatters/comparators if need be... - // tm.setFormatter(CODE, new CodeFormatter()); - // tm.setComparator(CODE, new CodeComparator()); - - // === retrieve table row items from some service... - // SomeService ss = get(SomeService.class); - // List<Item> items = ss.getItems() - - // fake data for demonstration purposes... - List<Item> items = getItems(); - for (Item item: items) { - populateRow(tm.addRow(), item); - } - } - - private void populateRow(TableModel.Row row, Item item) { - row.cell(ID, item.id()) - .cell(LABEL, item.label()) - .cell(CODE, item.code()); - } - } - - - // handler for sample item details requests - private final class SampleDetailRequestHandler extends RequestHandler { - - private SampleDetailRequestHandler() { - super(SAMPLE_DETAIL_REQ); + private SampleCustomDataRequestHandler() { + super(SAMPLE_CUSTOM_DATA_REQ); } @Override public void process(long sid, ObjectNode payload) { - String id = string(payload, ID, "(none)"); - - // SomeService ss = get(SomeService.class); - // Item item = ss.getItemDetails(id) - - // fake data for demonstration purposes... - Item item = getItem(id); - - ObjectNode rootNode = MAPPER.createObjectNode(); - ObjectNode data = MAPPER.createObjectNode(); - rootNode.set(DETAILS, data); - - if (item == null) { - rootNode.put(RESULT, "Item with id '" + id + "' not found"); - log.warn("attempted to get item detail for id '{}'", id); - - } else { - rootNode.put(RESULT, "Found item with id '" + id + "'"); - - data.put(ID, item.id()); - data.put(LABEL, item.label()); - data.put(CODE, item.code()); - data.put(COMMENT, "Some arbitrary comment"); - } - - sendMessage(SAMPLE_DETAIL_RESP, 0, rootNode); - } - } - - - // =================================================================== - // NOTE: The code below this line is to create fake data for this - // sample code. Normally you would use existing services to - // provide real data. - - // Lookup a single item. - private static Item getItem(String id) { - // We realize this code is really inefficient, but - // it suffices for our purposes of demonstration... - for (Item item : getItems()) { - if (item.id().equals(id)) { - return item; - } + someIncrement++; + someNumber += someIncrement; + log.debug("Computing data for {}...", someNumber); + + ObjectNode result = objectNode(); + result.put(NUMBER, someNumber); + result.put(SQUARE, someNumber * someNumber); + result.put(CUBE, someNumber * someNumber * someNumber); + result.put(MESSAGE, String.format(MSG_FORMAT, someIncrement + 1)); + sendMessage(SAMPLE_CUSTOM_DATA_RESP, 0, result); } - return null; - } - - // Produce a list of items. - private static List<Item> getItems() { - List<Item> items = new ArrayList<>(); - items.add(new Item("item-1", "foo", 42)); - items.add(new Item("item-2", "bar", 99)); - items.add(new Item("item-3", "baz", 65)); - return items; - } - - // Simple model class to provide sample data - private static class Item { - private final String id; - private final String label; - private final int code; - - Item(String id, String label, int code) { - this.id = id; - this.label = label; - this.code = code; - } - - String id() { return id; } - String label() { return label; } - int code() { return code; } } }
\ No newline at end of file diff --git a/framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/resources/app/view/sampleCustom/sampleCustom.css b/framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/resources/app/view/sampleCustom/sampleCustom.css new file mode 100644 index 00000000..ffeac0aa --- /dev/null +++ b/framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/resources/app/view/sampleCustom/sampleCustom.css @@ -0,0 +1,48 @@ +/* css for sample app custom view */ + +#ov-sample-custom { + padding: 20px; +} +.light #ov-sample-custom { + color: navy; +} +.dark #ov-sample-custom { + color: #88f; +} + +#ov-sample-custom .button-panel { + margin: 10px; + width: 200px; +} + +.light #ov-sample-custom .button-panel { + background-color: #ccf; +} +.dark #ov-sample-custom .button-panel { + background-color: #444; +} + +#ov-sample-custom .my-button { + cursor: pointer; + padding: 4px; + text-align: center; +} + +.light #ov-sample-custom .my-button { + color: white; + background-color: #99d; +} +.dark #ov-sample-custom .my-button { + color: black; + background-color: #aaa; +} + +#ov-sample-custom .number { + font-size: 140%; + text-align: right; +} + +#ov-sample-custom .quote { + margin: 10px 20px; + font-style: italic; +}
\ No newline at end of file diff --git a/framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/resources/app/view/sampleCustom/sampleCustom.html b/framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/resources/app/view/sampleCustom/sampleCustom.html new file mode 100644 index 00000000..d3d79a10 --- /dev/null +++ b/framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/resources/app/view/sampleCustom/sampleCustom.html @@ -0,0 +1,32 @@ +<!-- partial HTML --> +<div id="ov-sample-custom"> + <div class="button-panel"> + <div class="my-button" ng-click="getData()"> + Fetch Data + </div> + </div> + + <div class="data-panel"> + <table> + <tr> + <td> Number </td> + <td class="number"> {{data.number}} </td> + </tr> + <tr> + <td> Square </td> + <td class="number"> {{data.square}} </td> + </tr> + <tr> + <td> Cube </td> + <td class="number"> {{data.cube}} </td> + </tr> + </table> + + <p> + A message from our sponsors: + </p> + <p> + <span class="quote"> {{data.message}} </span> + </p> + </div> +</div> diff --git a/framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/resources/app/view/sampleCustom/sampleCustom.js b/framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/resources/app/view/sampleCustom/sampleCustom.js new file mode 100644 index 00000000..21058640 --- /dev/null +++ b/framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/resources/app/view/sampleCustom/sampleCustom.js @@ -0,0 +1,69 @@ +// js for sample app custom view +(function () { + 'use strict'; + + // injected refs + var $log, $scope, wss, ks; + + // constants + var dataReq = 'sampleCustomDataRequest', + dataResp = 'sampleCustomDataResponse'; + + function addKeyBindings() { + var map = { + space: [getData, 'Fetch data from server'], + + _helpFormat: [ + ['space'] + ] + }; + + ks.keyBindings(map); + } + + function getData() { + wss.sendEvent(dataReq); + } + + function respDataCb(data) { + $scope.data = data; + $scope.$apply(); + } + + + angular.module('ovSampleCustom', []) + .controller('OvSampleCustomCtrl', + ['$log', '$scope', 'WebSocketService', 'KeyService', + + function (_$log_, _$scope_, _wss_, _ks_) { + $log = _$log_; + $scope = _$scope_; + wss = _wss_; + ks = _ks_; + + var handlers = {}; + $scope.data = {}; + + // data response handler + handlers[dataResp] = respDataCb; + wss.bindHandlers(handlers); + + addKeyBindings(); + + // custom click handler + $scope.getData = getData; + + // get data the first time... + getData(); + + // cleanup + $scope.$on('$destroy', function () { + wss.unbindHandlers(handlers); + ks.unbindKeys(); + $log.log('OvSampleCustomCtrl has been destroyed'); + }); + + $log.log('OvSampleCustomCtrl has been created'); + }]); + +}()); diff --git a/framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/resources/css.html b/framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/resources/css.html index c4697256..4e7b7092 100644 --- a/framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/resources/css.html +++ b/framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/resources/css.html @@ -1 +1 @@ -<link rel="stylesheet" href="app/view/sample/sample.css">
\ No newline at end of file +<link rel="stylesheet" href="app/view/sampleCustom/sampleCustom.css">
\ No newline at end of file diff --git a/framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/resources/js.html b/framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/resources/js.html index 7cacc707..6550b85e 100644 --- a/framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/resources/js.html +++ b/framework/src/onos/tools/package/archetypes/ui/src/main/resources/archetype-resources/src/main/resources/js.html @@ -1 +1 @@ -<script src="app/view/sample/sample.js"></script>
\ No newline at end of file +<script src="app/view/sampleCustom/sampleCustom.js"></script>
\ No newline at end of file diff --git a/framework/src/onos/tools/package/archetypes/uitab/pom.xml b/framework/src/onos/tools/package/archetypes/uitab/pom.xml new file mode 100644 index 00000000..cb18f1f3 --- /dev/null +++ b/framework/src/onos/tools/package/archetypes/uitab/pom.xml @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ Copyright 2015 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. + --> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.onosproject</groupId> + <artifactId>onos-archetypes</artifactId> + <version>1.4.0-SNAPSHOT</version> + </parent> + + <artifactId>onos-uitab-archetype</artifactId> + <packaging>maven-archetype</packaging> + + <description>ONOS UI Table-View overlay archetype</description> + +</project> diff --git a/framework/src/onos/tools/package/archetypes/uitab/src/main/resources/META-INF/maven/archetype-metadata.xml b/framework/src/onos/tools/package/archetypes/uitab/src/main/resources/META-INF/maven/archetype-metadata.xml new file mode 100644 index 00000000..a6273811 --- /dev/null +++ b/framework/src/onos/tools/package/archetypes/uitab/src/main/resources/META-INF/maven/archetype-metadata.xml @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- + ~ Copyright 2015 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. + --> +<archetype-descriptor + xsi:schemaLocation="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0 http://maven.apache.org/xsd/archetype-descriptor-1.0.0.xsd" + name="onos-uitab" partial="true" + xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <fileSets> + <fileSet filtered="true" packaged="true" encoding="UTF-8"> + <directory>src/main/java</directory> + <includes> + <include>**/*.java</include> + </includes> + </fileSet> + <fileSet filtered="true" packaged="false" encoding="UTF-8"> + <directory>src/main/resources</directory> + <includes> + <include>**/*.html</include> + <include>**/*.js</include> + <include>**/*.css</include> + </includes> + </fileSet> + </fileSets> +</archetype-descriptor> diff --git a/framework/src/onos/tools/package/archetypes/uitab/src/main/resources/archetype-resources/pom.xml b/framework/src/onos/tools/package/archetypes/uitab/src/main/resources/archetype-resources/pom.xml new file mode 100644 index 00000000..05a62b27 --- /dev/null +++ b/framework/src/onos/tools/package/archetypes/uitab/src/main/resources/archetype-resources/pom.xml @@ -0,0 +1,140 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- + ~ Copyright 2015 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. + --> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>${groupId}</groupId> + <artifactId>${artifactId}</artifactId> + <version>${version}</version> + <packaging>bundle</packaging> + + <description>ONOS OSGi UI Table-View bundle archetype</description> + <url>http://onosproject.org</url> + + <properties> + <onos.version>1.4.0-SNAPSHOT</onos.version> + <!-- Uncomment to generate ONOS app from this module. + <onos.app.name>org.foo.app</onos.app.name> + <onos.app.origin>Foo, Inc.</onos.app.origin> + --> + </properties> + + <dependencies> + <dependency> + <groupId>org.onosproject</groupId> + <artifactId>onos-api</artifactId> + <version>${onos.version}</version> + </dependency> + + <dependency> + <groupId>org.onosproject</groupId> + <artifactId>onlab-osgi</artifactId> + <version>${onos.version}</version> + </dependency> + + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.11</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.onosproject</groupId> + <artifactId>onos-api</artifactId> + <version>${onos.version}</version> + <scope>test</scope> + <classifier>tests</classifier> + </dependency> + + <dependency> + <groupId>org.apache.felix</groupId> + <artifactId>org.apache.felix.scr.annotations</artifactId> + <version>1.9.8</version> + <scope>provided</scope> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + <version>2.5.3</version> + <extensions>true</extensions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>2.5.1</version> + <configuration> + <source>1.8</source> + <target>1.8</target> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-scr-plugin</artifactId> + <version>1.20.0</version> + <executions> + <execution> + <id>generate-scr-srcdescriptor</id> + <goals> + <goal>scr</goal> + </goals> + </execution> + </executions> + <configuration> + <supportedProjectTypes> + <supportedProjectType>bundle</supportedProjectType> + <supportedProjectType>war</supportedProjectType> + </supportedProjectTypes> + </configuration> + </plugin> + <plugin> + <groupId>org.onosproject</groupId> + <artifactId>onos-maven-plugin</artifactId> + <version>1.5</version> + <executions> + <execution> + <id>cfg</id> + <phase>generate-resources</phase> + <goals> + <goal>cfg</goal> + </goals> + </execution> + <execution> + <id>swagger</id> + <phase>generate-sources</phase> + <goals> + <goal>swagger</goal> + </goals> + </execution> + <execution> + <id>app</id> + <phase>package</phase> + <goals> + <goal>app</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + +</project> diff --git a/framework/src/onos/tools/package/archetypes/uitab/src/main/resources/archetype-resources/src/main/java/AppUiTableComponent.java b/framework/src/onos/tools/package/archetypes/uitab/src/main/resources/archetype-resources/src/main/java/AppUiTableComponent.java new file mode 100644 index 00000000..263564ce --- /dev/null +++ b/framework/src/onos/tools/package/archetypes/uitab/src/main/resources/archetype-resources/src/main/java/AppUiTableComponent.java @@ -0,0 +1,80 @@ +#set( $symbol_pound = '#' ) +#set( $symbol_dollar = '$' ) +#set( $symbol_escape = '\' ) +/* + * Copyright 2014,2015 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 ${package}; + +import com.google.common.collect.ImmutableList; +import org.apache.felix.scr.annotations.Activate; +import org.apache.felix.scr.annotations.Component; +import org.apache.felix.scr.annotations.Deactivate; +import org.apache.felix.scr.annotations.Reference; +import org.apache.felix.scr.annotations.ReferenceCardinality; +import org.onosproject.ui.UiExtension; +import org.onosproject.ui.UiExtensionService; +import org.onosproject.ui.UiMessageHandlerFactory; +import org.onosproject.ui.UiView; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.List; + +/** + * Skeletal ONOS UI Table-View application component. + */ +@Component(immediate = true) +public class AppUiTableComponent { + + private static final String VIEW_ID = "sampleTable"; + private static final String VIEW_TEXT = "Sample Table"; + + private final Logger log = LoggerFactory.getLogger(getClass()); + + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) + protected UiExtensionService uiExtensionService; + + // List of application views + private final List<UiView> uiViews = ImmutableList.of( + new UiView(UiView.Category.OTHER, VIEW_ID, VIEW_TEXT) + ); + + // Factory for UI message handlers + private final UiMessageHandlerFactory messageHandlerFactory = + () -> ImmutableList.of( + new AppUiTableMessageHandler() + ); + + // Application UI extension + protected UiExtension extension = + new UiExtension.Builder(getClass().getClassLoader(), uiViews) + .resourcePath(VIEW_ID) + .messageHandlerFactory(messageHandlerFactory) + .build(); + + @Activate + protected void activate() { + uiExtensionService.register(extension); + log.info("Started"); + } + + @Deactivate + protected void deactivate() { + uiExtensionService.unregister(extension); + log.info("Stopped"); + } + +} diff --git a/framework/src/onos/tools/package/archetypes/uitab/src/main/resources/archetype-resources/src/main/java/AppUiTableMessageHandler.java b/framework/src/onos/tools/package/archetypes/uitab/src/main/resources/archetype-resources/src/main/java/AppUiTableMessageHandler.java new file mode 100644 index 00000000..a673f1fd --- /dev/null +++ b/framework/src/onos/tools/package/archetypes/uitab/src/main/resources/archetype-resources/src/main/java/AppUiTableMessageHandler.java @@ -0,0 +1,190 @@ +#set( $symbol_pound = '#' ) +#set( $symbol_dollar = '$' ) +#set( $symbol_escape = '\' ) +/* + * Copyright 2014,2015 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 ${package}; + +import com.fasterxml.jackson.databind.node.ObjectNode; +import com.google.common.collect.ImmutableSet; +import org.onosproject.ui.RequestHandler; +import org.onosproject.ui.UiMessageHandler; +import org.onosproject.ui.table.TableModel; +import org.onosproject.ui.table.TableRequestHandler; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.lang.Override; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +/** + * Skeletal ONOS UI Table-View message handler. + */ +public class AppUiTableMessageHandler extends UiMessageHandler { + + private static final String SAMPLE_TABLE_DATA_REQ = "sampleTableDataRequest"; + private static final String SAMPLE_TABLE_DATA_RESP = "sampleTableDataResponse"; + private static final String SAMPLE_TABLES = "sampleTables"; + + private static final String SAMPLE_TABLE_DETAIL_REQ = "sampleTableDetailsRequest"; + private static final String SAMPLE_TABLE_DETAIL_RESP = "sampleTableDetailsResponse"; + private static final String DETAILS = "details"; + + private static final String ID = "id"; + private static final String LABEL = "label"; + private static final String CODE = "code"; + private static final String COMMENT = "comment"; + private static final String RESULT = "result"; + + private static final String[] COLUMN_IDS = { ID, LABEL, CODE }; + + private final Logger log = LoggerFactory.getLogger(getClass()); + + + @Override + protected Collection<RequestHandler> createRequestHandlers() { + return ImmutableSet.of( + new SampleTableDataRequestHandler(), + new SampleTableDetailRequestHandler() + ); + } + + // handler for sample table requests + private final class SampleTableDataRequestHandler extends TableRequestHandler { + + private SampleTableDataRequestHandler() { + super(SAMPLE_TABLE_DATA_REQ, SAMPLE_TABLE_DATA_RESP, SAMPLE_TABLES); + } + + // if necessary, override defaultColumnId() -- if it isn't "id" + + @Override + protected String[] getColumnIds() { + return COLUMN_IDS; + } + + // if required, override createTableModel() to set column formatters / comparators + + @Override + protected void populateTable(TableModel tm, ObjectNode payload) { + // === NOTE: the table model supplied here will have been created + // via a call to createTableModel(). To assign non-default + // cell formatters or comparators to the table model, override + // createTableModel() and set them there. + + // === retrieve table row items from some service... + // SomeService ss = get(SomeService.class); + // List<Item> items = ss.getItems() + + // fake data for demonstration purposes... + List<Item> items = getItems(); + for (Item item: items) { + populateRow(tm.addRow(), item); + } + } + + private void populateRow(TableModel.Row row, Item item) { + row.cell(ID, item.id()) + .cell(LABEL, item.label()) + .cell(CODE, item.code()); + } + } + + + // handler for sample item details requests + private final class SampleTableDetailRequestHandler extends RequestHandler { + + private SampleTableDetailRequestHandler() { + super(SAMPLE_TABLE_DETAIL_REQ); + } + + @Override + public void process(long sid, ObjectNode payload) { + String id = string(payload, ID, "(none)"); + + // SomeService ss = get(SomeService.class); + // Item item = ss.getItemDetails(id) + + // fake data for demonstration purposes... + Item item = getItem(id); + + ObjectNode rootNode = objectNode(); + ObjectNode data = objectNode(); + rootNode.set(DETAILS, data); + + if (item == null) { + rootNode.put(RESULT, "Item with id '" + id + "' not found"); + log.warn("attempted to get item detail for id '{}'", id); + + } else { + rootNode.put(RESULT, "Found item with id '" + id + "'"); + + data.put(ID, item.id()); + data.put(LABEL, item.label()); + data.put(CODE, item.code()); + data.put(COMMENT, "Some arbitrary comment"); + } + + sendMessage(SAMPLE_TABLE_DETAIL_RESP, 0, rootNode); + } + } + + + // =================================================================== + // NOTE: The code below this line is to create fake data for this + // sample code. Normally you would use existing services to + // provide real data. + + // Lookup a single item. + private static Item getItem(String id) { + // We realize this code is really inefficient, but + // it suffices for our purposes of demonstration... + for (Item item : getItems()) { + if (item.id().equals(id)) { + return item; + } + } + return null; + } + + // Produce a list of items. + private static List<Item> getItems() { + List<Item> items = new ArrayList<>(); + items.add(new Item("item-1", "foo", 42)); + items.add(new Item("item-2", "bar", 99)); + items.add(new Item("item-3", "baz", 65)); + return items; + } + + // Simple model class to provide sample data + private static class Item { + private final String id; + private final String label; + private final int code; + + Item(String id, String label, int code) { + this.id = id; + this.label = label; + this.code = code; + } + + String id() { return id; } + String label() { return label; } + int code() { return code; } + } +}
\ No newline at end of file diff --git a/framework/src/onos/tools/package/archetypes/uitab/src/main/resources/archetype-resources/src/main/resources/app/view/sampleTable/sampleTable.css b/framework/src/onos/tools/package/archetypes/uitab/src/main/resources/archetype-resources/src/main/resources/app/view/sampleTable/sampleTable.css new file mode 100644 index 00000000..5eb551b3 --- /dev/null +++ b/framework/src/onos/tools/package/archetypes/uitab/src/main/resources/archetype-resources/src/main/resources/app/view/sampleTable/sampleTable.css @@ -0,0 +1,35 @@ +/* css for sample table view */ + +#ov-sample-table h2 { + display: inline-block; +} + +/* Panel Styling */ +#ov-sample-table-item-details-panel.floatpanel { + position: absolute; + top: 115px; +} + +.light #ov-sample-table-item-details-panel.floatpanel { + background-color: rgb(229, 234, 237); +} +.dark #ov-sample-table-item-details-panel.floatpanel { + background-color: #3A4042; +} + +#ov-sample-table-item-details-panel h3 { + margin: 0; + font-size: large; +} + +#ov-sample-table-item-details-panel h4 { + margin: 0; +} + +#ov-sample-table-item-details-panel td { + padding: 5px; +} +#ov-sample-table-item-details-panel td.label { + font-style: italic; + opacity: 0.8; +} diff --git a/framework/src/onos/tools/package/archetypes/uitab/src/main/resources/archetype-resources/src/main/resources/app/view/sampleTable/sampleTable.html b/framework/src/onos/tools/package/archetypes/uitab/src/main/resources/archetype-resources/src/main/resources/app/view/sampleTable/sampleTable.html new file mode 100644 index 00000000..e20a94d7 --- /dev/null +++ b/framework/src/onos/tools/package/archetypes/uitab/src/main/resources/archetype-resources/src/main/resources/app/view/sampleTable/sampleTable.html @@ -0,0 +1,46 @@ +<!-- partial HTML --> +<div id="ov-sample-table"> + <div class="tabular-header"> + <h2>Items ({{tableData.length}} total)</h2> + <div class="ctrl-btns"> + <div class="refresh" ng-class="{active: autoRefresh}" + icon icon-id="refresh" icon-size="36" + tooltip tt-msg="autoRefreshTip" + ng-click="toggleRefresh()"></div> + </div> + </div> + + <div class="summary-list" onos-table-resize> + + <div class="table-header" onos-sortable-header> + <table> + <tr> + <td colId="id" sortable>Item ID </td> + <td colId="label" sortable>Label </td> + <td colId="code" sortable>Code </td> + </tr> + </table> + </div> + + <div class="table-body"> + <table> + <tr ng-if="!tableData.length" class="no-data"> + <td colspan="3"> + No Items found + </td> + </tr> + + <tr ng-repeat="item in tableData track by $index" + ng-click="selectCallback($event, item)" + ng-class="{selected: item.id === selId}"> + <td>{{item.id}}</td> + <td>{{item.label}}</td> + <td>{{item.code}}</td> + </tr> + </table> + </div> + + </div> + + <ov-sample-table-item-details-panel></ov-sample-table-item-details-panel> +</div> diff --git a/framework/src/onos/tools/package/archetypes/uitab/src/main/resources/archetype-resources/src/main/resources/app/view/sampleTable/sampleTable.js b/framework/src/onos/tools/package/archetypes/uitab/src/main/resources/archetype-resources/src/main/resources/app/view/sampleTable/sampleTable.js new file mode 100644 index 00000000..7b925550 --- /dev/null +++ b/framework/src/onos/tools/package/archetypes/uitab/src/main/resources/archetype-resources/src/main/resources/app/view/sampleTable/sampleTable.js @@ -0,0 +1,141 @@ +// js for sample app table view +(function () { + 'use strict'; + + // injected refs + var $log, $scope, fs, wss; + + // constants + var detailsReq = 'sampleTableDetailsRequest', + detailsResp = 'sampleTableDetailsResponse', + pName = 'ov-sample-table-item-details-panel', + + propOrder = ['id', 'label', 'code'], + friendlyProps = ['Item ID', 'Item Label', 'Special Code']; + + + function addProp(tbody, index, value) { + var tr = tbody.append('tr'); + + function addCell(cls, txt) { + tr.append('td').attr('class', cls).html(txt); + } + addCell('label', friendlyProps[index] + ' :'); + addCell('value', value); + } + + function populatePanel(panel) { + var title = panel.append('h3'), + tbody = panel.append('table').append('tbody'); + + title.text('Item Details'); + + propOrder.forEach(function (prop, i) { + addProp(tbody, i, $scope.panelDetails[prop]); + }); + + panel.append('hr'); + panel.append('h4').text('Comments'); + panel.append('p').text($scope.panelDetails.comment); + } + + function respDetailsCb(data) { + $scope.panelDetails = data.details; + $scope.$apply(); + } + + angular.module('ovSampleTable', []) + .controller('OvSampleTableCtrl', + ['$log', '$scope', 'TableBuilderService', + 'FnService', 'WebSocketService', + + function (_$log_, _$scope_, tbs, _fs_, _wss_) { + $log = _$log_; + $scope = _$scope_; + fs = _fs_; + wss = _wss_; + + var handlers = {}; + $scope.panelDetails = {}; + + // details response handler + handlers[detailsResp] = respDetailsCb; + wss.bindHandlers(handlers); + + // custom selection callback + function selCb($event, row) { + if ($scope.selId) { + wss.sendEvent(detailsReq, { id: row.id }); + } else { + $scope.hidePanel(); + } + $log.debug('Got a click on:', row); + } + + // TableBuilderService creating a table for us + tbs.buildTable({ + scope: $scope, + tag: 'sampleTable', + selCb: selCb + }); + + // cleanup + $scope.$on('$destroy', function () { + wss.unbindHandlers(handlers); + $log.log('OvSampleTableCtrl has been destroyed'); + }); + + $log.log('OvSampleTableCtrl has been created'); + }]) + + .directive('ovSampleTableItemDetailsPanel', ['PanelService', 'KeyService', + function (ps, ks) { + return { + restrict: 'E', + link: function (scope, element, attrs) { + // insert details panel with PanelService + // create the panel + var panel = ps.createPanel(pName, { + width: 200, + margin: 20, + hideMargin: 0 + }); + panel.hide(); + scope.hidePanel = function () { panel.hide(); }; + + function closePanel() { + if (panel.isVisible()) { + $scope.selId = null; + panel.hide(); + return true; + } + return false; + } + + // create key bindings to handle panel + ks.keyBindings({ + esc: [closePanel, 'Close the details panel'], + _helpFormat: ['esc'] + }); + ks.gestureNotes([ + ['click', 'Select a row to show item details'] + ]); + + // update the panel's contents when the data is changed + scope.$watch('panelDetails', function () { + if (!fs.isEmptyObject(scope.panelDetails)) { + panel.empty(); + populatePanel(panel); + panel.show(); + } + }); + + // cleanup on destroyed scope + scope.$on('$destroy', function () { + ks.unbindKeys(); + ps.destroyPanel(pName); + }); + } + }; + }]); +}()); diff --git a/framework/src/onos/tools/package/archetypes/uitab/src/main/resources/archetype-resources/src/main/resources/sampleTable/css.html b/framework/src/onos/tools/package/archetypes/uitab/src/main/resources/archetype-resources/src/main/resources/sampleTable/css.html new file mode 100644 index 00000000..26112b0d --- /dev/null +++ b/framework/src/onos/tools/package/archetypes/uitab/src/main/resources/archetype-resources/src/main/resources/sampleTable/css.html @@ -0,0 +1 @@ +<link rel="stylesheet" href="app/view/sampleTable/sampleTable.css">
\ No newline at end of file diff --git a/framework/src/onos/tools/package/archetypes/uitab/src/main/resources/archetype-resources/src/main/resources/sampleTable/js.html b/framework/src/onos/tools/package/archetypes/uitab/src/main/resources/archetype-resources/src/main/resources/sampleTable/js.html new file mode 100644 index 00000000..4bfa2169 --- /dev/null +++ b/framework/src/onos/tools/package/archetypes/uitab/src/main/resources/archetype-resources/src/main/resources/sampleTable/js.html @@ -0,0 +1 @@ +<script src="app/view/sampleTable/sampleTable.js"></script>
\ No newline at end of file diff --git a/framework/src/onos/tools/package/archetypes/uitab/src/test/resources/projects/basic/archetype.properties b/framework/src/onos/tools/package/archetypes/uitab/src/test/resources/projects/basic/archetype.properties new file mode 100644 index 00000000..a1213b40 --- /dev/null +++ b/framework/src/onos/tools/package/archetypes/uitab/src/test/resources/projects/basic/archetype.properties @@ -0,0 +1,21 @@ +# +# Copyright 2014 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. +# + +#Thu Dec 04 09:24:50 PST 2014 +package=it.pkg +version=0.1-SNAPSHOT +groupId=archetype.it +artifactId=basic diff --git a/framework/src/onos/tools/package/archetypes/uitab/src/test/resources/projects/basic/goal.txt b/framework/src/onos/tools/package/archetypes/uitab/src/test/resources/projects/basic/goal.txt new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/framework/src/onos/tools/package/archetypes/uitab/src/test/resources/projects/basic/goal.txt diff --git a/framework/src/onos/tools/package/archetypes/uitopo/pom.xml b/framework/src/onos/tools/package/archetypes/uitopo/pom.xml new file mode 100644 index 00000000..6ed7c871 --- /dev/null +++ b/framework/src/onos/tools/package/archetypes/uitopo/pom.xml @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ Copyright 2015 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. + --> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.onosproject</groupId> + <artifactId>onos-archetypes</artifactId> + <version>1.4.0-SNAPSHOT</version> + </parent> + + <artifactId>onos-uitopo-archetype</artifactId> + <packaging>maven-archetype</packaging> + + <description>ONOS UI Topology-Overlay overlay archetype</description> + +</project> diff --git a/framework/src/onos/tools/package/archetypes/uitopo/src/main/resources/META-INF/maven/archetype-metadata.xml b/framework/src/onos/tools/package/archetypes/uitopo/src/main/resources/META-INF/maven/archetype-metadata.xml new file mode 100644 index 00000000..26a9082d --- /dev/null +++ b/framework/src/onos/tools/package/archetypes/uitopo/src/main/resources/META-INF/maven/archetype-metadata.xml @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- + ~ Copyright 2015 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. + --> +<archetype-descriptor + xsi:schemaLocation="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0 http://maven.apache.org/xsd/archetype-descriptor-1.0.0.xsd" + name="onos-uitopo" partial="true" + xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <fileSets> + <fileSet filtered="true" packaged="true" encoding="UTF-8"> + <directory>src/main/java</directory> + <includes> + <include>**/*.java</include> + </includes> + </fileSet> + <fileSet filtered="true" packaged="false" encoding="UTF-8"> + <directory>src/main/resources</directory> + <includes> + <include>**/*.html</include> + <include>**/*.js</include> + <include>**/*.css</include> + </includes> + </fileSet> + </fileSets> +</archetype-descriptor> diff --git a/framework/src/onos/tools/package/archetypes/uitopo/src/main/resources/archetype-resources/pom.xml b/framework/src/onos/tools/package/archetypes/uitopo/src/main/resources/archetype-resources/pom.xml new file mode 100644 index 00000000..f0688ec2 --- /dev/null +++ b/framework/src/onos/tools/package/archetypes/uitopo/src/main/resources/archetype-resources/pom.xml @@ -0,0 +1,140 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- + ~ Copyright 2015 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. + --> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>${groupId}</groupId> + <artifactId>${artifactId}</artifactId> + <version>${version}</version> + <packaging>bundle</packaging> + + <description>ONOS OSGi UI Topology-Overlay bundle archetype</description> + <url>http://onosproject.org</url> + + <properties> + <onos.version>1.4.0-SNAPSHOT</onos.version> + <!-- Uncomment to generate ONOS app from this module. + <onos.app.name>org.foo.app</onos.app.name> + <onos.app.origin>Foo, Inc.</onos.app.origin> + --> + </properties> + + <dependencies> + <dependency> + <groupId>org.onosproject</groupId> + <artifactId>onos-api</artifactId> + <version>${onos.version}</version> + </dependency> + + <dependency> + <groupId>org.onosproject</groupId> + <artifactId>onlab-osgi</artifactId> + <version>${onos.version}</version> + </dependency> + + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.11</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.onosproject</groupId> + <artifactId>onos-api</artifactId> + <version>${onos.version}</version> + <scope>test</scope> + <classifier>tests</classifier> + </dependency> + + <dependency> + <groupId>org.apache.felix</groupId> + <artifactId>org.apache.felix.scr.annotations</artifactId> + <version>1.9.8</version> + <scope>provided</scope> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + <version>2.5.3</version> + <extensions>true</extensions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>2.5.1</version> + <configuration> + <source>1.8</source> + <target>1.8</target> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-scr-plugin</artifactId> + <version>1.20.0</version> + <executions> + <execution> + <id>generate-scr-srcdescriptor</id> + <goals> + <goal>scr</goal> + </goals> + </execution> + </executions> + <configuration> + <supportedProjectTypes> + <supportedProjectType>bundle</supportedProjectType> + <supportedProjectType>war</supportedProjectType> + </supportedProjectTypes> + </configuration> + </plugin> + <plugin> + <groupId>org.onosproject</groupId> + <artifactId>onos-maven-plugin</artifactId> + <version>1.5</version> + <executions> + <execution> + <id>cfg</id> + <phase>generate-resources</phase> + <goals> + <goal>cfg</goal> + </goals> + </execution> + <execution> + <id>swagger</id> + <phase>generate-sources</phase> + <goals> + <goal>swagger</goal> + </goals> + </execution> + <execution> + <id>app</id> + <phase>package</phase> + <goals> + <goal>app</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + +</project> diff --git a/framework/src/onos/tools/package/archetypes/uitopo/src/main/resources/archetype-resources/src/main/java/AppUiTopovComponent.java b/framework/src/onos/tools/package/archetypes/uitopo/src/main/resources/archetype-resources/src/main/java/AppUiTopovComponent.java new file mode 100644 index 00000000..fa62a784 --- /dev/null +++ b/framework/src/onos/tools/package/archetypes/uitopo/src/main/resources/archetype-resources/src/main/java/AppUiTopovComponent.java @@ -0,0 +1,89 @@ +#set( $symbol_pound = '#' ) +#set( $symbol_dollar = '$' ) +#set( $symbol_escape = '\' ) +/* + * Copyright 2014,2015 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 ${package}; + +import com.google.common.collect.ImmutableList; +import org.apache.felix.scr.annotations.Activate; +import org.apache.felix.scr.annotations.Component; +import org.apache.felix.scr.annotations.Deactivate; +import org.apache.felix.scr.annotations.Reference; +import org.apache.felix.scr.annotations.ReferenceCardinality; +import org.onosproject.ui.UiExtension; +import org.onosproject.ui.UiExtensionService; +import org.onosproject.ui.UiMessageHandlerFactory; +import org.onosproject.ui.UiTopoOverlayFactory; +import org.onosproject.ui.UiView; +import org.onosproject.ui.UiViewHidden; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.List; + +/** + * Skeletal ONOS UI Topology-Overlay application component. + */ +@Component(immediate = true) +public class AppUiTopovComponent { + + private static final ClassLoader CL = AppUiTopovComponent.class.getClassLoader(); + private static final String VIEW_ID = "sampleTopov"; + + private final Logger log = LoggerFactory.getLogger(getClass()); + + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) + protected UiExtensionService uiExtensionService; + + // List of application views + private final List<UiView> uiViews = ImmutableList.of( + new UiViewHidden(VIEW_ID) + ); + + // Factory for UI message handlers + private final UiMessageHandlerFactory messageHandlerFactory = + () -> ImmutableList.of( + new AppUiTopovMessageHandler() + ); + + // Factory for UI topology overlays + private final UiTopoOverlayFactory topoOverlayFactory = + () -> ImmutableList.of( + new AppUiTopovOverlay() + ); + + // Application UI extension + protected UiExtension extension = + new UiExtension.Builder(CL, uiViews) + .resourcePath(VIEW_ID) + .messageHandlerFactory(messageHandlerFactory) + .topoOverlayFactory(topoOverlayFactory) + .build(); + + @Activate + protected void activate() { + uiExtensionService.register(extension); + log.info("Started"); + } + + @Deactivate + protected void deactivate() { + uiExtensionService.unregister(extension); + log.info("Stopped"); + } + +} diff --git a/framework/src/onos/tools/package/archetypes/uitopo/src/main/resources/archetype-resources/src/main/java/AppUiTopovMessageHandler.java b/framework/src/onos/tools/package/archetypes/uitopo/src/main/resources/archetype-resources/src/main/java/AppUiTopovMessageHandler.java new file mode 100644 index 00000000..fe28186b --- /dev/null +++ b/framework/src/onos/tools/package/archetypes/uitopo/src/main/resources/archetype-resources/src/main/java/AppUiTopovMessageHandler.java @@ -0,0 +1,319 @@ +#set( $symbol_pound = '#' ) +#set( $symbol_dollar = '$' ) +#set( $symbol_escape = '\' ) +/* + * Copyright 2014,2015 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 ${package}; + +import com.fasterxml.jackson.databind.node.ObjectNode; +import com.google.common.base.Strings; +import com.google.common.collect.ImmutableSet; +import org.onlab.osgi.ServiceDirectory; +import org.onosproject.net.Device; +import org.onosproject.net.DeviceId; +import org.onosproject.net.Element; +import org.onosproject.net.HostId; +import org.onosproject.net.Link; +import org.onosproject.net.device.DeviceService; +import org.onosproject.net.host.HostService; +import org.onosproject.net.link.LinkService; +import org.onosproject.ui.RequestHandler; +import org.onosproject.ui.UiConnection; +import org.onosproject.ui.UiMessageHandler; +import org.onosproject.ui.topo.Highlights; +import org.onosproject.ui.topo.TopoJson; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; +import java.util.Timer; +import java.util.TimerTask; + +/** + * Skeletal ONOS UI Topology-Overlay message handler. + */ +public class AppUiTopovMessageHandler extends UiMessageHandler { + + private static final String SAMPLE_DISPLAY_START = "sampleDisplayStart"; + private static final String SAMPLE_DISPLAY_UPDATE = "sampleDisplayUpdate"; + private static final String SAMPLE_DISPLAY_STOP = "sampleDisplayStop"; + + private static final String ID = "id"; + private static final String MODE = "mode"; + + private static final long UPDATE_PERIOD_MS = 1000; + + private static final Link[] EMPTY_LINK_SET = new Link[0]; + + private enum Mode { IDLE, MOUSE, LINK } + + private final Logger log = LoggerFactory.getLogger(getClass()); + + private DeviceService deviceService; + private HostService hostService; + private LinkService linkService; + + private final Timer timer = new Timer("sample-overlay"); + private TimerTask demoTask = null; + private Mode currentMode = Mode.IDLE; + private Element elementOfNote; + private Link[] linkSet = EMPTY_LINK_SET; + private int linkIndex; + + + // ===============-=-=-=-=-=-======================-=-=-=-=-=-=-================================ + + + @Override + public void init(UiConnection connection, ServiceDirectory directory) { + super.init(connection, directory); + deviceService = directory.get(DeviceService.class); + hostService = directory.get(HostService.class); + linkService = directory.get(LinkService.class); + } + + @Override + protected Collection<RequestHandler> createRequestHandlers() { + return ImmutableSet.of( + new DisplayStartHandler(), + new DisplayUpdateHandler(), + new DisplayStopHandler() + ); + } + + // === ------------------------- + // === Handler classes + + private final class DisplayStartHandler extends RequestHandler { + public DisplayStartHandler() { + super(SAMPLE_DISPLAY_START); + } + + @Override + public void process(long sid, ObjectNode payload) { + String mode = string(payload, MODE); + + log.debug("Start Display: mode [{}]", mode); + clearState(); + clearForMode(); + + switch (mode) { + case "mouse": + currentMode = Mode.MOUSE; + cancelTask(); + sendMouseData(); + break; + + case "link": + currentMode = Mode.LINK; + scheduleTask(); + initLinkSet(); + sendLinkData(); + break; + + default: + currentMode = Mode.IDLE; + cancelTask(); + break; + } + } + } + + private final class DisplayUpdateHandler extends RequestHandler { + public DisplayUpdateHandler() { + super(SAMPLE_DISPLAY_UPDATE); + } + + @Override + public void process(long sid, ObjectNode payload) { + String id = string(payload, ID); + log.debug("Update Display: id [{}]", id); + if (!Strings.isNullOrEmpty(id)) { + updateForMode(id); + } else { + clearForMode(); + } + } + } + + private final class DisplayStopHandler extends RequestHandler { + public DisplayStopHandler() { + super(SAMPLE_DISPLAY_STOP); + } + + @Override + public void process(long sid, ObjectNode payload) { + log.debug("Stop Display"); + cancelTask(); + clearState(); + clearForMode(); + } + } + + // === ------------ + + private void clearState() { + currentMode = Mode.IDLE; + elementOfNote = null; + linkSet = EMPTY_LINK_SET; + } + + private void updateForMode(String id) { + log.debug("host service: {}", hostService); + log.debug("device service: {}", deviceService); + + try { + HostId hid = HostId.hostId(id); + log.debug("host id {}", hid); + elementOfNote = hostService.getHost(hid); + log.debug("host element {}", elementOfNote); + + } catch (Exception e) { + try { + DeviceId did = DeviceId.deviceId(id); + log.debug("device id {}", did); + elementOfNote = deviceService.getDevice(did); + log.debug("device element {}", elementOfNote); + + } catch (Exception e2) { + log.debug("Unable to process ID [{}]", id); + elementOfNote = null; + } + } + + switch (currentMode) { + case MOUSE: + sendMouseData(); + break; + + case LINK: + sendLinkData(); + break; + + default: + break; + } + + } + + private void clearForMode() { + sendHighlights(new Highlights()); + } + + private void sendHighlights(Highlights highlights) { + sendMessage(TopoJson.highlightsMessage(highlights)); + } + + + private void sendMouseData() { + if (elementOfNote != null && elementOfNote instanceof Device) { + DeviceId devId = (DeviceId) elementOfNote.id(); + Set<Link> links = linkService.getDeviceEgressLinks(devId); + sendHighlights(fromLinks(links, devId)); + } + // Note: could also process Host, if available + } + + private Highlights fromLinks(Set<Link> links, DeviceId devId) { + DemoLinkMap linkMap = new DemoLinkMap(); + if (links != null) { + log.debug("Processing {} links", links.size()); + links.forEach(linkMap::add); + } else { + log.debug("No egress links found for device {}", devId); + } + + Highlights highlights = new Highlights(); + + for (DemoLink dlink : linkMap.biLinks()) { + dlink.makeImportant().setLabel("Yo!"); + highlights.add(dlink.highlight(null)); + } + return highlights; + } + + private void initLinkSet() { + Set<Link> links = new HashSet<>(); + for (Link link : linkService.getActiveLinks()) { + links.add(link); + } + linkSet = links.toArray(new Link[links.size()]); + linkIndex = 0; + log.debug("initialized link set to {}", linkSet.length); + } + + private void sendLinkData() { + DemoLinkMap linkMap = new DemoLinkMap(); + for (Link link : linkSet) { + linkMap.add(link); + } + DemoLink dl = linkMap.add(linkSet[linkIndex]); + dl.makeImportant().setLabel(Integer.toString(linkIndex)); + log.debug("sending link data (index {})", linkIndex); + + linkIndex += 1; + if (linkIndex >= linkSet.length) { + linkIndex = 0; + } + + Highlights highlights = new Highlights(); + for (DemoLink dlink : linkMap.biLinks()) { + highlights.add(dlink.highlight(null)); + } + + sendHighlights(highlights); + } + + private synchronized void scheduleTask() { + if (demoTask == null) { + log.debug("Starting up demo task..."); + demoTask = new DisplayUpdateTask(); + timer.schedule(demoTask, UPDATE_PERIOD_MS, UPDATE_PERIOD_MS); + } else { + log.debug("(demo task already running"); + } + } + + private synchronized void cancelTask() { + if (demoTask != null) { + demoTask.cancel(); + demoTask = null; + } + } + + + private class DisplayUpdateTask extends TimerTask { + @Override + public void run() { + try { + switch (currentMode) { + case LINK: + sendLinkData(); + break; + + default: + break; + } + } catch (Exception e) { + log.warn("Unable to process demo task: {}", e.getMessage()); + log.debug("Oops", e); + } + } + } + +}
\ No newline at end of file diff --git a/framework/src/onos/tools/package/archetypes/uitopo/src/main/resources/archetype-resources/src/main/java/AppUiTopovOverlay.java b/framework/src/onos/tools/package/archetypes/uitopo/src/main/resources/archetype-resources/src/main/java/AppUiTopovOverlay.java new file mode 100644 index 00000000..98999825 --- /dev/null +++ b/framework/src/onos/tools/package/archetypes/uitopo/src/main/resources/archetype-resources/src/main/java/AppUiTopovOverlay.java @@ -0,0 +1,75 @@ +#set( $symbol_pound = '#' ) +#set( $symbol_dollar = '$' ) +#set( $symbol_escape = '\' ) +/* + * Copyright 2014,2015 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 ${package}; + +import org.onosproject.ui.UiTopoOverlay; +import org.onosproject.ui.topo.ButtonId; +import org.onosproject.ui.topo.PropertyPanel; +import org.onosproject.ui.topo.TopoConstants.CoreButtons; +import org.onosproject.ui.topo.TopoConstants.Glyphs; + +import static org.onosproject.ui.topo.TopoConstants.Properties.*; + +/** + * Our topology overlay. + */ +public class AppUiTopovOverlay extends UiTopoOverlay { + + // NOTE: this must match the ID defined in sampleTopov.js + private static final String OVERLAY_ID = "meowster-overlay"; + + private static final String MY_TITLE = "My App Rocks!"; + private static final String MY_VERSION = "Beta-1.0.0042"; + private static final String MY_DEVICE_TITLE = "I changed the title"; + + private static final ButtonId FOO_BUTTON = new ButtonId("foo"); + private static final ButtonId BAR_BUTTON = new ButtonId("bar"); + + public AppUiTopovOverlay() { + super(OVERLAY_ID); + } + + + @Override + public void modifySummary(PropertyPanel pp) { + pp.title(MY_TITLE) + .typeId(Glyphs.CROWN) + .removeProps( + TOPOLOGY_SSCS, + INTENTS, + TUNNELS, + FLOWS, + VERSION + ) + .addProp(VERSION, MY_VERSION); + } + + @Override + public void modifyDeviceDetails(PropertyPanel pp) { + pp.title(MY_DEVICE_TITLE); + pp.removeProps(LATITUDE, LONGITUDE); + + pp.addButton(FOO_BUTTON) + .addButton(BAR_BUTTON); + + pp.removeButtons(CoreButtons.SHOW_PORT_VIEW) + .removeButtons(CoreButtons.SHOW_GROUP_VIEW); + } + +} diff --git a/framework/src/onos/tools/package/archetypes/uitopo/src/main/resources/archetype-resources/src/main/java/DemoLink.java b/framework/src/onos/tools/package/archetypes/uitopo/src/main/resources/archetype-resources/src/main/java/DemoLink.java new file mode 100644 index 00000000..4a97f7bd --- /dev/null +++ b/framework/src/onos/tools/package/archetypes/uitopo/src/main/resources/archetype-resources/src/main/java/DemoLink.java @@ -0,0 +1,57 @@ +#set( $symbol_pound = '#' ) +#set( $symbol_dollar = '$' ) +#set( $symbol_escape = '\' ) +/* + * Copyright 2014,2015 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 ${package}; + +import org.onosproject.net.Link; +import org.onosproject.net.LinkKey; +import org.onosproject.ui.topo.BiLink; +import org.onosproject.ui.topo.LinkHighlight; +import org.onosproject.ui.topo.LinkHighlight.Flavor; + +/** + * Our demo concrete class of a bi-link. We give it state so we can decide + * how to create link highlights. + */ +public class DemoLink extends BiLink { + + private boolean important = false; + private String label = null; + + public DemoLink(LinkKey key, Link link) { + super(key, link); + } + + public DemoLink makeImportant() { + important = true; + return this; + } + + public DemoLink setLabel(String label) { + this.label = label; + return this; + } + + @Override + public LinkHighlight highlight(Enum<?> anEnum) { + Flavor flavor = important ? Flavor.PRIMARY_HIGHLIGHT + : Flavor.SECONDARY_HIGHLIGHT; + return new LinkHighlight(this.linkId(), flavor) + .setLabel(label); + } +} diff --git a/framework/src/onos/tools/package/archetypes/uitopo/src/main/resources/archetype-resources/src/main/java/DemoLinkMap.java b/framework/src/onos/tools/package/archetypes/uitopo/src/main/resources/archetype-resources/src/main/java/DemoLinkMap.java new file mode 100644 index 00000000..cc13d998 --- /dev/null +++ b/framework/src/onos/tools/package/archetypes/uitopo/src/main/resources/archetype-resources/src/main/java/DemoLinkMap.java @@ -0,0 +1,33 @@ +#set( $symbol_pound = '#' ) +#set( $symbol_dollar = '$' ) +#set( $symbol_escape = '\' ) +/* + * Copyright 2014,2015 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 ${package}; + +import org.onosproject.net.Link; +import org.onosproject.net.LinkKey; +import org.onosproject.ui.topo.BiLinkMap; + +/** + * Our concrete link map. + */ +public class DemoLinkMap extends BiLinkMap<DemoLink> { + @Override + protected DemoLink create(LinkKey linkKey, Link link) { + return new DemoLink(linkKey, link); + } +} diff --git a/framework/src/onos/tools/package/archetypes/uitopo/src/main/resources/archetype-resources/src/main/resources/app/view/sampleTopov/sampleTopov.css b/framework/src/onos/tools/package/archetypes/uitopo/src/main/resources/archetype-resources/src/main/resources/app/view/sampleTopov/sampleTopov.css new file mode 100644 index 00000000..cbf460f9 --- /dev/null +++ b/framework/src/onos/tools/package/archetypes/uitopo/src/main/resources/archetype-resources/src/main/resources/app/view/sampleTopov/sampleTopov.css @@ -0,0 +1,2 @@ +/* css for sample app topology overlay */ + diff --git a/framework/src/onos/tools/package/archetypes/uitopo/src/main/resources/archetype-resources/src/main/resources/app/view/sampleTopov/sampleTopov.html b/framework/src/onos/tools/package/archetypes/uitopo/src/main/resources/archetype-resources/src/main/resources/app/view/sampleTopov/sampleTopov.html new file mode 100644 index 00000000..b1c9acbb --- /dev/null +++ b/framework/src/onos/tools/package/archetypes/uitopo/src/main/resources/archetype-resources/src/main/resources/app/view/sampleTopov/sampleTopov.html @@ -0,0 +1,4 @@ +<!-- partial HTML --> +<div id="ov-sample-topov"> + <p>This is a hidden view .. just a placeholder to house the javascript</p> +</div> diff --git a/framework/src/onos/tools/package/archetypes/uitopo/src/main/resources/archetype-resources/src/main/resources/app/view/sampleTopov/sampleTopovDemo.js b/framework/src/onos/tools/package/archetypes/uitopo/src/main/resources/archetype-resources/src/main/resources/app/view/sampleTopov/sampleTopovDemo.js new file mode 100644 index 00000000..0b82d811 --- /dev/null +++ b/framework/src/onos/tools/package/archetypes/uitopo/src/main/resources/archetype-resources/src/main/resources/app/view/sampleTopov/sampleTopovDemo.js @@ -0,0 +1,104 @@ +/* + * Copyright 2015 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. + */ + +/* + Sample Demo module. This contains the "business logic" for the topology + overlay that we are implementing. + */ + +(function () { + 'use strict'; + + // injected refs + var $log, fs, flash, wss; + + // constants + var displayStart = 'sampleDisplayStart', + displayUpdate = 'sampleDisplayUpdate', + displayStop = 'sampleDisplayStop'; + + // internal state + var currentMode = null; + + + // === --------------------------- + // === Helper functions + + function sendDisplayStart(mode) { + wss.sendEvent(displayStart, { + mode: mode + }); + } + + function sendDisplayUpdate(what) { + wss.sendEvent(displayUpdate, { + id: what ? what.id : '' + }); + } + + function sendDisplayStop() { + wss.sendEvent(displayStop); + } + + // === --------------------------- + // === Main API functions + + function startDisplay(mode) { + if (currentMode === mode) { + $log.debug('(in mode', mode, 'already)'); + } else { + currentMode = mode; + sendDisplayStart(mode); + flash.flash('Starting display mode: ' + mode); + } + } + + function updateDisplay(m) { + if (currentMode) { + sendDisplayUpdate(m); + } + } + + function stopDisplay() { + if (currentMode) { + currentMode = null; + sendDisplayStop(); + flash.flash('Canceling display mode'); + return true; + } + return false; + } + + // === --------------------------- + // === Module Factory Definition + + angular.module('ovSampleTopov', []) + .factory('SampleTopovDemoService', + ['$log', 'FnService', 'FlashService', 'WebSocketService', + + function (_$log_, _fs_, _flash_, _wss_) { + $log = _$log_; + fs = _fs_; + flash = _flash_; + wss = _wss_; + + return { + startDisplay: startDisplay, + updateDisplay: updateDisplay, + stopDisplay: stopDisplay + }; + }]); +}()); diff --git a/framework/src/onos/tools/package/archetypes/uitopo/src/main/resources/archetype-resources/src/main/resources/app/view/sampleTopov/sampleTopovOverlay.js b/framework/src/onos/tools/package/archetypes/uitopo/src/main/resources/archetype-resources/src/main/resources/app/view/sampleTopov/sampleTopovOverlay.js new file mode 100644 index 00000000..12875e1f --- /dev/null +++ b/framework/src/onos/tools/package/archetypes/uitopo/src/main/resources/archetype-resources/src/main/resources/app/view/sampleTopov/sampleTopovOverlay.js @@ -0,0 +1,143 @@ +// sample topology overlay - client side +// +// This is the glue that binds our business logic (in sampleTopovDemo.js) +// to the overlay framework. + +(function () { + 'use strict'; + + // injected refs + var $log, tov, stds; + + // internal state should be kept in the service module (not here) + + // our overlay definition + var overlay = { + // NOTE: this must match the ID defined in AppUiTopoOverlay + overlayId: 'meowster-overlay', + glyphId: '*star4', + tooltip: 'Sample Meowster Topo Overlay', + + // These glyphs get installed using the overlayId as a prefix. + // e.g. 'star4' is installed as 'meowster-overlay-star4' + // They can be referenced (from this overlay) as '*star4' + // That is, the '*' prefix stands in for 'meowster-overlay-' + glyphs: { + star4: { + vb: '0 0 8 8', + d: 'M1,4l2,-1l1,-2l1,2l2,1l-2,1l-1,2l-1,-2z' + }, + banner: { + vb: '0 0 6 6', + d: 'M1,1v4l2,-2l2,2v-4z' + } + }, + + activate: function () { + $log.debug("Sample topology overlay ACTIVATED"); + }, + deactivate: function () { + stds.stopDisplay(); + $log.debug("Sample topology overlay DEACTIVATED"); + }, + + // detail panel button definitions + buttons: { + foo: { + gid: 'chain', + tt: 'A FOO action', + cb: function (data) { + $log.debug('FOO action invoked with data:', data); + } + }, + bar: { + gid: '*banner', + tt: 'A BAR action', + cb: function (data) { + $log.debug('BAR action invoked with data:', data); + } + } + }, + + // Key bindings for traffic overlay buttons + // NOTE: fully qual. button ID is derived from overlay-id and key-name + keyBindings: { + 0: { + cb: function () { stds.stopDisplay(); }, + tt: 'Cancel Display Mode', + gid: 'xMark' + }, + V: { + cb: function () { stds.startDisplay('mouse'); }, + tt: 'Start Mouse Mode', + gid: '*banner' + }, + F: { + cb: function () { stds.startDisplay('link'); }, + tt: 'Start Link Mode', + gid: 'chain' + }, + G: { + cb: buttonCallback, + tt: 'Uses the G key', + gid: 'crown' + }, + + _keyOrder: [ + '0', 'V', 'F', 'G' + ] + }, + + hooks: { + // hook for handling escape key + // Must return true to consume ESC, false otherwise. + escape: function () { + // Must return true to consume ESC, false otherwise. + return stds.stopDisplay(); + }, + + // hooks for when the selection changes... + empty: function () { + selectionCallback('empty'); + }, + single: function (data) { + selectionCallback('single', data); + }, + multi: function (selectOrder) { + selectionCallback('multi', selectOrder); + tov.addDetailButton('foo'); + tov.addDetailButton('bar'); + }, + mouseover: function (m) { + // m has id, class, and type properties + $log.debug('mouseover:', m); + stds.updateDisplay(m); + }, + mouseout: function () { + $log.debug('mouseout'); + stds.updateDisplay(); + } + } + }; + + + function buttonCallback(x) { + $log.debug('Toolbar-button callback', x); + } + + function selectionCallback(x, d) { + $log.debug('Selection callback', x, d); + } + + // invoke code to register with the overlay service + angular.module('ovSampleTopov') + .run(['$log', 'TopoOverlayService', 'SampleTopovDemoService', + + function (_$log_, _tov_, _stds_) { + $log = _$log_; + tov = _tov_; + stds = _stds_; + tov.register(overlay); + }]); + +}()); diff --git a/framework/src/onos/tools/package/archetypes/uitopo/src/main/resources/archetype-resources/src/main/resources/sampleTopov/css.html b/framework/src/onos/tools/package/archetypes/uitopo/src/main/resources/archetype-resources/src/main/resources/sampleTopov/css.html new file mode 100644 index 00000000..0ed6f53c --- /dev/null +++ b/framework/src/onos/tools/package/archetypes/uitopo/src/main/resources/archetype-resources/src/main/resources/sampleTopov/css.html @@ -0,0 +1 @@ +<link rel="stylesheet" href="app/view/sampleTopov/sampleTopov.css">
\ No newline at end of file diff --git a/framework/src/onos/tools/package/archetypes/uitopo/src/main/resources/archetype-resources/src/main/resources/sampleTopov/js.html b/framework/src/onos/tools/package/archetypes/uitopo/src/main/resources/archetype-resources/src/main/resources/sampleTopov/js.html new file mode 100644 index 00000000..4fed1f08 --- /dev/null +++ b/framework/src/onos/tools/package/archetypes/uitopo/src/main/resources/archetype-resources/src/main/resources/sampleTopov/js.html @@ -0,0 +1,2 @@ +<script src="app/view/sampleTopov/sampleTopovDemo.js"></script> +<script src="app/view/sampleTopov/sampleTopovOverlay.js"></script>
\ No newline at end of file diff --git a/framework/src/onos/tools/package/archetypes/uitopo/src/test/resources/projects/basic/archetype.properties b/framework/src/onos/tools/package/archetypes/uitopo/src/test/resources/projects/basic/archetype.properties new file mode 100644 index 00000000..a1213b40 --- /dev/null +++ b/framework/src/onos/tools/package/archetypes/uitopo/src/test/resources/projects/basic/archetype.properties @@ -0,0 +1,21 @@ +# +# Copyright 2014 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. +# + +#Thu Dec 04 09:24:50 PST 2014 +package=it.pkg +version=0.1-SNAPSHOT +groupId=archetype.it +artifactId=basic diff --git a/framework/src/onos/tools/package/archetypes/uitopo/src/test/resources/projects/basic/goal.txt b/framework/src/onos/tools/package/archetypes/uitopo/src/test/resources/projects/basic/goal.txt new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/framework/src/onos/tools/package/archetypes/uitopo/src/test/resources/projects/basic/goal.txt diff --git a/framework/src/onos/tools/package/config/samples/component-cfg.json b/framework/src/onos/tools/package/config/samples/component-cfg.json new file mode 100644 index 00000000..f1168e44 --- /dev/null +++ b/framework/src/onos/tools/package/config/samples/component-cfg.json @@ -0,0 +1,5 @@ +{ + "org.onosproject.proxyarp.ProxyArp": { + "ipv6NeighborDiscovery": true + } +}
\ No newline at end of file diff --git a/framework/src/onos/tools/package/config/samples/network-cfg.json b/framework/src/onos/tools/package/config/samples/network-cfg.json new file mode 100644 index 00000000..c2af8b81 --- /dev/null +++ b/framework/src/onos/tools/package/config/samples/network-cfg.json @@ -0,0 +1,66 @@ +{ + "ports" : { + "of:0000000000000002/1" : { + "interfaces" : [ + { + "ips" : [ "192.168.10.101/24" ], + "mac" : "08:9e:01:82:38:68", + "vlan" : "100" + } + ] + }, + "of:0000000000000002/20" : { + "interfaces" : [ + { + "ips" : [ "192.168.20.101/24" ], + "mac" : "08:9e:01:82:38:68", + "vlan" : "200" + } + ] + } + }, + "devices" : { + "of:0000000000000002" : { + "segmentrouting" : { + "name" : "Leaf-R1", + "nodeSid" : 101, + "routerIp" : "10.0.1.254", + "routerMac" : "00:00:00:00:01:80", + "isEdgeRouter" : true, + "adjacencySids" : [ + { "sid" : 100, "port" : [2, 3] }, + { "sid" : 200, "port" : [4, 5] } + ] + } + }, + "of:0000000000000191" : { + "segmentrouting" : { + "name" : "Spine-R1", + "nodeSid" : 105, + "routerIp" : "192.168.0.11", + "routerMac" : "00:00:01:00:11:80", + "isEdgeRouter" : false + } + } + }, + "apps" : { + "org.onosproject.router" : { + "bgp" : { + "bgpSpeakers" : [ + { + "connectPoint" : "of:00000000000000aa/10", + "peers" : [ + "192.168.10.1" + ] + }, + { + "connectPoint" : "of:00000000000000aa/20", + "peers" : [ + "192.168.20.1" + ] + } + ] + } + } + } +} diff --git a/framework/src/onos/tools/test/bin/ogroup-opts b/framework/src/onos/tools/test/bin/ogroup-opts index 41842bdd..f02b7a8f 100644 --- a/framework/src/onos/tools/test/bin/ogroup-opts +++ b/framework/src/onos/tools/test/bin/ogroup-opts @@ -44,7 +44,7 @@ function _cell-opts () { fi } -complete -F _cell-opts cell +complete -F _cell-opts cell vicell # Tab completion settings for onos-create-app. diff --git a/framework/src/onos/tools/test/bin/onos b/framework/src/onos/tools/test/bin/onos index 89197db5..780a90dc 100755 --- a/framework/src/onos/tools/test/bin/onos +++ b/framework/src/onos/tools/test/bin/onos @@ -3,6 +3,27 @@ # ONOS remote command-line client. # ----------------------------------------------------------------------------- +function _usage () { +cat << _EOF_ +usage: + $(basename $0) [-w] [node] + +flags: +- -w : Waits for ONOS instance to reach run-level 100, i.e. to be fully started. + +options: +- [node] : the node to attach to + +summary: + ONOS remote command-line client. + + The -w flag depends on 'onos-wait-for-start'. If [node] is unspecified, \$OCI + is used. + +_EOF_ +} +[ "$1" = "-h" ] && _usage && exit 0 + [ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1 . $ONOS_ROOT/tools/build/envDefaults . $ONOS_ROOT/tools/test/bin/find-node.sh diff --git a/framework/src/onos/tools/test/bin/onos-archetypes-test b/framework/src/onos/tools/test/bin/onos-archetypes-test index 7ae00332..331c4332 100755 --- a/framework/src/onos/tools/test/bin/onos-archetypes-test +++ b/framework/src/onos/tools/test/bin/onos-archetypes-test @@ -3,6 +3,19 @@ # Builds a set of projects using ONOS archetypes. # ----------------------------------------------------------------------------- +function _usage () { +cat << _EOF_ +usage: + $(basename $0) + +summary: + Builds a set of projects using ONOS archetypes. + +_EOF_ +} + +[ "$1" = "-h" ] && _usage && exit 0 + set -e export AROOT=/tmp/foo diff --git a/framework/src/onos/tools/test/bin/onos-batch b/framework/src/onos/tools/test/bin/onos-batch index 67864a22..ae288916 100755 --- a/framework/src/onos/tools/test/bin/onos-batch +++ b/framework/src/onos/tools/test/bin/onos-batch @@ -3,6 +3,28 @@ # Executes selected set of ONOS commands using the batch mode. # ----------------------------------------------------------------------------- +function _usage () { +cat << _EOF_ +usage: + $(basename $0) [node] <commands> + +options: +- [node] <commands> : node to run <commands> + +summary: + Executes selected set of ONOS commands using the batch mode. + + <commands> is a comma-separated list of ONOS CLI commands. + + If [node] isn't specified, the defualt target becomes \$OCI. When no commands + are specified, the commands 'summary','intents','flows', and 'hosts' are + executed against \$OCI. + +_EOF_ +} + +[ "$1" = "-h" ] && _usage && exit 0 + [ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1 . $ONOS_ROOT/tools/build/envDefaults diff --git a/framework/src/onos/tools/test/bin/onos-config b/framework/src/onos/tools/test/bin/onos-config index 5c3ab024..348cb839 100755 --- a/framework/src/onos/tools/test/bin/onos-config +++ b/framework/src/onos/tools/test/bin/onos-config @@ -3,6 +3,28 @@ # Remotely configures & starts ONOS for the first time. # ----------------------------------------------------------------------------- +function _usage () { +cat << _EOF_ +usage: + $(basename $0) [node] + +options: +- [node] : The node to configure + +summary: + Remotely configures and starts ONOS for the first time. + + The procedure for configruing a node include determining base features, + applications to load at startup, and clustering and logical network view + configurations, among others. + + If [node] isn't specified, the defualt target becomes \$OCI. + +_EOF_ +} + +[ "$1" = "-h" ] && _usage && exit 0 + [ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1 . $ONOS_ROOT/tools/build/envDefaults diff --git a/framework/src/onos/tools/test/bin/onos-install b/framework/src/onos/tools/test/bin/onos-install index 7384c2e3..139944e4 100755 --- a/framework/src/onos/tools/test/bin/onos-install +++ b/framework/src/onos/tools/test/bin/onos-install @@ -3,6 +3,32 @@ # Remotely pushes bits to a remote node and installs ONOS on it. # ----------------------------------------------------------------------------- +function _usage () { +cat << _EOF_ +usage: + $(basename $0) [-fn] [-m] <settings> [node] + +flags: +- -f : forces uninstall of currently installed ONOS +- -n : do not copy over onos.conf upstart configuration file. +- -m <settings> : pass <settings> XML file to remote maven installation + +options: +- [node] : remote node to install ONOS on. + +summary: + Remotely pushes bits to a remote node and installs ONOS on it. + + The [-n] flag assumes that Upstart is used. The [-f] flag depends on + and 'onos-config'. + + If [node] is not specified the default target is \$OCI. + +_EOF_ +} + +[ "$1" = "-h" ] && _usage && exit 0 + [ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1 . $ONOS_ROOT/tools/build/envDefaults diff --git a/framework/src/onos/tools/test/bin/onos-push-bits b/framework/src/onos/tools/test/bin/onos-push-bits index 8c9276fc..4d425c63 100755 --- a/framework/src/onos/tools/test/bin/onos-push-bits +++ b/framework/src/onos/tools/test/bin/onos-push-bits @@ -2,6 +2,24 @@ # ----------------------------------------------------------------------------- # Remotely pushes bits to a remote node in preparation for install. # ----------------------------------------------------------------------------- +function _usage () { +cat << _EOF_ +usage: + $(basename $0) [node] + +options: +- [node] : the target node to prime for installation + +summary: + Remotely pushes bits to a remote node in preparation for install. + + $(basename $0) is invoked as part of 'onos-install', and shouldn't be + directly invoked for the most part. + +_EOF_ +} + +[ "$1" = "-h" ] && _usage && exit 0 [ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1 . $ONOS_ROOT/tools/build/envDefaults diff --git a/framework/src/onos/tools/test/bin/onos-service b/framework/src/onos/tools/test/bin/onos-service index cc694911..35764e6f 100755 --- a/framework/src/onos/tools/test/bin/onos-service +++ b/framework/src/onos/tools/test/bin/onos-service @@ -34,7 +34,6 @@ fi case $2 in start|stop|restart|status) - # Select the target if [ "${1}" = "--cell" ]; then nodes=$(env | sort | egrep "OC[0-9]+" | cut -d= -f2) diff --git a/framework/src/onos/tools/test/bin/onos-set-controllers b/framework/src/onos/tools/test/bin/onos-set-controllers index 5b3cd6f7..27cc16c8 100755 --- a/framework/src/onos/tools/test/bin/onos-set-controllers +++ b/framework/src/onos/tools/test/bin/onos-set-controllers @@ -6,7 +6,7 @@ controllers="" for node in $ONOS_INSTANCES; do - controllers="$controllers tcp:$node:${OF_PORT:-6633}" + controllers="$controllers tcp:$node:${OF_PORT:-6653}" done ssh ${ONOS_USER:-sdn}@$OCN " diff --git a/framework/src/onos/tools/test/bin/onos-uninstall b/framework/src/onos/tools/test/bin/onos-uninstall index 7a8b9a5f..ff8ff536 100755 --- a/framework/src/onos/tools/test/bin/onos-uninstall +++ b/framework/src/onos/tools/test/bin/onos-uninstall @@ -3,6 +3,24 @@ # Remotely stops & uninstalls ONOS on the specified node. # ----------------------------------------------------------------------------- +function _usage () { +cat << _EOF_ +usage: + $(basename $0) [node] + +options: +- [node] : The remote instance to uninstall ONOS from. + +summary: + Remotely stops and uninstalls ONOS on the specified node. + + If [node] isn't specified, \$OCI becomes the target. + +_EOF_ +} + +[ "$1" = "-h" ] && _usage && exit 0 + [ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1 . $ONOS_ROOT/tools/build/envDefaults @@ -16,9 +34,12 @@ ssh $remote " [ -z \"\$(ps -ef | grep karaf.jar | grep -v grep)\" ] && break sleep 1 done - [ -z \"\$(ps -ef | grep karaf.jar | grep -v grep)\" ] || echo 'ONOS failed to stop.' + [ -z \"\$(ps -ef | grep karaf.jar | grep -v grep)\" ] || \ + (echo 'ONOS failed to stop.'; status=1) # Remove onos directory and init file - sudo rm -fr $ONOS_INSTALL_DIR - [ -f /etc/init/onos.conf ] && sudo rm /etc/init/onos.conf + [ -d $ONOS_INSTALL_DIR ] && sudo rm -fr $ONOS_INSTALL_DIR + [ -f /etc/init/onos.conf ] && sudo rm -f /etc/init/onos.conf + + exit \${status:-0}; " diff --git a/framework/src/onos/tools/test/bin/onos-watch b/framework/src/onos/tools/test/bin/onos-watch index 28e88c2f..11962f9e 100755 --- a/framework/src/onos/tools/test/bin/onos-watch +++ b/framework/src/onos/tools/test/bin/onos-watch @@ -2,6 +2,30 @@ # ----------------------------------------------------------------------------- # Monitors selected set of ONOS commands using the system watch command. # ----------------------------------------------------------------------------- +function _usage () { +cat << _EOF_ +usage: + $(basename $0) [node] <commands> [watchflags] + +options: +- [node] <commands> : the node to run the commands against +- [watchflags] : flags to be passed to the watch command. + +summary: + Monitors selected set of ONOS commands using the system watch command. + + <commands> is a comma-sepatarted list of ONOS CLI commands. If no commands + are supplied, the commands run are 'summary', 'intents', 'flows', and + 'hosts' against \$OCI. + + Note that [watchflags] only applies to platforms with the Linux-like watch + command. For other platforms, the default behavior of watch (refresh every 2 + s) is emulated. + +_EOF_ +} + +[ "$1" = "-h" ] && _usage && exit 0 [ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1 . $ONOS_ROOT/tools/build/envDefaults @@ -14,4 +38,10 @@ aux=/tmp/onos-watch.$$ trap "rm -f $aux" EXIT echo "$commands" | tr ',' '\n' > $aux -watch $3 "onos $node -b <$aux 2>/dev/null" + +# emulate watch if not Linux. +if [ "$(uname)" != "Linux" ]; then + while clear; "onos $node -b <$aux 2>/dev/null" ; do sleep 2; done +else + watch $3 "onos $node -b <$aux 2>/dev/null" +fi diff --git a/framework/src/onos/tools/test/cells/andrea b/framework/src/onos/tools/test/cells/andrea new file mode 100644 index 00000000..1f9f22fe --- /dev/null +++ b/framework/src/onos/tools/test/cells/andrea @@ -0,0 +1,11 @@ +# Andrea's ProxMox ONOS instances 1,2,3 & ONOS mininet box + +export ONOS_NIC="10.128.12.*" +export OC1="10.128.12.1" +export OC2="10.128.12.2" +export OC3="10.128.12.3" +export OCN="10.128.12.4" + +export OCT=$OC1 +export ONOS_USE_SSH=true +export ONOS_APPS=drivers,openflow,proxyarp,ovsdb diff --git a/framework/src/onos/tools/test/cells/tomx b/framework/src/onos/tools/test/cells/tomx index 3e528ee8..91036e67 100644 --- a/framework/src/onos/tools/test/cells/tomx +++ b/framework/src/onos/tools/test/cells/tomx @@ -7,4 +7,5 @@ export OC3="10.128.11.3" export OCN="10.128.11.4" export OCT=$OC1 -export ONOS_APPS=drivers,openflow,proxyarp
\ No newline at end of file +export ONOS_USE_SSH=true +export ONOS_APPS=drivers,openflow,proxyarp,mobility
\ No newline at end of file diff --git a/framework/src/onos/tools/test/scenarios/archetypes.xml b/framework/src/onos/tools/test/scenarios/archetypes.xml index 8244a32f..5440b55f 100644 --- a/framework/src/onos/tools/test/scenarios/archetypes.xml +++ b/framework/src/onos/tools/test/scenarios/archetypes.xml @@ -44,6 +44,24 @@ <step name="Verify-UI" requires="^" exec="onos-check-views ${OCI} id=sample"/> + <step name="Create-App-UI-Table-Overlay" requires="Reinstall-App-With-UI" + exec="onos-create-app uitab org.test.app test-app 1.2.3 org.test.app -DinteractiveMode=false"/> + <step name="Build-App-With-UI-Table" requires="^" + exec="mvn clean install"/> + <step name="Reinstall-App-With-UI-Table" requires="^,~Verify-UI" + exec="onos-app ${OCI} reinstall! target/test-app-1.2.3.oar"/> + <step name="Verify-UI-Table" requires="^" + exec="onos-check-views ${OCI} id=sample"/> + + <step name="Create-App-UI-Topo-Overlay" requires="Reinstall-App-With-UI-Table" + exec="onos-create-app uitopo org.test.app test-app 1.2.3 org.test.app -DinteractiveMode=false"/> + <step name="Build-App-With-UI-Topo" requires="^" + exec="mvn clean install"/> + <step name="Reinstall-App-With-UI-Topo" requires="^,~Verify-UI-Table" + exec="onos-app ${OCI} reinstall! target/test-app-1.2.3.oar"/> + <step name="Verify-UI-Topo" requires="^" + exec="onos-check-views ${OCI} id=sample"/> + <step name="Uninstall-App" requires="^" exec="onos-app ${OCI} uninstall org.foo.app"/> </group> diff --git a/framework/src/onos/tools/test/topos/onos.py b/framework/src/onos/tools/test/topos/onos.py index ae6045e3..f9d4ba23 100755 --- a/framework/src/onos/tools/test/topos/onos.py +++ b/framework/src/onos/tools/test/topos/onos.py @@ -31,7 +31,7 @@ class ONOS( Controller ): Controller.__init__( self, name, **kwargs ) # the following have been done for us: #self.ip = ip ('127.0.0.1') - #self.port = port (6633) + #self.port = port (6653) #self.protocol = protocol ('tcp') #self.checkListening() diff --git a/framework/src/onos/tools/test/topos/optical2.py b/framework/src/onos/tools/test/topos/optical2.py index 36cdbadd..b778592c 100644 --- a/framework/src/onos/tools/test/topos/optical2.py +++ b/framework/src/onos/tools/test/topos/optical2.py @@ -69,7 +69,7 @@ topos = {'optical': ( lambda: OpticalTopo() )} def run(): - c = RemoteController('c','127.0.0.1',6633) + c = RemoteController('c','127.0.0.1',6653) net = Mininet( topo=OpticalTopo(),controller=None,autoSetMacs=True) net.addController(c) net.start() diff --git a/framework/src/onos/tools/test/topos/solar.py b/framework/src/onos/tools/test/topos/solar.py index ea11b664..f316162a 100644 --- a/framework/src/onos/tools/test/topos/solar.py +++ b/framework/src/onos/tools/test/topos/solar.py @@ -23,7 +23,7 @@ class Solar(object): # We are creating the controller with local-loopback on purpose to avoid # having the switches connect immediately. Instead, we'll set controller # explicitly for each switch after configuring it as we want. - self.ctrls = [ RemoteController(cname, cip, 6633) for cip in cips ] + self.ctrls = [ RemoteController(cname, cip, 6653) for cip in cips ] self.net = Mininet(controller=RemoteController, switch = OVSKernelSwitch, build=False) diff --git a/framework/src/onos/tools/test/topos/sys-nonlinear-10.config b/framework/src/onos/tools/test/topos/sys-nonlinear-10.config index 2b999d39..b3a718dd 100644 --- a/framework/src/onos/tools/test/topos/sys-nonlinear-10.config +++ b/framework/src/onos/tools/test/topos/sys-nonlinear-10.config @@ -56,7 +56,7 @@ [{switch,1, [{backend,linc_us4_oe}, {datapath_id,"00:00:ff:ff:ff:ff:ff:01"}, - {controllers,[{"Switch0-Controller","10.1.8.147",6633,tcp}]}, + {controllers,[{"Switch0-Controller","10.1.8.147",6653,tcp}]}, {controllers_listener,disabled}, {queues_status,disabled}, {ports, @@ -66,7 +66,7 @@ {switch,2, [{backend,linc_us4_oe}, {datapath_id,"00:00:ff:ff:ff:ff:ff:02"}, - {controllers,[{"Switch0-Controller","10.1.8.147",6633,tcp}]}, + {controllers,[{"Switch0-Controller","10.1.8.147",6653,tcp}]}, {controllers_listener,disabled}, {queues_status,disabled}, {ports, @@ -76,7 +76,7 @@ {switch,3, [{backend,linc_us4_oe}, {datapath_id,"00:00:ff:ff:ff:ff:ff:03"}, - {controllers,[{"Switch0-Controller","10.1.8.147",6633,tcp}]}, + {controllers,[{"Switch0-Controller","10.1.8.147",6653,tcp}]}, {controllers_listener,disabled}, {queues_status,disabled}, {ports, @@ -86,7 +86,7 @@ {switch,4, [{backend,linc_us4_oe}, {datapath_id,"00:00:ff:ff:ff:ff:ff:04"}, - {controllers,[{"Switch0-Controller","10.1.8.147",6633,tcp}]}, + {controllers,[{"Switch0-Controller","10.1.8.147",6653,tcp}]}, {controllers_listener,disabled}, {queues_status,disabled}, {ports, @@ -96,7 +96,7 @@ {switch,5, [{backend,linc_us4_oe}, {datapath_id,"00:00:ff:ff:ff:ff:ff:05"}, - {controllers,[{"Switch0-Controller","10.1.8.147",6633,tcp}]}, + {controllers,[{"Switch0-Controller","10.1.8.147",6653,tcp}]}, {controllers_listener,disabled}, {queues_status,disabled}, {ports, @@ -107,7 +107,7 @@ {switch,7, [{backend,linc_us4_oe}, {datapath_id,"00:00:ff:ff:ff:ff:ff:07"}, - {controllers,[{"Switch0-Controller","10.1.8.147",6633,tcp}]}, + {controllers,[{"Switch0-Controller","10.1.8.147",6653,tcp}]}, {controllers_listener,disabled}, {queues_status,disabled}, {ports, @@ -118,7 +118,7 @@ {switch,8, [{backend,linc_us4_oe}, {datapath_id,"00:00:ff:ff:ff:ff:ff:08"}, - {controllers,[{"Switch0-Controller","10.1.8.147",6633,tcp}]}, + {controllers,[{"Switch0-Controller","10.1.8.147",6653,tcp}]}, {controllers_listener,disabled}, {queues_status,disabled}, {ports, @@ -128,7 +128,7 @@ {switch,9, [{backend,linc_us4_oe}, {datapath_id,"00:00:ff:ff:ff:ff:ff:09"}, - {controllers,[{"Switch0-Controller","10.1.8.147",6633,tcp}]}, + {controllers,[{"Switch0-Controller","10.1.8.147",6653,tcp}]}, {controllers_listener,disabled}, {queues_status,disabled}, {ports, @@ -138,7 +138,7 @@ {switch,10, [{backend,linc_us4_oe}, {datapath_id,"00:00:ff:ff:ff:ff:ff:0A"}, - {controllers,[{"Switch0-Controller","10.1.8.147",6633,tcp}]}, + {controllers,[{"Switch0-Controller","10.1.8.147",6653,tcp}]}, {controllers_listener,disabled}, {queues_status,disabled}, {ports, @@ -148,7 +148,7 @@ {switch,6, [{backend,linc_us4_oe}, {datapath_id,"00:00:ff:ff:ff:ff:ff:06"}, - {controllers,[{"Switch0-Controller","10.1.8.147",6633,tcp}]}, + {controllers,[{"Switch0-Controller","10.1.8.147",6653,tcp}]}, {controllers_listener,disabled}, {queues_status,disabled}, {ports, diff --git a/framework/src/onos/tools/test/topos/sys-nonlinear-4.config b/framework/src/onos/tools/test/topos/sys-nonlinear-4.config index b843146a..b1451bee 100644 --- a/framework/src/onos/tools/test/topos/sys-nonlinear-4.config +++ b/framework/src/onos/tools/test/topos/sys-nonlinear-4.config @@ -18,7 +18,7 @@ [{switch,1, [{backend,linc_us4_oe}, {datapath_id,"00:00:ff:ff:ff:ff:ff:01"}, - {controllers,[{"Switch0-Controller","10.1.8.147",6633,tcp}]}, + {controllers,[{"Switch0-Controller","10.1.8.147",6653,tcp}]}, {controllers_listener,disabled}, {queues_status,disabled}, {ports, @@ -28,7 +28,7 @@ {switch,3, [{backend,linc_us4_oe}, {datapath_id,"00:00:ff:ff:ff:ff:ff:03"}, - {controllers,[{"Switch0-Controller","10.1.8.147",6633,tcp}]}, + {controllers,[{"Switch0-Controller","10.1.8.147",6653,tcp}]}, {controllers_listener,disabled}, {queues_status,disabled}, {ports, @@ -37,7 +37,7 @@ {switch,2, [{backend,linc_us4_oe}, {datapath_id,"00:00:ff:ff:ff:ff:ff:02"}, - {controllers,[{"Switch0-Controller","10.1.8.147",6633,tcp}]}, + {controllers,[{"Switch0-Controller","10.1.8.147",6653,tcp}]}, {controllers_listener,disabled}, {queues_status,disabled}, {ports, @@ -47,7 +47,7 @@ {switch,4, [{backend,linc_us4_oe}, {datapath_id,"00:00:ff:ff:ff:ff:ff:04"}, - {controllers,[{"Switch0-Controller","10.1.8.147",6633,tcp}]}, + {controllers,[{"Switch0-Controller","10.1.8.147",6653,tcp}]}, {controllers_listener,disabled}, {queues_status,disabled}, {ports, diff --git a/framework/src/onos/tools/test/topos/sys.config b/framework/src/onos/tools/test/topos/sys.config index 2b999d39..b3a718dd 100644 --- a/framework/src/onos/tools/test/topos/sys.config +++ b/framework/src/onos/tools/test/topos/sys.config @@ -56,7 +56,7 @@ [{switch,1, [{backend,linc_us4_oe}, {datapath_id,"00:00:ff:ff:ff:ff:ff:01"}, - {controllers,[{"Switch0-Controller","10.1.8.147",6633,tcp}]}, + {controllers,[{"Switch0-Controller","10.1.8.147",6653,tcp}]}, {controllers_listener,disabled}, {queues_status,disabled}, {ports, @@ -66,7 +66,7 @@ {switch,2, [{backend,linc_us4_oe}, {datapath_id,"00:00:ff:ff:ff:ff:ff:02"}, - {controllers,[{"Switch0-Controller","10.1.8.147",6633,tcp}]}, + {controllers,[{"Switch0-Controller","10.1.8.147",6653,tcp}]}, {controllers_listener,disabled}, {queues_status,disabled}, {ports, @@ -76,7 +76,7 @@ {switch,3, [{backend,linc_us4_oe}, {datapath_id,"00:00:ff:ff:ff:ff:ff:03"}, - {controllers,[{"Switch0-Controller","10.1.8.147",6633,tcp}]}, + {controllers,[{"Switch0-Controller","10.1.8.147",6653,tcp}]}, {controllers_listener,disabled}, {queues_status,disabled}, {ports, @@ -86,7 +86,7 @@ {switch,4, [{backend,linc_us4_oe}, {datapath_id,"00:00:ff:ff:ff:ff:ff:04"}, - {controllers,[{"Switch0-Controller","10.1.8.147",6633,tcp}]}, + {controllers,[{"Switch0-Controller","10.1.8.147",6653,tcp}]}, {controllers_listener,disabled}, {queues_status,disabled}, {ports, @@ -96,7 +96,7 @@ {switch,5, [{backend,linc_us4_oe}, {datapath_id,"00:00:ff:ff:ff:ff:ff:05"}, - {controllers,[{"Switch0-Controller","10.1.8.147",6633,tcp}]}, + {controllers,[{"Switch0-Controller","10.1.8.147",6653,tcp}]}, {controllers_listener,disabled}, {queues_status,disabled}, {ports, @@ -107,7 +107,7 @@ {switch,7, [{backend,linc_us4_oe}, {datapath_id,"00:00:ff:ff:ff:ff:ff:07"}, - {controllers,[{"Switch0-Controller","10.1.8.147",6633,tcp}]}, + {controllers,[{"Switch0-Controller","10.1.8.147",6653,tcp}]}, {controllers_listener,disabled}, {queues_status,disabled}, {ports, @@ -118,7 +118,7 @@ {switch,8, [{backend,linc_us4_oe}, {datapath_id,"00:00:ff:ff:ff:ff:ff:08"}, - {controllers,[{"Switch0-Controller","10.1.8.147",6633,tcp}]}, + {controllers,[{"Switch0-Controller","10.1.8.147",6653,tcp}]}, {controllers_listener,disabled}, {queues_status,disabled}, {ports, @@ -128,7 +128,7 @@ {switch,9, [{backend,linc_us4_oe}, {datapath_id,"00:00:ff:ff:ff:ff:ff:09"}, - {controllers,[{"Switch0-Controller","10.1.8.147",6633,tcp}]}, + {controllers,[{"Switch0-Controller","10.1.8.147",6653,tcp}]}, {controllers_listener,disabled}, {queues_status,disabled}, {ports, @@ -138,7 +138,7 @@ {switch,10, [{backend,linc_us4_oe}, {datapath_id,"00:00:ff:ff:ff:ff:ff:0A"}, - {controllers,[{"Switch0-Controller","10.1.8.147",6633,tcp}]}, + {controllers,[{"Switch0-Controller","10.1.8.147",6653,tcp}]}, {controllers_listener,disabled}, {queues_status,disabled}, {ports, @@ -148,7 +148,7 @@ {switch,6, [{backend,linc_us4_oe}, {datapath_id,"00:00:ff:ff:ff:ff:ff:06"}, - {controllers,[{"Switch0-Controller","10.1.8.147",6633,tcp}]}, + {controllers,[{"Switch0-Controller","10.1.8.147",6653,tcp}]}, {controllers_listener,disabled}, {queues_status,disabled}, {ports, |