fix large optical config

Change-Id: I8c264ad0228defb4fe9087a6d070912d3c3b9e75
diff --git a/tools/test/topos/oe-nonlinear-10.json b/tools/test/topos/oe-nonlinear-10.json
index 52e8b99..29086bb 100644
--- a/tools/test/topos/oe-nonlinear-10.json
+++ b/tools/test/topos/oe-nonlinear-10.json
@@ -4,55 +4,85 @@
             "uri": "of:0000ffffffffff01", "mac": "ffffffffffff01", "type": "ROADM",
             "mfr": "Linc", "hw": "OE", "sw": "?", "serial": "?", "name": "SFO-W10",
             "annotations": { "latitude": 37.6, "longitude": 122.3, "optical.regens": 0 },
-            "ports": [ { "port": 10, "speed": 100000, "type": "FIBER" }, { "port": 20, "speed": 0, "type": "FIBER" } ]
+            "ports": [ { "port": 10, "speed": 100000, "type": "FIBER" },
+            { "port": 20, "speed": 0, "type": "FIBER" },
+            { "port": 50, "speed":100000, "type": "FIBER" } ]
         },
         {
             "uri": "of:0000ffffffffff02", "mac": "ffffffffffff02", "type": "ROADM",
             "mfr": "Linc", "hw": "OE", "sw": "?", "serial": "?", "name": "SJC-W10",
             "annotations": { "latitude": 37.3, "longitude": 121.9, "optical.regens": 0 },
-            "ports": [ { "port": 11, "speed": 100000, "type": "FIBER" }, { "port": 21, "speed": 0, "type": "FIBER" } ]
+            "ports": [ { "port": 20, "speed": 100000, "type": "FIBER" },
+            { "port": 30, "speed": 0, "type": "FIBER" },
+            { "port": 50, "speed": 0, "type": "FIBER" } ]
         },
         {
             "uri": "of:0000ffffffffff03", "mac": "ffffffffffff03", "type": "ROADM",
             "mfr": "Linc", "hw": "OE", "sw": "?", "serial": "?", "name": "LAX-W10",
             "annotations": { "latitude": 33.9, "longitude": 118.4, "optical.regens": 0 },
-            "ports": [ { "port": 30, "speed": 0, "type": "FIBER" }, { "port": 31, "speed": 0, "type": "FIBER" } ]
+            "ports": [ { "port": 30, "speed": 0, "type": "FIBER" },
+            { "port": 50, "speed": 0, "type": "FIBER" },
+            { "port": 20, "speed": 0, "type": "FIBER" } ]
         },
         {
             "uri": "of:0000ffffffffff04", "mac": "ffffffffffff04", "type": "ROADM",
             "mfr": "Linc", "hw": "OE", "sw": "?", "serial": "?", "name": "SDG-W10",
             "annotations": { "latitude": 32.8, "longitude": 117.1, "optical.regens": 3 },
-            "ports": [ { "port": 30, "speed": 0, "type": "FIBER" }, { "port": 31, "speed": 0, "type": "FIBER" } ]
+            "ports": [ { "port": 30, "speed": 0, "type": "FIBER" },
+            { "port":50, "speed": 0, "type": "FIBER" },
+             { "port":20, "speed": 0, "type": "FIBER" }]
         },
         {
             "uri": "of:0000ffffffffff05", "mac": "ffffffffffff05", "type": "ROADM",
             "mfr": "Linc", "hw": "OE", "sw": "?", "serial": "?", "name": "MSP-M10",
             "annotations": { "latitude": 44.8, "longitude": 93.1, "optical.regens": 3 },
-            "ports": [ { "port": 30, "speed": 0, "type": "FIBER" }, { "port": 31, "speed": 0, "type": "FIBER" } ]
+            "ports": [ { "port": 20, "speed": 0, "type": "FIBER" },
+             { "port": 30, "speed": 0, "type": "FIBER" },
+             { "port": 40, "speed": 0, "type": "FIBER" },
+             { "port": 50, "speed": 0, "type": "FIBER" }]
+        },
+        {
+            "uri": "of:0000ffffffffff06", "mac": "ffffffffffff06", "type": "ROADM",
+            "mfr": "Linc", "hw": "OE", "sw": "?", "serial": "?", "name": "DFW-M10",
+            "annotations": { "latitude": 32.8, "longitude": 97.1, "optical.regens": 3 },
+            "ports": [ { "port": 10, "speed": 0, "type": "FIBER" },
+            { "port": 20, "speed": 0, "type": "FIBER" },
+             { "port": 30, "speed": 0, "type": "FIBER" },
+             { "port": 40, "speed": 0, "type": "FIBER" },
+             { "port": 50, "speed": 0, "type": "FIBER" }]
         },
         {
             "uri": "of:0000ffffffffff07", "mac": "ffffffffffff07", "type": "ROADM",
             "mfr": "Linc", "hw": "OE", "sw": "?", "serial": "?", "name": "CHG-N10",
             "annotations": { "latitude": 41.8, "longitude": 120.1, "optical.regens": 3 },
-            "ports": [ { "port": 30, "speed": 0, "type": "FIBER" }, { "port": 31, "speed": 0, "type": "FIBER" } ]
+            "ports": [ { "port": 10, "speed": 0, "type": "FIBER" },
+            { "port": 20, "speed": 0, "type": "FIBER" },
+             { "port": 30, "speed": 0, "type": "FIBER" },
+             { "port": 50, "speed": 0, "type": "FIBER" }]
         },
         {
             "uri": "of:0000ffffffffff08", "mac": "ffffffffffff08", "type": "ROADM",
             "mfr": "Linc", "hw": "OE", "sw": "?", "serial": "?", "name": "IAD-M10",
             "annotations": { "latitude": 38.8, "longitude": 77.1, "optical.regens": 3 },
-            "ports": [ { "port": 30, "speed": 0, "type": "FIBER" }, { "port": 31, "speed": 0, "type": "FIBER" } ]
+            "ports": [ { "port": 20, "speed": 0, "type": "FIBER" },
+             { "port": 30, "speed": 0, "type": "FIBER" },
+             { "port": 50, "speed": 0, "type": "FIBER" }]
         },
         {
             "uri": "of:0000ffffffffff09", "mac": "ffffffffffff09", "type": "ROADM",
             "mfr": "Linc", "hw": "OE", "sw": "?", "serial": "?", "name": "JFK-M10",
             "annotations": { "latitude": 40.8, "longitude": 73.1, "optical.regens": 0 },
-            "ports": [ { "port": 30, "speed": 0, "type": "FIBER" }, { "port": 31, "speed": 0, "type": "FIBER" } ]
+            "ports": [ { "port": 10, "speed": 0, "type": "FIBER" },
+            { "port": 20, "speed": 0, "type": "FIBER" },
+            { "port": 50, "speed": 0, "type": "FIBER" }]
         },
         {
             "uri": "of:0000ffffffffff0A", "mac": "ffffffffffff0A", "type": "ROADM",
             "mfr": "Linc", "hw": "OE", "sw": "?", "serial": "?", "name": "ATL-S10",
             "annotations": { "latitude": 33.8, "longitude": 84.1, "optical.regens": 0 },
-            "ports": [ { "port": 30, "speed": 0, "type": "FIBER" }, { "port": 31, "speed": 0, "type": "FIBER" } ]
+            "ports": [ { "port": 10, "speed": 0, "type": "FIBER" },
+            { "port": 20, "speed": 0, "type": "FIBER" },
+            { "port": 50, "speed": 0, "type": "FIBER" }]
         },
         {
             "uri": "of:0000ffffffff0001", "mac": "ffffffffff0001", "type": "SWITCH",
diff --git a/tools/test/topos/optical2.py b/tools/test/topos/optical2.py
new file mode 100644
index 0000000..8d171d6
--- /dev/null
+++ b/tools/test/topos/optical2.py
@@ -0,0 +1,104 @@
+#!/usr/bin/env python
+
+''' file: custom/optical.py '''
+
+from mininet.topo import Topo
+from mininet.net import Mininet
+from mininet.cli import CLI
+from mininet.log import setLogLevel, info
+from mininet.link import Intf, Link
+from mininet.node import RemoteController
+
+class NullIntf( Intf ):
+    "A dummy interface with a blank name that doesn't do any configuration"
+    def __init__( self, name, **params ):
+        self.name = ''
+
+class NullLink( Link ):
+    "A dummy link that doesn't touch either interface"
+    def makeIntfPair( cls, intf1, intf2 ):
+        pass
+    def delete( self ):
+        pass
+
+class OpticalTopo(Topo):
+    def addIntf( self, switch, intfName ):
+        "Add intf intfName to switch"
+        self.addLink( switch, switch, cls=NullLink,
+                      intfName1=intfName, cls2=NullIntf )
+    def __init__(self):
+
+        # Initialize topology
+        Topo.__init__(self)
+
+        # Add hosts and switches
+        h1 = self.addHost('h1')
+        h2 = self.addHost('h2')
+        h3 = self.addHost('h3')
+        h4 = self.addHost('h4')
+        h5 = self.addHost('h5')
+        h6 = self.addHost('h6')
+
+        s1 = self.addSwitch('s1',dpid="0000ffffffff0001")
+        s2 = self.addSwitch('s2',dpid="0000ffffffff0002")
+        s3 = self.addSwitch('s3',dpid="0000ffffffff0003")
+        s4 = self.addSwitch('s4',dpid="0000ffffffff0004")
+        s5 = self.addSwitch('s5',dpid="0000ffffffff0005")
+        s6 = self.addSwitch('s6',dpid="0000ffffffff0006")
+
+
+        # Add links from hosts to OVS
+        self.addLink(s1, h1)
+        self.addLink(s2, h2)
+        self.addLink(s3, h3)
+        self.addLink(s4, h4)
+        self.addLink(s5, h5)
+        self.addLink(s6, h6)
+
+        # temporary packet link from s1 to s2 for testing
+        # self.addLink( s1, s2 )
+
+        # add links from ovs to linc-oe
+        # sorry about the syntax :(
+        self.addLink(s1, s1, intfName1='s1-eth0', intfName2='tap29')
+        self.addLink(s2, s2, intfName1='s2-eth0', intfName2='tap30')
+        self.addLink(s3, s3, intfName1='s3-eth0', intfName2='tap31')
+        self.addLink(s4, s4, intfName1='s4-eth0', intfName2='tap32')
+        self.addLink(s5, s5, intfName1='s5-eth0', intfName2='tap33')
+        self.addLink(s6, s6, intfName1='s6-eth0', intfName2='tap34')
+
+        #self.addLink(s1, s2, s3, s4, s5, s6)
+        #intfName1 = 'tap3', intfName\2 = 'tap4', intfName2 = 'tap5',
+        # intfName2 = 'tap6', intfName2 = 'tap7', intfName2 = 'tap8'
+
+    # if you use, sudo mn --custom custom/optical.py, then register the topo:
+topos = {'optical': ( lambda: OpticalTopo() )}
+
+def installStaticFlows(net):
+    for swName in ['s1', 's2', 's3', 's4', 's5', 's6']:
+        info('Adding flows to %s...' % swName)
+        sw = net[swName]
+        sw.dpctl('add-flow', 'in_port=1,actions=output=2')
+        sw.dpctl('add-flow', 'in_port=2,actions=output=1')
+        info(sw.dpctl('dump-flows'))
+
+
+def run():
+    c = RemoteController('c','10.1.8.147',6633)
+    net = Mininet( topo=OpticalTopo(),controller=None)
+    net.addController(c)
+    net.start()
+
+    # intf1 = Intf( 'tap3', node=net.nameToNode['s1'] )
+    # intf2 = Intf( 'tap4', node=net.nameToNode['s2'] )
+    # net.nameToNode['s1'].attach( intf1 )
+    # net.nameToNode['s2'].attach( intf2 )
+
+    #installStaticFlows( net )
+    CLI( net )
+    net.stop()
+
+# if the script is run directly (sudo custom/optical.py):
+if __name__ == '__main__':
+    setLogLevel('info')
+    run()
diff --git a/tools/test/topos/sys.config b/tools/test/topos/sys.config
new file mode 100644
index 0000000..2b999d3
--- /dev/null
+++ b/tools/test/topos/sys.config
@@ -0,0 +1,183 @@
+[{linc,
+     [{of_config,disabled},
+      {software_desc,<<"LINC-OE OpenFlow Software Switch 1.1">>},
+      {capable_switch_ports,
+          [{port,1,[{interface,"dummy"},{type,optical}]},
+           {port,2,[{interface,"dummy"},{type,optical}]},
+           {port,3,[{interface,"dummy"},{type,optical}]},
+           {port,4,[{interface,"dummy"},{type,optical}]},
+           {port,5,[{interface,"dummy"},{type,optical}]},
+           {port,6,[{interface,"dummy"},{type,optical}]},
+           {port,7,[{interface,"dummy"},{type,optical}]},
+           {port,8,[{interface,"dummy"},{type,optical}]},
+           {port,9,[{interface,"dummy"},{type,optical}]},
+           {port,10,[{interface,"dummy"},{type,optical}]},
+           {port,11,[{interface,"dummy"},{type,optical}]},
+           {port,12,[{interface,"dummy"},{type,optical}]},
+           {port,13,[{interface,"dummy"},{type,optical}]},
+           {port,14,[{interface,"dummy"},{type,optical}]},
+           {port,15,[{interface,"dummy"},{type,optical}]},
+           {port,16,[{interface,"dummy"},{type,optical}]},
+           {port,17,[{interface,"dummy"},{type,optical}]},
+           {port,18,[{interface,"dummy"},{type,optical}]},
+           {port,19,[{interface,"dummy"},{type,optical}]},
+           {port,20,[{interface,"dummy"},{type,optical}]},
+           {port,21,[{interface,"dummy"},{type,optical}]},
+           {port,22,[{interface,"dummy"},{type,optical}]},
+           {port,23,[{interface,"dummy"},{type,optical}]},
+           {port,24,[{interface,"dummy"},{type,optical}]},
+           {port,25,[{interface,"dummy"},{type,optical}]},
+           {port,26,[{interface,"dummy"},{type,optical}]},
+           {port,27,[{interface,"dummy"},{type,optical}]},
+           {port,28,[{interface,"dummy"},{type,optical}]},
+           {port,29,[{interface,"tap29"}]},
+           {port,30,[{interface,"tap30"}]},
+           {port,31,[{interface,"tap31"}]},
+           {port,32,[{interface,"tap32"}]},
+           {port,33,[{interface,"tap33"}]},
+           {port,34,[{interface,"tap34"}]}]},
+      {capable_switch_queues,[]},
+      {optical_links,
+          [{{1,50},{2,30}},
+           {{2,50},{3,30}},
+           {{3,50},{4,50}},
+           {{1,20},{5,50}},
+           {{2,20},{5,20}},
+           {{3,20},{6,50}},
+           {{4,20},{6,20}},
+           {{5,30},{6,40}},
+           {{5,40},{7,50}},
+           {{6,30},{8,50}},
+           {{7,20},{8,30}},
+           {{7,30},{9,50}},
+           {{8,20},{10,50}},
+           {{9,20},{10,20}}]},
+      {logical_switches,
+          [{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_listener,disabled},
+                {queues_status,disabled},
+                {ports,
+                    [{port,1,[{queues,[]},{port_no,50}]},
+                     {port,7,[{queues,[]},{port_no,20}]},
+                     {port,29,[{queues,[]},{port_no,10}]}]}]},
+           {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_listener,disabled},
+                {queues_status,disabled},
+                {ports,
+                    [{port,2,[{queues,[]},{port_no,30}]},
+                     {port,3,[{queues,[]},{port_no,50}]},
+                     {port,9,[{queues,[]},{port_no,20}]}]}]},
+           {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_listener,disabled},
+                {queues_status,disabled},
+                {ports,
+                    [{port,4,[{queues,[]},{port_no,30}]},
+                     {port,5,[{queues,[]},{port_no,50}]},
+                     {port,11,[{queues,[]},{port_no,20}]}]}]},
+           {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_listener,disabled},
+                {queues_status,disabled},
+                {ports,
+                    [{port,6,[{queues,[]},{port_no,50}]},
+                     {port,13,[{queues,[]},{port_no,20}]},
+                     {port,30,[{queues,[]},{port_no,10}]}]}]},
+           {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_listener,disabled},
+                {queues_status,disabled},
+                {ports,
+                    [{port,8,[{queues,[]},{port_no,50}]},
+                     {port,10,[{queues,[]},{port_no,20}]},
+                     {port,15,[{queues,[]},{port_no,30}]},
+                     {port,17,[{queues,[]},{port_no,40}]}]}]},
+           {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_listener,disabled},
+                {queues_status,disabled},
+                {ports,
+                    [{port,18,[{queues,[]},{port_no,50}]},
+                     {port,21,[{queues,[]},{port_no,20}]},
+                     {port,23,[{queues,[]},{port_no,30}]},
+                     {port,32,[{queues,[]},{port_no,10}]}]}]},
+           {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_listener,disabled},
+                {queues_status,disabled},
+                {ports,
+                    [{port,20,[{queues,[]},{port_no,50}]},
+                     {port,22,[{queues,[]},{port_no,30}]},
+                     {port,25,[{queues,[]},{port_no,20}]}]}]},
+           {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_listener,disabled},
+                {queues_status,disabled},
+                {ports,
+                    [{port,24,[{queues,[]},{port_no,50}]},
+                     {port,27,[{queues,[]},{port_no,20}]},
+                     {port,33,[{queues,[]},{port_no,10}]}]}]},
+           {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_listener,disabled},
+                {queues_status,disabled},
+                {ports,
+                    [{port,26,[{queues,[]},{port_no,50}]},
+                     {port,28,[{queues,[]},{port_no,20}]},
+                     {port,34,[{queues,[]},{port_no,10}]}]}]},
+           {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_listener,disabled},
+                {queues_status,disabled},
+                {ports,
+                    [{port,12,[{queues,[]},{port_no,50}]},
+                     {port,14,[{queues,[]},{port_no,20}]},
+                     {port,16,[{queues,[]},{port_no,40}]},
+                     {port,19,[{queues,[]},{port_no,30}]},
+                     {port,31,[{queues,[]},{port_no,10}]}]}]}]}]},
+ {epcap,[{verbose,false},{stats_interval,10}]},
+ {enetconf,
+     [{capabilities,
+          [{base,{1,0}},
+           {base,{1,1}},
+           {startup,{1,0}},
+           {'writable-running',{1,0}}]},
+      {callback_module,linc_ofconfig},
+      {sshd_ip,any},
+      {sshd_port,1830},
+      {sshd_user_passwords,[{"linc","linc"}]}]},
+ {lager,
+     [{handlers,
+          [{lager_console_backend,info},
+           {lager_file_backend,
+               [{"log/error.log",error,10485760,"$D0",5},
+                {"log/console.log",info,10485760,"$D0",5}]}]}]},
+ {sasl,
+     [{sasl_error_logger,{file,"log/sasl-error.log"}},
+      {errlog_type,error},
+      {error_logger_mf_dir,"log/sasl"},
+      {error_logger_mf_maxbytes,10485760},
+      {error_logger_mf_maxfiles,5}]},
+ {sync,[{excluded_modules,[procket]}]}].