ECMP app fixes

Change-Id: Ib437f1e92cb90f7bc97539a447637066747c5532
diff --git a/tools/dev/mininet/bmv2.py b/tools/dev/mininet/bmv2.py
index e942646..fb3d9d8 100644
--- a/tools/dev/mininet/bmv2.py
+++ b/tools/dev/mininet/bmv2.py
@@ -18,7 +18,6 @@
 CPU_PORT = 255
 PKT_BYTES_TO_DUMP = 80
 VALGRIND_PREFIX = 'valgrind --leak-check=yes'
-VALGRIND_SLEEP = 10  # seconds
 
 
 def parseBoolean(value):
@@ -52,7 +51,7 @@
 
     def __init__(self, name, json=None, debugger=False, loglevel="warn", elogger=False,
                  persistent=False, grpcPort=None, thriftPort=None, netcfg=True, dryrun=False,
-                 pipeconfId="", pktdump=False, valgrind=False, **kwargs):
+                 pipeconfId="", pktdump=False, valgrind=False, netcfgSleep=1, **kwargs):
         Switch.__init__(self, name, **kwargs)
         self.grpcPort = ONOSBmv2Switch.pickUnusedPort() if not grpcPort else grpcPort
         self.thriftPort = ONOSBmv2Switch.pickUnusedPort() if not thriftPort else thriftPort
@@ -71,6 +70,7 @@
         self.netcfg = parseBoolean(netcfg)
         self.dryrun = parseBoolean(dryrun)
         self.valgrind = parseBoolean(valgrind)
+        self.netcfgSleep = netcfgSleep
         self.netcfgfile = '/tmp/bmv2-%d-netcfg.json' % self.deviceId
         self.pipeconfId = pipeconfId
         if persistent:
@@ -229,11 +229,12 @@
             out = self.cmd(cmdStr)
             if out:
                 print out
-            if self.valgrind:
-                # With valgrind, it takes some time before the gRPC server is available.
-                # Wait before pushing the netcfg.
-                info("\n*** Waiting %d seconds before pushing the config to ONOS...\n" % VALGRIND_SLEEP)
-                time.sleep(VALGRIND_SLEEP)
+
+        # Wait before pushing the netcfg.
+        if self.netcfgSleep > 0:
+            info("\n*** Waiting %d seconds before pushing the config to ONOS...\n"
+                 % self.netcfgSleep)
+        time.sleep(self.netcfgSleep)
 
         try:  # onos.py
             clist = controllers[0].nodes()
diff --git a/tools/test/topos/bmv2-demo.py b/tools/test/topos/bmv2-demo.py
index 171cc6f..2864dca 100755
--- a/tools/test/topos/bmv2-demo.py
+++ b/tools/test/topos/bmv2-demo.py
@@ -70,7 +70,10 @@
                                                     netcfg=False,
                                                     longitude=longitude,
                                                     latitude=latitude,
-                                                    pipeconfId=args.pipeconf_id)
+                                                    pipeconfId=args.pipeconf_id,
+                                                    valgrind=True,
+                                                    netcfgSleep=0,
+                                                    leglevel="debug")
 
         for i in range(1, args.size + 1):
             for j in range(1, args.size + 1):
@@ -233,8 +236,14 @@
 
     print "Network started"
 
+    generateNetcfg(onosIp, net, args)
+
+    sleep(30)
+    print "Uploading netcfg..."
+    call(("%s/onos-netcfg" % RUN_PACK_PATH, onosIp, TEMP_NETCFG_FILE))
+
     # Generate background traffic.
-    sleep(3)
+    sleep(5)
     for (h1, h2) in combinations(net.hosts, 2):
         h1.startPingBg(h2)
         h2.startPingBg(h1)
@@ -250,11 +259,6 @@
     # print "Starting traffic from h1 to h3..."
     # net.hosts[0].startIperfClient(net.hosts[-1], flowBw="200k", numFlows=100, duration=10)
 
-    generateNetcfg(onosIp, net, args)
-
-    print "Uploading netcfg..."
-    call(("%s/onos-netcfg" % RUN_PACK_PATH, onosIp, TEMP_NETCFG_FILE))
-
     if not args.onos_ip:
         ONOSCLI(net)
     else: