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)
14 # Convert Network CIDR to Netmask
16 # Number of args to shift, 255..255, first non-255 byte, zeroes
17 set -- $(( 5 - ($1 / 8) )) 255 255 255 255 $(( (255 << (8 - ($1 % 8))) & 255 )) 0 0 0
18 [ $1 -gt 1 ] && shift $1 || shift
19 echo ${1-0}.${2-0}.${3-0}.${4-0}
22 # OpenStack network configuration
23 if [[ $CLOUD_ENV == "openstack" ]]
25 echo 127.0.0.1 $(hostname) >> /etc/hosts
27 # Allow remote login as root
28 mv /root/.ssh/authorized_keys /root/.ssh/authorized_keys.bk
29 cp /home/ubuntu/.ssh/authorized_keys /root/.ssh
31 MTU=$(/sbin/ifconfig | grep MTU | sed 's/.*MTU://' | sed 's/ .*//' | sort -n | head -1)
33 IP=$(cat /opt/config/brgemu_net_ipaddr.txt)
34 BITS=$(cat /opt/config/brgemu_net_cidr.txt | cut -d"/" -f2)
35 NETMASK=$(cdr2mask $BITS)
36 echo "auto eth2" >> /etc/network/interfaces
37 echo "iface eth2 inet static" >> /etc/network/interfaces
38 echo " address $IP" >> /etc/network/interfaces
39 echo " netmask $NETMASK" >> /etc/network/interfaces
40 echo " mtu $MTU" >> /etc/network/interfaces
45 # Download required dependencies
46 echo "deb http://ppa.launchpad.net/openjdk-r/ppa/ubuntu $(lsb_release -c -s) main" >> /etc/apt/sources.list.d/java.list
47 echo "deb-src http://ppa.launchpad.net/openjdk-r/ppa/ubuntu $(lsb_release -c -s) main" >> /etc/apt/sources.list.d/java.list
49 apt-get install --allow-unauthenticated -y wget openjdk-8-jdk apt-transport-https ca-certificates g++ libcurl4-gnutls-dev
52 # Install the tools required for download codes
53 apt-get install -y expect git patch
55 #Download and build the VPP codes
57 git clone ${VPP_SOURCE_REPO_URL} -b ${VPP_SOURCE_REPO_BRANCH} vpp
58 wget -O VPP-Add-Option82-Nat-Filter-For-vBRG.patch ${VPP_PATCH_URL}
61 patch -p1 < ../VPP-Add-Option82-Nat-Filter-For-vBRG.patch
64 spawn make install-dep;
66 \"Do you want to continue?*\" {send \"Y\r\"; interact}
72 make V=0 PLATFORM=vpp TAG=vpp install-deb
74 # Install the VPP package
78 # Auto-start configuration for the VPP
79 cat > /etc/vpp/startup.conf << EOF
85 cli-listen localhost:5002
86 startup-config /etc/vpp/setup.gate
98 ## In the VPP there is one main thread and optionally the user can create worker(s)
99 ## The main thread and worker thread(s) can be pinned to CPU core(s) manually or automatically
101 ## Manual pinning of thread(s) to CPU core(s)
103 ## Set logical CPU core where main thread runs
106 ## Set logical CPU core(s) where worker threads are running
107 # corelist-workers 2-3,18-19
109 ## Automatic pinning of thread(s) to CPU core(s)
111 ## Sets number of CPU core(s) to be skipped (1 ... N-1)
112 ## Skipped CPU core(s) are not used for pinning main thread and working thread(s).
113 ## The main thread is automatically pinned to the first available CPU core and worker(s)
114 ## are pinned to next free CPU core(s) after core assigned to main thread
117 ## Specify a number of workers to be created
118 ## Workers are pinned to N consecutive CPU cores while skipping "skip-cores" CPU core(s)
119 ## and main thread's CPU core
122 ## Set scheduling policy and priority of main and worker threads
124 ## Scheduling policy options are: other (SCHED_OTHER), batch (SCHED_BATCH)
125 ## idle (SCHED_IDLE), fifo (SCHED_FIFO), rr (SCHED_RR)
126 # scheduler-policy fifo
128 ## Scheduling priority is used only for "real-time policies (fifo and rr),
129 ## and has to be in the range of priorities supported for a particular policy
130 # scheduler-priority 50
134 ## Change default settings for all intefaces
136 ## Number of receive queues, enables RSS
140 ## Number of transmit queues, Default is equal
141 ## to number of worker threads or 1 if no workers treads
144 ## Number of descriptors in transmit and receive rings
145 ## increasing or reducing number can impact performance
146 ## Default is 1024 for both rx and tx
150 ## VLAN strip offload mode for interface
152 # vlan-strip-offload on
155 ## Whitelist specific interface by specifying PCI address
158 ## Whitelist specific interface by specifying PCI address and in
159 ## addition specify custom parameters for this interface
164 ## Change UIO driver used by VPP, Options are: igb_uio, vfio-pci
165 ## and uio_pci_generic (default)
166 # uio-driver vfio-pci
168 ## Disable mutli-segment buffers, improves performance but
169 ## disables Jumbo MTU support
172 ## Increase number of buffers allocated, needed only in scenarios with
173 ## large number of interfaces and worker threads. Value is per CPU socket.
177 ## Change hugepages allocation per-socket, needed only if there is need for
178 ## larger number of mbufs. Default is 256M on each detected CPU socket
179 # socket-mem 2048,2048
184 cat > /etc/vpp/setup.gate << EOF
185 set int state GigabitEthernet0/8/0 up
186 set dhcp client intfc GigabitEthernet0/8/0 hostname brg-emulator
189 set int state tap-0 up
191 set interface l2 bridge tap-0 10 0
192 set bridge-domain arp term 10
195 cat >> /opt/config/ip.txt << EOF
199 cat > /opt/bind_nic.sh << EOF
202 if [[ ! $(ps -aux | grep [[:alnum:]]*/vpp/startup.conf | wc -l) = 2 ]]; then
203 #echo "vpp not running"
208 nic_name=$(lshw -C network | grep "logical name:")
209 nic_name=${nic_name#*:}
210 ifconfig $nic_name down
214 re=${line#*/[0-9]/[0-9]}
215 if [ "$line" != "$re" ]; then
217 vppctl set dhcp client intfc $nic
218 vppctl set int state $nic up
221 done < <(vppctl show int addr)
222 while read -r sdnc_ip
224 if [[ $sdnc_ip = sdnc_ip* ]]; then
225 sdnc_ip=${sdnc_ip#*" "}
228 done < /opt/config/ip.txt
230 vppctl tap connect tap0
231 vppctl set int state tap-0 up
232 vppctl set int ip addr tap-0 20.0.0.40/24
233 ifconfig tap0 192.168.4.20/24
234 route add -host $sdnc_ip tap0
235 route add -host 20.0.0.40 tap0
236 vppctl ip route add 192.168.4.0/24 via tap-0
237 vppctl set interface snat in tap-0 out $nic
240 if [[ "$hw" = tap-0* ]]; then
243 hw_addr=${hw_addr#" "}
246 done < <(vppctl show hardware)
247 arp -s $sdnc_ip $hw_addr
249 chmod +x /opt/bind_nic.sh
252 cat > /opt/set_nat.sh << EOF
257 if [[ ! $(ps -aux | grep [[:alnum:]]*/vpp/startup.conf | wc -l) = 2 ]]; then
258 #echo "vpp not running"
265 if [ flag = 0 ]; then
266 re=${line#*/[0-9]/[0-9]}
267 if [ "$line" != "$re" ]; then
275 if [[ $ip = *\.*\.*\.* ]]; then
276 #echo "ip address is $ip"
277 if [ ! -f /opt/config/ip.txt ]; then
278 echo "file /opt/config/ip.txt doesn't exists"
283 if [[ $tap_ip = hcip* ]]; then
284 tap_ip=${tap_ip#*" "}
285 echo "hc tap ip address is $tap_ip"
286 vppctl snat add static mapping local $tap_ip external $ip
289 done < /opt/config/ip.txt
291 if [[ ! $ip = */[0-9] ]]; then
297 done < <(vppctl show int addr)
301 chmod +x /opt/set_nat.sh
303 # Download and install HC2VPP from source
305 git clone ${HC2VPP_SOURCE_REPO_URL} -b ${HC2VPP_SOURCE_REPO_BRANCH} hc2vpp
307 apt-get install -y maven
308 cat > ~/.m2/settings.xml << EOF
309 <?xml version="1.0" encoding="UTF-8"?>
310 <!-- vi: set et smarttab sw=2 tabstop=2: -->
311 <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
312 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
313 xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
317 <id>fd.io-release</id>
320 <id>fd.io-mirror</id>
321 <name>fd.io-mirror</name>
322 <url>https://nexus.fd.io/content/groups/public/</url>
324 <enabled>true</enabled>
325 <updatePolicy>never</updatePolicy>
328 <enabled>false</enabled>
334 <id>fd.io-mirror</id>
335 <name>fd.io-mirror</name>
336 <url>https://nexus.fd.io/content/repositories/public/</url>
338 <enabled>true</enabled>
339 <updatePolicy>never</updatePolicy>
342 <enabled>false</enabled>
345 </pluginRepositories>
349 <id>fd.io-snapshots</id>
352 <id>fd.io-snapshot</id>
353 <name>fd.io-snapshot</name>
354 <url>https://nexus.fd.io/content/repositories/fd.io.snapshot/</url>
356 <enabled>false</enabled>
359 <enabled>true</enabled>
365 <id>fd.io-snapshot</id>
366 <name>fd.io-snapshot</name>
367 <url>https://nexus.fd.io/content/repositories/fd.io.snapshot/</url>
369 <enabled>false</enabled>
372 <enabled>true</enabled>
375 </pluginRepositories>
378 <id>opendaylight-snapshots</id>
381 <id>opendaylight-snapshot</id>
382 <name>opendaylight-snapshot</name>
383 <url>https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/</url>
385 <enabled>false</enabled>
388 <enabled>true</enabled>
394 <id>opendaylight-shapshot</id>
395 <name>opendaylight-snapshot</name>
396 <url>https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/</url>
398 <enabled>false</enabled>
401 <enabled>true</enabled>
404 </pluginRepositories>
409 <activeProfile>fd.io-release</activeProfile>
410 <activeProfile>fd.io-snapshots</activeProfile>
411 <activeProfile>opendaylight-snapshots</activeProfile>
418 l_version=$(cat pom.xml | grep "<version>" | head -1)
419 l_version=$(echo "${l_version%<*}")
420 l_version=$(echo "${l_version#*>}")
421 mv vpp-integration/minimal-distribution/target/vpp-integration-distribution-${l_version}-hc/vpp-integration-distribution-${l_version} /opt/honeycomb
422 sed -i 's/127.0.0.1/0.0.0.0/g' /opt/honeycomb/config/honeycomb.json
424 # Create systemctl service for Honeycomb
425 cat > /etc/systemd/system/honeycomb.service << EOF
427 Description=Honeycomb Agent for the VPP control plane
428 Documentation=https://wiki.fd.io/view/Honeycomb
433 ExecStart=/opt/honeycomb/honeycomb
438 WantedBy=multi-user.target
440 systemctl enable /etc/systemd/system/honeycomb.service
442 # Download DHCP config files
444 wget $REPO_URL_BLOB/org.onap.demo/vnfs/vcpe/$INSTALL_SCRIPT_VERSION/v_brgemu_init.sh
445 wget $REPO_URL_BLOB/org.onap.demo/vnfs/vcpe/$INSTALL_SCRIPT_VERSION/v_brgemu.sh
446 chmod +x v_brgemu_init.sh
448 mv v_brgemu.sh /etc/init.d
449 update-rc.d v_brgemu.sh defaults
451 # Rename network interface in openstack Ubuntu 16.04 images. Then, reboot the VM to pick up changes
452 if [[ $CLOUD_ENV != "rackspace" ]]
454 sed -i "s/GRUB_CMDLINE_LINUX=.*/GRUB_CMDLINE_LINUX=\"net.ifnames=0 biosdevname=0\"/g" /etc/default/grub
455 grub-mkconfig -o /boot/grub/grub.cfg
456 sed -i "s/ens[0-9]*/eth0/g" /etc/network/interfaces.d/*.cfg
457 sed -i "s/ens[0-9]*/eth0/g" /etc/udev/rules.d/70-persistent-net.rules
458 echo 'network: {config: disabled}' >> /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg
459 echo "APT::Periodic::Unattended-Upgrade \"0\";" >> /etc/apt/apt.conf.d/10periodic