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 make
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
84 spawn make install-dep;
86 \"Do you want to continue?*\" {send \"Y\r\"; interact}
90 # Install the evel-library first since we need the lib
92 apt-get install -y libcurl4-openssl-dev
93 git clone http://gerrit.onap.org/r/demo
94 cd demo/vnfs/VES5.0/evel/evel-library/bldjobs
96 cp ../libs/x86_64/libevel.so /usr/lib
99 cd /opt/vpp/build-root
101 make V=0 PLATFORM=vpp TAG=vpp install-deb
103 # Install the VPP package
104 apt install -y python-ply-lex-3.5 python-ply-yacc-3.5 python-pycparser python-cffi
108 # Auto-start configuration for the VPP
109 cat > /etc/vpp/startup.conf << EOF
115 cli-listen localhost:5002
116 startup-config /etc/vpp/setup.gate
128 ## In the VPP there is one main thread and optionally the user can create worker(s)
129 ## The main thread and worker thread(s) can be pinned to CPU core(s) manually or automatically
131 ## Manual pinning of thread(s) to CPU core(s)
133 ## Set logical CPU core where main thread runs
136 ## Set logical CPU core(s) where worker threads are running
137 # corelist-workers 2-3,18-19
139 ## Automatic pinning of thread(s) to CPU core(s)
141 ## Sets number of CPU core(s) to be skipped (1 ... N-1)
142 ## Skipped CPU core(s) are not used for pinning main thread and working thread(s).
143 ## The main thread is automatically pinned to the first available CPU core and worker(s)
144 ## are pinned to next free CPU core(s) after core assigned to main thread
147 ## Specify a number of workers to be created
148 ## Workers are pinned to N consecutive CPU cores while skipping "skip-cores" CPU core(s)
149 ## and main thread's CPU core
152 ## Set scheduling policy and priority of main and worker threads
154 ## Scheduling policy options are: other (SCHED_OTHER), batch (SCHED_BATCH)
155 ## idle (SCHED_IDLE), fifo (SCHED_FIFO), rr (SCHED_RR)
156 # scheduler-policy fifo
158 ## Scheduling priority is used only for "real-time policies (fifo and rr),
159 ## and has to be in the range of priorities supported for a particular policy
160 # scheduler-priority 50
164 ## Change default settings for all intefaces
166 ## Number of receive queues, enables RSS
170 ## Number of transmit queues, Default is equal
171 ## to number of worker threads or 1 if no workers treads
174 ## Number of descriptors in transmit and receive rings
175 ## increasing or reducing number can impact performance
176 ## Default is 1024 for both rx and tx
180 ## VLAN strip offload mode for interface
182 # vlan-strip-offload on
185 ## Whitelist specific interface by specifying PCI address
188 ## Whitelist specific interface by specifying PCI address and in
189 ## addition specify custom parameters for this interface
194 ## Change UIO driver used by VPP, Options are: igb_uio, vfio-pci
195 ## and uio_pci_generic (default)
196 # uio-driver vfio-pci
198 ## Disable mutli-segment buffers, improves performance but
199 ## disables Jumbo MTU support
202 ## Increase number of buffers allocated, needed only in scenarios with
203 ## large number of interfaces and worker threads. Value is per CPU socket.
207 ## Change hugepages allocation per-socket, needed only if there is need for
208 ## larger number of mbufs. Default is 256M on each detected CPU socket
209 # socket-mem 2048,2048
214 cat > /etc/vpp/setup.gate << EOF
215 set int state GigabitEthernet0/8/0 up
216 set int ip address GigabitEthernet0/8/0 10.1.0.20/24
218 set int state GigabitEthernet0/9/0 up
219 set int ip address GigabitEthernet0/9/0 10.5.0.20/24
221 create vxlan tunnel src 10.5.0.20 dst 10.5.0.21 vni 100
224 # Download and install HC2VPP from source
226 git clone ${HC2VPP_SOURCE_REPO_URL} -b ${HC2VPP_SOURCE_REPO_BRANCH} hc2vpp
227 wget -O Hc2vpp-Add-VES-agent-for-vG-MUX.patch ${HC2VPP_PATCH_URL}
229 apt-get install -y maven
230 cat > ~/.m2/settings.xml << EOF
231 <?xml version="1.0" encoding="UTF-8"?>
232 <!-- vi: set et smarttab sw=2 tabstop=2: -->
233 <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
234 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
235 xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
239 <id>fd.io-release</id>
242 <id>fd.io-mirror</id>
243 <name>fd.io-mirror</name>
244 <url>https://nexus.fd.io/content/groups/public/</url>
246 <enabled>true</enabled>
247 <updatePolicy>never</updatePolicy>
250 <enabled>false</enabled>
256 <id>fd.io-mirror</id>
257 <name>fd.io-mirror</name>
258 <url>https://nexus.fd.io/content/repositories/public/</url>
260 <enabled>true</enabled>
261 <updatePolicy>never</updatePolicy>
264 <enabled>false</enabled>
267 </pluginRepositories>
271 <id>fd.io-snapshots</id>
274 <id>fd.io-snapshot</id>
275 <name>fd.io-snapshot</name>
276 <url>https://nexus.fd.io/content/repositories/fd.io.snapshot/</url>
278 <enabled>false</enabled>
281 <enabled>true</enabled>
287 <id>fd.io-snapshot</id>
288 <name>fd.io-snapshot</name>
289 <url>https://nexus.fd.io/content/repositories/fd.io.snapshot/</url>
291 <enabled>false</enabled>
294 <enabled>true</enabled>
297 </pluginRepositories>
300 <id>opendaylight-snapshots</id>
303 <id>opendaylight-snapshot</id>
304 <name>opendaylight-snapshot</name>
305 <url>https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/</url>
307 <enabled>false</enabled>
310 <enabled>true</enabled>
316 <id>opendaylight-shapshot</id>
317 <name>opendaylight-snapshot</name>
318 <url>https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/</url>
320 <enabled>false</enabled>
323 <enabled>true</enabled>
326 </pluginRepositories>
331 <activeProfile>fd.io-release</activeProfile>
332 <activeProfile>fd.io-snapshots</activeProfile>
333 <activeProfile>opendaylight-snapshots</activeProfile>
339 patch -p1 < ../Hc2vpp-Add-VES-agent-for-vG-MUX.patch
341 l_version=$(cat pom.xml | grep "<version>" | head -1)
342 l_version=$(echo "${l_version%<*}")
343 l_version=$(echo "${l_version#*>}")
344 mv vpp-integration/minimal-distribution/target/vpp-integration-distribution-${l_version}-hc/vpp-integration-distribution-${l_version} /opt/honeycomb
345 sed -i 's/127.0.0.1/0.0.0.0/g' /opt/honeycomb/config/honeycomb.json
347 # Create systemctl service for Honeycomb
348 cat > /etc/systemd/system/honeycomb.service << EOF
350 Description=Honeycomb Agent for the VPP control plane
351 Documentation=https://wiki.fd.io/view/Honeycomb
356 ExecStart=/opt/honeycomb/honeycomb
361 WantedBy=multi-user.target
363 systemctl enable /etc/systemd/system/honeycomb.service
365 #Create a systemd service for auto-save
366 cat > /usr/bin/save_config << EOF
369 #########################################################################
371 # Copyright (c) 2017 Intel and/or its affiliates.
373 # Licensed under the Apache License, Version 2.0 (the "License");
374 # you may not use this file except in compliance with the License.
375 # You may obtain a copy of the License at:
377 # http://www.apache.org/licenses/LICENSE-2.0
379 # Unless required by applicable law or agreed to in writing, software
380 # distributed under the License is distributed on an "AS IS" BASIS,
381 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
382 # See the License for the specific language governing permissions and
383 # limitations under the License.
385 ##########################################################################
387 ############################### Variables ################################
388 VPP_SETUP_GATE=/etc/vpp/setup.gate
390 ############################### Functions ################################
392 # Write the commands to the startup scripts.
394 # We could set VPP configuration to the startup.conf.
395 # Write the configuration to the startup scripts so we could
396 # restore the system after rebooting.
398 write_startup_scripts()
403 if [[ ${is_add} == add ]] ;then
406 if [[ ${line} == ${cmd} ]] ;then
409 done < ${VPP_SETUP_GATE}
411 echo "${cmd}" >> ${VPP_SETUP_GATE}
415 if [[ ${line} == ${cmd} ]] ;then
416 sed -i "/${line}/d" ${VPP_SETUP_GATE}
419 done < ${VPP_SETUP_GATE}
423 # Saves the VES agent configuration to the startup script.
425 # Get the current VES agent configuration from the bash command:
426 # $vppctl show ves agent
427 # Server Addr Server Port Interval Enabled
428 # 127.0.0.1 8080 10 True
429 # Set the VES agent configuration with the bash command:
430 # $vppctl set ves agent server 127.0.0.1 port 8080 intval 10
438 local ves_config=`vppctl show ves agent | head -2 | tail -1`
439 if [ "${ves_config}" != "" ] ;then
440 server=`echo ${ves_config} | awk '{ print $1 }'`
441 port=`echo ${ves_config} | awk '{ print $2 }'`
442 intval=`echo ${ves_config} | awk '{ print $3 }'`
443 write_startup_scripts add "set ves agent server ${server} port ${port} intval ${intval}"
447 # Save the VxLAN Tunnel Configuration to the startup script.
449 # Get the current VxLAN tunnel configuration with bash command:
450 # $vppctl show vxlan tunnel
451 # [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
452 # [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
453 # Set the VxLAN Tunnel with the bash command:
454 # $vppctl create vxlan tunnel src 10.3.0.2 dst 10.1.0.20 vni 100
462 vppctl show vxlan tunnel | while read line
464 if [ "${line}" != "" ] ;then
465 src=`echo ${line} | awk '{ print $3 }'`
466 dst=`echo ${line} | awk '{ print $5 }'`
467 vni=`echo ${line} | awk '{ print $7 }'`
469 write_startup_scripts add "create vxlan tunnel src ${src} dst ${dst} vni ${vni}"
474 # Save the VxLAN tunnel L2 xconnect configuration to the startup script.
476 # Get the Current L2 Address configuration with bash command:
477 # $vppctl show int addr
479 # vxlan_tunnel0 (up):
480 # l2 xconnect vxlan_tunnel1
481 # vxlan_tunnel1 (up):
482 # l2 xconnect vxlan_tunnel0
483 # Save the VxLAN tunnel L2 xconnect configuration with bash command:
484 # $vppctl set interface l2 xconnect vxlan_tunnel0 vxlan_tunnel1
486 save_vxlan_xconnect()
491 vppctl show int addr | while read line
493 if [[ ${line} == vxlan_tunnel* ]] ;then
495 while [[ ${next} != l2* ]] || [[ ${next} == "" ]]
500 if [[ ${next} == l2* ]] ;then
501 ingress=`echo ${line} | awk '{ print $1 }'`
502 egress=`echo ${next} | awk '{ print $3 }'`
503 write_startup_scripts add "set interface l2 xconnect ${ingress} ${egress}"
509 ################################# MAIN ###################################
518 chmod a+x /usr/bin/save_config
519 cat > /etc/systemd/system/autosave.service << EOF
521 Description=Run Scripts at Start and Stop
528 ExecStop=/usr/bin/save_config
531 WantedBy=multi-user.target
533 systemctl enable /etc/systemd/system/autosave.service
535 # Download DHCP config files
537 wget $REPO_URL_BLOB/org.onap.demo/vnfs/vcpe/$INSTALL_SCRIPT_VERSION/v_gmux_init.sh
538 wget $REPO_URL_BLOB/org.onap.demo/vnfs/vcpe/$INSTALL_SCRIPT_VERSION/v_gmux.sh
539 chmod +x v_gmux_init.sh
541 mv v_gmux.sh /etc/init.d
542 update-rc.d v_gmux.sh defaults
544 # Rename network interface in openstack Ubuntu 16.04 images. Then, reboot the VM to pick up changes
545 if [[ $CLOUD_ENV != "rackspace" ]]
547 sed -i "s/GRUB_CMDLINE_LINUX=.*/GRUB_CMDLINE_LINUX=\"net.ifnames=0 biosdevname=0\"/g" /etc/default/grub
548 grub-mkconfig -o /boot/grub/grub.cfg
549 sed -i "s/ens[0-9]*/eth0/g" /etc/network/interfaces.d/*.cfg
550 sed -i "s/ens[0-9]*/eth0/g" /etc/udev/rules.d/70-persistent-net.rules
551 echo 'network: {config: disabled}' >> /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg
552 echo "APT::Periodic::Unattended-Upgrade \"0\";" >> /etc/apt/apt.conf.d/10periodic