[CORD-2289] add ng4T synchronizer and playbooks

Change-Id: Icf2c8095233a8748c9398f1840a580eaeff6bdb8
(cherry picked from commit b6eba07b7c2344af5aacfa27ce7a2aedba719ee8)
diff --git a/xos/models/venb.xproto b/xos/models/venb.xproto
index 591e9cb..6c92171 100644
--- a/xos/models/venb.xproto
+++ b/xos/models/venb.xproto
@@ -3,8 +3,8 @@
 
 message VENBService (Service){
     option verbose_name = "Virtual eNodeB Service";
-    required string login_user = 1 [help_text = "vENB VM login user", default = "ubuntu", max_length = 32, content_type = "stripped", null = False, db_index = False, blank = False];
-    required string login_password = 2 [help_text = "vENB VM login password", default = "cfguser", max_length = 32, content_type = "stripped", null = False, db_index = False, blank = False];
+    required string login_user = 1 [help_text = "vENB VM login user", default = "ng40", max_length = 32, content_type = "stripped", null = False, db_index = False, blank = False];
+    required string login_password = 2 [help_text = "vENB VM login password", default = "ng40", max_length = 32, content_type = "stripped", null = False, db_index = False, blank = False];
     required string tas_ip = 3 [help_text = "TAS IP address", default = "103.0.0.100", max_length = 32, null = False, db_index = False, blank = False];
     required string ntp_ip = 4 [help_text = "NTP server IP address", default = "193.0.0.222", max_length = 32, null = False, db_index = False, blank = False];
 }
diff --git a/xos/synchronizer/steps/roles/ng4t_config/defaults/main.yml b/xos/synchronizer/steps/roles/ng4t_config/defaults/main.yml
index 2b9f42e..d9b0fa9 100644
--- a/xos/synchronizer/steps/roles/ng4t_config/defaults/main.yml
+++ b/xos/synchronizer/steps/roles/ng4t_config/defaults/main.yml
@@ -13,5 +13,6 @@
 # limitations under the License.
 
 ---
-ng4t_license_src:  /opt/xos/synchronizers/venb/files/ng4t-license.txt
-ng4t_license_dest: /tmp/license.txt
\ No newline at end of file
+ng4t_license_src:  /opt/xos/synchronizers/venb/files/ng40-license
+ng4t_license_dest: /home/ng40/install/ng40-license
+ng4t_ipconfig_dest: /home/ng40/install/ipconfig
\ No newline at end of file
diff --git a/xos/synchronizer/steps/roles/ng4t_config/tasks/main.yml b/xos/synchronizer/steps/roles/ng4t_config/tasks/main.yml
index 42e1049..e37d0f6 100644
--- a/xos/synchronizer/steps/roles/ng4t_config/tasks/main.yml
+++ b/xos/synchronizer/steps/roles/ng4t_config/tasks/main.yml
@@ -13,9 +13,43 @@
 # limitations under the License.
 
 ---
+- name: Set SSH password
+  set_fact:
+    ansible_ssh_pass: "{{ password }}"
+
+- name: check s11_network interface
+  shell: ifconfig | grep -B1 "inet addr:{{ mme_s11_ip }}" | awk '$1!="inet" && $1!="--" {print $1}'
+  args:
+    executable: /bin/bash
+  register: mme_s11_interface
+
+- name: check s1u_network interface
+  shell: ifconfig | grep -B1 "inet addr:{{ enb1_s1u_ip }}" | awk '$1!="inet" && $1!="--" {print $1}'
+  args:
+    executable: /bin/bash
+  register: enb1_s1u_interface
+
+- name: check sgi_network interface
+  shell: ifconfig | grep -B1 "inet addr:{{ appserver_sgi_ip }}" | awk '$1!="inet" && $1!="--" {print $1}'
+  args:
+    executable: /bin/bash
+  register: appserver_sgi_interface
+
 - name: Copy license file
   copy:
     src: "{{ ng4t_license_src }}"
     dest: "{{ ng4t_license_dest }}"
-    owner: root
-    mode: 0644
+
+- name: Create ipconfig file
+  template:
+    src: ./templates/ipconfig.j2
+    dest: "{{ ng4t_ipconfig_dest }}"
+
+- name: Set instance to hosts file
+  shell: "echo 127.0.1.1       $(cat /etc/hostname) >> /etc/hosts"
+
+- name: Start install ng4t
+  sudo: no
+  shell: /home/ng40/install/ng40init
+  args:
+    executable: /bin/bash
diff --git a/xos/synchronizer/steps/roles/ng4t_config/templates/ipconfig.j2 b/xos/synchronizer/steps/roles/ng4t_config/templates/ipconfig.j2
new file mode 100644
index 0000000..ef2bb1b
--- /dev/null
+++ b/xos/synchronizer/steps/roles/ng4t_config/templates/ipconfig.j2
@@ -0,0 +1,27 @@
+# ENB network
+ENB1_S1U_DEV={{ enb1_s1u_interface.stdout }}
+ENB1_S1U_IP={{ enb1_s1u_ip }}
+ENB1_S1U_NET={{ enb1_s1u_netmask }}
+#ENB2_S1U_DEV=ens6:1
+#ENB2_S1U_IP=111.0.0.4
+#ENB2_S1U_NET=24
+
+# MME network
+MME_S11_DEV={{ mme_s11_interface.stdout }}
+MME_S11_IP={{ mme_s11_ip }}
+MME_S11_NET={{ mme_s11_netmask }}
+
+# SAEGW network
+SGW_S11_IP={{ spgw_s11_ip }}
+
+# Application Server network
+AS_DEV={{ appserver_sgi_interface.stdout }}
+AS_IP={{ appserver_sgi_ip }}
+AS_GW={{ appserver_sgi_gateway }}
+AS_NET={{ appserver_sgi_netmask }}
+
+# Control (ssh) network
+SSH_NG40_RAN={{ ssh_venb_ip }}
+SSH_NGIC_CP_IP={{ ssh_vspgwc_ip }}
+SSH_NGIC_DP_IP={{ ssh_vspgwu_ip }}
+SSH_NGIC_FPC_IP={{ fpc_management_ip }}
\ No newline at end of file
diff --git a/xos/synchronizer/steps/sync_venbserviceinstance.py b/xos/synchronizer/steps/sync_venbserviceinstance.py
index c0a4593..5d5cb6c 100644
--- a/xos/synchronizer/steps/sync_venbserviceinstance.py
+++ b/xos/synchronizer/steps/sync_venbserviceinstance.py
@@ -43,12 +43,18 @@
     def get_extra_attributes(self, o):
 
         fields = {}
-        fields['flat_ip'] = self.get_ip_address('flat_network', o, 'get_venb_flat_ip')
         service = self.get_service(o)
         fields['login_user'] = service.login_user
         fields['login_password'] = service.login_password
-        fields['tas_ip'] = service.tas_ip
-        fields['ntp_ip'] = service.ntp_ip
+        fields['venb_s1u_ip'] = self.get_ip_address('s1u_network', VENBServiceInstance, 'venb_s1u_ip')
+        fields['venb_s11_ip'] = self.get_ip_address('s11_network', VENBServiceInstance, 'venb_s11_ip')
+        fields['vspgwc_s11_ip'] = self.get_ip_address('s11_network', VSPGWCTenant, 'vspgwc_s11_ip')
+        fields['venb_sgi_ip'] = self.get_ip_address('sgi_network', VENBServiceInstance, 'venb_sgi_ip')
+        fields['vspgwu_sgi_ip'] = self.get_ip_address('sgi_network', VSPGWUTenant, 'vspgwu_sgi_ip')
+        fields['venb_management_ip'] = self.get_ip_address('management', VENBServiceInstance, 'venb_management_ip')
+        fields['vspgwc_management_ip'] = self.get_ip_address('management', VSPGWCTenant, 'vspgwc_management_ip')
+        fields['vspgwu_management_ip'] = self.get_ip_address('management', VSPGWUTenant, 'vspgwu_management_ip')
+
         return fields
 
     def get_ip_address(self, network_name, service_instance, parameter):
diff --git a/xos/synchronizer/steps/venbserviceinstance_playbook.yaml b/xos/synchronizer/steps/venbserviceinstance_playbook.yaml
index 4da768e..675fbe4 100644
--- a/xos/synchronizer/steps/venbserviceinstance_playbook.yaml
+++ b/xos/synchronizer/steps/venbserviceinstance_playbook.yaml
@@ -17,15 +17,23 @@
   gather_facts: False
   connection: ssh
   user: {{ login_user }}
-  # These are still the old variables; update for ng4T emulator
+  sudo: yes
+
   vars:
-    - ts_ip: {{ flat_ip }}
-    - ts_mask: "255.255.255.0"
-    - ts_gateway: "103.0.0.254"
-    - ts_host_name: "{{ instance_name }}"
-    - tas_ip: "{{ tas_ip }}"
-    - ntp_ip: "{{ ntp_ip }}"
     - password: "{{ login_password }}"
+    - enb1_s1u_ip: {{ venb_s1u_ip }}
+    - enb1_s1u_netmask: 24
+    - mme_s11_ip: {{ venb_s11_ip }}
+    - mme_s11_netmask: 24
+    - spgw_s11_ip: {{ vspgwc_s11_ip }}
+    - appserver_sgi_ip: {{ venb_sgi_ip }}
+    - appserver_sgi_gateway: {{ vspgwu_sgi_ip }}
+    - appserver_sgi_netmask: 24
+    - ssh_venb_ip: {{ venb_management_ip }}
+    - ssh_vspgwc_ip: {{ vspgwc_management_ip }}
+    - ssh_vspgwu_ip: {{ vspgwu_management_ip }}
+    - fpc_management_ip: ''
+
   roles:
     - ng4t_config