3 REPO_URL_BLOB=$(cat /opt/config/repo_url_blob.txt)
4 REPO_URL_ARTIFACTS=$(cat /opt/config/repo_url_artifacts.txt)
5 DEMO_ARTIFACTS_VERSION=$(cat /opt/config/demo_artifacts_version.txt)
6 INSTALL_SCRIPT_VERSION=$(cat /opt/config/install_script_version.txt)
7 VPP_SOURCE_REPO_URL=$(cat /opt/config/vpp_source_repo_url.txt)
8 VPP_SOURCE_REPO_BRANCH=$(cat /opt/config/vpp_source_repo_branch.txt)
9 VPP_PATCH_URL=$(cat /opt/config/vpp_patch_url.txt)
10 HC2VPP_SOURCE_REPO_URL=$(cat /opt/config/hc2vpp_source_repo_url.txt)
11 HC2VPP_SOURCE_REPO_BRANCH=$(cat /opt/config/hc2vpp_source_repo_branch.txt)
12 CLOUD_ENV=$(cat /opt/config/cloud_env.txt)
15 # 'build' - just build the code
16 # 'done' - code is build, install and setup
17 # 'auto' - bulid, install and setup
20 if [[ -f /opt/config/compile_state.txt ]]
22 BUILD_STATE=$(cat /opt/config/compile_state.txt)
25 # Convert Network CIDR to Netmask
27 # Number of args to shift, 255..255, first non-255 byte, zeroes
28 set -- $(( 5 - ($1 / 8) )) 255 255 255 255 $(( (255 << (8 - ($1 % 8))) & 255 )) 0 0 0
29 [ $1 -gt 1 ] && shift $1 || shift
30 echo ${1-0}.${2-0}.${3-0}.${4-0}
33 # OpenStack network configuration
34 if [[ $BUILD_STATE != "build" ]]
36 if [[ $CLOUD_ENV == "openstack" ]]
38 echo 127.0.0.1 $(hostname) >> /etc/hosts
40 # Allow remote login as root
41 mv /root/.ssh/authorized_keys /root/.ssh/authorized_keys.bk
42 cp /home/ubuntu/.ssh/authorized_keys /root/.ssh
44 fi # endif BUILD_STATE != "build"
46 if [[ $BUILD_STATE != "done" ]]
48 # Download required dependencies
49 echo "deb http://ppa.launchpad.net/openjdk-r/ppa/ubuntu $(lsb_release -c -s) main" >> /etc/apt/sources.list.d/java.list
50 echo "deb-src http://ppa.launchpad.net/openjdk-r/ppa/ubuntu $(lsb_release -c -s) main" >> /etc/apt/sources.list.d/java.list
52 apt-get install --allow-unauthenticated -y wget openjdk-8-jdk apt-transport-https ca-certificates g++ libcurl4-gnutls-dev
55 # Install the tools required for download codes
56 apt-get install -y expect git patch make linux-image-extra-`uname -r`
57 #Download and build the VPP codes
59 git clone ${VPP_SOURCE_REPO_URL} -b ${VPP_SOURCE_REPO_BRANCH} vpp
60 wget -O VPP-Add-Option82-Nat-Filter-For-vBRG.patch ${VPP_PATCH_URL}
63 patch -p1 < ../VPP-Add-Option82-Nat-Filter-For-vBRG.patch
66 spawn make install-dep;
68 \"Do you want to continue?*\" {send \"Y\r\"; interact}
74 make V=0 PLATFORM=vpp TAG=vpp install-deb
76 # Install the VPP package
79 fi # endif BUILD_STATE != "done"
81 if [[ $BUILD_STATE != "build" ]]
83 # Auto-start configuration for the VPP
84 cat > /etc/vpp/startup.conf << EOF
90 cli-listen localhost:5002
91 startup-config /etc/vpp/setup.gate
103 ## In the VPP there is one main thread and optionally the user can create worker(s)
104 ## The main thread and worker thread(s) can be pinned to CPU core(s) manually or automatically
106 ## Manual pinning of thread(s) to CPU core(s)
108 ## Set logical CPU core where main thread runs
111 ## Set logical CPU core(s) where worker threads are running
112 # corelist-workers 2-3,18-19
114 ## Automatic pinning of thread(s) to CPU core(s)
116 ## Sets number of CPU core(s) to be skipped (1 ... N-1)
117 ## Skipped CPU core(s) are not used for pinning main thread and working thread(s).
118 ## The main thread is automatically pinned to the first available CPU core and worker(s)
119 ## are pinned to next free CPU core(s) after core assigned to main thread
122 ## Specify a number of workers to be created
123 ## Workers are pinned to N consecutive CPU cores while skipping "skip-cores" CPU core(s)
124 ## and main thread's CPU core
127 ## Set scheduling policy and priority of main and worker threads
129 ## Scheduling policy options are: other (SCHED_OTHER), batch (SCHED_BATCH)
130 ## idle (SCHED_IDLE), fifo (SCHED_FIFO), rr (SCHED_RR)
131 # scheduler-policy fifo
133 ## Scheduling priority is used only for "real-time policies (fifo and rr),
134 ## and has to be in the range of priorities supported for a particular policy
135 # scheduler-priority 50
139 ## Change default settings for all intefaces
141 ## Number of receive queues, enables RSS
145 ## Number of transmit queues, Default is equal
146 ## to number of worker threads or 1 if no workers treads
149 ## Number of descriptors in transmit and receive rings
150 ## increasing or reducing number can impact performance
151 ## Default is 1024 for both rx and tx
155 ## VLAN strip offload mode for interface
157 # vlan-strip-offload on
160 ## Whitelist specific interface by specifying PCI address
162 ## Whitelist specific interface by specifying PCI address and in
163 ## addition specify custom parameters for this interface
168 ## Change UIO driver used by VPP, Options are: igb_uio, vfio-pci
169 ## and uio_pci_generic (default)
170 # uio-driver vfio-pci
172 ## Disable mutli-segment buffers, improves performance but
173 ## disables Jumbo MTU support
176 ## Increase number of buffers allocated, needed only in scenarios with
177 ## large number of interfaces and worker threads. Value is per CPU socket.
181 ## Change hugepages allocation per-socket, needed only if there is need for
182 ## larger number of mbufs. Default is 256M on each detected CPU socket
183 # socket-mem 2048,2048
188 #Get list of network device PCI bus addresses
190 while read -r line ; do
191 if [ "$line" != "${line#*network device}" ]; then
192 echo -n "${line%% *} "
197 NICS=$(get_nic_pci_list)
198 NICS=`echo ${NICS} | sed 's/[0]\+\([0-9]\)/\1/g' | sed 's/[.:]/\//g'`
201 BRG_BNG_NIC=GigabitEthernet`echo ${NICS} | cut -d " " -f 2` # second interface in list
202 echo $BRG_BNG_NIC > /opt/config/brg_nic.txt
205 cat > /etc/vpp/setup.gate << EOF
206 set int state ${BRG_BNG_NIC} up
207 set dhcp client intfc ${BRG_BNG_NIC} hostname brg-emulator
210 set int state tap-0 up
212 set interface l2 bridge tap-0 10 0
213 set bridge-domain arp term 10
216 echo "sdnc_ip: $(cat /opt/config/sdnc_ip.txt)" > /opt/config/ip.txt
217 echo "hcip: 192.168.4.20" >> /opt/config/ip.txt
220 cat > /opt/bind_nic.sh << 'EOF'
224 if [[ ! $(ps -aux | grep [[:alnum:]]*/vpp/startup.conf | wc -l) = 2 ]];
226 echo "vpp not running"
233 BRG_BNG_NIC=$(cat /opt/config/brg_nic.txt)
234 sdnc_ip=$(cat /opt/config/sdnc_ip.txt)
236 vppctl tap connect tap0
238 vppctl set int state tap-1 up
239 vppctl set int ip addr tap-1 20.0.0.40/24
240 ifconfig tap0 192.168.4.20/24
241 route add -host $sdnc_ip tap0
242 route add -host 20.0.0.40 tap0
243 vppctl ip route add 192.168.4.0/24 via tap-1
244 vppctl set interface snat in tap-1 out ${BRG_BNG_NIC}
245 vppctl snat add interface address ${BRG_BNG_NIC}
248 output=$(vppctl show dhcp client)
249 vbng_ip=${output##*gw }
251 vppctl ip route add $vbng_ip/32 via $vbng_ip ${BRG_BNG_NIC}
252 vppctl ip route add $sdnc_ip/32 via $vbng_ip ${BRG_BNG_NIC}
254 #Get HW addr of tap-1
257 if [[ "$hw" = tap-1* ]];
263 done < <(vppctl show hardware)
264 arp -s $sdnc_ip $hw_addr
265 arp -s 20.0.0.40 $hw_addr
271 tap0_addr=${var%inet*}
273 vppctl set ip arp tap-1 192.168.4.20 $tap0_addr
276 chmod +x /opt/bind_nic.sh
279 cat > /opt/set_nat.sh << 'EOF'
284 if [[ ! $(ps -aux | grep [[:alnum:]]*/vpp/startup.conf | wc -l) = 2 ]];
286 #echo "vpp not running"
295 re=${line#*/[0-9]/[0-9]}
296 if [ "$line" != "$re" ];
305 if [[ $ip = *\.*\.*\.* ]];
307 #echo "ip address is $ip"
308 if [ ! -f /opt/config/ip.txt ];
310 echo "file /opt/config/ip.txt doesn't exists"
315 if [[ $tap_ip = hcip* ]];
317 tap_ip=${tap_ip#*" "}
318 echo "hc tap ip address is $tap_ip"
319 vppctl snat add static mapping tcp local $tap_ip 8183 external $ip 8183
322 done < /opt/config/ip.txt
324 if [[ ! $ip = */[0-9] ]];
331 done < <(vppctl show int addr)
335 chmod +x /opt/set_nat.sh
336 fi # endif BUILD_STATE != "build"
338 if [[ $BUILD_STATE != "done" ]]
341 # Download and install HC2VPP from source
343 git clone ${HC2VPP_SOURCE_REPO_URL} -b ${HC2VPP_SOURCE_REPO_BRANCH} hc2vpp
345 apt-get -f -y install
346 apt-get install -y maven
348 cat > ~/.m2/settings.xml << EOF
349 <?xml version="1.0" encoding="UTF-8"?>
350 <!-- vi: set et smarttab sw=2 tabstop=2: -->
351 <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
352 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
353 xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
357 <id>fd.io-release</id>
360 <id>fd.io-mirror</id>
361 <name>fd.io-mirror</name>
362 <url>https://nexus.fd.io/content/groups/public/</url>
364 <enabled>true</enabled>
365 <updatePolicy>never</updatePolicy>
368 <enabled>false</enabled>
374 <id>fd.io-mirror</id>
375 <name>fd.io-mirror</name>
376 <url>https://nexus.fd.io/content/repositories/public/</url>
378 <enabled>true</enabled>
379 <updatePolicy>never</updatePolicy>
382 <enabled>false</enabled>
385 </pluginRepositories>
389 <id>fd.io-snapshots</id>
392 <id>fd.io-snapshot</id>
393 <name>fd.io-snapshot</name>
394 <url>https://nexus.fd.io/content/repositories/fd.io.snapshot/</url>
396 <enabled>false</enabled>
399 <enabled>true</enabled>
405 <id>fd.io-snapshot</id>
406 <name>fd.io-snapshot</name>
407 <url>https://nexus.fd.io/content/repositories/fd.io.snapshot/</url>
409 <enabled>false</enabled>
412 <enabled>true</enabled>
415 </pluginRepositories>
418 <id>opendaylight-snapshots</id>
421 <id>opendaylight-snapshot</id>
422 <name>opendaylight-snapshot</name>
423 <url>https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/</url>
425 <enabled>false</enabled>
428 <enabled>true</enabled>
434 <id>opendaylight-shapshot</id>
435 <name>opendaylight-snapshot</name>
436 <url>https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/</url>
438 <enabled>false</enabled>
441 <enabled>true</enabled>
444 </pluginRepositories>
449 <activeProfile>fd.io-release</activeProfile>
450 <activeProfile>fd.io-snapshots</activeProfile>
451 <activeProfile>opendaylight-snapshots</activeProfile>
458 l_version=$(cat pom.xml | grep "<version>" | head -1)
459 l_version=$(echo "${l_version%<*}")
460 l_version=$(echo "${l_version#*>}")
461 mv vpp-integration/minimal-distribution/target/vpp-integration-distribution-${l_version}-hc/vpp-integration-distribution-${l_version} /opt/honeycomb
462 sed -i 's/127.0.0.1/0.0.0.0/g' /opt/honeycomb/config/honeycomb.json
464 # Disable automatic upgrades
465 if [[ $CLOUD_ENV != "rackspace" ]]
467 echo "APT::Periodic::Unattended-Upgrade \"0\";" >> /etc/apt/apt.conf.d/10periodic
468 sed -i 's/\(APT::Periodic::Unattended-Upgrade\) "1"/\1 "0"/' /etc/apt/apt.conf.d/20auto-upgrades
470 fi # endif BUILD_STATE != "done"
472 if [[ $BUILD_STATE != "build" ]]
474 # Create systemctl service for Honeycomb
475 cat > /etc/systemd/system/honeycomb.service << EOF
477 Description=Honeycomb Agent for the VPP control plane
478 Documentation=https://wiki.fd.io/view/Honeycomb
483 ExecStart=/opt/honeycomb/honeycomb
488 WantedBy=multi-user.target
490 systemctl enable /etc/systemd/system/honeycomb.service
492 # Download DHCP config files
494 wget $REPO_URL_BLOB/org.onap.demo/vnfs/vcpe/$INSTALL_SCRIPT_VERSION/v_brgemu_init.sh
495 wget $REPO_URL_BLOB/org.onap.demo/vnfs/vcpe/$INSTALL_SCRIPT_VERSION/v_brgemu.sh
496 sed -i '/# Provides:/c\# Provides: vbrg ' /opt/v_brgemu.sh
497 chmod +x v_brgemu_init.sh
499 mv v_brgemu.sh /etc/init.d
500 update-rc.d v_brgemu.sh defaults
502 # Rename network interface in openstack Ubuntu 16.04 images. Then, reboot the VM to pick up changes
503 if [[ $CLOUD_ENV != "rackspace" ]]
505 sed -i "s/GRUB_CMDLINE_LINUX=.*/GRUB_CMDLINE_LINUX=\"net.ifnames=0 biosdevname=0\"/g" /etc/default/grub
506 grub-mkconfig -o /boot/grub/grub.cfg
507 sed -i "s/ens[0-9]*/eth0/g" /etc/network/interfaces.d/*.cfg
508 sed -i "s/ens[0-9]*/eth0/g" /etc/udev/rules.d/70-persistent-net.rules
509 echo 'network: {config: disabled}' >> /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg
514 fi # endif BUILD_STATE != "build"