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
200 cat > /opt/set_nat.sh << EOF
205 if [[ ! $(ps -aux | grep [[:alnum:]]*/vpp/startup.conf | wc -l) = 2 ]]; then
206 #echo "vpp not running"
212 if [ flag = 0 ]; then
213 re=${line#*/[0-9]/[0-9]}
214 if [ "$line" != "$re" ]; then
222 if [[ $ip = *\.*\.*\.* ]]; then
223 #echo "ip address is $ip"
224 if [ ! -f /opt/config/ip.txt ]; then
225 echo "file /opt/config/ip.txt doesn't exists"
230 if [[ $tap_ip = hcip* ]]; then
231 tap_ip=${tap_ip#*" "}
232 echo "hc tap ip address is $tap_ip"
233 vppctl snat add static mapping local $tap_ip external $ip
236 done < /opt/config/ip.txt
238 if [[ ! $ip = */[0-9] ]]; then
244 done < <(vppctl show int addr)
248 # Download and install HC2VPP from source
250 git clone ${HC2VPP_SOURCE_REPO_URL} -b ${HC2VPP_SOURCE_REPO_BRANCH} hc2vpp
252 apt-get install -y maven
253 cat > ~/.m2/settings.xml << EOF
254 <?xml version="1.0" encoding="UTF-8"?>
255 <!-- vi: set et smarttab sw=2 tabstop=2: -->
256 <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
257 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
258 xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
262 <id>fd.io-release</id>
265 <id>fd.io-mirror</id>
266 <name>fd.io-mirror</name>
267 <url>https://nexus.fd.io/content/groups/public/</url>
269 <enabled>true</enabled>
270 <updatePolicy>never</updatePolicy>
273 <enabled>false</enabled>
279 <id>fd.io-mirror</id>
280 <name>fd.io-mirror</name>
281 <url>https://nexus.fd.io/content/repositories/public/</url>
283 <enabled>true</enabled>
284 <updatePolicy>never</updatePolicy>
287 <enabled>false</enabled>
290 </pluginRepositories>
294 <id>fd.io-snapshots</id>
297 <id>fd.io-snapshot</id>
298 <name>fd.io-snapshot</name>
299 <url>https://nexus.fd.io/content/repositories/fd.io.snapshot/</url>
301 <enabled>false</enabled>
304 <enabled>true</enabled>
310 <id>fd.io-snapshot</id>
311 <name>fd.io-snapshot</name>
312 <url>https://nexus.fd.io/content/repositories/fd.io.snapshot/</url>
314 <enabled>false</enabled>
317 <enabled>true</enabled>
320 </pluginRepositories>
323 <id>opendaylight-snapshots</id>
326 <id>opendaylight-snapshot</id>
327 <name>opendaylight-snapshot</name>
328 <url>https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/</url>
330 <enabled>false</enabled>
333 <enabled>true</enabled>
339 <id>opendaylight-shapshot</id>
340 <name>opendaylight-snapshot</name>
341 <url>https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/</url>
343 <enabled>false</enabled>
346 <enabled>true</enabled>
349 </pluginRepositories>
354 <activeProfile>fd.io-release</activeProfile>
355 <activeProfile>fd.io-snapshots</activeProfile>
356 <activeProfile>opendaylight-snapshots</activeProfile>
363 l_version=$(cat pom.xml | grep "<version>" | head -1)
364 l_version=$(echo "${l_version%<*}")
365 l_version=$(echo "${l_version#*>}")
366 mv vpp-integration/minimal-distribution/target/vpp-integration-distribution-${l_version}-hc/vpp-integration-distribution-${l_version} /opt/honeycomb
367 sed -i 's/127.0.0.1/0.0.0.0/g' /opt/honeycomb/config/honeycomb.json
369 # Create systemctl service for Honeycomb
370 cat > /etc/systemd/system/honeycomb.service << EOF
372 Description=Honeycomb Agent for the VPP control plane
373 Documentation=https://wiki.fd.io/view/Honeycomb
378 ExecStart=/opt/honeycomb/honeycomb
383 WantedBy=multi-user.target
385 systemctl enable /etc/systemd/system/honeycomb.service
387 # Download DHCP config files
389 wget $REPO_URL_BLOB/org.onap.demo/vnfs/vcpe/$INSTALL_SCRIPT_VERSION/v_brgemu_init.sh
390 wget $REPO_URL_BLOB/org.onap.demo/vnfs/vcpe/$INSTALL_SCRIPT_VERSION/v_brgemu.sh
391 chmod +x v_brgemu_init.sh
393 mv v_brgemu.sh /etc/init.d
394 update-rc.d v_brgemu.sh defaults
396 # Rename network interface in openstack Ubuntu 16.04 images. Then, reboot the VM to pick up changes
397 if [[ $CLOUD_ENV != "rackspace" ]]
399 sed -i "s/GRUB_CMDLINE_LINUX=.*/GRUB_CMDLINE_LINUX=\"net.ifnames=0 biosdevname=0\"/g" /etc/default/grub
400 grub-mkconfig -o /boot/grub/grub.cfg
401 sed -i "s/ens[0-9]*/eth0/g" /etc/network/interfaces.d/*.cfg
402 sed -i "s/ens[0-9]*/eth0/g" /etc/udev/rules.d/70-persistent-net.rules
403 echo 'network: {config: disabled}' >> /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg
404 echo "APT::Periodic::Unattended-Upgrade \"0\";" >> /etc/apt/apt.conf.d/10periodic