Onos cord instance wrapper works now across test case restarts.
Fix the vrouter test case to activate the relevant apps for vrouter.

Change-Id: I392f8a18052435b140996ba68e2071cf378f1798
diff --git a/src/test/utils/CordContainer.py b/src/test/utils/CordContainer.py
index d1db4ff..2f34675 100644
--- a/src/test/utils/CordContainer.py
+++ b/src/test/utils/CordContainer.py
@@ -193,8 +193,7 @@
             print('Infinity time pause the container %s' %cnt['Id'])
         return 'success'
 
-    def connect_to_br(self):
-        index = 0
+    def connect_to_br(self, index = 0):
         self.CONFIG_LOCK.acquire()
         try:
             with docker_netns(self.name) as pid:
@@ -213,7 +212,7 @@
                         br = ip.link_lookup(ifname=quagga_config['bridge'])
                     br = br[0]
                     ip.link('set', index=br, state='up')
-                    ifname = '{0}-{1}'.format(self.name, index)
+                    ifname = '{0}-{1}'.format(self.name[:12], index)
                     ifs = ip.link_lookup(ifname=ifname)
                     if len(ifs) > 0:
                        ip.link_remove(ifs[0])
@@ -294,7 +293,7 @@
     """Use this when running the cord tester agent on the onos compute node"""
     onos_config_dir_guest = '/root/onos/config'
 
-    def __init__(self, onos_ip, conf, service_profile, synchronizer, start = True, boot_delay = 60):
+    def __init__(self, onos_ip, conf, service_profile, synchronizer, start = True, boot_delay = 25):
         if not os.access(conf, os.F_OK):
             raise Exception('ONOS cord configuration location %s is invalid' %conf)
         if not os.access(service_profile, os.F_OK):
@@ -337,7 +336,7 @@
             self.volumes = volumes
 
         ##Create an container instance of xos onos
-        self.xos_onos = Container(xos_onos_name, image, tag = '')
+        super(OnosCord, self).__init__(xos_onos_name, image, tag = '', quagga_config = Onos.QUAGGA_CONFIG)
         self.last_cfg = None
         if self.start_wrapper:
             #fetch the current config of onos cord instance and save it
@@ -356,7 +355,10 @@
             json_data = json.dumps(network_cfg, indent=4)
             with open('{}/network-cfg.json'.format(self.onos_config_dir), 'w') as f:
                 f.write(json_data)
-        if restart is False:
+
+        #we avoid using docker-compose restart for now.
+        #since we don't want to retain the metadata across restarts
+        if True:
             #stop and start and synchronize the services before installing tester cord apps
             cmds = [ 'cd {} && docker-compose down'.format(self.onos_cord_dir),
                      'cd {} && docker-compose up -d'.format(self.onos_cord_dir),
@@ -374,6 +376,12 @@
             try:
                 os.system(cmd)
             except: pass
+
+        ##we could also connect container to default docker network but disabled for now
+        #Container.connect_to_network(self.name, 'bridge')
+
+        #connect container to the quagga bridge
+        self.connect_to_br(index = 0)
         print('Waiting %d seconds for ONOS instance to start' %self.boot_delay)
         time.sleep(self.boot_delay)