Adding packaging script.
Added display of raw DPID and IPs or MACs for hosts.
Showing
6 changed files
with
102 additions
and
17 deletions
| ... | @@ -15,6 +15,7 @@ import org.onlab.onos.net.topology.Topology; | ... | @@ -15,6 +15,7 @@ import org.onlab.onos.net.topology.Topology; |
| 15 | import org.onlab.onos.net.topology.TopologyGraph; | 15 | import org.onlab.onos.net.topology.TopologyGraph; |
| 16 | import org.onlab.onos.net.topology.TopologyService; | 16 | import org.onlab.onos.net.topology.TopologyService; |
| 17 | import org.onlab.onos.net.topology.TopologyVertex; | 17 | import org.onlab.onos.net.topology.TopologyVertex; |
| 18 | +import org.onlab.packet.IPAddress; | ||
| 18 | import org.onlab.rest.BaseResource; | 19 | import org.onlab.rest.BaseResource; |
| 19 | 20 | ||
| 20 | import javax.ws.rs.GET; | 21 | import javax.ws.rs.GET; |
| ... | @@ -54,6 +55,7 @@ public class TopologyResource extends BaseResource { | ... | @@ -54,6 +55,7 @@ public class TopologyResource extends BaseResource { |
| 54 | ArrayNode vertexesNode = mapper.createArrayNode(); | 55 | ArrayNode vertexesNode = mapper.createArrayNode(); |
| 55 | for (TopologyVertex vertex : graph.getVertexes()) { | 56 | for (TopologyVertex vertex : graph.getVertexes()) { |
| 56 | vertexesNode.add(json(mapper, vertex.deviceId(), 2, | 57 | vertexesNode.add(json(mapper, vertex.deviceId(), 2, |
| 58 | + vertex.deviceId().uri().getSchemeSpecificPart(), | ||
| 57 | deviceService.isAvailable(vertex.deviceId()))); | 59 | deviceService.isAvailable(vertex.deviceId()))); |
| 58 | } | 60 | } |
| 59 | 61 | ||
| ... | @@ -70,14 +72,17 @@ public class TopologyResource extends BaseResource { | ... | @@ -70,14 +72,17 @@ public class TopologyResource extends BaseResource { |
| 70 | // Merge the exterior and interior vertexes and inject host links as | 72 | // Merge the exterior and interior vertexes and inject host links as |
| 71 | // the exterior edges. | 73 | // the exterior edges. |
| 72 | for (Host host : hostService.getHosts()) { | 74 | for (Host host : hostService.getHosts()) { |
| 73 | - vertexesNode.add(json(mapper, host.id(), 3, true)); | 75 | + Set<IPAddress> ipAddresses = host.ipAddresses(); |
| 76 | + IPAddress ipAddress = ipAddresses.isEmpty() ? null : ipAddresses.iterator().next(); | ||
| 77 | + String label = ipAddress != null ? ipAddress.toString() : host.mac().toString(); | ||
| 78 | + vertexesNode.add(json(mapper, host.id(), 3, label, true)); | ||
| 74 | edgesNode.add(json(mapper, 1, host.location(), new ConnectPoint(host.id(), portNumber(-1)))); | 79 | edgesNode.add(json(mapper, 1, host.location(), new ConnectPoint(host.id(), portNumber(-1)))); |
| 75 | } | 80 | } |
| 76 | 81 | ||
| 77 | // Now put the vertexes and edges into a root node and ship them off | 82 | // Now put the vertexes and edges into a root node and ship them off |
| 78 | ObjectNode rootNode = mapper.createObjectNode(); | 83 | ObjectNode rootNode = mapper.createObjectNode(); |
| 79 | - rootNode.put("vertexes", vertexesNode); | 84 | + rootNode.set("vertexes", vertexesNode); |
| 80 | - rootNode.put("edges", edgesNode); | 85 | + rootNode.set("edges", edgesNode); |
| 81 | return Response.ok(rootNode.toString()).build(); | 86 | return Response.ok(rootNode.toString()).build(); |
| 82 | } | 87 | } |
| 83 | 88 | ||
| ... | @@ -126,12 +131,12 @@ public class TopologyResource extends BaseResource { | ... | @@ -126,12 +131,12 @@ public class TopologyResource extends BaseResource { |
| 126 | return aggLinks; | 131 | return aggLinks; |
| 127 | } | 132 | } |
| 128 | 133 | ||
| 129 | - | ||
| 130 | // Produces JSON for a graph vertex. | 134 | // Produces JSON for a graph vertex. |
| 131 | private ObjectNode json(ObjectMapper mapper, ElementId id, int group, | 135 | private ObjectNode json(ObjectMapper mapper, ElementId id, int group, |
| 132 | - boolean isOnline) { | 136 | + String label, boolean isOnline) { |
| 133 | return mapper.createObjectNode() | 137 | return mapper.createObjectNode() |
| 134 | .put("name", id.uri().toString()) | 138 | .put("name", id.uri().toString()) |
| 139 | + .put("label", label) | ||
| 135 | .put("group", group) | 140 | .put("group", group) |
| 136 | .put("online", isOnline); | 141 | .put("online", isOnline); |
| 137 | } | 142 | } | ... | ... |
| ... | @@ -147,8 +147,8 @@ | ... | @@ -147,8 +147,8 @@ |
| 147 | } | 147 | } |
| 148 | return false; | 148 | return false; |
| 149 | } | 149 | } |
| 150 | - node = {"id": vertex.name, "group": vertex.group, | 150 | + node = {"id": vertex.name, "label": vertex.label, |
| 151 | - "online": vertex.online, "stamp": stamp}; | 151 | + "group": vertex.group, "online": vertex.online, "stamp": stamp}; |
| 152 | nodes.push(node); | 152 | nodes.push(node); |
| 153 | topo.vertexes[vertex.name] = node; | 153 | topo.vertexes[vertex.name] = node; |
| 154 | update(); | 154 | update(); |
| ... | @@ -288,7 +288,7 @@ | ... | @@ -288,7 +288,7 @@ |
| 288 | .attr("class", "textClass") | 288 | .attr("class", "textClass") |
| 289 | .attr("x", 20) | 289 | .attr("x", 20) |
| 290 | .attr("y", ".31em") | 290 | .attr("y", ".31em") |
| 291 | - .text(function (d) { return d.id; }); | 291 | + .text(function (d) { return d.label; }); |
| 292 | 292 | ||
| 293 | node.exit().remove(); | 293 | node.exit().remove(); |
| 294 | 294 | ... | ... |
| ... | @@ -4,12 +4,17 @@ import org.onlab.onos.net.DeviceId; | ... | @@ -4,12 +4,17 @@ import org.onlab.onos.net.DeviceId; |
| 4 | 4 | ||
| 5 | /** | 5 | /** |
| 6 | * Service for injecting flow rules into the environment and for obtaining | 6 | * Service for injecting flow rules into the environment and for obtaining |
| 7 | - * information about flow rules already in the environment. | 7 | + * information about flow rules already in the environment. This implements |
| 8 | + * semantics of a distributed authoritative flow table where the master copy | ||
| 9 | + * of the flow rules lies with the controller and the devices hold only the | ||
| 10 | + * 'cached' copy. | ||
| 8 | */ | 11 | */ |
| 9 | public interface FlowRuleService { | 12 | public interface FlowRuleService { |
| 10 | 13 | ||
| 11 | /** | 14 | /** |
| 12 | * Returns the collection of flow entries applied on the specified device. | 15 | * Returns the collection of flow entries applied on the specified device. |
| 16 | + * This will include flow rules which may not yet have been applied to | ||
| 17 | + * the device. | ||
| 13 | * | 18 | * |
| 14 | * @param deviceId device identifier | 19 | * @param deviceId device identifier |
| 15 | * @return collection of flow rules | 20 | * @return collection of flow rules |
| ... | @@ -17,7 +22,9 @@ public interface FlowRuleService { | ... | @@ -17,7 +22,9 @@ public interface FlowRuleService { |
| 17 | Iterable<FlowEntry> getFlowEntries(DeviceId deviceId); | 22 | Iterable<FlowEntry> getFlowEntries(DeviceId deviceId); |
| 18 | 23 | ||
| 19 | /** | 24 | /** |
| 20 | - * Applies the specified flow rules onto their respective devices. | 25 | + * Applies the specified flow rules onto their respective devices. These |
| 26 | + * flow rules will be retained by the system and re-applied anytime the | ||
| 27 | + * device reconnects to the controller. | ||
| 21 | * | 28 | * |
| 22 | * @param flowRules one or more flow rules | 29 | * @param flowRules one or more flow rules |
| 23 | * throws SomeKindOfException that indicates which ones were applied and | 30 | * throws SomeKindOfException that indicates which ones were applied and |
| ... | @@ -26,7 +33,9 @@ public interface FlowRuleService { | ... | @@ -26,7 +33,9 @@ public interface FlowRuleService { |
| 26 | void applyFlowRules(FlowRule... flowRules); | 33 | void applyFlowRules(FlowRule... flowRules); |
| 27 | 34 | ||
| 28 | /** | 35 | /** |
| 29 | - * Removes the specified flow rules from their respective devices. | 36 | + * Removes the specified flow rules from their respective devices. If the |
| 37 | + * device is not presently connected to the controller, these flow will | ||
| 38 | + * be removed once the device reconnects. | ||
| 30 | * | 39 | * |
| 31 | * @param flowRules one or more flow rules | 40 | * @param flowRules one or more flow rules |
| 32 | * throws SomeKindOfException that indicates which ones were removed and | 41 | * throws SomeKindOfException that indicates which ones were removed and |
| ... | @@ -34,6 +43,10 @@ public interface FlowRuleService { | ... | @@ -34,6 +43,10 @@ public interface FlowRuleService { |
| 34 | */ | 43 | */ |
| 35 | void removeFlowRules(FlowRule... flowRules); | 44 | void removeFlowRules(FlowRule... flowRules); |
| 36 | 45 | ||
| 46 | + | ||
| 47 | + // void addInitialFlowContributor(InitialFlowContributor contributor); | ||
| 48 | + // void removeInitialFlowContributor(InitialFlowContributor contributor); | ||
| 49 | + | ||
| 37 | /** | 50 | /** |
| 38 | * Adds the specified flow rule listener. | 51 | * Adds the specified flow rule listener. |
| 39 | * | 52 | * | ... | ... |
| ... | @@ -39,27 +39,27 @@ | ... | @@ -39,27 +39,27 @@ |
| 39 | 39 | ||
| 40 | <feature name="onos-rest" version="1.0.0" | 40 | <feature name="onos-rest" version="1.0.0" |
| 41 | description="ONOS REST API components"> | 41 | description="ONOS REST API components"> |
| 42 | - <feature>onos-core</feature> | 42 | + <feature>onos-api</feature> |
| 43 | <feature>onos-thirdparty-web</feature> | 43 | <feature>onos-thirdparty-web</feature> |
| 44 | <bundle>mvn:org.onlab.onos/onos-rest/1.0.0-SNAPSHOT</bundle> | 44 | <bundle>mvn:org.onlab.onos/onos-rest/1.0.0-SNAPSHOT</bundle> |
| 45 | </feature> | 45 | </feature> |
| 46 | 46 | ||
| 47 | <feature name="onos-gui" version="1.0.0" | 47 | <feature name="onos-gui" version="1.0.0" |
| 48 | description="ONOS GUI console components"> | 48 | description="ONOS GUI console components"> |
| 49 | - <feature>onos-core</feature> | 49 | + <feature>onos-api</feature> |
| 50 | <feature>onos-thirdparty-web</feature> | 50 | <feature>onos-thirdparty-web</feature> |
| 51 | <bundle>mvn:org.onlab.onos/onos-gui/1.0.0-SNAPSHOT</bundle> | 51 | <bundle>mvn:org.onlab.onos/onos-gui/1.0.0-SNAPSHOT</bundle> |
| 52 | </feature> | 52 | </feature> |
| 53 | 53 | ||
| 54 | <feature name="onos-cli" version="1.0.0" | 54 | <feature name="onos-cli" version="1.0.0" |
| 55 | description="ONOS admin command console components"> | 55 | description="ONOS admin command console components"> |
| 56 | - <feature>onos-core</feature> | 56 | + <feature>onos-api</feature> |
| 57 | <bundle>mvn:org.onlab.onos/onos-cli/1.0.0-SNAPSHOT</bundle> | 57 | <bundle>mvn:org.onlab.onos/onos-cli/1.0.0-SNAPSHOT</bundle> |
| 58 | </feature> | 58 | </feature> |
| 59 | 59 | ||
| 60 | <feature name="onos-openflow" version="1.0.0" | 60 | <feature name="onos-openflow" version="1.0.0" |
| 61 | description="ONOS OpenFlow API, Controller & Providers"> | 61 | description="ONOS OpenFlow API, Controller & Providers"> |
| 62 | - <feature>onos-core</feature> | 62 | + <feature>onos-api</feature> |
| 63 | <bundle>mvn:io.netty/netty/3.9.2.Final</bundle> | 63 | <bundle>mvn:io.netty/netty/3.9.2.Final</bundle> |
| 64 | 64 | ||
| 65 | <bundle>mvn:org.onlab.onos/onos-of-api/1.0.0-SNAPSHOT</bundle> | 65 | <bundle>mvn:org.onlab.onos/onos-of-api/1.0.0-SNAPSHOT</bundle> |
| ... | @@ -74,14 +74,14 @@ | ... | @@ -74,14 +74,14 @@ |
| 74 | 74 | ||
| 75 | <feature name="onos-app-tvue" version="1.0.0" | 75 | <feature name="onos-app-tvue" version="1.0.0" |
| 76 | description="ONOS sample topology viewer application"> | 76 | description="ONOS sample topology viewer application"> |
| 77 | - <feature>onos-core</feature> | 77 | + <feature>onos-api</feature> |
| 78 | <feature>onos-thirdparty-web</feature> | 78 | <feature>onos-thirdparty-web</feature> |
| 79 | <bundle>mvn:org.onlab.onos/onos-app-tvue/1.0.0-SNAPSHOT</bundle> | 79 | <bundle>mvn:org.onlab.onos/onos-app-tvue/1.0.0-SNAPSHOT</bundle> |
| 80 | </feature> | 80 | </feature> |
| 81 | 81 | ||
| 82 | <feature name="onos-app-fwd" version="1.0.0" | 82 | <feature name="onos-app-fwd" version="1.0.0" |
| 83 | description="ONOS sample forwarding application"> | 83 | description="ONOS sample forwarding application"> |
| 84 | - <feature>onos-core</feature> | 84 | + <feature>onos-api</feature> |
| 85 | <bundle>mvn:org.onlab.onos/onos-app-fwd/1.0.0-SNAPSHOT</bundle> | 85 | <bundle>mvn:org.onlab.onos/onos-app-fwd/1.0.0-SNAPSHOT</bundle> |
| 86 | </feature> | 86 | </feature> |
| 87 | 87 | ... | ... |
tools/package/bin/onos-ctl
0 → 100755
tools/package/package
0 → 100755
| 1 | +#!/bin/bash | ||
| 2 | +#------------------------------------------------------------------------------- | ||
| 3 | +# Packages ONOS distributable into onos.tar.gz | ||
| 4 | +#------------------------------------------------------------------------------- | ||
| 5 | + | ||
| 6 | +export M2_REPO=${M2_REPO:-~/.m2/repository} | ||
| 7 | +export KARAF_ZIP=${KARAF_ZIP:-~/Downloads/apache-karaf-3.0.1.zip} | ||
| 8 | +export KARAF_DIST=$(basename $KARAF_ZIP .zip) | ||
| 9 | + | ||
| 10 | +export ONOS_VERSION=${ONOS_VERSION:-1.0.0-SNAPSHOT} | ||
| 11 | +export ONOS_STAGE_ROOT=${ONOS_STAGE_ROOT:-/tmp} | ||
| 12 | +export ONOS_BITS=onos-$ONOS_VERSION | ||
| 13 | +export ONOS_STAGE=$ONOS_STAGE_ROOT/$ONOS_BITS | ||
| 14 | + | ||
| 15 | +# Bail on any errors | ||
| 16 | +set -e | ||
| 17 | + | ||
| 18 | +rm -fr $ONOS_STAGE # Remove this when package script is completed | ||
| 19 | + | ||
| 20 | +# Make sure we have the original apache karaf bits first | ||
| 21 | +[ ! -d $M2_REPO ] && echo "M2 repository $M2_REPO not found" && exit 1 | ||
| 22 | +[ ! -f $KARAF_ZIP ] && echo "Apache Karaf bits $KARAF_ZIP not found" && exit 1 | ||
| 23 | +[ -d $ONOS_STAGE ] && echo "ONOS stage $ONOS_STAGE already exists" && exit 1 | ||
| 24 | + | ||
| 25 | +# Create the stage directory and warp into it | ||
| 26 | +mkdir -p $ONOS_STAGE | ||
| 27 | +cd $ONOS_STAGE | ||
| 28 | + | ||
| 29 | +# Unroll the Apache Karaf bits and make the ONOS top-level directories. | ||
| 30 | +unzip $KARAF_ZIP | ||
| 31 | +mkdir bin | ||
| 32 | +mkdir lib | ||
| 33 | + | ||
| 34 | +# Stage the ONOS admin scripts | ||
| 35 | +cp -r $ONOS_ROOT/tools/package/bin . | ||
| 36 | + | ||
| 37 | +# Stage the ONOS bundles | ||
| 38 | +mkdir -p lib/org/onlab | ||
| 39 | +cp -r $M2_REPO/org/onlab lib/org | ||
| 40 | + | ||
| 41 | + | ||
| 42 | +# Patch the Apache Karaf distribution file to point to the lib as maven repo | ||
| 43 | +#perl -pi.old -e "s|^org.ops4j.pax.url.mvn.repositories= |org.ops4j.pax.url.mvn.repositories= \\\n file:../../lib, |" $ONOS_STAGE/$KARAF_DIST/etc/org.ops4j.pax.url.mvn.cfg | ||
| 44 | + | ||
| 45 | +# Patch the Apache Karaf distribution file to add ONOS features repository | ||
| 46 | +perl -pi.old -e "s|^(featuresRepositories=.*)|\1,mvn:org.onlab.onos/onos-features/$ONOS_VERSION/xml/features|" \ | ||
| 47 | + $ONOS_STAGE/$KARAF_DIST/etc/org.apache.karaf.features.cfg | ||
| 48 | + | ||
| 49 | +# Patch the Apache Karaf distribution file to load ONOS features | ||
| 50 | +perl -pi.old -e 's|^(featuresBoot=.*)|\1,onos-api,onos-core,onos-cli,onos-rest,onos-gui,onos-openflow,onos-app-tvue|' \ | ||
| 51 | + /tmp/onos-1.0.0-SNAPSHOT/apache-karaf-3.0.1/etc/org.apache.karaf.features.cfg | ||
| 52 | + | ||
| 53 | +# Patch the Apache Karaf distribution with ONOS branding bundle | ||
| 54 | +cp $M2_REPO/org/onlab/onos/onos-branding/$ONOS_VERSION/onos-branding-*.jar \ | ||
| 55 | + $ONOS_STAGE/apache-karaf-*/lib | ||
| 56 | + | ||
| 57 | +# Now package up the ONOS tar file | ||
| 58 | +cd $ONOS_STAGE_ROOT | ||
| 59 | +tar zcf $ONOS_BITS.tar.gz $ONOS_BITS |
-
Please register or login to post a comment