Support for cord-tester to work with latest voltha. (manifest-ponsim.json with latest voltha_loc)
The latest voltha uses ssl connections to onos as well. So that support has been added for cord-tester onos starts.
Also changes to cord subscriber test uplink vlan map to use the new device naming convention of voltha.

Change-Id: I420d4532a7da59cb367afa63222d8cc2acbd0d86
diff --git a/src/test/cordSubscriber/cordSubscriberTest.py b/src/test/cordSubscriber/cordSubscriberTest.py
index 64143c0..442b092 100644
--- a/src/test/cordSubscriber/cordSubscriberTest.py
+++ b/src/test/cordSubscriber/cordSubscriberTest.py
@@ -268,7 +268,7 @@
 
       VOLTHA_HOST = None
       VOLTHA_REST_PORT = 8881
-      VOLTHA_UPLINK_VLAN_MAP = { 'of:0000000000000001' : '222' }
+      VOLTHA_UPLINK_VLAN_MAP = { 'of:0001000000000001' : '222' }
       VOLTHA_IGMP_ITERATIONS = 100
       VOLTHA_CONFIG_FAKE = True
       VOLTHA_OLT_TYPE = 'simulated_olt'
diff --git a/src/test/setup/cord-test.py b/src/test/setup/cord-test.py
index 2b89284..4b8958c 100755
--- a/src/test/setup/cord-test.py
+++ b/src/test/setup/cord-test.py
@@ -585,7 +585,6 @@
 
     onos_cord = None
     Onos.update_data_dir(test_manifest.karaf_version)
-
     if onos_cord_loc:
         if onos_cord_loc.find(os.path.sep) < 0:
             onos_cord_loc = os.path.join(os.getenv('HOME'), onos_cord_loc)
@@ -623,6 +622,10 @@
         ##don't setup cluster config again
         cluster_mode = False
     if onos_ip is None:
+        if voltha_loc:
+            voltha_key = os.path.join(voltha_loc, 'docker', 'onos_cfg', 'onos.jks')
+            Onos.update_ssl_key(voltha_key)
+            test_manifest.start_switch = False
         image_names = test_manifest.onos_image.rsplit(':', 1)
         onos_cnt['image'] = image_names[0]
         if len(image_names) > 1:
@@ -921,6 +924,10 @@
     onos = None
     onos_ips = []
     if onos_ip is None:
+        if voltha_loc:
+            voltha_key = os.path.join(voltha_loc, 'docker', 'onos_cfg', 'onos.jks')
+            Onos.update_ssl_key(voltha_key)
+            test_manifest.start_switch = False
         data_volume = '{}-data'.format(Onos.NAME) if test_manifest.shared_volume else None
         onos = Onos(image = Onos.IMAGE, tag = Onos.TAG, boot_delay = 60, cluster = cluster_mode,
                     data_volume = data_volume, async = async_mode, network = test_manifest.docker_network)
diff --git a/src/test/utils/CordContainer.py b/src/test/utils/CordContainer.py
index 4458869..ab49cb5 100644
--- a/src/test/utils/CordContainer.py
+++ b/src/test/utils/CordContainer.py
@@ -596,6 +596,7 @@
     onos_form_cluster = os.path.join(setup_dir, 'onos-form-cluster')
     cord_apps_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', 'apps')
     host_guest_map = ( (host_config_dir, guest_config_dir), )
+    ssl_key = None
     cluster_cfg = os.path.join(host_config_dir, 'cluster.json')
     cluster_mode = False
     cluster_instances = []
@@ -653,6 +654,14 @@
         Onos.guest_data_dir = '/root/onos/apache-karaf-{}/data'.format(karaf)
         Onos.guest_log_file = '/root/onos/apache-karaf-{}/data/log/karaf.log'.format(karaf)
 
+    @classmethod
+    def update_ssl_key(cls, key):
+        if os.access(key, os.F_OK):
+            try:
+                shutil.copy(key, cls.host_config_dir)
+                cls.ssl_key = os.path.join(cls.host_config_dir, os.path.basename(key))
+            except:pass
+
     def remove_data_volume(self):
         if self.data_map is not None:
             self.remove_data_map(*self.data_map)
@@ -678,6 +687,9 @@
         self.data_map = None
         instance_memory = (get_mem(jvm_heap_size = Onos.JVM_HEAP_SIZE, instances = Onos.MAX_INSTANCES),) * 2
         self.env['JAVA_OPTS'] = self.JAVA_OPTS_FORMAT.format(*instance_memory)
+        if self.ssl_key:
+            key_files = ( os.path.join(self.guest_config_dir, os.path.basename(self.ssl_key)), ) * 2
+            self.env['JAVA_OPTS'] += ' -DenableOFTLS=true -Djavax.net.ssl.keyStore={} -Djavax.net.ssl.keyStorePassword=222222 -Djavax.net.ssl.trustStore={} -Djavax.net.ssl.trustStorePassword=222222'.format(*key_files)
         if cluster is True:
             self.ports = []
             if data_volume is not None:
diff --git a/src/test/utils/VolthaCtrl.py b/src/test/utils/VolthaCtrl.py
index d7ab139..8e70dd4 100644
--- a/src/test/utils/VolthaCtrl.py
+++ b/src/test/utils/VolthaCtrl.py
@@ -62,6 +62,7 @@
             print('Chameleon voltha sevice is already running. Skipped start')
 
         #now start voltha and ofagent
+        voltha_setup_cmd = "cd {} && sh -c '. ./env.sh && make rebuild-venv && make protos'".format(self.voltha_loc)
         voltha_start_cmd = "cd {} && sh -c '. ./env.sh && \
         nohup python voltha/main.py -v --consul=localhost:8500 --kafka={}:9092 -I {} \
         --fluentd={}:24224 --rest-port=8880 --grpc-port=50555 \
@@ -69,7 +70,15 @@
                                          self.service_map['kafka']['ip'],
                                          self.interface,
                                          self.service_map['fluentd']['ip'])
+        pki_dir = '{}/pki'.format(self.voltha_loc)
         if not self.service_running('python voltha/main.py'):
+            voltha_pki_dir = '/voltha'
+            if os.access(pki_dir, os.F_OK):
+                pki_xfer_cmd = 'mkdir -p {} && cp -rv {}/pki {}'.format(voltha_pki_dir,
+                                                                        self.voltha_loc,
+                                                                        voltha_pki_dir)
+                os.system(pki_xfer_cmd)
+            #os.system(voltha_setup_cmd)
             ret = os.system(voltha_start_cmd)
             if ret != 0:
                 raise Exception('Failed to start VOLTHA. Return code %d' %ret)
@@ -84,6 +93,12 @@
                                           self.service_map['fluentd']['ip'],
                                           self.controller)
         if not self.service_running('python ofagent/main.py'):
+            ofagent_pki_dir = '/ofagent'
+            if os.access(pki_dir, os.F_OK):
+                pki_xfer_cmd = 'mkdir -p {} && cp -rv {}/pki {}'.format(ofagent_pki_dir,
+                                                                        self.voltha_loc,
+                                                                        ofagent_pki_dir)
+                os.system(pki_xfer_cmd)
             ret = os.system(ofagent_start_cmd)
             if ret != 0:
                 raise Exception('VOLTHA ofagent not started. Failed with return code %d' %ret)