ONOS-6259: Topo2 - Implement server-side highlighting model (WIP)
- added locType parameter to region-add command
- created RegionABC sample topology
- fixed possible NPE in Topo2Jsonifier.jsonClosedRegion()
- added "plain" sprite layout
- check for undefined sprite layout and log a warning
- updated logger.sh script
- fixed Topo2Model to have a reference to colleciton before initialization

Change-Id: Ie6af28516338f5d64576bf465373cb5df3dff52c
diff --git a/tools/test/topos/regionabc-onos.py b/tools/test/topos/regionabc-onos.py
new file mode 100644
index 0000000..f2c8218
--- /dev/null
+++ b/tools/test/topos/regionabc-onos.py
@@ -0,0 +1,6 @@
+#!/usr/bin/python
+
+from onosnet import run
+from regionabc import RegionABC
+
+run( RegionABC() )
diff --git a/tools/test/topos/regionabc.json b/tools/test/topos/regionabc.json
new file mode 100644
index 0000000..b5d15e0
--- /dev/null
+++ b/tools/test/topos/regionabc.json
@@ -0,0 +1,49 @@
+{
+  "devices": {
+    "of:0000000000000001": {
+      "basic": {
+        "name": "S1",
+        "gridX": 40,
+        "gridY": 20
+      }
+    },
+    "of:0000000000000002": {
+      "basic": {
+        "name": "S2",
+        "gridX": 40,
+        "gridY": 40
+      }
+    },
+
+    "of:0000000000000003": {
+      "basic": {
+        "name": "S3",
+        "gridX": 40,
+        "gridY": 20
+      }
+    },
+    "of:0000000000000004": {
+      "basic": {
+        "name": "S4",
+        "gridX": 40,
+        "gridY": 40
+      }
+    },
+
+    "of:0000000000000005": {
+      "basic": {
+        "name": "S5",
+        "gridX": 40,
+        "gridY": 20
+      }
+    },
+    "of:0000000000000006": {
+      "basic": {
+        "name": "S6",
+        "gridX": 40,
+        "gridY": 40
+      }
+    }
+
+  }
+}
diff --git a/tools/test/topos/regionabc.py b/tools/test/topos/regionabc.py
new file mode 100644
index 0000000..a26d3d3
--- /dev/null
+++ b/tools/test/topos/regionabc.py
@@ -0,0 +1,60 @@
+#!/usr/bin/env python
+
+"""
+      [1] ----- [3] ----- [5]
+       |   ____/ | \       |
+       |  /      |  \____  |
+       | /       |       \ |
+      [2] ----- [4] ----- [6]
+"""
+from mininet.topo import Topo
+
+class RegionABC( Topo ):
+    """Simple 6 switch example"""
+
+    def __init__( self ):
+        """Create a topology."""
+
+        # Initialize Topology
+        Topo.__init__( self )
+
+        # add nodes, switches first...
+        S1 = self.addSwitch( 's1' )
+        S2 = self.addSwitch( 's2' )
+        S3 = self.addSwitch( 's3' )
+        S4 = self.addSwitch( 's4' )
+        S5 = self.addSwitch( 's5' )
+        S6 = self.addSwitch( 's6' )
+
+        # ... and now hosts
+        S1_host = self.addHost( 'h1' )
+        S2_host = self.addHost( 'h2' )
+        S3_host = self.addHost( 'h3' )
+        S4_host = self.addHost( 'h4' )
+        S5_host  = self.addHost( 'h5' )
+        S6_host = self.addHost( 'h6' )
+
+        # add edges between switch and corresponding host
+        self.addLink( S1, S1_host )
+        self.addLink( S2, S2_host )
+        self.addLink( S3, S3_host )
+        self.addLink( S4, S4_host )
+        self.addLink( S5, S5_host )
+        self.addLink( S6, S6_host )
+
+        # add edges between switches as diagrammed above
+        self.addLink( S1, S2, bw=10, delay='1.0ms')
+        self.addLink( S1, S3, bw=10, delay='1.0ms')
+        self.addLink( S2, S3, bw=10, delay='1.0ms')
+        self.addLink( S2, S4, bw=10, delay='1.0ms')
+        self.addLink( S3, S4, bw=10, delay='1.0ms')
+        self.addLink( S3, S5, bw=10, delay='1.0ms')
+        self.addLink( S3, S6, bw=10, delay='1.0ms')
+        self.addLink( S4, S6, bw=10, delay='1.0ms')
+        self.addLink( S5, S6, bw=10, delay='1.0ms')
+
+topos = { 'regionabc': ( lambda: RegionABC() ) }
+
+if __name__ == '__main__':
+    from onosnet import run
+    run( RegionABC() )
diff --git a/tools/test/topos/regionabc.sh b/tools/test/topos/regionabc.sh
new file mode 100755
index 0000000..64e205a
--- /dev/null
+++ b/tools/test/topos/regionabc.sh
@@ -0,0 +1,82 @@
+#!/bin/bash
+#
+# A simple test topology of three regions, A, B, and C.
+#
+# Script Configuration:
+#
+# host     : the controller instance against which this script is run
+
+host=${1:-127.0.0.1}
+
+
+###------------------------------------------------------
+### Start by adding the three regions A, B, and C
+
+# region-add <region-id> <region-name> <region-type> \
+#   <lat/Y> <long/X> <locType> <region-master>
+
+onos ${host} <<-EOF
+
+# -- define regions
+region-add rA "Region A" LOGICAL_GROUP 30 20 grid ${host}
+region-add rB "Region B" LOGICAL_GROUP 30 40 grid ${host}
+region-add rC "Region C" LOGICAL_GROUP 30 60 grid ${host}
+
+# -- set peer locations
+region-add-peer-loc rA rB 40 70
+region-add-peer-loc rA rC 50 70
+
+region-add-peer-loc rB rA 30 10
+region-add-peer-loc rB rC 30 70
+
+region-add-peer-loc rC rA 10 10
+region-add-peer-loc rC rB 20 10
+
+EOF
+
+###------------------------------------------------------
+### Add layouts, associating backing regions, and optional parent
+
+# layout-add <layout-id> <bg-ref> \
+#   [ <region-id> <parent-layout-id> <scale> <offset-x> <offset-y> ]
+#
+
+onos ${host} <<-EOF
+
+# -- top level
+layout-add root +plain . . 1.0 0.0 0.0
+
+# -- layouts for top level regions
+layout-add lA +plain rA root 1.0 0.0 0.0
+layout-add lB +plain rB root 1.0 0.0 0.0
+layout-add lC +plain rC root 1.0 0.0 0.0
+
+# -- summary
+layouts
+EOF
+
+###------------------------------------------------------
+### Assign devices to each of their regions
+
+onos ${host} <<-EOF
+
+region-add-devices rA \
+    of:0000000000000001 \
+    of:0000000000000002 \
+
+region-add-devices rB \
+    of:0000000000000003 \
+    of:0000000000000004 \
+
+region-add-devices rC \
+    of:0000000000000005 \
+    of:0000000000000006 \
+
+EOF
+
+###------------------------------------------------------
+### Configure devices and hosts
+
+onos-netcfg ${host} regionabc.json
+
+
diff --git a/tools/test/topos/regions-bayarea-grid.sh b/tools/test/topos/regions-bayarea-grid.sh
index ba7ec95..03b2813 100755
--- a/tools/test/topos/regions-bayarea-grid.sh
+++ b/tools/test/topos/regions-bayarea-grid.sh
@@ -206,15 +206,16 @@
 
 ### Add regions and associate devices with them
 #
-# region-add <region-id> <region-name> <region-type> <lat/Y> <long/X> <region-master>
+# region-add <region-id> <region-name> <region-type> \
+#   <lat/Y> <long/X> <locType> <region-master>
 # region-add-devices <region-id> <device-id>...
 
 onos ${host} <<-EOF
 
-region-add c01 "San Francisco" DATA_CENTER 37.75394143914288 -122.45945851660800 ${host}
-region-add c02 "Palo Alto"     DATA_CENTER 37.45466637790734 -122.21838933304870 ${host}
-region-add c03 "San Jose"      DATA_CENTER 37.34425619809433 -121.94768095808017 ${host}
-region-add c04 "Fremont"      DATA_CENTER 37.54328280574901 -122.01205548699211 ${host}
+region-add c01 "San Francisco" DATA_CENTER 37.75394143914288 -122.45945851660800 geo ${host}
+region-add c02 "Palo Alto"     DATA_CENTER 37.45466637790734 -122.21838933304870 geo ${host}
+region-add c03 "San Jose"      DATA_CENTER 37.34425619809433 -121.94768095808017 geo ${host}
+region-add c04 "Fremont"      DATA_CENTER 37.54328280574901 -122.01205548699211 geo ${host}
 
 region-add-devices c01 \
     null:0000000000000001 \
diff --git a/tools/test/topos/regions-bayarea.sh b/tools/test/topos/regions-bayarea.sh
index ae0ef10..f37373f 100755
--- a/tools/test/topos/regions-bayarea.sh
+++ b/tools/test/topos/regions-bayarea.sh
@@ -206,15 +206,16 @@
 
 ### Add regions and associate devices with them
 #
-# region-add <region-id> <region-name> <region-type> <region-master>
+# region-add <region-id> <region-name> <region-type> \
+#   <lat/Y> <long/X> <locType> <region-master>
 # region-add-devices <region-id> <device-id>...
 
 onos ${host} <<-EOF
 
-region-add c01 SanFrancisco DATA_CENTER 37.75394143914288 -122.45945851660800 ${host}
-region-add c02 PaloAlto     DATA_CENTER 37.45466637790734 -122.21838933304870 ${host}
-region-add c03 SanJose      DATA_CENTER 37.34425619809433 -121.94768095808017 ${host}
-region-add c04 Fremont      DATA_CENTER 37.54328280574901 -122.01205548699211 ${host}
+region-add c01 SanFrancisco DATA_CENTER 37.75394143914288 -122.45945851660800 geo ${host}
+region-add c02 PaloAlto     DATA_CENTER 37.45466637790734 -122.21838933304870 geo ${host}
+region-add c03 SanJose      DATA_CENTER 37.34425619809433 -121.94768095808017 geo ${host}
+region-add c04 Fremont      DATA_CENTER 37.54328280574901 -122.01205548699211 geo ${host}
 
 region-add-devices c01 \
     null:0000000000000001 \
diff --git a/tools/test/topos/regions-europe.sh b/tools/test/topos/regions-europe.sh
index 58f2944..44e64fc 100755
--- a/tools/test/topos/regions-europe.sh
+++ b/tools/test/topos/regions-europe.sh
@@ -28,17 +28,18 @@
 ### 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> <lat/Y> <long/X> <region-master>
+# region-add <region-id> <region-name> <region-type> \
+#   <lat/Y> <long/X> <locType> <region-master>
 
 onos ${host} <<-EOF
 
-region-add rUK "United Kingdom" COUNTRY 52.206035 -1.310384 ${host}
-region-add rIT "Italy"   COUNTRY 44.447951  11.093161 ${host}
-region-add rFR "France"  COUNTRY 47.066264  2.711458 ${host}
-region-add rDE "Germany" COUNTRY 50.863152  9.761971 ${host}
-region-add rES "Spain"   COUNTRY 40.416704 -3.7035824 ${host}
+region-add rUK "United Kingdom" COUNTRY 52.206035 -1.310384 geo ${host}
+region-add rIT "Italy"   COUNTRY 44.447951  11.093161 geo ${host}
+region-add rFR "France"  COUNTRY 47.066264  2.711458 geo ${host}
+region-add rDE "Germany" COUNTRY 50.863152  9.761971 geo ${host}
+region-add rES "Spain"   COUNTRY 40.416704 -3.7035824 geo ${host}
 
-region-add rMilan "Milan" METRO 45.4654 9.1859 ${host}
+region-add rMilan "Milan" METRO 45.4654 9.1859 geo ${host}
 
 EOF