WIP:: Initial stab at regions demo for Europe
- Added UK network
- Added France network
Also:
- Augmented "null-simulation start custom" to reset ID seeds.
Change-Id: I643ed7864da76a1077ca089c1c990e9d322bb527
diff --git a/providers/null/src/main/java/org/onosproject/provider/nil/CustomTopologySimulator.java b/providers/null/src/main/java/org/onosproject/provider/nil/CustomTopologySimulator.java
index 9470a48..9ea7138 100644
--- a/providers/null/src/main/java/org/onosproject/provider/nil/CustomTopologySimulator.java
+++ b/providers/null/src/main/java/org/onosproject/provider/nil/CustomTopologySimulator.java
@@ -107,4 +107,13 @@
@Override
protected void createHosts() {
}
+
+ /**
+ * Resets the device and host ID seeds to the default values. That is, the
+ * next assigned values will start from 1 again.
+ */
+ public void resetIdSeeds() {
+ nextDeviceId = 0;
+ nextHostId = 0;
+ }
}
diff --git a/providers/null/src/main/java/org/onosproject/provider/nil/cli/NullControlCommand.java b/providers/null/src/main/java/org/onosproject/provider/nil/cli/NullControlCommand.java
index 6edf6e5..21ed57f 100644
--- a/providers/null/src/main/java/org/onosproject/provider/nil/cli/NullControlCommand.java
+++ b/providers/null/src/main/java/org/onosproject/provider/nil/cli/NullControlCommand.java
@@ -19,7 +19,9 @@
import org.apache.karaf.shell.commands.Command;
import org.onosproject.cfg.ComponentConfigService;
import org.onosproject.cli.AbstractShellCommand;
+import org.onosproject.provider.nil.CustomTopologySimulator;
import org.onosproject.provider.nil.NullProviders;
+import org.onosproject.provider.nil.TopologySimulator;
import static org.onosproject.cli.StartStopCompleter.START;
@@ -30,13 +32,15 @@
description = "Starts or stops topology simulation")
public class NullControlCommand extends AbstractShellCommand {
+ private static final String CUSTOM = "custom";
+
@Argument(index = 0, name = "cmd", description = "Control command: start/stop",
required = true, multiValued = false)
String cmd = null;
@Argument(index = 1, name = "topoShape",
- description = "Topology shape: e.g. configured, linear, reroute, centipede, tree, spineleaf, " +
- ", mesh, fattree",
+ description = "Topology shape: e.g. configured, linear, reroute, " +
+ "centipede, tree, spineleaf, mesh, fattree, custom",
required = false, multiValued = false)
String topoShape = null;
@@ -48,6 +52,18 @@
}
service.setProperty(NullProviders.class.getName(), "enabled",
cmd.equals(START) ? "true" : "false");
+
+ // If we are re-starting the "custom" topology, reset the counts
+ // on the auto-assigned IDs for null-devices and null-hosts, so that
+ // scripts can rely on consistent assignment of IDs to nodes.
+ if (CUSTOM.equals(topoShape) && START.equals(cmd)) {
+ NullProviders npService = get(NullProviders.class);
+ TopologySimulator simulator = npService.currentSimulator();
+ if (simulator instanceof CustomTopologySimulator) {
+ CustomTopologySimulator sim = (CustomTopologySimulator) simulator;
+ sim.resetIdSeeds();
+ }
+ }
}
}
diff --git a/tools/test/topos/regions-bayarea-grid.sh b/tools/test/topos/regions-bayarea-grid.sh
index d6267d4..ba7ec95 100755
--- a/tools/test/topos/regions-bayarea-grid.sh
+++ b/tools/test/topos/regions-bayarea-grid.sh
@@ -206,7 +206,7 @@
### Add regions and associate devices with them
#
-# region-add <region-id> <region-name> <region-type> <long/Y> <lat/X> <region-master>
+# region-add <region-id> <region-name> <region-type> <lat/Y> <long/X> <region-master>
# region-add-devices <region-id> <device-id>...
onos ${host} <<-EOF
diff --git a/tools/test/topos/regions-europe.sh b/tools/test/topos/regions-europe.sh
index 37f500a..d0f6d04 100755
--- a/tools/test/topos/regions-europe.sh
+++ b/tools/test/topos/regions-europe.sh
@@ -1,6 +1,6 @@
#!/bin/bash
# -----------------------------------------------------------------------------
-# Creates a replica of the GEANT topology using ONOS null provider
+# Creates a Europe-based topology (with regions) using ONOS null provider
# -----------------------------------------------------------------------------
# config
@@ -24,10 +24,11 @@
sleep ${sleepfor}
+###------------------------------------------------------
### Start by adding Country regions
# Note that Long/Lat places region icon nicely in the country center
-# region-add <region-id> <region-name> <region-type> <long/Y> <lat/X> <region-master>
+# region-add <region-id> <region-name> <region-type> <lat/Y> <long/X> <region-master>
onos ${host} <<-EOF
@@ -41,23 +42,6 @@
###------------------------------------------------------
-###----- TEMPORARY DATA ---------------------------------
-
-#region-add rLON "London" COUNTRY 51.507321 -0.1276473 ${host}
-#region-add rMIL "Milan" COUNTRY 45.466797 9.1904984 ${host}
-#region-add rPAR "Paris" COUNTRY 48.856610 2.3514992 ${host}
-#region-add rFRA "Frankfurt" COUNTRY 50.110652 8.6820934 ${host}
-#region-add rMAD "Madrid" COUNTRY 40.416704 -3.7035824 ${host}
-
-# null-create-device switch LON ${nports} 51.507321 -0.1276473
-# null-create-device switch PAR ${nports} 48.856610 2.3514992
-# null-create-device switch MIL ${nports} 45.466797 9.1904984
-# null-create-device switch FRA ${nports} 50.110652 8.6820934
-# null-create-device switch MAD ${nports} 40.416704 -3.7035824
-
-###------------------------------------------------------
-
-
### Add layouts, associating backing regions, and optional parent.
# layout-add <layout-id> <bg-ref> \
# [ <region-id> <parent-layout-id> <scale> <offset-x> <offset-y> ]
@@ -69,20 +53,110 @@
layout-add root @europe . . 6.664 -2992.552 -2473.084
# -- layouts for top level regions
-layout-add lUK @europe rUK root 13.99 -6233.775 -5111.723
-layout-add lIT @europe rIT root 14.72 -7793.210 -6623.814
-layout-add lFR @europe rFR root 16.91 -8225.716 -7198.134
-layout-add lDE @europe rDE root 17.63 -9119.646 -7044.949
-layout-add lES @europe rES root 21.41 -9994.596 -10135.655
+layout-add lUK @europe rUK root 31.43 -14979.6 -12644.8
+layout-add lIT @europe rIT root 14.72 -7793.2 -6623.8
+layout-add lFR @europe rFR root 16.91 -8225.7 -7198.1
+layout-add lDE @europe rDE root 17.63 -9119.6 -7044.9
+layout-add lES @europe rES root 21.41 -9994.5 -10135.6
# -- layouts for country sub-regions
# TODO
# -- summary of installed layouts
layouts
-
EOF
+###------------------------------------------------------
+### Add devices, hosts and links for each of the regions
+
+onos ${host} <<-EOF
+
+# -- UK devices
+
+null-create-device switch London ${nports} 51.5073 -0.1276
+null-create-device switch Reading ${nports} 51.4543 -0.9781
+null-create-device switch Portsmouth ${nports} 50.8198 -1.0880
+null-create-device switch Bristol ${nports} 51.4545 -2.5879
+null-create-device switch Warrington ${nports} 53.3900 -2.5970
+null-create-device switch Leeds ${nports} 53.8008 -1.5491
+
+# -- Assign UK devices to UK region
+
+region-add-devices rUK \
+ null:0000000000000001 \
+ null:0000000000000002 \
+ null:0000000000000003 \
+ null:0000000000000004 \
+ null:0000000000000005 \
+ null:0000000000000006 \
+
+# -- UK hosts
+
+null-create-host London 192.168.1.1 51.8697 -0.0287
+null-create-host London 192.168.1.2 51.7225 0.7624
+null-create-host London 192.168.1.3 51.1437 0.4694
+
+null-create-host Bristol 192.168.1.4 51.7500 -2.6000
+
+# -- UK connectivity
+
+null-create-link direct London Reading
+null-create-link direct London Portsmouth
+null-create-link direct Reading Bristol
+null-create-link direct Portsmouth Bristol
+null-create-link direct Reading Warrington
+null-create-link direct London Leeds
+null-create-link direct Leeds Warrington
+
+# -- UK Peers
+
+# rUK_rES 50.4060 -3.3860
+# rUK_rFR 50.4060 -1.8482
+# rUK_rIT 50.4060 -0.1361
+# rUK_rDE 50.4060 1.2491
+
+
+# -- France Devices
+
+null-create-device switch Paris ${nports} 48.8566 2.3522
+null-create-device switch Lyon ${nports} 45.7640 4.8357
+null-create-device switch Bordeaux ${nports} 44.8378 -0.5792
+null-create-device switch Marseille ${nports} 43.2965 5.3698
+null-create-device switch Nice ${nports} 43.7102 7.2620
+
+# -- Assign France devices to France region
+
+region-add-devices rFR \
+ null:0000000000000007 \
+ null:0000000000000008 \
+ null:0000000000000009 \
+ null:000000000000000a \
+ null:000000000000000b \
+
+
+# -- France hosts
+
+null-create-host Paris 192.168.2.1 49.5134 2.8882
+null-create-host Lyon 192.168.2.2 46.4590 5.2380
+
+# -- France connectivity
+
+null-create-link direct Paris Lyon
+null-create-link direct Paris Bordeaux
+null-create-link direct Lyon Bordeaux
+null-create-link direct Marseille Bordeaux
+null-create-link direct Marseille Lyon
+null-create-link direct Marseille Nice
+null-create-link direct Lyon Nice
+
+# -- France Peers
+
+# rFR_rES 42.6806 -2.1273
+# rFR_rUK 50.6164 -2.1013
+# rFR_rIT 45.1105 9.7450
+# rFR_rDE 49.6307 7.9326
+
+EOF
### Set up debug log messages for classes we care about
onos ${host} <<-EOF