[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/roles/interface_config/tasks/main.yml b/xos/synchronizer/steps/roles/interface_config/tasks/main.yml
index fa8b2f4..7aae3d2 100644
--- a/xos/synchronizer/steps/roles/interface_config/tasks/main.yml
+++ b/xos/synchronizer/steps/roles/interface_config/tasks/main.yml
@@ -13,18 +13,41 @@
# limitations under the License.
---
-- name: create config directory for interface config file
- file:
- path: "{{source_path}}"
- state: directory
- mode: 0755
+
+- name: resolve sudo timeout
+ become: yes
+ shell: "echo 127.0.1.1 $(cat /etc/hostname) >> /etc/hosts"
- name: make interface config file
+ become: yes
template:
src=interface.cfg.j2
- dest="{{source_path}}/interface.cfg"
+ dest="{{source_path}}/config/interface.cfg" owner=root group=root mode=755
+
+- name: get date
+ shell: date +"%Y-%m-%d_%H-%M"
+ register: tmp_date
+
+- name: assign results into each variable
+ set_fact:
+ date: "{{ tmp_date.stdout }}"
- name: make cp_config config file
+ become: yes
template:
src=cp_config.cfg.j2
- dest="{{source_path}}/cp_config.cfg"
\ No newline at end of file
+ dest="{{source_path}}/config/cp_config.cfg" owner=root group=root mode=755
+
+#- name: Build ngic
+# become: yes
+# shell: "{{ item }}"
+# args:
+# chdir: "{{ source_path }}"
+# environment:
+# NG_CORE: "{{ source_path }}"
+# RTE_SDK: "{{ source_path }}/dpdk"
+# RTE_TARGET: "x86_64-native-linuxapp-gcc"
+# HYPERSCANDIR: "/root/ngic/hyperscan-4.1.0"
+# with_items:
+# - make
+# - /root/ngic/cp/run.sh -c 1
diff --git a/xos/synchronizer/steps/roles/interface_config/templates/cp_config.cfg.j2 b/xos/synchronizer/steps/roles/interface_config/templates/cp_config.cfg.j2
index bb4a7df..33e5413 100644
--- a/xos/synchronizer/steps/roles/interface_config/templates/cp_config.cfg.j2
+++ b/xos/synchronizer/steps/roles/interface_config/templates/cp_config.cfg.j2
@@ -1,4 +1,3 @@
-{% set date = ansible_date_time['date'] ~ '_' ~ ansible_date_time['hour'] ~ '_' ~ ansible_date_time['minute'] %}
NOW={{ date }}
FILE="logs/cp_{{ date }}.log"
S11_SGW_IP={{ s11_sgw_ip }}
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)
diff --git a/xos/synchronizer/steps/vspgwctenant_playbook.yaml b/xos/synchronizer/steps/vspgwctenant_playbook.yaml
index 818ef6a..9fc240a 100644
--- a/xos/synchronizer/steps/vspgwctenant_playbook.yaml
+++ b/xos/synchronizer/steps/vspgwctenant_playbook.yaml
@@ -14,12 +14,14 @@
---
- hosts: {{ instance_name }}
- gather_facts: True
+ gather_facts: False
connection: ssh
- user: ubuntu
- sudo: yes
+ remote_user: ubuntu
+ become: yes
+ become_user: root
+ become_method: sudo
vars:
- - source_path: /var/tmp/config
+ - source_path: /root/ngic
- zmq_sub_ip: {{ zmq_sub_ip }}
- zmq_pub_ip: {{ zmq_pub_ip }}
- dp_comm_ip: {{ dp_comm_ip }}
@@ -30,6 +32,6 @@
- s11_mme_ip: {{ s11_mme_ip }}
- s1u_sgw_ip: {{ s1u_sgw_ip }}
- scenario: {{ scenario }}
+
roles:
- interface_config
-