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 HC2VPP_PATCH_URL=$(cat /opt/config/hc2vpp_patch_url.txt)
13 CLOUD_ENV=$(cat /opt/config/cloud_env.txt)
15 # Convert Network CIDR to Netmask
17 # Number of args to shift, 255..255, first non-255 byte, zeroes
18 set -- $(( 5 - ($1 / 8) )) 255 255 255 255 $(( (255 << (8 - ($1 % 8))) & 255 )) 0 0 0
19 [ $1 -gt 1 ] && shift $1 || shift
20 echo ${1-0}.${2-0}.${3-0}.${4-0}
23 # OpenStack network configuration
24 if [[ $CLOUD_ENV == "openstack" ]]
26 echo 127.0.0.1 $(hostname) >> /etc/hosts
28 # Allow remote login as root
29 mv /root/.ssh/authorized_keys /root/.ssh/authorized_keys.bk
30 cp /home/ubuntu/.ssh/authorized_keys /root/.ssh
32 MTU=$(/sbin/ifconfig | grep MTU | sed 's/.*MTU://' | sed 's/ .*//' | sort -n | head -1)
34 IP=$(cat /opt/config/bng_mux_net_ipaddr.txt)
35 BITS=$(cat /opt/config/bng_mux_net_cidr.txt | cut -d"/" -f2)
36 NETMASK=$(cdr2mask $BITS)
37 echo "auto eth1" >> /etc/network/interfaces
38 echo "iface eth1 inet static" >> /etc/network/interfaces
39 echo " address $IP" >> /etc/network/interfaces
40 echo " netmask $NETMASK" >> /etc/network/interfaces
41 echo " mtu $MTU" >> /etc/network/interfaces
43 IP=$(cat /opt/config/oam_ipaddr.txt)
44 BITS=$(cat /opt/config/oam_cidr.txt | cut -d"/" -f2)
45 NETMASK=$(cdr2mask $BITS)
46 echo "auto eth2" >> /etc/network/interfaces
47 echo "iface eth2 inet static" >> /etc/network/interfaces
48 echo " address $IP" >> /etc/network/interfaces
49 echo " netmask $NETMASK" >> /etc/network/interfaces
50 echo " mtu $MTU" >> /etc/network/interfaces
52 IP=$(cat /opt/config/mux_gw_net_ipaddr.txt)
53 BITS=$(cat /opt/config/mux_gw_net_cidr.txt | cut -d"/" -f2)
54 NETMASK=$(cdr2mask $BITS)
55 echo "auto eth3" >> /etc/network/interfaces
56 echo "iface eth3 inet static" >> /etc/network/interfaces
57 echo " address $IP" >> /etc/network/interfaces
58 echo " netmask $NETMASK" >> /etc/network/interfaces
59 echo " mtu $MTU" >> /etc/network/interfaces
66 # Download required dependencies
67 echo "deb http://ppa.launchpad.net/openjdk-r/ppa/ubuntu $(lsb_release -c -s) main" >> /etc/apt/sources.list.d/java.list
68 echo "deb-src http://ppa.launchpad.net/openjdk-r/ppa/ubuntu $(lsb_release -c -s) main" >> /etc/apt/sources.list.d/java.list
70 apt-get install --allow-unauthenticated -y wget openjdk-8-jdk apt-transport-https ca-certificates g++ libcurl4-gnutls-dev
73 # Install the tools required for download codes
74 apt-get install -y expect git patch
76 #Download and build the VPP codes
78 git clone ${VPP_SOURCE_REPO_URL} -b ${VPP_SOURCE_REPO_BRANCH} vpp
79 wget -O Vpp-Add-VES-agent-for-vG-MUX.patch ${VPP_PATCH_URL}
82 patch -p1 < ../Vpp-Add-VES-agent-for-vG-MUX.patch
85 spawn make install-dep;
87 \"Do you want to continue?*\" {send \"Y\r\"; interact}
93 make V=0 PLATFORM=vpp TAG=vpp install-deb
95 # Install the evel-library first since we need the lib
97 apt-get install -y libcurl4-openssl-dev
98 git clone https://github.com/att/evel-library.git
99 cd evel-library/bldjobs
101 cp /opt/evel-library/libs/libevel.so /usr/lib
104 # Install the VPP package
105 cd /opt/vpp/build-root
109 # Auto-start configuration for the VPP
110 cat > /etc/vpp/startup.conf << EOF
116 cli-listen localhost:5002
117 startup-config /etc/vpp/setup.gate
129 ## In the VPP there is one main thread and optionally the user can create worker(s)
130 ## The main thread and worker thread(s) can be pinned to CPU core(s) manually or automatically
132 ## Manual pinning of thread(s) to CPU core(s)
134 ## Set logical CPU core where main thread runs
137 ## Set logical CPU core(s) where worker threads are running
138 # corelist-workers 2-3,18-19
140 ## Automatic pinning of thread(s) to CPU core(s)
142 ## Sets number of CPU core(s) to be skipped (1 ... N-1)
143 ## Skipped CPU core(s) are not used for pinning main thread and working thread(s).
144 ## The main thread is automatically pinned to the first available CPU core and worker(s)
145 ## are pinned to next free CPU core(s) after core assigned to main thread
148 ## Specify a number of workers to be created
149 ## Workers are pinned to N consecutive CPU cores while skipping "skip-cores" CPU core(s)
150 ## and main thread's CPU core
153 ## Set scheduling policy and priority of main and worker threads
155 ## Scheduling policy options are: other (SCHED_OTHER), batch (SCHED_BATCH)
156 ## idle (SCHED_IDLE), fifo (SCHED_FIFO), rr (SCHED_RR)
157 # scheduler-policy fifo
159 ## Scheduling priority is used only for "real-time policies (fifo and rr),
160 ## and has to be in the range of priorities supported for a particular policy
161 # scheduler-priority 50
165 ## Change default settings for all intefaces
167 ## Number of receive queues, enables RSS
171 ## Number of transmit queues, Default is equal
172 ## to number of worker threads or 1 if no workers treads
175 ## Number of descriptors in transmit and receive rings
176 ## increasing or reducing number can impact performance
177 ## Default is 1024 for both rx and tx
181 ## VLAN strip offload mode for interface
183 # vlan-strip-offload on
186 ## Whitelist specific interface by specifying PCI address
189 ## Whitelist specific interface by specifying PCI address and in
190 ## addition specify custom parameters for this interface
195 ## Change UIO driver used by VPP, Options are: igb_uio, vfio-pci
196 ## and uio_pci_generic (default)
197 # uio-driver vfio-pci
199 ## Disable mutli-segment buffers, improves performance but
200 ## disables Jumbo MTU support
203 ## Increase number of buffers allocated, needed only in scenarios with
204 ## large number of interfaces and worker threads. Value is per CPU socket.
208 ## Change hugepages allocation per-socket, needed only if there is need for
209 ## larger number of mbufs. Default is 256M on each detected CPU socket
210 # socket-mem 2048,2048
215 cat > /etc/vpp/setup.gate << EOF
216 set int state GigabitEthernet0/8/0 up
217 set int ip address GigabitEthernet0/8/0 10.1.0.20/24
219 set int state GigabitEthernet0/9/0 up
220 set int ip address GigabitEthernet0/9/0 10.5.0.20/24
222 create vxlan tunnel src 10.5.0.20 dst 10.5.0.21 vni 100
225 # Download and install HC2VPP from source
227 git clone ${HC2VPP_SOURCE_REPO_URL} -b ${HC2VPP_SOURCE_REPO_BRANCH} hc2vpp
228 wget -O Hc2vpp-Add-VES-agent-for-vG-MUX.patch ${HC2VPP_PATCH_URL}
230 apt-get install -y maven
231 cat > ~/.m2/settings.xml << EOF
232 <?xml version="1.0" encoding="UTF-8"?>
233 <!-- vi: set et smarttab sw=2 tabstop=2: -->
234 <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
235 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
236 xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
240 <id>fd.io-release</id>
243 <id>fd.io-mirror</id>
244 <name>fd.io-mirror</name>
245 <url>https://nexus.fd.io/content/groups/public/</url>
247 <enabled>true</enabled>
248 <updatePolicy>never</updatePolicy>
251 <enabled>false</enabled>
257 <id>fd.io-mirror</id>
258 <name>fd.io-mirror</name>
259 <url>https://nexus.fd.io/content/repositories/public/</url>
261 <enabled>true</enabled>
262 <updatePolicy>never</updatePolicy>
265 <enabled>false</enabled>
268 </pluginRepositories>
272 <id>fd.io-snapshots</id>
275 <id>fd.io-snapshot</id>
276 <name>fd.io-snapshot</name>
277 <url>https://nexus.fd.io/content/repositories/fd.io.snapshot/</url>
279 <enabled>false</enabled>
282 <enabled>true</enabled>
288 <id>fd.io-snapshot</id>
289 <name>fd.io-snapshot</name>
290 <url>https://nexus.fd.io/content/repositories/fd.io.snapshot/</url>
292 <enabled>false</enabled>
295 <enabled>true</enabled>
298 </pluginRepositories>
301 <id>opendaylight-snapshots</id>
304 <id>opendaylight-snapshot</id>
305 <name>opendaylight-snapshot</name>
306 <url>https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/</url>
308 <enabled>false</enabled>
311 <enabled>true</enabled>
317 <id>opendaylight-shapshot</id>
318 <name>opendaylight-snapshot</name>
319 <url>https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/</url>
321 <enabled>false</enabled>
324 <enabled>true</enabled>
327 </pluginRepositories>
332 <activeProfile>fd.io-release</activeProfile>
333 <activeProfile>fd.io-snapshots</activeProfile>
334 <activeProfile>opendaylight-snapshots</activeProfile>
340 patch -p1 < ../Hc2vpp-Add-VES-agent-for-vG-MUX.patch
342 l_version=$(cat pom.xml | grep "<version>" | head -1)
343 l_version=$(echo "${l_version%<*}")
344 l_version=$(echo "${l_version#*>}")
345 mv vpp-integration/minimal-distribution/target/vpp-integration-distribution-${l_version}-hc/vpp-integration-distribution-${l_version} /opt/honeycomb
346 sed -i 's/127.0.0.1/0.0.0.0/g' /opt/honeycomb/config/honeycomb.json
348 # Create systemctl service for Honeycomb
349 cat > /etc/systemd/system/honeycomb.service << EOF
351 Description=Honeycomb Agent for the VPP control plane
352 Documentation=https://wiki.fd.io/view/Honeycomb
357 ExecStart=/opt/honeycomb/honeycomb
362 WantedBy=multi-user.target
364 systemctl enable /etc/systemd/system/honeycomb.service
366 #Create a systemd service for auto-save
367 cat > /usr/bin/save_config << EOF
370 #########################################################################
372 # Copyright (c) 2017 Intel and/or its affiliates.
374 # Licensed under the Apache License, Version 2.0 (the "License");
375 # you may not use this file except in compliance with the License.
376 # You may obtain a copy of the License at:
378 # http://www.apache.org/licenses/LICENSE-2.0
380 # Unless required by applicable law or agreed to in writing, software
381 # distributed under the License is distributed on an "AS IS" BASIS,
382 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
383 # See the License for the specific language governing permissions and
384 # limitations under the License.
386 ##########################################################################
388 ############################### Variables ################################
389 VPP_SETUP_GATE=/etc/vpp/setup.gate
391 ############################### Functions ################################
393 # Write the commands to the startup scripts.
395 # We could set VPP configuration to the startup.conf.
396 # Write the configuration to the startup scripts so we could
397 # restore the system after rebooting.
399 write_startup_scripts()
404 if [[ ${is_add} == add ]] ;then
407 if [[ ${line} == ${cmd} ]] ;then
410 done < ${VPP_SETUP_GATE}
412 echo "${cmd}" >> ${VPP_SETUP_GATE}
416 if [[ ${line} == ${cmd} ]] ;then
417 sed -i "/${line}/d" ${VPP_SETUP_GATE}
420 done < ${VPP_SETUP_GATE}
424 # Saves the VES agent configuration to the startup script.
426 # Get the current VES agent configuration from the bash command:
427 # $vppctl show ves agent
428 # Server Addr Server Port Interval Enabled
429 # 127.0.0.1 8080 10 True
430 # Set the VES agent configuration with the bash command:
431 # $vppctl set ves agent server 127.0.0.1 port 8080 intval 10
439 local ves_config=`vppctl show ves agent | head -2 | tail -1`
440 if [ "${ves_config}" != "" ] ;then
441 server=`echo ${ves_config} | awk '{ print $1 }'`
442 port=`echo ${ves_config} | awk '{ print $2 }'`
443 intval=`echo ${ves_config} | awk '{ print $3 }'`
444 write_startup_scripts add "set ves agent server ${server} port ${port} intval ${intval}"
448 # Save the VxLAN Tunnel Configuration to the startup script.
450 # Get the current VxLAN tunnel configuration with bash command:
451 # $vppctl show vxlan tunnel
452 # [0] src 10.3.0.2 dst 10.1.0.20 vni 100 sw_if_index 1 encap_fib_index 0 fib_entry_index 7 decap_next l2
453 # [1] src 10.5.0.20 dst 10.5.0.21 vni 100 sw_if_index 2 encap_fib_index 0 fib_entry_index 8 decap_next l2
454 # Set the VxLAN Tunnel with the bash command:
455 # $vppctl create vxlan tunnel src 10.3.0.2 dst 10.1.0.20 vni 100
463 vppctl show vxlan tunnel | while read line
465 if [ "${line}" != "" ] ;then
466 src=`echo ${line} | awk '{ print $3 }'`
467 dst=`echo ${line} | awk '{ print $5 }'`
468 vni=`echo ${line} | awk '{ print $7 }'`
470 write_startup_scripts add "create vxlan tunnel src ${src} dst ${dst} vni ${vni}"
475 # Save the VxLAN tunnel L2 xconnect configuration to the startup script.
477 # Get the Current L2 Address configuration with bash command:
478 # $vppctl show int addr
480 # vxlan_tunnel0 (up):
481 # l2 xconnect vxlan_tunnel1
482 # vxlan_tunnel1 (up):
483 # l2 xconnect vxlan_tunnel0
484 # Save the VxLAN tunnel L2 xconnect configuration with bash command:
485 # $vppctl set interface l2 xconnect vxlan_tunnel0 vxlan_tunnel1
487 save_vxlan_xconnect()
492 vppctl show int addr | while read line
494 if [[ ${line} == vxlan_tunnel* ]] ;then
496 while [[ ${next} != l2* ]] || [[ ${next} == "" ]]
501 if [[ ${next} == l2* ]] ;then
502 ingress=`echo ${line} | awk '{ print $1 }'`
503 egress=`echo ${next} | awk '{ print $3 }'`
504 write_startup_scripts add "set interface l2 xconnect ${ingress} ${egress}"
510 ################################# MAIN ###################################
519 chmod a+x /usr/bin/save_config
520 cat > /etc/systemd/system/autosave.service << EOF
522 Description=Run Scripts at Start and Stop
529 ExecStop=/usr/bin/save_config
532 WantedBy=multi-user.target
534 systemctl enable /etc/systemd/system/autosave.service
536 # Download DHCP config files
538 wget $REPO_URL_BLOB/org.onap.demo/vnfs/vcpe/$INSTALL_SCRIPT_VERSION/v_gmux_init.sh
539 wget $REPO_URL_BLOB/org.onap.demo/vnfs/vcpe/$INSTALL_SCRIPT_VERSION/v_gmux.sh
540 chmod +x v_gmux_init.sh
542 mv v_gmux.sh /etc/init.d
543 update-rc.d v_gmux.sh defaults
545 # Rename network interface in openstack Ubuntu 16.04 images. Then, reboot the VM to pick up changes
546 if [[ $CLOUD_ENV != "rackspace" ]]
548 sed -i "s/GRUB_CMDLINE_LINUX=.*/GRUB_CMDLINE_LINUX=\"net.ifnames=0 biosdevname=0\"/g" /etc/default/grub
549 grub-mkconfig -o /boot/grub/grub.cfg
550 sed -i "s/ens[0-9]*/eth0/g" /etc/network/interfaces.d/*.cfg
551 sed -i "s/ens[0-9]*/eth0/g" /etc/udev/rules.d/70-persistent-net.rules
552 echo 'network: {config: disabled}' >> /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg
553 echo "APT::Periodic::Unattended-Upgrade \"0\";" >> /etc/apt/apt.conf.d/10periodic