3 REPO_URL_ARTIFACTS=$(cat /opt/config/repo_url_artifacts.txt)
4 DEMO_ARTIFACTS_VERSION=$(cat /opt/config/demo_artifacts_version.txt)
5 NB_API_VERSION=$(cat /opt/config/nb_api_version.txt)
6 INSTALL_SCRIPT_VERSION=$(cat /opt/config/install_script_version.txt)
7 CLOUD_ENV=$(cat /opt/config/cloud_env.txt)
9 # Convert Network CIDR to Netmask
11 # Number of args to shift, 255..255, first non-255 byte, zeroes
12 set -- $(( 5 - ($1 / 8) )) 255 255 255 255 $(( (255 << (8 - ($1 % 8))) & 255 )) 0 0 0
13 [ $1 -gt 1 ] && shift $1 || shift
14 echo ${1-0}.${2-0}.${3-0}.${4-0}
17 # OpenStack network configuration
18 if [[ $CLOUD_ENV == "openstack" ]]
20 echo 127.0.0.1 $(hostname) >> /etc/hosts
22 # Allow remote login as root
23 mv /root/.ssh/authorized_keys /root/.ssh/authorized_keys.bk
24 cp /home/ubuntu/.ssh/authorized_keys /root/.ssh
26 MTU=$(/sbin/ifconfig | grep MTU | sed 's/.*MTU://' | sed 's/ .*//' | sort -n | head -1)
28 IP=$(cat /opt/config/local_private_ipaddr.txt)
29 BITS=$(cat /opt/config/pktgen_private_net_cidr.txt | cut -d"/" -f2)
30 NETMASK=$(cdr2mask $BITS)
31 echo "auto eth1" >> /etc/network/interfaces
32 echo "iface eth1 inet static" >> /etc/network/interfaces
33 echo " address $IP" >> /etc/network/interfaces
34 echo " netmask $NETMASK" >> /etc/network/interfaces
35 echo " mtu $MTU" >> /etc/network/interfaces
37 IP=$(cat /opt/config/oam_private_ipaddr.txt)
38 BITS=$(cat /opt/config/onap_private_net_cidr.txt | cut -d"/" -f2)
39 NETMASK=$(cdr2mask $BITS)
40 echo "auto eth2" >> /etc/network/interfaces
41 echo "iface eth2 inet static" >> /etc/network/interfaces
42 echo " address $IP" >> /etc/network/interfaces
43 echo " netmask $NETMASK" >> /etc/network/interfaces
44 echo " mtu $MTU" >> /etc/network/interfaces
47 # Download required dependencies
48 echo "deb http://ppa.launchpad.net/openjdk-r/ppa/ubuntu $(lsb_release -c -s) main" >> /etc/apt/sources.list.d/java.list
49 echo "deb-src http://ppa.launchpad.net/openjdk-r/ppa/ubuntu $(lsb_release -c -s) main" >> /etc/apt/sources.list.d/java.list
51 apt-get install --allow-unauthenticated -y make wget openjdk-8-jdk gcc libcurl4-openssl-dev python-pip bridge-utils apt-transport-https ca-certificates git maven
52 pip install jsonschema
54 # Download vFirewall demo code for packet generator
56 unzip -p -j /opt/vlbms-scripts-$INSTALL_SCRIPT_VERSION.zip v_packetgen_init.sh > /opt/v_packetgen_init.sh
57 unzip -p -j /opt/vlbms-scripts-$INSTALL_SCRIPT_VERSION.zip vpacketgen.sh > /opt/vpacketgen.sh
58 unzip -p -j /opt/vlbms-scripts-$INSTALL_SCRIPT_VERSION.zip run_streams_dns.sh > /opt/run_streams_dns.sh
59 unzip -p -j /opt/vlbms-scripts-$INSTALL_SCRIPT_VERSION.zip properties.conf > /opt/config/properties.conf
60 unzip -p -j /opt/vlbms-scripts-$INSTALL_SCRIPT_VERSION.zip run_health.sh > /opt/run_health.sh
61 wget $REPO_URL_ARTIFACTS/org/onap/demo/vnf/vlb/vlb_dns_streams/$DEMO_ARTIFACTS_VERSION/vlb_dns_streams-$DEMO_ARTIFACTS_VERSION-demo.tar.gz
63 sed -i 's/primary=.*/primary=false/g' /opt/config/properties.conf
64 sed -i 's/vnfc=.*/vnfc=vPacketGen/g' /opt/config/properties.conf
66 tar -zmxvf vlb_dns_streams-$DEMO_ARTIFACTS_VERSION-demo.tar.gz
67 mv vlb_dns_streams-$DEMO_ARTIFACTS_VERSION dns_streams
69 # Clone Honeycomb interface for the VNF component
71 git init honeycomb-api
73 git remote add origin https://gerrit.onap.org/r/p/demo.git
74 git config core.sparsecheckout true
75 echo "vnfs/vLBMS/apis" >> .git/info/sparse-checkout
76 git pull --depth=1 origin beijing
79 cat > ~/.m2/settings.xml << EOF
80 <?xml version="1.0" encoding="UTF-8"?>
81 <!-- vi: set et smarttab sw=2 tabstop=2: -->
82 <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
83 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
84 xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
88 <id>fd.io-release</id>
92 <name>fd.io-mirror</name>
93 <url>https://nexus.fd.io/content/groups/public/</url>
95 <enabled>true</enabled>
96 <updatePolicy>never</updatePolicy>
99 <enabled>false</enabled>
105 <id>fd.io-mirror</id>
106 <name>fd.io-mirror</name>
107 <url>https://nexus.fd.io/content/repositories/public/</url>
109 <enabled>true</enabled>
110 <updatePolicy>never</updatePolicy>
113 <enabled>false</enabled>
116 </pluginRepositories>
120 <id>fd.io-snapshots</id>
123 <id>fd.io-snapshot</id>
124 <name>fd.io-snapshot</name>
125 <url>https://nexus.fd.io/content/repositories/fd.io.snapshot/</url>
127 <enabled>false</enabled>
130 <enabled>true</enabled>
136 <id>fd.io-snapshot</id>
137 <name>fd.io-snapshot</name>
138 <url>https://nexus.fd.io/content/repositories/fd.io.snapshot/</url>
140 <enabled>false</enabled>
143 <enabled>true</enabled>
146 </pluginRepositories>
149 <id>opendaylight-snapshots</id>
152 <id>opendaylight-snapshot</id>
153 <name>opendaylight-snapshot</name>
154 <url>https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/</url>
156 <enabled>false</enabled>
159 <enabled>true</enabled>
165 <id>opendaylight-shapshot</id>
166 <name>opendaylight-snapshot</name>
167 <url>https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/</url>
169 <enabled>false</enabled>
172 <enabled>true</enabled>
175 </pluginRepositories>
180 <activeProfile>fd.io-release</activeProfile>
181 <activeProfile>fd.io-snapshots</activeProfile>
182 <activeProfile>opendaylight-snapshots</activeProfile>
187 cd /opt/honeycomb-api/vnfs/vLBMS/apis
190 sed -i 's/"restconf-binding-address": "127.0.0.1",/"restconf-binding-address": "0.0.0.0",/g' /opt/honeycomb-api/vnfs/vLBMS/apis/vlb-vnf-onap-distribution/target/vlb-vnf-onap-distribution-$NB_API_VERSION-hc/vlb-vnf-onap-distribution-$NB_API_VERSION/config/honeycomb.json
191 sed -i 's/"netconf-tcp-binding-address": "127.0.0.1",/"netconf-tcp-binding-address": "0.0.0.0",/g' /opt/honeycomb-api/vnfs/vLBMS/apis/vlb-vnf-onap-distribution/target/vlb-vnf-onap-distribution-$NB_API_VERSION-hc/vlb-vnf-onap-distribution-$NB_API_VERSION/config/honeycomb.json
195 chmod +x v_packetgen_init.sh
196 chmod +x vpacketgen.sh
197 chmod +x run_streams_dns.sh
198 chmod +x run_health.sh
200 echo "vpp" > config/service.txt
203 export UBUNTU="xenial"
204 export RELEASE=".stable.1707"
205 rm /etc/apt/sources.list.d/99fd.io.list
206 echo "deb [trusted=yes] https://nexus.fd.io/content/repositories/fd.io$RELEASE.ubuntu.$UBUNTU.main/ ./" | tee -a /etc/apt/sources.list.d/99fd.io.list
208 apt-get install -y vpp vpp-dpdk-dkms vpp-lib vpp-dbg vpp-plugins vpp-dev
211 # Run instantiation script
213 mv vpacketgen.sh /etc/init.d
214 update-rc.d vpacketgen.sh defaults
216 # Rename network interface in openstack Ubuntu 16.04 images. Then, reboot the VM to pick up changes
217 if [[ $CLOUD_ENV != "rackspace" ]]
219 sed -i "s/GRUB_CMDLINE_LINUX=.*/GRUB_CMDLINE_LINUX=\"net.ifnames=0 biosdevname=0\"/g" /etc/default/grub
220 grub-mkconfig -o /boot/grub/grub.cfg
221 sed -i "s/ens[0-9]*/eth0/g" /etc/network/interfaces.d/*.cfg
222 sed -i "s/ens[0-9]*/eth0/g" /etc/udev/rules.d/70-persistent-net.rules
223 echo 'network: {config: disabled}' >> /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg
224 echo "APT::Periodic::Unattended-Upgrade \"0\";" >> /etc/apt/apt.conf.d/10periodic
228 ./v_packetgen_init.sh