Test: Now cord-test.py setup would start and provision the test container to run nosetests from the container.
If one wants to dynamically launch the test container for running cord-tester tests,
they can still do the cord-test.py run to execute the tests.

Change-Id: I0df8604398c3369385b9e4ffeb590ce89565498d
diff --git a/src/test/setup/cord-test.py b/src/test/setup/cord-test.py
index 29f4ee1..fecbb5d 100755
--- a/src/test/setup/cord-test.py
+++ b/src/test/setup/cord-test.py
@@ -348,7 +348,8 @@
 ##Starts onos/radius/quagga containers as appropriate
 def setupCordTester(args):
     onos_cnt = {'tag':'latest'}
-    update_map = { 'quagga' : False, 'radius' : False }
+    nose_cnt = {'image': CordTester.IMAGE, 'tag': 'latest'}
+    update_map = { 'quagga' : False, 'radius' : False, 'test': False }
     update_map[args.update.lower()] = True
 
     if args.update.lower() == 'all':
@@ -393,12 +394,39 @@
         quagga_ip = quagga.ip()
         print('Quagga running with IP %s' %quagga_ip)
 
-    #Finally start the test server and daemonize
     params = args.server.split(':')
     ip = params[0]
     port = CORD_TEST_PORT
     if len(params) > 1:
         port = int(params[1])
+
+    #provision the test container
+    if not args.dont_provision:
+        test_cnt_env = { 'ONOS_CONTROLLER_IP' : onos_ip,
+                         'ONOS_AAA_IP' : radius_ip,
+                         'QUAGGA_IP': quagga_ip if quagga_ip is not None else '',
+                         'CORD_TEST_HOST' : ip,
+                         'CORD_TEST_PORT' : port,
+                       }
+        if args.olt:
+            olt_conf_test_loc = os.path.join(CordTester.sandbox_setup, 'olt_config.json')
+            test_cnt_env['OLT_CONFIG'] = olt_conf_test_loc
+
+        test_cnt = CordTester((),
+                              ctlr_ip = onos_ip,
+                              image = nose_cnt['image'],
+                              tag = nose_cnt['tag'],
+                              env = test_cnt_env,
+                              rm = False,
+                              update = update_map['test'])
+
+        if args.start_switch or not args.olt:
+            test_cnt.start_switch()
+        if test_cnt.olt:
+            test_cnt.setup_intfs(port_num = 0)
+        print('Test container %s started and provisioned to run tests using nosetests' %(test_cnt.name))
+
+    #Finally start the test server and daemonize
     cord_test_server_start(daemonize = True, cord_test_host = ip, cord_test_port = port)
 
 def cleanupTests(args):
@@ -460,6 +488,9 @@
                         'Eg: --update=quagga to rebuild quagga image.'
                         '    --update=radius to rebuild radius server image.'
                         '    --update=all to rebuild all cord tester images.')
+    parser_setup.add_argument('-d', '--dont-provision', action='store_true', help='Dont start test container.')
+    parser_setup.add_argument('-p', '--olt', action='store_true', help='Use OLT config')
+    parser_setup.add_argument('-s', '--start-switch', action='store_true', help='Start OVS when running under OLT config')
     parser_setup.set_defaults(func=setupCordTester)
 
     parser_list = subparser.add_parser('list', help='List test cases')