3 NEXUS_ARTIFACT_REPO=$(cat /opt/config/nexus_artifact_repo.txt)
4 NB_API_VERSION=$(cat /opt/config/nb_api_version.txt)
5 INSTALL_SCRIPT_VERSION=$(cat /opt/config/install_script_version.txt)
6 CLOUD_ENV=$(cat /opt/config/cloud_env.txt)
8 # Convert Network CIDR to Netmask
10 # Number of args to shift, 255..255, first non-255 byte, zeroes
11 set -- $(( 5 - ($1 / 8) )) 255 255 255 255 $(( (255 << (8 - ($1 % 8))) & 255 )) 0 0 0
12 [ $1 -gt 1 ] && shift $1 || shift
13 echo ${1-0}.${2-0}.${3-0}.${4-0}
16 # OpenStack network configuration
17 if [[ $CLOUD_ENV == "openstack" ]]
19 echo 127.0.0.1 $(hostname) >> /etc/hosts
21 # Allow remote login as root
22 mv /root/.ssh/authorized_keys /root/.ssh/authorized_keys.bk
23 cp /home/ubuntu/.ssh/authorized_keys /root/.ssh
25 MTU=$(/sbin/ifconfig | grep MTU | sed 's/.*MTU://' | sed 's/ .*//' | sort -n | head -1)
27 IP=$(cat /opt/config/local_private_ipaddr.txt)
28 BITS=$(cat /opt/config/vlb_private_net_cidr.txt | cut -d"/" -f2)
29 NETMASK=$(cdr2mask $BITS)
30 echo "auto eth1" >> /etc/network/interfaces
31 echo "iface eth1 inet static" >> /etc/network/interfaces
32 echo " address $IP" >> /etc/network/interfaces
33 echo " netmask $NETMASK" >> /etc/network/interfaces
34 echo " mtu $MTU" >> /etc/network/interfaces
36 IP=$(cat /opt/config/oam_private_ipaddr.txt)
37 BITS=$(cat /opt/config/onap_private_net_cidr.txt | cut -d"/" -f2)
38 NETMASK=$(cdr2mask $BITS)
39 echo "auto eth2" >> /etc/network/interfaces
40 echo "iface eth2 inet static" >> /etc/network/interfaces
41 echo " address $IP" >> /etc/network/interfaces
42 echo " netmask $NETMASK" >> /etc/network/interfaces
43 echo " mtu $MTU" >> /etc/network/interfaces
46 # Download required dependencies
47 echo "deb http://ppa.launchpad.net/openjdk-r/ppa/ubuntu $(lsb_release -c -s) main" >> /etc/apt/sources.list.d/java.list
48 echo "deb-src http://ppa.launchpad.net/openjdk-r/ppa/ubuntu $(lsb_release -c -s) main" >> /etc/apt/sources.list.d/java.list
50 apt-get install --allow-unauthenticated -y wget openjdk-8-jdk bind9 bind9utils bind9-doc apt-transport-https ca-certificates git maven
53 # Download vDNS demo code for DNS Server
55 unzip -p -j /opt/vlbms-scripts-$INSTALL_SCRIPT_VERSION.zip v_dns_init.sh > /opt/v_dns_init.sh
56 unzip -p -j /opt/vlbms-scripts-$INSTALL_SCRIPT_VERSION.zip vdns.sh > /opt/vdns.sh
57 unzip -p -j /opt/vlbms-scripts-$INSTALL_SCRIPT_VERSION.zip set_gre_tunnel.sh > /opt/set_gre_tunnel.sh
58 unzip -p -j /opt/vlbms-scripts-$INSTALL_SCRIPT_VERSION.zip properties.conf > /opt/config/properties.conf
59 unzip -p -j /opt/vlbms-scripts-$INSTALL_SCRIPT_VERSION.zip run_health_vdns.sh > /opt/run_health.sh
61 sed -i 's/primary=.*/primary=false/g' /opt/config/properties.conf
62 sed -i 's/vnfc=.*/vnfc=vDNS/g' /opt/config/properties.conf
64 # Clone Honeycomb interface for the VNF component
66 git init honeycomb-api
68 git remote add origin https://gerrit.onap.org/r/demo.git
69 git config core.sparsecheckout true
70 echo "vnfs/vLBMS/apis" >> .git/info/sparse-checkout
71 git pull --depth=1 origin master
74 cat > ~/.m2/settings.xml << EOF
75 <?xml version="1.0" encoding="UTF-8"?>
76 <!-- vi: set et smarttab sw=2 tabstop=2: -->
77 <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
78 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
79 xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
83 <id>fd.io-release</id>
87 <name>fd.io-mirror</name>
88 <url>https://nexus.fd.io/content/groups/public/</url>
90 <enabled>true</enabled>
91 <updatePolicy>never</updatePolicy>
94 <enabled>false</enabled>
100 <id>fd.io-mirror</id>
101 <name>fd.io-mirror</name>
102 <url>https://nexus.fd.io/content/repositories/public/</url>
104 <enabled>true</enabled>
105 <updatePolicy>never</updatePolicy>
108 <enabled>false</enabled>
111 </pluginRepositories>
115 <id>fd.io-snapshots</id>
118 <id>fd.io-snapshot</id>
119 <name>fd.io-snapshot</name>
120 <url>https://nexus.fd.io/content/repositories/fd.io.snapshot/</url>
122 <enabled>false</enabled>
125 <enabled>true</enabled>
131 <id>fd.io-snapshot</id>
132 <name>fd.io-snapshot</name>
133 <url>https://nexus.fd.io/content/repositories/fd.io.snapshot/</url>
135 <enabled>false</enabled>
138 <enabled>true</enabled>
141 </pluginRepositories>
144 <id>opendaylight-snapshots</id>
147 <id>opendaylight-snapshot</id>
148 <name>opendaylight-snapshot</name>
149 <url>https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/</url>
151 <enabled>false</enabled>
154 <enabled>true</enabled>
160 <id>opendaylight-shapshot</id>
161 <name>opendaylight-snapshot</name>
162 <url>https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/</url>
164 <enabled>false</enabled>
167 <enabled>true</enabled>
170 </pluginRepositories>
175 <activeProfile>fd.io-release</activeProfile>
176 <activeProfile>fd.io-snapshots</activeProfile>
177 <activeProfile>opendaylight-snapshots</activeProfile>
182 cd /opt/honeycomb-api/vnfs/vLBMS/apis
185 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
186 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
189 chmod +x v_dns_init.sh
191 chmod +x set_gre_tunnel.sh
192 chmod +x run_health.sh
194 # Download Bind config files
196 unzip -p -j /opt/vlbms-scripts-$INSTALL_SCRIPT_VERSION.zip db_dnsdemo_onap_org > /opt/db_dnsdemo_onap_org
197 unzip -p -j /opt/vlbms-scripts-$INSTALL_SCRIPT_VERSION.zip named.conf.options > /opt/named.conf.options
198 unzip -p -j /opt/vlbms-scripts-$INSTALL_SCRIPT_VERSION.zip named.conf.local > /opt/named.conf.local
200 echo "bind9" > service.txt
204 mkdir /etc/bind/zones
205 sed -i "s/OPTIONS=.*/OPTIONS=\"-4 -u bind\"/g" /etc/default/bind9
206 mv db_dnsdemo_onap_org /etc/bind/zones/db.dnsdemo.onap.org
207 mv named.conf.options /etc/bind/
208 mv named.conf.local /etc/bind/
211 # Run instantiation script
213 mv vdns.sh /etc/init.d
214 update-rc.d vdns.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