# Copyright 2017-present Open Networking Foundation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

---

# Make shell script to run vSPGW-C with log
- name: make run with log file
  become: yes
  template:
    src=run_with_log.sh.j2
    dest="{{source_path_4_1}}/cp/run_with_log.sh" owner=root group=root mode=755

# This part should be run after user plane (data plane) runs in vSPGW-U
# If not, vSPGW-U and vSPGW-C will not be working well
- name: build and run vspgwc
  become: yes
  shell: "{{ item }}"
  args:
    chdir: "{{ source_path_4_1 }}/cp"
  environment:
    NG_CORE: "{{ source_path_4_1 }}"
    RTE_SDK: "{{ source_path_4_1 }}/dpdk"
    RTE_TARGET: "x86_64-native-linuxapp-gcc"
    HYPERSCANDIR: "{{ source_path_4_1 }}/hyperscan-4.1.0"
  with_items:
    - make clean
    - make
    - ./run_with_log.sh

# Finish
- name: write flag
  become: yes
  shell: "echo 1 > {{source_path_4_1}}/cp/finish_flag_build_and_run"