Fix: Install ONOS cord apps when ONOS is running externally and tester started with "-e" option.
Also set the ONOS restart disabled flag based on whether running the tester under olt with ONOS on another node.

Change-Id: I12402cb15f321d8e97c44f7677f589af10498343
diff --git a/src/test/setup/cord-test.py b/src/test/setup/cord-test.py
index 49a7211..5dabe1c 100755
--- a/src/test/setup/cord-test.py
+++ b/src/test/setup/cord-test.py
@@ -276,14 +276,19 @@
         onos = Onos(image = onos_cnt['image'], tag = onos_cnt['tag'], boot_delay = 60)
         onos_ip = onos.ip()
 
+    print('Onos IP %s, Test type %s' %(onos_ip, args.test_type))
+    print('Installing ONOS cord apps')
+    Onos.install_cord_apps(onos_ip = onos_ip)
+
+    print('Installing cord tester ONOS app %s' %onos_app_file)
+    OnosCtrl.install_app(args.app, onos_ip = onos_ip)
+
+    if radius_ip is None:
         ##Start Radius container
         radius = Radius( update = update_map['radius'])
         radius_ip = radius.ip()
-        print('Radius server running with IP %s' %radius_ip)
 
-    print('Onos IP %s, Test type %s' %(onos_ip, args.test_type))
-    print('Installing cord tester ONOS app %s' %onos_app_file)
-    OnosCtrl.install_app(args.app, onos_ip = onos_ip)
+    print('Radius server running with IP %s' %radius_ip)
 
     if args.quagga == True:
         #Start quagga. Builds container if required
@@ -294,6 +299,7 @@
                      'QUAGGA_IP': test_host,
                      'CORD_TEST_HOST' : test_host,
                      'CORD_TEST_PORT' : test_port,
+                     'ONOS_RESTART_DISABLED' : 1 if args.olt and args.test_controller else 0,
                    }
     if args.olt:
         olt_conf_test_loc = os.path.join(CordTester.sandbox_setup, 'olt_config.json')
@@ -376,15 +382,19 @@
         onos = Onos(image = onos_cnt['image'], tag = onos_cnt['tag'], boot_delay = 60)
         onos_ip = onos.ip()
 
+    print('Onos IP %s' %onos_ip)
+    print('Installing ONOS cord apps')
+    Onos.install_cord_apps(onos_ip = onos_ip)
+
+    print('Installing cord tester ONOS app %s' %onos_app_file)
+    OnosCtrl.install_app(args.app, onos_ip = onos_ip)
+
     ##Start Radius container if not started
     if radius_ip is None:
         radius = Radius( update = update_map['radius'])
         radius_ip = radius.ip()
 
     print('Radius server running with IP %s' %radius_ip)
-    print('Onos IP %s' %onos_ip)
-    print('Installing cord tester ONOS app %s' %onos_app_file)
-    OnosCtrl.install_app(args.app, onos_ip = onos_ip)
 
     if args.quagga == True:
         #Start quagga. Builds container if required
@@ -404,6 +414,7 @@
                          'QUAGGA_IP': ip,
                          'CORD_TEST_HOST' : ip,
                          'CORD_TEST_PORT' : port,
+                         'ONOS_RESTART_DISABLED' : 1 if args.olt and args.test_controller else 0,
                        }
         if args.olt:
             olt_conf_test_loc = os.path.join(CordTester.sandbox_setup, 'olt_config.json')
diff --git a/src/test/utils/CordContainer.py b/src/test/utils/CordContainer.py
index f22dbfd..e5f7526 100644
--- a/src/test/utils/CordContainer.py
+++ b/src/test/utils/CordContainer.py
@@ -240,13 +240,11 @@
             print('Waiting %d seconds for ONOS to boot' %(boot_delay))
             time.sleep(boot_delay)
 
-        self.install_cord_apps()
-
     @classmethod
-    def install_cord_apps(cls):
+    def install_cord_apps(cls, onos_ip = None):
         for app, version in cls.onos_cord_apps:
             app_file = '{}/{}-{}.oar'.format(cls.cord_apps_dir, app, version)
-            ok, code = OnosCtrl.install_app(app_file)
+            ok, code = OnosCtrl.install_app(app_file, onos_ip = onos_ip)
             ##app already installed (conflicts)
             if code in [ 409 ]:
                 ok = True