diff options
Diffstat (limited to 'framework/src/onos/tools')
24 files changed, 956 insertions, 80 deletions
diff --git a/framework/src/onos/tools/build/conf/pom.xml b/framework/src/onos/tools/build/conf/pom.xml index d56168f2..c76939ce 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.1-SNAPSHOT</version> + <version>1.2-SNAPSHOT</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 fc6757a5..9260bae8 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 @@ -257,10 +257,6 @@ <!-- <module name="MagicNumber"/> --> <module name="MissingSwitchDefault"/> - <module name="RedundantThrows"> - <property name="allowSubclasses" value="true"/> - </module> - <module name="SimplifyBooleanExpression"/> <module name="SimplifyBooleanReturn"/> diff --git a/framework/src/onos/tools/build/onos-change-version b/framework/src/onos/tools/build/onos-change-version index a7117429..b41255b1 100755 --- a/framework/src/onos/tools/build/onos-change-version +++ b/framework/src/onos/tools/build/onos-change-version @@ -41,7 +41,7 @@ sed -i "" -E "s/Version\.version\(\"[^\"]*\"\)/Version.version(\"$NEW_VERSION\") # Augment the version in archetypes tree. mvn -f tools/package/archetypes/pom.xml versions:set -DnewVersion=$NEW_VERSION versions:commit -for atype in api bundle cli ui; do +for atype in api bundle cli ui uitab uitopo; do pom="tools/package/archetypes/$atype/src/main/resources/archetype-resources/pom.xml" sed -i "" -E "1,/<onos.version>/s/<onos.version>[^<]*</<onos.version>$NEW_VERSION</g" $pom done @@ -51,6 +51,3 @@ sed -i "" -E "s/-DarchetypeVersion=[^\"]*/-DarchetypeVersion=$NEW_VERSION/g" $ON perl -i -0pe "s#<artifactId>cord-gui<.*\n.*version>#<artifactId>cord-gui</artifactId>\n <version>$NEW_VERSION</version>#" $ONOS_ROOT/apps/demo/cord-gui/pom.xml sed -i "" -E "s#demo/cord-gui/target/cord-gui-.*\.war#demo/cord-gui/target/cord-gui-$NEW_VERSION.war#" $ONOS_ROOT/apps/demo/cord-gui/src/scripts/pullwar.sh sed -i "" -E "s#CORD=./cord-gui-.*\.war#CORD=./cord-gui-$NEW_VERSION.war#" $ONOS_ROOT/apps/demo/cord-gui/src/scripts/run.me - -# Augment the acl app -sed -i "" -E "s/<onos.version>[^<]*</<onos.version>$NEW_VERSION</g" $ONOS_ROOT/apps/acl/pom.xml diff --git a/framework/src/onos/tools/build/onos-package b/framework/src/onos/tools/build/onos-package index 5566e60d..e7f2cbe3 100755 --- a/framework/src/onos/tools/build/onos-package +++ b/framework/src/onos/tools/build/onos-package @@ -50,16 +50,25 @@ function build_stage_dir() { $ONOS_ROOT/tools/package/bin/onos-client > bin/onos chmod a+x bin/onos-service bin/onos - # Stage the ONOS bundles, but only those that match the version - mkdir -p $ONOS_STAGE/$KARAF_DIST/system/org/onosproject - find $M2_REPO/org/onosproject -type f -path "*/$ONOS_POM_VERSION/*" \ - \( -name '*.jar' -o -name '*.pom' -o -name '*-features.xml' \) \ - | grep -v -Ee '-tests.jar|-[0-9]{8}.[0-9]{6}-' \ - | while read src; do - dst=$ONOS_STAGE/$KARAF_DIST/system/${src#$M2_REPO/*} - mkdir -p $(dirname $dst) - cp $src $dst - done + if [ -d $ONOS_ROOT/tools/package/karaf-assembly/target/repo ]; then + cp -r $ONOS_ROOT/tools/package/karaf-assembly/target/repo/* $ONOS_STAGE/$KARAF_DIST/system + #FIXME we need to add onos-features manually + mkdir -p $ONOS_STAGE/$KARAF_DIST/system/org/onosproject/onos-features/$ONOS_POM_VERSION + cp $M2_REPO/org/onosproject/onos-features/$ONOS_POM_VERSION/onos-features* \ + $ONOS_STAGE/$KARAF_DIST/system/org/onosproject/onos-features/$ONOS_POM_VERSION + else + # TODO: Deprecated so remove when confident staging works. + # Stage the ONOS bundles, but only those that match the version + mkdir -p $ONOS_STAGE/$KARAF_DIST/system/org/onosproject + find $M2_REPO/org/onosproject -type f -path "*/$ONOS_POM_VERSION/*" \ + \( -name '*.jar' -o -name '*.pom' -o -name '*-features.xml' \) \ + | grep -v -Ee '-tests.jar|-[0-9]{8}.[0-9]{6}-' \ + | while read src; do + dst=$ONOS_STAGE/$KARAF_DIST/system/${src#$M2_REPO/*} + mkdir -p $(dirname $dst) + cp $src $dst + done + fi # ONOS Patching ---------------------------------------------------------------- @@ -153,6 +162,11 @@ function build_rpm() { # Bail on any errors set -e +# Run karaf assembly to collect artifacts for off-line installations. +aux=/tmp/assembly-$$.log +trap "rm -f $aux 2>/dev/null" EXIT +cd $ONOS_ROOT/tools/package/karaf-assembly && mvn clean install > $aux 2>&1 + # Before starting make sure the environment is clan - delete onos staging folder rm -fr $ONOS_STAGE diff --git a/framework/src/onos/tools/build/pom.xml b/framework/src/onos/tools/build/pom.xml index ea473ed2..33b3a09b 100644 --- a/framework/src/onos/tools/build/pom.xml +++ b/framework/src/onos/tools/build/pom.xml @@ -81,7 +81,6 @@ <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-javadoc-plugin</artifactId> - <version>2.9.1</version> <executions> <execution> <id>attach-javadocs</id> diff --git a/framework/src/onos/tools/dev/bash_profile b/framework/src/onos/tools/dev/bash_profile index b8244a77..6bab610e 100644 --- a/framework/src/onos/tools/dev/bash_profile +++ b/framework/src/onos/tools/dev/bash_profile @@ -140,11 +140,12 @@ function cells { done } -# Miscellaneous +# Find a process by regex function spy { ps -ef | egrep "$@" | grep -v egrep } +# Kill a process by regex function nuke { spy "$@" | cut -c7-11 | xargs kill } @@ -186,5 +187,9 @@ function vicell { ($apply) && cell ${cdf} } -# autocomplete for certain utilities +# Autocomplete for certain utilities . ${ONOS_ROOT}/tools/test/bin/ogroup-opts + + +# Load AT&T MPLS topo GEO data +alias atttopo='onos-topo-cfg $OCI $ONOS_ROOT/tools/test/topos/attmpls.json'
\ No newline at end of file diff --git a/framework/src/onos/tools/dev/bin/onos-build-selective.exclude b/framework/src/onos/tools/dev/bin/onos-build-selective.exclude index 487f848c..33bf08a3 100644 --- a/framework/src/onos/tools/dev/bin/onos-build-selective.exclude +++ b/framework/src/onos/tools/dev/bin/onos-build-selective.exclude @@ -7,4 +7,5 @@ .*/jdvue/.* .*/ovsdb/api/.* .*/netconf/flow/.* -.*/vtn/sfcmgr/.*
\ No newline at end of file +.*/vtn/sfcmgr/.* +/tools/package/yangtools/.*
\ 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 index 9e9257e0..f6879f07 100644 --- a/framework/src/onos/tools/package/config/samples/network-cfg.json +++ b/framework/src/onos/tools/package/config/samples/network-cfg.json @@ -1,67 +1,86 @@ { "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" - } - ] - } + "of:0000000000000002/1" : { + "interfaces" : [ + { + "ips" : [ "192.168.10.101/24" ], + "mac" : "08:9e:01:82:38:68", + "vlan" : "100" + } + ] + }, + "of:0000000000000002/2" : { + "interfaces" : [ + { + "ips" : [ "192.168.20.101/24" ], + "mac" : "08:9e:01:82:38:68", + "vlan" : "200" + } + ] + } }, "devices" : { - "of:0000000000000002" : { - "segmentrouting" : { + "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, "ports" : [2, 3] }, - { "sid" : 200, "ports" : [4, 5] } + { "adjSids" : 100, "ports" : [2, 3] }, + { "adjSids" : 200, "ports" : [4, 5] } ] } - }, - "of:0000000000000191" : { - "segmentrouting" : { + }, + "of:0000000000000191" : { + "segmentrouting" : { "name" : "Spine-R1", "nodeSid" : 105, "routerIp" : "192.168.0.11", "routerMac" : "00:00:01:00:11:80", - "isEdgeRouter" : false + "isEdgeRouter" : false, + "adjacencySids" : [] } - } + } }, "apps" : { - "org.onosproject.router" : { - "bgp" : { - "bgpSpeakers" : [ - { - "connectPoint" : "of:00000000000000aa/10", - "peers" : [ - "192.168.10.1" - ] - }, - { - "connectPoint" : "of:00000000000000aa/20", - "peers" : [ - "192.168.20.1" - ] - } - ] - } - } + "org.onosproject.router" : { + "bgp" : { + "bgpSpeakers" : [ + { + "connectPoint" : "of:00000000000000aa/10", + "peers" : [ + "192.168.10.1" + ] + }, + { + "connectPoint" : "of:00000000000000aa/20", + "peers" : [ + "192.168.20.1" + ] + } + ] + } + } + }, + "hosts" : { + "00:00:00:00:00:01/4093": { + "basic": { + "ips": [ + "10.0.1.1" + ], + "location": "of:0000000000000001/3" + } + }, + "00:00:00:00:00:02/4093": { + "basic": { + "ips": [ + "10.0.1.2" + ], + "location": "of:0000000000000001/4" + } + } } } diff --git a/framework/src/onos/tools/package/etc/samples/org.onosproject.faultmanagement.impl.AlarmsManager.cfg b/framework/src/onos/tools/package/etc/samples/org.onosproject.faultmanagement.impl.AlarmsManager.cfg new file mode 100644 index 00000000..99795e57 --- /dev/null +++ b/framework/src/onos/tools/package/etc/samples/org.onosproject.faultmanagement.impl.AlarmsManager.cfg @@ -0,0 +1,6 @@ +# +# devices which may have faults. +# TODO change to NetworkConfig subsystem. +# +fmDevices = 172.27.7.110,172.27.7.110,3.3.3.3 + diff --git a/framework/src/onos/tools/package/karaf-assembly/onos-assembly.py b/framework/src/onos/tools/package/karaf-assembly/onos-assembly.py new file mode 100755 index 00000000..1e394bf6 --- /dev/null +++ b/framework/src/onos/tools/package/karaf-assembly/onos-assembly.py @@ -0,0 +1,80 @@ +#!/usr/bin/env python +''' + Builds synthetic feature file that includes all core, provider, and application + features, so that we can pre-stage all bundles required to run ONOS off-line. +''' + +import os +import xml.etree.ElementTree as ET + +FEATURE_TAG = '{http://karaf.apache.org/xmlns/features/v1.2.0}feature' +STAGED_REPOS = 'target/staged-repos.xml' + +if 'ONOS_ROOT' in os.environ: + ONOS_ROOT = os.environ['ONOS_ROOT'] +else: + # fallback to working directory if ONOS_ROOT is not set + ONOS_ROOT = os.getcwd() + +def findFeatureFiles(path=ONOS_ROOT): + #only descend into target directories that have pom + for root, dirs, files in os.walk(path): + if 'pom.xml' not in files: + if 'target' in dirs: + #pruning target dir with no pom.xml + dirs.remove('target') + if '/target' in root: + if '/classes/' in root: + #filter out features.xml for maven-plugin + continue + for f in files: + if f.endswith('features.xml'): + yield os.path.join(root, f) + +def featuresFromFile(file): + features = [] + tree = ET.parse(file) + root = tree.getroot() + for feature in root.findall(FEATURE_TAG): + features.append(feature.attrib['name']) + return features + +if __name__ == '__main__': + outputTree = ET.Element('features') + uberFeature = ET.Element('feature', attrib={'name' : 'onos-uber-synthetic'}) + for file in findFeatureFiles(): + features = featuresFromFile(file) + if len(features) > 0: + ET.SubElement(outputTree, 'repository').text = 'file:%s' % file + for feature in features: + ET.SubElement(uberFeature, 'feature').text = feature + outputTree.append(uberFeature) + + outputFile = os.path.join(os.path.dirname(os.path.realpath(__file__)), STAGED_REPOS) + outputDir = os.path.dirname(outputFile) + if not os.path.exists(outputDir): + os.mkdir(outputDir) + ET.ElementTree(outputTree).write(outputFile) + + import sys + if '-d' in sys.argv: + # -------- TODO for debug only -------- + def indent(elem, level=0): + #function borrowed from: http://effbot.org/zone/element-lib.htm#prettyprint + i = "\n" + level*" " + if len(elem): + if not elem.text or not elem.text.strip(): + elem.text = i + " " + if not elem.tail or not elem.tail.strip(): + elem.tail = i + for elem in elem: + indent(elem, level+1) + if not elem.tail or not elem.tail.strip(): + elem.tail = i + else: + if level and (not elem.tail or not elem.tail.strip()): + elem.tail = i + + print 'Writing to file:', outputFile + indent(outputTree) + ET.dump(outputTree) diff --git a/framework/src/onos/tools/package/karaf-assembly/pom.xml b/framework/src/onos/tools/package/karaf-assembly/pom.xml new file mode 100644 index 00000000..4b47c0d1 --- /dev/null +++ b/framework/src/onos/tools/package/karaf-assembly/pom.xml @@ -0,0 +1,84 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- + ~ 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. + --> +<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/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.onosproject</groupId> + <artifactId>onos-base</artifactId> + <version>1</version> + </parent> + + <groupId>org.onosproject</groupId> + <artifactId>onos-assembly</artifactId> + <version>1.0</version> + <packaging>pom</packaging> + + <description>ONOS Apache Karaf assembly definitions</description> + + <build> + <plugins> + <plugin> + <artifactId>maven-antrun-plugin</artifactId> + <version>1.8</version> + <executions> + <execution> + <phase>generate-sources</phase> + <configuration> + <target> + <exec executable="python"> + <arg value="${basedir}/onos-assembly.py"/> + </exec> + </target> + </configuration> + <goals> + <goal>run</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.karaf.tooling</groupId> + <artifactId>karaf-maven-plugin</artifactId> + <version>3.0.3</version> + + <executions> + <execution> + <id>features-add-to-repo</id> + <phase>generate-resources</phase> + <goals> + <goal>features-add-to-repository</goal> + </goals> + <configuration> + <descriptors> + <descriptor>file:${basedir}/target/staged-repos.xml</descriptor> + </descriptors> + <features> + <feature>onos-uber-synthetic</feature> + </features> + <repository>target/repo</repository> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> + +</project> diff --git a/framework/src/onos/tools/package/maven-plugin/pom.xml b/framework/src/onos/tools/package/maven-plugin/pom.xml index c2b5d8ae..5a287d04 100644 --- a/framework/src/onos/tools/package/maven-plugin/pom.xml +++ b/framework/src/onos/tools/package/maven-plugin/pom.xml @@ -23,8 +23,9 @@ <relativePath>../../build/pom.xml</relativePath> </parent> + <groupId>org.onosproject</groupId> <artifactId>onos-maven-plugin</artifactId> - <version>1.6-SNAPSHOT</version> + <version>1.7-SNAPSHOT</version> <packaging>maven-plugin</packaging> <description>Maven plugin for packaging ONOS applications or generating diff --git a/framework/src/onos/tools/package/maven-plugin/src/main/java/org/onosproject/maven/OnosSwaggerMojo.java b/framework/src/onos/tools/package/maven-plugin/src/main/java/org/onosproject/maven/OnosSwaggerMojo.java index 0ee5382e..a98557dc 100644 --- a/framework/src/onos/tools/package/maven-plugin/src/main/java/org/onosproject/maven/OnosSwaggerMojo.java +++ b/framework/src/onos/tools/package/maven-plugin/src/main/java/org/onosproject/maven/OnosSwaggerMojo.java @@ -243,7 +243,7 @@ public class OnosSwaggerMojo extends AbstractMojo { String resourcePath, ArrayNode tagArray, ObjectNode definitions) { String fullPath = resourcePath, consumes = "", produces = "", comment = javaMethod.getComment(); - DocletTag tag = javaMethod.getTagByName("rsModel"); + DocletTag tag = javaMethod.getTagByName("onos.rsModel"); for (JavaAnnotation annotation : javaMethod.getAnnotations()) { String name = annotation.getType().getName(); if (name.equals(PATH)) { @@ -293,6 +293,7 @@ public class OnosSwaggerMojo extends AbstractMojo { + param + ".json"); String lines = Files.readLines(config, Charsets.UTF_8).stream().reduce((t, u) -> t + u). get(); + lines = lines.replaceAll("\\s+",""); definitions.putPOJO(param, lines); } catch (IOException e) { e.printStackTrace(); diff --git a/framework/src/onos/tools/package/yangtools/pom.xml b/framework/src/onos/tools/package/yangtools/pom.xml new file mode 100644 index 00000000..82422c0f --- /dev/null +++ b/framework/src/onos/tools/package/yangtools/pom.xml @@ -0,0 +1,76 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<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>org.onosproject</groupId> + <artifactId>yangloader</artifactId> + <version>1.0-SNAPSHOT</version> + <dependencies> + <dependency> + <groupId>commons-configuration</groupId> + <artifactId>commons-configuration</artifactId> + <version>1.10</version> + </dependency> + <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + <version>2.4</version> + </dependency> + <dependency> + <groupId>com.google.guava</groupId> + <artifactId>guava</artifactId> + <version>18.0</version> + </dependency> + <dependency> + <groupId>org.onosproject</groupId> + <artifactId>onlab-misc</artifactId> + <version>1.4.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>commons-collections</groupId> + <artifactId>commons-collections</artifactId> + <version>3.2.1</version> + <optional>true</optional> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-jdk14</artifactId> + <version>1.7.12</version> + </dependency> + </dependencies> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>3.3</version> + <configuration> + <source>1.8</source> + <target>1.8</target> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-shade-plugin</artifactId> + <version>2.3</version> + <executions> + <execution> + <phase>package</phase> + <goals> + <goal>shade</goal> + </goals> + <configuration> + <transformers> + <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> + <mainClass>org.onoproject.yangtool.YangLoaderMain</mainClass> + </transformer> + </transformers> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> + +</project> diff --git a/framework/src/onos/tools/package/yangtools/src/main/java/org/onoproject/yangtool/YangLoader.java b/framework/src/onos/tools/package/yangtools/src/main/java/org/onoproject/yangtool/YangLoader.java new file mode 100644 index 00000000..37126890 --- /dev/null +++ b/framework/src/onos/tools/package/yangtools/src/main/java/org/onoproject/yangtool/YangLoader.java @@ -0,0 +1,167 @@ +package org.onoproject.yangtool; + +import com.google.common.io.Files; +import org.apache.commons.configuration.ConfigurationException; +import org.apache.commons.configuration.XMLConfiguration; +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.IOUtils; +import org.onlab.util.Tools; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.nio.charset.Charset; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +/** + * Class that takes in input two paths, one to the yang file and one where + * to generate the interface, and a yang container name, generates the sources + * through OpenDaylight code generator plugin from yang, and modifies + * them accordingly to the needs of the ONOS behavior system. + */ +public class YangLoader { + /** + * Public method to take a yang file from the input folder and generate classes + * to the output folder. + * @param inputFolder forlder with the yang files + * @param completeOuputFolder folder where to put the desired classes + * @throws IOException + * @throws ConfigurationException + * @throws InterruptedException + */ + public void generateBehaviourInterface(String inputFolder, + String completeOuputFolder) + throws IOException, ConfigurationException, InterruptedException { + File projectDir = createTemporaryProject(inputFolder); + List<String> containerNames = findContainerName( + new File(projectDir.getAbsolutePath() + "/src")); + System.out.println("Containers " + containerNames); + generateJava(projectDir); + //modifyClasses(containerName, projectDir, completeInterfaceOuputFolder); + copyFiles(new File(projectDir.getAbsolutePath() + "/dst"), + new File(completeOuputFolder)); + //System.out.println("Sources in " + completeOuputFolder); + + } + + private List<String> findContainerName(File scrDir) { + List<String> allContainers = new ArrayList<>(); + Arrays.asList(scrDir.listFiles()).stream().forEach(f -> { + try { + FileUtils.readLines(f).stream() + .filter(line -> line.matches("(.*)container(.*)\\{")) + .collect(Collectors.toList()).forEach(s -> { + s = s.replace("container", ""); + s = s.replace("{", ""); + allContainers.add(s.trim()); + }); + + } catch (IOException e) { + throw new RuntimeException(e); + } + }); + return allContainers; + } + + private File createTemporaryProject(String inputFolder) throws IOException, + ConfigurationException { + File tempDir = Files.createTempDir(); + File scrDir = new File(tempDir, "src"); + scrDir.mkdir(); + copyFiles(new File(inputFolder), scrDir); + createPomFile(tempDir, scrDir); + return tempDir; + + } + + private void copyFiles(File inputFolder, File scrDir) throws IOException { + Tools.copyDirectory(inputFolder, scrDir); + } + + private void createPomFile(File tempDir, File scrDir) throws ConfigurationException { + File pom = new File(tempDir, "pom.xml"); + File dstDir = new File(tempDir, "dst"); + dstDir.mkdir(); + XMLConfiguration cfg = new XMLConfiguration(); + cfg.load(getClass().getResourceAsStream("/pom-template.xml")); + cfg.setProperty("build.plugins.plugin.executions.execution." + + "configuration.yangFilesRootDir", scrDir.getPath()); + cfg.setProperty("build.plugins.plugin.executions." + + "execution.configuration.codeGenerators." + + "generator.outputBaseDir", dstDir.getPath()); + cfg.save(pom); + } + + private void generateJava(File projectDir) + throws IOException, InterruptedException { + Runtime rt = Runtime.getRuntime(); + Process pr = rt.exec("mvn generate-sources", null, projectDir); + String s = IOUtils.toString(pr.getInputStream(), "UTF-8"); + if (pr.waitFor() == 0) { + if (s.contains("[WARNING]")) { + System.out.println("Sources not generated, warning log: \n" + s); + } else { + System.out.println("Sources generated"); + } + } else { + System.out.println("Sources not generated. " + s + + " \nError " + pr.getInputStream().read()); + } + } + + //parsing classes part, for now is not used. + private void modifyClasses(String containerName, File projectDir, + String pathToNewInterface) throws IOException { + String odlInterfacepath = getPathWithFileName(containerName, projectDir.getPath()); + odlInterfacepath = odlInterfacepath + "/"; + parseClass(odlInterfacepath, pathToNewInterface, containerName); + System.out.println("ONOS behaviour interface generated " + + "correctly at " + pathToNewInterface); + } + + private String getPathWithFileName(String filename, String pathToGenerated) { + File[] directories = new File(pathToGenerated).listFiles(File::isDirectory); + while (directories.length != 0) { + pathToGenerated = pathToGenerated + "/" + directories[0].getName(); + directories = new File(pathToGenerated).listFiles(File::isDirectory); + } + File dir = new File(pathToGenerated); + File behaviour = (File) Arrays.asList(dir.listFiles()).stream() + .filter(f -> f.getName().equals(filename)).toArray()[0]; + return behaviour.getParentFile().getAbsolutePath(); + } + + private void parseClass(String filePath, String pathToNewInterface, + String filename) throws IOException { + InputStream fis = null; + String newFile = "package org.onosproject.net.behaviour;\n" + + "import org.onosproject.net.driver.HandlerBehaviour;\n"; + fis = new FileInputStream(filePath + filename); + InputStreamReader isr = new InputStreamReader(fis, Charset.forName("UTF-8")); + BufferedReader br = new BufferedReader(isr); + String line; + while ((line = br.readLine()) != null) { + if (!line.contains("org.opendaylight.")) { + if (line.contains("ChildOf")) { + newFile = newFile + "HandlerBehaviour\n"; + } else { + newFile = newFile + line + "\n"; + } + } + } + PrintWriter out = new PrintWriter(pathToNewInterface + + filename.replace(".java", "") + + "Interface.java"); + out.print(newFile); + out.flush(); + } + + +} diff --git a/framework/src/onos/tools/package/yangtools/src/main/java/org/onoproject/yangtool/YangLoaderMain.java b/framework/src/onos/tools/package/yangtools/src/main/java/org/onoproject/yangtool/YangLoaderMain.java new file mode 100644 index 00000000..7b137677 --- /dev/null +++ b/framework/src/onos/tools/package/yangtools/src/main/java/org/onoproject/yangtool/YangLoaderMain.java @@ -0,0 +1,16 @@ +package org.onoproject.yangtool; + +import org.apache.commons.configuration.ConfigurationException; + +import java.io.IOException; + +/** + * Main of the uangloader tool in order to be called through command line. + */ +public class YangLoaderMain { + public static void main (String args []) throws IOException, + ConfigurationException, InterruptedException { + YangLoader yl = new YangLoader(); + yl.generateBehaviourInterface(args[0], args[1]); + } +} diff --git a/framework/src/onos/tools/package/yangtools/src/main/resources/pom-template.xml b/framework/src/onos/tools/package/yangtools/src/main/resources/pom-template.xml new file mode 100644 index 00000000..5280e213 --- /dev/null +++ b/framework/src/onos/tools/package/yangtools/src/main/resources/pom-template.xml @@ -0,0 +1,95 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<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>yangloader</artifactId> + <version>1.0-SNAPSHOT</version> + <pluginRepositories> + <pluginRepository> + <id>opendaylight-release</id> + <name>opendaylight-release</name> + <url> + http://nexus.opendaylight.org/content/repositories/opendaylight.release/ + </url> + </pluginRepository> + <pluginRepository> + <id>opendaylight-snapshot</id> + <name>opendaylight-snapshot</name> + <url> + http://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/ + </url> + </pluginRepository> + </pluginRepositories> + <repositories> + <repository> + <id>opendaylight-release</id> + <name>opendaylight-release</name> + <url> + http://nexus.opendaylight.org/content/repositories/opendaylight.release/ + </url> + </repository> + <repository> + <id>opendaylight-snapshot</id> + <name>opendaylight-snapshot</name> + <url> + http://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/ + </url> + </repository> + </repositories> + <dependencies> + <dependency> + <groupId>org.opendaylight.yangtools</groupId> + <artifactId>yang-binding</artifactId> + <version>0.7.2-Lithium-SR2</version> + </dependency> + </dependencies> + <build> + <plugins> + <plugin> + <groupId>org.opendaylight.yangtools</groupId> + <artifactId>yang-maven-plugin</artifactId> + <version>0.7.2-Lithium-SR2</version> + <executions> + <execution> + <goals> + <goal>generate-sources</goal> + </goals> + <configuration> + <!-- directory containing yang files to parse and generate code --> + <yangFilesRootDir>INPUTDIR</yangFilesRootDir> + <codeGenerators> + <generator> + <codeGeneratorClass> + org.opendaylight.yangtools.maven.sal.api.gen.plugin.CodeGeneratorImpl + </codeGeneratorClass> + <!-- directory into which generated files will be placed --> + <outputBaseDir>OUTPUTDIR</outputBaseDir> + </generator> + </codeGenerators> + <inspectDependencies>false</inspectDependencies> + </configuration> + </execution> + </executions> + <dependencies> + <dependency> + <groupId>org.opendaylight.yangtools</groupId> + <artifactId>maven-sal-api-gen-plugin</artifactId> + <version>0.7.2-Lithium-SR2</version> + <type>jar</type> + </dependency> + </dependencies> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>3.3</version> + <configuration> + <source>1.8</source> + <target>1.8</target> + </configuration> + </plugin> + </plugins> + </build> +</project> diff --git a/framework/src/onos/tools/test/bin/ogroup-opts b/framework/src/onos/tools/test/bin/ogroup-opts index f02b7a8f..eec2f224 100644 --- a/framework/src/onos/tools/test/bin/ogroup-opts +++ b/framework/src/onos/tools/test/bin/ogroup-opts @@ -51,7 +51,7 @@ complete -F _cell-opts cell vicell function _ocapp-opts () { local cur=${COMP_WORDS[COMP_CWORD]} if [ $COMP_CWORD -eq 1 ]; then - COMPREPLY=( $( compgen -W "bundle ui cli" -- $cur ) ) + COMPREPLY=( $( compgen -W "app bundle ui uitable uitopo cli" -- $cur ) ) fi } diff --git a/framework/src/onos/tools/test/cells/andrea b/framework/src/onos/tools/test/cells/andrea index 1f9f22fe..0074f2d6 100644 --- a/framework/src/onos/tools/test/cells/andrea +++ b/framework/src/onos/tools/test/cells/andrea @@ -8,4 +8,4 @@ export OCN="10.128.12.4" export OCT=$OC1 export ONOS_USE_SSH=true -export ONOS_APPS=drivers,openflow,proxyarp,ovsdb +export ONOS_APPS=drivers,openflow,proxyarp,ovsdb,pathpainter diff --git a/framework/src/onos/tools/test/cells/tomx b/framework/src/onos/tools/test/cells/tomx index 91036e67..bc7f1e06 100644 --- a/framework/src/onos/tools/test/cells/tomx +++ b/framework/src/onos/tools/test/cells/tomx @@ -8,4 +8,4 @@ export OCN="10.128.11.4" export OCT=$OC1 export ONOS_USE_SSH=true -export ONOS_APPS=drivers,openflow,proxyarp,mobility
\ No newline at end of file +export ONOS_APPS=drivers,openflow,proxyarp,mobility,pathpainter
\ No newline at end of file diff --git a/framework/src/onos/tools/test/configs/network-cfg-2x2-leaf-spine.json b/framework/src/onos/tools/test/configs/network-cfg-2x2-leaf-spine.json new file mode 100644 index 00000000..828d2735 --- /dev/null +++ b/framework/src/onos/tools/test/configs/network-cfg-2x2-leaf-spine.json @@ -0,0 +1,108 @@ +{ + "ports" : { + "of:0000000000000001/3" : { + "interfaces" : [ + { + "ips" : [ "10.0.1.254/24" ], + "mac" : "08:9e:01:82:38:68", + "vlan" : "100" + } + ] + }, + "of:0000000000000001/4" : { + "interfaces" : [ + { + "ips" : [ "10.0.1.254/24" ], + "mac" : "08:9e:01:82:38:68", + "vlan" : "100" + } + ] + }, + "of:0000000000000002/3" : { + "interfaces" : [ + { + "ips" : [ "10.0.2.254/24" ], + "mac" : "08:9e:01:82:38:68", + "vlan" : "100" + } + ] + }, + "of:0000000000000002/4" : { + "interfaces" : [ + { + "ips" : [ "10.0.2.254/24" ], + "mac" : "08:9e:01:82:38:68", + "vlan" : "100" + } + ] + } + }, + "devices" : { + "of:0000000000000001" : { + "segmentrouting" : { + "name" : "Leaf-R1", + "nodeSid" : 101, + "routerIp" : "10.0.1.254", + "routerMac" : "00:00:00:00:01:80", + "isEdgeRouter" : true, + "adjacencySids" : [] + } + }, + "of:0000000000000002" : { + "segmentrouting" : { + "name" : "Leaf-R2", + "nodeSid" : 102, + "routerIp" : "10.0.2.254", + "routerMac" : "00:00:00:00:02:80", + "isEdgeRouter" : true, + "adjacencySids" : [] + } + }, + "of:0000000000000191" : { + "segmentrouting" : { + "name" : "Spine-R1", + "nodeSid" : 103, + "routerIp" : "192.168.0.11", + "routerMac" : "00:00:01:00:11:80", + "isEdgeRouter" : false, + "adjacencySids" : [] + } + }, + "of:0000000000000192" : { + "segmentrouting" : { + "name" : "Spine-R2", + "nodeSid" : 104, + "routerIp" : "192.168.0.22", + "routerMac" : "00:00:01:00:22:80", + "isEdgeRouter" : false, + "adjacencySids" : [] + } + } + }, + "hosts" : { + "00:00:00:00:00:01/4093" : { + "basic": { + "ips": ["10.0.1.1"], + "location": "of:0000000000000001/3" + } + }, + "00:00:00:00:00:02/4093" : { + "basic": { + "ips": ["10.0.1.2"], + "location": "of:0000000000000001/4" + } + }, + "00:00:00:00:00:03/4093" : { + "basic": { + "ips": ["10.0.2.1"], + "location": "of:0000000000000002/3" + } + }, + "00:00:00:00:00:04/4093" : { + "basic": { + "ips": ["10.0.2.2"], + "location": "of:0000000000000002/4" + } + } + } +} diff --git a/framework/src/onos/tools/test/configs/network-cfg-4x4-leaf-spine.json b/framework/src/onos/tools/test/configs/network-cfg-4x4-leaf-spine.json new file mode 100644 index 00000000..4efcf97d --- /dev/null +++ b/framework/src/onos/tools/test/configs/network-cfg-4x4-leaf-spine.json @@ -0,0 +1,208 @@ +{ + "ports" : { + "of:0000000000000001/5" : { + "interfaces" : [ + { + "ips" : [ "10.0.1.254/24" ], + "mac" : "08:9e:01:82:38:68", + "vlan" : "100" + } + ] + }, + "of:0000000000000001/6" : { + "interfaces" : [ + { + "ips" : [ "10.0.1.254/24" ], + "mac" : "08:9e:01:82:38:68", + "vlan" : "100" + } + ] + }, + "of:0000000000000002/5" : { + "interfaces" : [ + { + "ips" : [ "10.0.2.254/24" ], + "mac" : "08:9e:01:82:38:68", + "vlan" : "100" + } + ] + }, + "of:0000000000000002/6" : { + "interfaces" : [ + { + "ips" : [ "10.0.2.254/24" ], + "mac" : "08:9e:01:82:38:68", + "vlan" : "100" + } + ] + }, + "of:0000000000000003/5" : { + "interfaces" : [ + { + "ips" : [ "10.0.3.254/24" ], + "mac" : "08:9e:01:82:38:68", + "vlan" : "100" + } + ] + }, + "of:0000000000000003/6" : { + "interfaces" : [ + { + "ips" : [ "10.0.3.254/24" ], + "mac" : "08:9e:01:82:38:68", + "vlan" : "100" + } + ] + }, + "of:0000000000000004/5" : { + "interfaces" : [ + { + "ips" : [ "10.0.4.254/24" ], + "mac" : "08:9e:01:82:38:68", + "vlan" : "100" + } + ] + }, + "of:0000000000000004/6" : { + "interfaces" : [ + { + "ips" : [ "10.0.4.254/24" ], + "mac" : "08:9e:01:82:38:68", + "vlan" : "100" + } + ] + } + }, + "devices" : { + "of:0000000000000001" : { + "segmentrouting" : { + "name" : "Leaf-R1", + "nodeSid" : 101, + "routerIp" : "10.0.1.254", + "routerMac" : "00:00:00:00:01:80", + "isEdgeRouter" : true, + "adjacencySids" : [] + } + }, + "of:0000000000000002" : { + "segmentrouting" : { + "name" : "Leaf-R2", + "nodeSid" : 102, + "routerIp" : "10.0.2.254", + "routerMac" : "00:00:00:00:02:80", + "isEdgeRouter" : true, + "adjacencySids" : [] + } + }, + "of:0000000000000003" : { + "segmentrouting" : { + "name" : "Leaf-R3", + "nodeSid" : 103, + "routerIp" : "10.0.3.254", + "routerMac" : "00:00:00:00:03:80", + "isEdgeRouter" : true, + "adjacencySids" : [] + } + }, + "of:0000000000000004" : { + "segmentrouting" : { + "name" : "Leaf-R4", + "nodeSid" : 104, + "routerIp" : "10.0.4.254", + "routerMac" : "00:00:00:00:04:80", + "isEdgeRouter" : true, + "adjacencySids" : [] + } + }, + "of:0000000000000191" : { + "segmentrouting" : { + "name" : "Spine-R1", + "nodeSid" : 105, + "routerIp" : "192.168.0.11", + "routerMac" : "00:00:01:00:11:80", + "isEdgeRouter" : false, + "adjacencySids" : [] + } + }, + "of:0000000000000192" : { + "segmentrouting" : { + "name" : "Spine-R2", + "nodeSid" : 106, + "routerIp" : "192.168.0.22", + "routerMac" : "00:00:01:00:22:80", + "isEdgeRouter" : false, + "adjacencySids" : [] + } + }, + "of:0000000000000193" : { + "segmentrouting" : { + "name" : "Spine-R3", + "nodeSid" : 107, + "routerIp" : "192.168.0.33", + "routerMac" : "00:00:03:00:33:80", + "isEdgeRouter" : false, + "adjacencySids" : [] + } + }, + "of:0000000000000194" : { + "segmentrouting" : { + "name" : "Spine-R4", + "nodeSid" : 108, + "routerIp" : "192.168.0.44", + "routerMac" : "00:00:04:00:44:80", + "isEdgeRouter" : false, + "adjacencySids" : [] + } + } + }, + "hosts" : { + "00:00:00:00:00:01/4093" : { + "basic": { + "ips": ["10.0.1.1"], + "location": "of:0000000000000001/5" + } + }, + "00:00:00:00:00:02/4093" : { + "basic": { + "ips": ["10.0.1.2"], + "location": "of:0000000000000001/6" + } + }, + "00:00:00:00:00:03/4093" : { + "basic": { + "ips": ["10.0.2.1"], + "location": "of:0000000000000002/5" + } + }, + "00:00:00:00:00:04/4093" : { + "basic": { + "ips": ["10.0.2.2"], + "location": "of:0000000000000002/6" + } + }, + "00:00:00:00:00:05/4093" : { + "basic": { + "ips": ["10.0.3.1"], + "location": "of:0000000000000003/5" + } + }, + "00:00:00:00:00:06/4093" : { + "basic": { + "ips": ["10.0.3.2"], + "location": "of:0000000000000003/6" + } + }, + "00:00:00:00:00:07/4093" : { + "basic": { + "ips": ["10.0.4.1"], + "location": "of:0000000000000004/5" + } + }, + "00:00:00:00:00:08/4093" : { + "basic": { + "ips": ["10.0.4.2"], + "location": "of:0000000000000004/6" + } + } + } +} diff --git a/framework/src/onos/tools/test/topos/attmplsfast.py b/framework/src/onos/tools/test/topos/attmplsfast.py index 7f904462..cc7479be 100644 --- a/framework/src/onos/tools/test/topos/attmplsfast.py +++ b/framework/src/onos/tools/test/topos/attmplsfast.py @@ -15,19 +15,23 @@ from mininet.util import dumpNodeConnections class AttMplsTopo( Topo ): "Internet Topology Zoo Specimen." - def build( self ): + def __init__( self ): "Create a topology." + # Initialize Topology + Topo.__init__( self ) + # add nodes, switches first... + NY54 = self.addSwitch( 's25' ) # 40.728270, -73.994483 CMBR = self.addSwitch( 's1' ) # 42.373730, -71.109734 - CHCG = self.addSwitch( 's2' ) # 41.877461, -87.642892 + CHCG = self.addSwitch( 's2', protocols='OpenFlow13' ) # 41.877461, -87.642892 CLEV = self.addSwitch( 's3' ) # 41.498928, -81.695217 RLGH = self.addSwitch( 's4' ) # 35.780150, -78.644026 ATLN = self.addSwitch( 's5' ) # 33.749017, -84.394168 PHLA = self.addSwitch( 's6' ) # 39.952906, -75.172278 WASH = self.addSwitch( 's7' ) # 38.906696, -77.035509 NSVL = self.addSwitch( 's8' ) # 36.166410, -86.787305 - STLS = self.addSwitch( 's9' ) # 38.626418, -90.198143 + STLS = self.addSwitch( 's9', protocols='OpenFlow13' ) # 38.626418, -90.198143 NWOR = self.addSwitch( 's10' ) # 29.951475, -90.078434 HSTN = self.addSwitch( 's11' ) # 29.763249, -95.368332 SNAN = self.addSwitch( 's12' ) # 29.424331, -98.491745 @@ -40,12 +44,12 @@ class AttMplsTopo( Topo ): PTLD = self.addSwitch( 's19' ) # 45.523317, -122.677768 STTL = self.addSwitch( 's20' ) # 47.607326, -122.331786 SLKC = self.addSwitch( 's21' ) # 40.759577, -111.895079 - LA03 = self.addSwitch( 's22' ) # 34.056346, -118.235951 + LA03 = self.addSwitch( 's22', protocols='OpenFlow13' ) # 34.056346, -118.235951 SNDG = self.addSwitch( 's23' ) # 32.714564, -117.153528 PHNX = self.addSwitch( 's24' ) # 33.448289, -112.076299 - NY54 = self.addSwitch( 's25' ) # 40.728270, -73.994483 # ... and now hosts + NY54_host = self.addHost( 'h25' ) CMBR_host = self.addHost( 'h1' ) CHCG_host = self.addHost( 'h2' ) CLEV_host = self.addHost( 'h3' ) @@ -70,7 +74,6 @@ class AttMplsTopo( Topo ): LA03_host = self.addHost( 'h22' ) SNDG_host = self.addHost( 'h23' ) PHNX_host = self.addHost( 'h24' ) - NY54_host = self.addHost( 'h25' ) # add edges between switch and corresponding host self.addLink( NY54 , NY54_host ) diff --git a/framework/src/onos/tools/test/topos/metro.py b/framework/src/onos/tools/test/topos/metro.py index 1979b103..5a73cb6b 100755 --- a/framework/src/onos/tools/test/topos/metro.py +++ b/framework/src/onos/tools/test/topos/metro.py @@ -86,8 +86,8 @@ class Domain(object): class OpticalDomain(Domain): """ An emulated optical metro core. It is Domain 0. """ def build(self): - oean = { "optical.regens": 0 } for i in range (1,4): + oean = { "optical.regens": 0 } self.addSwitch('OE%s' % i, dpid='0000ffffffffff0%s' % i, annotations=oean, cls=LINCSwitch) an = { "optical.waves": 80, "optical.type": "WDM", "optical.kms": 1000, "durable": "true" } |