[CORD-2138] change ansible-playbook files due to the change of scenario and add build process

Change-Id: Ie0841a245efbc820d3c9661435de48dbc2b22441
(cherry picked from commit 6d66759d4b237d848e16e4e13c7e4b68fe334bdf)
diff --git a/xos/synchronizer/steps/sync_vspgwctenant.py b/xos/synchronizer/steps/sync_vspgwctenant.py
index 5fa2c08..0c90978 100644
--- a/xos/synchronizer/steps/sync_vspgwctenant.py
+++ b/xos/synchronizer/steps/sync_vspgwctenant.py
@@ -36,32 +36,19 @@
         super(SyncVSPGWCTenant, self).__init__(*args, **kwargs)
 
     def get_extra_attributes(self, o):
-        if self.get_scenario() == 'manual':
-            return self.get_extra_attributes_for_manual()
 
-        fields = {}
-        fields['scenario'] = self.get_scenario()
-        # for interface.cfg file
-        fields['zmq_sub_ip'] = self.get_ip_address('sbi_network', SDNControllerServiceInstance, 'zmq_sub_ip')
-        fields['zmq_pub_ip'] = self.get_ip_address('sbi_network', SDNControllerServiceInstance, 'zmq_pub_ip')
-        fields['dp_comm_ip'] = self.get_ip_address('sbi_network', VSPGWUTenant, 'dp_comm_ip')
-        fields['cp_comm_ip'] = self.get_ip_address('nbi_network', VSPGWCTenant, 'cp_comm_ip')
-        fields['fpc_ip'] = self.get_ip_address('nbi_network', SDNControllerServiceInstance, 'fpc_ip')
-        fields['cp_nb_server_ip'] = self.get_ip_address('nbi_network', VSPGWCTenant, 'cp_nb_server_ip')
+        scenario = self.get_scenario()
 
-        # for cp_config.cfg file
-        fields['s11_sgw_ip'] = self.get_ip_address('s11_network', VSPGWCTenant, 's11_sgw_ip')
-        fields['s1u_sgw_ip'] = self.get_ip_address('s1u_network', VSPGWUTenant, 's1u_sgw_ip')
-
-        # the parameter 's11_mme_ip' depends on scenarios
-        if self.get_scenario() == 'ng4t':
-            fields['s11_mme_ip'] = self.get_ip_address('s11_network', VMMETenant, 's11_mme_ip')
-        elif self.get_scenario() == 'spirent':
-            fields['s11_mme_ip'] = self.get_ip_address('s11_network', VENBServiceInstance, 's11_mme_ip')
+        if scenario == 'ng4t_with_sdncontroller':
+            return self.get_values_for_ng4t_w_sdncontroller()
+        elif scenario == 'ng4t_without_sdncontroller':
+            return self.get_values_for_ng4t_wo_sdncontroller()
+        elif scenario == 'spirent_with_sdncontroller':
+            return self.get_values_for_spirent_w_sdncontroller()
+        elif scenario == 'spirent_without_sdncontroller':
+            return self.get_values_for_spirent_wo_sdncontroller()
         else:
-            fields['s11_mme_ip'] = "scenario_error"
-
-        return fields
+            return self.get_extra_attributes_for_manual()
 
     # fields for manual case
     def get_extra_attributes_for_manual(self):
@@ -82,6 +69,79 @@
 
         return fields
 
+    def get_values_for_ng4t_w_sdncontroller(self):
+        fields = {}
+        fields['scenario'] = "ng4t_with_sdncontroller"
+        # for interface.cfg file
+        fields['zmq_sub_ip'] = self.get_ip_address('sbi_network', SDNControllerServiceInstance, 'zmq_sub_ip')
+        fields['zmq_pub_ip'] = self.get_ip_address('sbi_network', SDNControllerServiceInstance, 'zmq_pub_ip')
+        fields['dp_comm_ip'] = self.get_ip_address('sbi_network', VSPGWUTenant, 'dp_comm_ip')
+        fields['cp_comm_ip'] = self.get_ip_address('nbi_network', VSPGWCTenant, 'cp_comm_ip')
+        fields['fpc_ip'] = self.get_ip_address('nbi_network', SDNControllerServiceInstance, 'fpc_ip')
+        fields['cp_nb_server_ip'] = self.get_ip_address('nbi_network', VSPGWCTenant, 'cp_nb_server_ip')
+
+        # for cp_config.cfg file
+        fields['s11_sgw_ip'] = self.get_ip_address('s11_network', VSPGWCTenant, 's11_sgw_ip')
+        fields['s1u_sgw_ip'] = self.get_ip_address('s1u_network', VSPGWUTenant, 's1u_sgw_ip')
+        fields['s11_mme_ip'] = self.get_ip_address('s11_network', VMMETenant, 's11_mme_ip')
+
+        return fields
+
+    def get_values_for_ng4t_wo_sdncontroller(self):
+        fields = {}
+        fields['scenario'] = "ng4t_without_sdncontroller"
+        # for interface.cfg file
+        fields['zmq_sub_ip'] = "127.0.0.1"
+        fields['zmq_pub_ip'] = "127.0.0.1"
+        fields['dp_comm_ip'] = self.get_ip_address('spgw_network', VSPGWUTenant, 'dp_comm_ip')
+        fields['cp_comm_ip'] = self.get_ip_address('spgw_network', VSPGWCTenant, 'cp_comm_ip')
+        fields['fpc_ip'] = "127.0.0.1"
+        fields['cp_nb_server_ip'] = "127.0.0.1"
+
+        # for cp_config.cfg file
+        fields['s11_sgw_ip'] = self.get_ip_address('s11_network', VSPGWCTenant, 's11_sgw_ip')
+        fields['s1u_sgw_ip'] = self.get_ip_address('s1u_network', VSPGWUTenant, 's1u_sgw_ip')
+        fields['s11_mme_ip'] = self.get_ip_address('s11_network', VMMETenant, 's11_mme_ip')
+
+        return fields
+
+    def get_values_for_spirent_w_sdncontroller(self):
+        fields = {}
+        fields['scenario'] = "spirent_with_sdncontroller"
+        # for interface.cfg file
+        fields['zmq_sub_ip'] = self.get_ip_address('sbi_network', SDNControllerServiceInstance, 'zmq_sub_ip')
+        fields['zmq_pub_ip'] = self.get_ip_address('sbi_network', SDNControllerServiceInstance, 'zmq_pub_ip')
+        fields['dp_comm_ip'] = self.get_ip_address('sbi_network', VSPGWUTenant, 'dp_comm_ip')
+        fields['cp_comm_ip'] = self.get_ip_address('nbi_network', VSPGWCTenant, 'cp_comm_ip')
+        fields['fpc_ip'] = self.get_ip_address('nbi_network', SDNControllerServiceInstance, 'fpc_ip')
+        fields['cp_nb_server_ip'] = self.get_ip_address('nbi_network', VSPGWCTenant, 'cp_nb_server_ip')
+
+        # for cp_config.cfg file
+        fields['s11_sgw_ip'] = self.get_ip_address('s11_network', VSPGWCTenant, 's11_sgw_ip')
+        fields['s1u_sgw_ip'] = self.get_ip_address('s1u_network', VSPGWUTenant, 's1u_sgw_ip')
+        fields['s11_mme_ip'] = self.get_ip_address('s11_network', VENBServiceInstance, 's11_mme_ip')
+
+        return fields
+
+    def get_values_for_spirent_wo_sdncontroller(self):
+        fields = {}
+        fields['scenario'] = "spirent_without_sdncontroller"
+        # for interface.cfg file
+        fields['zmq_sub_ip'] = "127.0.0.1"
+        fields['zmq_pub_ip'] = "127.0.0.1"
+        fields['dp_comm_ip'] = self.get_ip_address('spgw_network', VSPGWUTenant, 'dp_comm_ip')
+        fields['cp_comm_ip'] = self.get_ip_address('spgw_network', VSPGWCTenant, 'cp_comm_ip')
+        fields['fpc_ip'] = "127.0.0.1"
+        fields['cp_nb_server_ip'] = "127.0.0.1"
+
+        # for cp_config.cfg file
+        fields['s11_sgw_ip'] = self.get_ip_address('s11_network', VSPGWCTenant, 's11_sgw_ip')
+        fields['s1u_sgw_ip'] = self.get_ip_address('s1u_network', VSPGWUTenant, 's1u_sgw_ip')
+        fields['s11_mme_ip'] = self.get_ip_address('s11_network', VENBServiceInstance, 's11_mme_ip')
+
+        return fields
+
+
     def has_venb(self):
         # try get vMME instance
         try:
@@ -102,26 +162,63 @@
 
         return True
 
+    def has_sdncontroller(self):
+        # try get vMME instance
+        try:
+            instance_id = self.get_instance_id(SDNControllerServiceInstance)
+        except Exception:
+            print 'cannot get SDNControllerServiceInstance'
+            return False
+
+        return True
+
+    def has_vspgwu(self):
+        # try get vMME instance
+        try:
+            instance_id = self.get_instance_id(VSPGWUTenant)
+        except Exception:
+            print 'cannot get VSPGWUTenant'
+            return False
+
+        return True
+
+    def has_internetemulator(self):
+        # try get vMME instance
+        try:
+            instance_id = self.get_instance_id(InternetEmulatorServiceInstance)
+        except Exception:
+            print 'cannot get InternetEmulatorServiceInstance'
+            return False
+
+        return True
+
 
     # Which scenario does it use among Spirent or NG4T?
     def get_scenario(self):
         # try get vENB instance: one of both Spirent and NG4T
         venb_flag = self.has_venb()
         vmme_flag = self.has_vmme()
+        sdncontroller_flag = self.has_sdncontroller()
+        vspgwu_flag = self.has_vspgwu()
+        internetemulator_flag = self.has_internetemulator()
 
-        if vmme_flag:
-            return 'ng4t'
-        else:
-            if venb_flag:
-                return 'spirent'
-            else:
-                return 'manual'
+        if vmme_flag and venb_flag and sdncontroller_flag and vspgwu_flag and internetemulator_flag:
+            return 'ng4t_with_sdncontroller'
 
+        if vmme_flag and venb_flag and (not sdncontroller_flag) and vspgwu_flag and internetemulator_flag:
+            return 'ng4t_without_sdncontroller'
+
+        if (not vmme_flag) and venb_flag and sdncontroller_flag and vspgwu_flag and (not internetemulator_flag):
+            return 'spirent_with_sdncontroller'
+
+        if (not vmme_flag) and venb_flag and (not sdncontroller_flag) and vspgwu_flag and (not internetemulator_flag):
+            return 'spirent_without_sdncontroller'
+
+        return 'manual'
+
+    # To get IP address
     def get_ip_address(self, network_name, service_instance, parameter):
 
-        if self.get_scenario() == 'manual':
-            return "manual"
-
         try:
             net_id = self.get_network_id(network_name)
             ins_id = self.get_instance_id(service_instance)