diff options
Diffstat (limited to 'stacks/lwip_stack/vagrant')
-rw-r--r-- | stacks/lwip_stack/vagrant/Vagrantfile | 65 | ||||
-rw-r--r-- | stacks/lwip_stack/vagrant/build.sh | 59 | ||||
-rw-r--r-- | stacks/lwip_stack/vagrant/env.sh | 7 | ||||
-rw-r--r-- | stacks/lwip_stack/vagrant/start_nstackMain.sh | 105 |
4 files changed, 236 insertions, 0 deletions
diff --git a/stacks/lwip_stack/vagrant/Vagrantfile b/stacks/lwip_stack/vagrant/Vagrantfile new file mode 100644 index 0000000..b3a31c1 --- /dev/null +++ b/stacks/lwip_stack/vagrant/Vagrantfile @@ -0,0 +1,65 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +Vagrant.configure(2) do |config| + + # Pick the right distro and bootstrap, default is ubuntu1604 + distro = ( ENV['DMM_VAGRANT_DISTRO'] || "ubuntu") + if distro == 'centos7' + config.vm.box = "puppetlabs/centos-7.2-64-nocm" + else + config.vm.box = "puppetlabs/ubuntu-16.04-64-nocm" + end + config.vm.box_check_update = false + + # Create DMM client and server VM's + config.vm.define "dmm-stackx-server" do |server| + server.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"../../../scripts/install_prereq.sh") + server.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"build.sh"), :args => "/DMM vagrant" + server.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"start_nstackMain.sh"), :args => "/DMM vagrant" + end + config.vm.define "dmm-stackx-client" do |client| + client.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"../../../scripts/install_prereq.sh") + client.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"build.sh"), :args => "/DMM vagrant" + client.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"start_nstackMain.sh"), :args => "/DMM vagrant" + end + + + # vagrant-cachier caches apt/yum etc to speed subsequent + # vagrant up + # to enable, run + # vagrant plugin install vagrant-cachier + # + if Vagrant.has_plugin?("vagrant-cachier") + config.cache.scope = :box + end + + # Define some physical ports for your VMs to be used by DPDK + nics = (ENV['DMM_VAGRANT_NICS'] || "2").to_i(10) + for i in 1..nics + config.vm.network "private_network", type: "dhcp" + # config.vm.network "private_network", ip: "172.28.128.200" + # config.vm.network "private_network", ip: "172.28.128.201" + end + + # use http proxy if avaiable + if ENV['http_proxy'] && Vagrant.has_plugin?("vagrant-proxyconf") + config.proxy.http = ENV['http_proxy'] + config.proxy.https = ENV['https_proxy'] + config.proxy.no_proxy = "localhost,127.0.0.1" + end + + vmcpu=(ENV['DMM_VAGRANT_VMCPU'] || 4) + vmram=(ENV['DMM_VAGRANT_VMRAM'] || 5120) + + config.ssh.forward_agent = true + config.ssh.forward_x11 = true + + config.vm.provider "virtualbox" do |vb| + vb.customize ["modifyvm", :id, "--ioapic", "on"] + vb.memory = "#{vmram}" + vb.cpus = "#{vmcpu}" + + config.vm.synced_folder "../../../", "/DMM", type: "rsync" + end +end diff --git a/stacks/lwip_stack/vagrant/build.sh b/stacks/lwip_stack/vagrant/build.sh new file mode 100644 index 0000000..a934eef --- /dev/null +++ b/stacks/lwip_stack/vagrant/build.sh @@ -0,0 +1,59 @@ +######################################################################### +# Copyright (c) 2018 Huawei Technologies Co.,Ltd. +# 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. +######################################################################### +#!/bin/bash -x + +set -x + +TIMESTAMP=$(date +%Y-%m-%d_%H-%M-%S) +log_file="/tmp/build_log.txt-$TIMESTAMP" +exec 1> >(tee -a "$log_file") 2>&1 + +# Get Command Line arguements if present +if [ "$1" == "from-base-build" ]; then + WAS_DMM_BUILT="YES" +fi + +if [ "x$1" != "x" ] && [ "$1" != "from-base-build" ]; then + TEMP_DIR=$1 + DMM_BUILD_SCRIPT_DIR=${TEMP_DIR}/scripts + LWIP_BUILD_DIR=${TEMP_DIR}/stacks/lwip_stack/build/ +else + TEMP_DIR=`dirname $(readlink -f $0)`/.. + DMM_BUILD_SCRIPT_DIR=${TEMP_DIR}/../../scripts + LWIP_BUILD_DIR=${TEMP_DIR}/build/ +fi + +echo 0:$0 +echo 1:$1 +echo 2:$2 +echo TEMP_DIR: $TEMP_DIR +echo DMM_BUILD_SCRIPT_DIR: $DMM_BUILD_SCRIPT_DIR +echo LWIP_BUILD_DIR: $LWIP_BUILD_DIR + +if [ 'x$WAS_DMM_BUILT' != "xYES" ]; then + bash -x $DMM_BUILD_SCRIPT_DIR/build.sh +fi + +#===========build LWIP=========== +echo "LWIP build started....." +cd $LWIP_BUILD_DIR +cmake .. +make -j 8 +if [ $? -eq 0 ]; then + echo "LWIP build is SUCCESS" +else + echo "LWIP build has FAILED" + exit 1 +fi diff --git a/stacks/lwip_stack/vagrant/env.sh b/stacks/lwip_stack/vagrant/env.sh new file mode 100644 index 0000000..96ad346 --- /dev/null +++ b/stacks/lwip_stack/vagrant/env.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +#export DMM_VAGRANT_DISTRO="ubuntu1604" +export DMM_VAGRANT_DISTRO="centos7" +export DMM_VAGRANT_NICS=2 +export DMM_VAGRANT_VMCPU=4 +export DMM_VAGRANT_VMRAM=8192 diff --git a/stacks/lwip_stack/vagrant/start_nstackMain.sh b/stacks/lwip_stack/vagrant/start_nstackMain.sh new file mode 100644 index 0000000..d7016c7 --- /dev/null +++ b/stacks/lwip_stack/vagrant/start_nstackMain.sh @@ -0,0 +1,105 @@ +######################################################################### +# Copyright (c) 2018 Huawei Technologies Co.,Ltd. +# 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. +######################################################################### +#!/bin/bash -x + +set -x + +DPDK_DOWNLOAD_PATH=/tmp/dpdk +ifname=enp0s8 + +if [ "x$1" != "x" ] && [ "$1" != "from-base-build" ]; then + TEMP_DIR=$1 + DMM_BUILD_SCRIPT_DIR=${TEMP_DIR}/scripts + LWIP_BUILD_DIR=${TEMP_DIR}/stacks/lwip_stack/build/ +else + TEMP_DIR=`dirname $(readlink -f $0)`/.. + DMM_BUILD_SCRIPT_DIR=${TEMP_DIR}/../../scripts + LWIP_BUILD_DIR=${TEMP_DIR}/build/ +fi + +LIB_PATH=$LWIP_BUILD_DIR/../release/lib64/ + +echo 0:$0 +echo 1:$1 +echo 2:$2 +echo TEMP_DIR: $TEMP_DIR +echo DMM_BUILD_SCRIPT_DIR: $DMM_BUILD_SCRIPT_DIR +echo LWIP_BUILD_DIR: $LWIP_BUILD_DIR +echo LIB_PATH: $LIB_PATH + +#===========check hugepages================= +source $DMM_BUILD_SCRIPT_DIR/check_hugepage.sh + +OS_ID=$(grep '^ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g') +if [ "$OS_ID" == "centos" ]; then + ifaddress1=$(ifconfig $ifname | grep 'inet' | cut -d: -f2 | awk '{print $2}') + echo $ifaddress1 + ifaddresscut=$(ifconfig $ifname | grep 'inet' | head -n 1 | awk -F " " '{print $2}' | awk -F "." '{print $1"."$2"."$3}') + echo $ifaddresscut + ifmac=$(ifconfig $ifname | grep 'ether' | awk -F " " '{print $2}') + echo $ifmac +elif [ "$OS_ID" == "ubuntu" ]; then + ifaddress1=$(ifconfig $ifname | grep 'inet' | head -n 1 | cut -d: -f2 | awk '{print $1}') + echo $ifaddress1 + ifaddresscut=$(ifconfig $ifname | grep 'inet' | head -n 1 | cut -d: -f2 | awk '{print $1}' | awk -F "." '{print $1"."$2"."$3}') + echo $ifaddresscut + ifmac=$(ifconfig $ifname | grep 'HWaddr' | awk -F " " '{print $5}') + echo $ifmac +fi + +cd $LWIP_BUILD_DIR/../ +cd release/script +sed -i 's!DPDK_INSTALL_PATH=.*!DPDK_INSTALL_PATH='$DPDK_DOWNLOAD_PATH'/dpdk-18.02!1' nstack_var.sh + +cd ../ +chmod 775 * +cp ./configure/*.json bin/ +cd bin + +sed -i 's!192.168.1.175!'$ifaddress1'!1' ip_data.json + +sed -i 's!192.168.1.1!'$ifaddresscut'.1!1' network_data_tonStack.json + +if [ "$OS_ID" == "centos" ]; then + sed -i 's!ens4!'$ifname'!1' network_data_tonStack.json +elif [ "$OS_ID" == "ubuntu" ]; then + sed -i 's!ens4!'$ifname'!1' network_data_tonStack.json +fi +sed -i 's!ens4!'$ifname'!1' network_data_tonStack.json + +cd $DMM_BUILD_SCRIPT_DIR/../release/bin +cp -r . ../../stacks/lwip_stack/app_test +cd $DMM_BUILD_SCRIPT_DIR/../stacks/lwip_stack/app_test +cp -r ../configure/*.json . + +sed -i 's!192.168.1.1!'$ifaddresscut'.1!1' rd_config.json + +sudo mkdir -p /var/run/ip_module/ +sudo mkdir -p /var/log/nStack/ip_module/ + +export LD_LIBRARY_PATH=$LIB_PATH +export NSTACK_LOG_ON=DBG + +cd $LWIP_BUILD_DIR/../release +bash -x ./stop_nstack.sh +bash -x ./start_nstack.sh +check_result=$(pgrep nStackMain) +if [ -z "$check_result" ]; then + echo "nStackMain execute failed" + exit 1 +else + echo "nStackMain execute successful" + exit 0 +fi |