aboutsummaryrefslogtreecommitdiffstats
path: root/vnfs/vLB/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'vnfs/vLB/scripts')
-rw-r--r--vnfs/vLB/scripts/.DS_Storebin8196 -> 0 bytes
-rw-r--r--vnfs/vLB/scripts/add_dns.sh12
-rw-r--r--vnfs/vLB/scripts/dnsmembership.sh4
-rw-r--r--vnfs/vLB/scripts/remove_dns.sh14
-rwxr-xr-xvnfs/vLB/scripts/run_streams_dns.sh2
-rw-r--r--vnfs/vLB/scripts/v_dns_install.sh22
-rwxr-xr-xvnfs/vLB/scripts/v_lb_init.sh34
-rw-r--r--vnfs/vLB/scripts/v_lb_install.sh46
-rw-r--r--vnfs/vLB/scripts/v_packetgen_init.sh (renamed from vnfs/vLB/scripts/v_packetgen_for_dns_demo_init.sh)50
-rw-r--r--vnfs/vLB/scripts/v_packetgen_install.sh76
-rw-r--r--vnfs/vLB/scripts/vdnspacketgen_change_streams_ports.sh13
-rw-r--r--vnfs/vLB/scripts/vpacketgen.sh (renamed from vnfs/vLB/scripts/vpacketgenfordnsdemo.sh)2
12 files changed, 163 insertions, 112 deletions
diff --git a/vnfs/vLB/scripts/.DS_Store b/vnfs/vLB/scripts/.DS_Store
deleted file mode 100644
index 32f7ecab..00000000
--- a/vnfs/vLB/scripts/.DS_Store
+++ /dev/null
Binary files differ
diff --git a/vnfs/vLB/scripts/add_dns.sh b/vnfs/vLB/scripts/add_dns.sh
index 04dfc771..3574e085 100644
--- a/vnfs/vLB/scripts/add_dns.sh
+++ b/vnfs/vLB/scripts/add_dns.sh
@@ -7,15 +7,17 @@ then
fi
DNS_IPADDR=$1
-MY_PUBLIC_IP=$(cat /opt/config/local_public_ipaddr.txt)
-MY_PRIVATE_IP=$(cat /opt/config/local_private_ipaddr.txt)
+IP_TO_PKTGEN_NET=$(cat /opt/config/ip_to_pktgen_net.txt)
+IP_TO_DNS_NET=$(cat /opt/config/ip_to_dns_net.txt)
+GRE_IPADDR=$(cat /opt/config/gre_ipaddr.txt)
-vppctl lb as $MY_PUBLIC_IP"/32" $DNS_IPADDR
-GRE=$(vppctl create gre tunnel src $MY_PRIVATE_IP dst $DNS_IPADDR)
+vppctl lb as $IP_TO_PKTGEN_NET"/32" $DNS_IPADDR
+GRE=$(vppctl create gre tunnel src $IP_TO_DNS_NET dst $DNS_IPADDR)
+vppctl set int ip address $GRE $GRE_IPADDR"/32"
vppctl set int state $GRE up
# Update the number of vDNSs currently active
FD="/opt/VES/code/evel_training/VESreporting/active_dns.txt"
CURR_DNS=$(cat $FD)
let CURR_DNS=$CURR_DNS+1
-echo $CURR_DNS > $FD
+echo $CURR_DNS > $FD \ No newline at end of file
diff --git a/vnfs/vLB/scripts/dnsmembership.sh b/vnfs/vLB/scripts/dnsmembership.sh
index 345dc3ff..e18ab803 100644
--- a/vnfs/vLB/scripts/dnsmembership.sh
+++ b/vnfs/vLB/scripts/dnsmembership.sh
@@ -1,6 +1,6 @@
#!/bin/bash
-MY_PUBLIC_IP=$(cat /opt/config/local_public_ipaddr.txt)
+IP_TO_PKTGEN_NET=$(cat /opt/config/ip_to_pktgen_net.txt)
VERSION=$(cat /opt/config/demo_artifacts_version.txt)
-java -jar dns-manager-$VERSION.jar $MY_PUBLIC_IP 8888 10 3 0
+java -jar dns-manager-$VERSION.jar $IP_TO_PKTGEN_NET 8888 10 3 0
diff --git a/vnfs/vLB/scripts/remove_dns.sh b/vnfs/vLB/scripts/remove_dns.sh
index 1d505abe..f400aa0f 100644
--- a/vnfs/vLB/scripts/remove_dns.sh
+++ b/vnfs/vLB/scripts/remove_dns.sh
@@ -2,23 +2,23 @@
if [ ! "$#" -eq 1 ]
then
- echo "Usage: ./add_dns.sh [remote DNS server]"
+ echo "Usage: ./remove_dns.sh [remote DNS server]"
exit
fi
DNS_IPADDR=$1
-MY_PUBLIC_IP=$(cat /opt/config/local_public_ipaddr.txt)
-MY_PRIVATE_IP=$(cat /opt/config/local_private_ipaddr.txt)
+IP_TO_PKTGEN_NET=$(cat /opt/config/ip_to_pktgen_net.txt)
+IP_TO_DNS_NET=$(cat /opt/config/ip_to_dns_net.txt)
-vppctl lb as $MY_PUBLIC_ID"/32" $DNS_IPADDR del
-vppctl create gre tunnel src $MY_PRIVATE_IP dst $DNS_IPADDR del
+vppctl lb as $IP_TO_PKTGEN_NET"/32" $DNS_IPADDR del
+vppctl create gre tunnel src $IP_TO_DNS_NET dst $DNS_IPADDR del
# Update the number of vDNSs currently active
FD="/opt/VES/code/evel_training/VESreporting/active_dns.txt"
CURR_DNS=$(cat $FD)
let CURR_DNS=$CURR_DNS-1
if [[ $CURR_DNS -lt 0 ]]
-then
+then
CURR_DNS=0
fi
-echo $CURR_DNS > $FD
+echo $CURR_DNS > $FD \ No newline at end of file
diff --git a/vnfs/vLB/scripts/run_streams_dns.sh b/vnfs/vLB/scripts/run_streams_dns.sh
index 4d4e5432..cf95fa53 100755
--- a/vnfs/vLB/scripts/run_streams_dns.sh
+++ b/vnfs/vLB/scripts/run_streams_dns.sh
@@ -3,7 +3,7 @@
vppctl packet-gen disable
vppctl packet-gen enable-stream dns1
vppctl packet-gen enable-stream dns2
-sleep 300
+sleep 100
vppctl packet-gen enable-stream dns3
vppctl packet-gen enable-stream dns4
vppctl packet-gen enable-stream dns5
diff --git a/vnfs/vLB/scripts/v_dns_install.sh b/vnfs/vLB/scripts/v_dns_install.sh
index 83441ac9..91cce8ab 100644
--- a/vnfs/vLB/scripts/v_dns_install.sh
+++ b/vnfs/vLB/scripts/v_dns_install.sh
@@ -42,19 +42,16 @@ then
echo " address $IP" >> /etc/network/interfaces
echo " netmask $NETMASK" >> /etc/network/interfaces
echo " mtu $MTU" >> /etc/network/interfaces
-
- ifup eth1
- ifup eth2
fi
# Download required dependencies
-add-apt-repository -y ppa:openjdk-r/ppa
+echo "deb http://ppa.launchpad.net/openjdk-r/ppa/ubuntu $(lsb_release -c -s) main" >> /etc/apt/sources.list.d/java.list
+echo "deb-src http://ppa.launchpad.net/openjdk-r/ppa/ubuntu $(lsb_release -c -s) main" >> /etc/apt/sources.list.d/java.list
apt-get update
-apt-get install -y wget openjdk-8-jdk bind9 bind9utils bind9-doc apt-transport-https ca-certificates
+apt-get install --allow-unauthenticated -y wget openjdk-8-jdk bind9 bind9utils bind9-doc apt-transport-https ca-certificates
sleep 1
# Download vDNS demo code for DNS Server
-mkdir /opt/config
mkdir /opt/FDclient
cd /opt
@@ -92,4 +89,17 @@ sleep 1
cd /opt
mv vdns.sh /etc/init.d
update-rc.d vdns.sh defaults
+
+# Rename network interface in openstack Ubuntu 16.04 images. Then, reboot the VM to pick up changes
+if [[ $CLOUD_ENV != "rackspace" ]]
+then
+ sed -i "s/GRUB_CMDLINE_LINUX=.*/GRUB_CMDLINE_LINUX=\"net.ifnames=0 biosdevname=0\"/g" /etc/default/grub
+ grub-mkconfig -o /boot/grub/grub.cfg
+ sed -i "s/ens[0-9]*/eth0/g" /etc/network/interfaces.d/*.cfg
+ sed -i "s/ens[0-9]*/eth0/g" /etc/udev/rules.d/70-persistent-net.rules
+ echo 'network: {config: disabled}' >> /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg
+ echo "APT::Periodic::Unattended-Upgrade \"0\";" >> /etc/apt/apt.conf.d/10periodic
+ reboot
+fi
+
./v_dns_init.sh \ No newline at end of file
diff --git a/vnfs/vLB/scripts/v_lb_init.sh b/vnfs/vLB/scripts/v_lb_init.sh
index 8767a943..9223e043 100755
--- a/vnfs/vLB/scripts/v_lb_init.sh
+++ b/vnfs/vLB/scripts/v_lb_init.sh
@@ -1,7 +1,7 @@
#!/bin/bash
# Start VPP
-start vpp
+systemctl start vpp
sleep 1
# Compute the network CIDR from the Netmask
@@ -25,30 +25,33 @@ mask2cidr() {
echo "$nbits"
}
-IPADDR1_MASK=$(ifconfig eth0 | grep "Mask" | awk '{print $4}' | awk -F ":" '{print $2}')
+IPADDR1_MASK=$(ifconfig eth3 | grep "Mask" | awk '{print $4}' | awk -F ":" '{print $2}')
IPADDR1_CIDR=$(mask2cidr $IPADDR1_MASK)
IPADDR2_MASK=$(ifconfig eth1 | grep "Mask" | awk '{print $4}' | awk -F ":" '{print $2}')
IPADDR2_CIDR=$(mask2cidr $IPADDR2_MASK)
# Configure VPP for vPacketGenerator
-IPADDR1=$(ifconfig eth0 | grep "inet addr" | tr -s ' ' | cut -d' ' -f3 | cut -d':' -f2)
+IPADDR1=$(ifconfig eth3 | grep "inet addr" | tr -s ' ' | cut -d' ' -f3 | cut -d':' -f2)
IPADDR2=$(ifconfig eth1 | grep "inet addr" | tr -s ' ' | cut -d' ' -f3 | cut -d':' -f2)
-HWADDR1=$(ifconfig eth0 | grep HWaddr | tr -s ' ' | cut -d' ' -f5)
+HWADDR1=$(ifconfig eth3 | grep HWaddr | tr -s ' ' | cut -d' ' -f5)
HWADDR2=$(ifconfig eth1 | grep HWaddr | tr -s ' ' | cut -d' ' -f5)
-FAKE_HWADDR1=$(echo -n 00; dd bs=1 count=5 if=/dev/urandom 2>/dev/null |hexdump -v -e '/1 ":%02X"')
-FAKE_HWADDR2=$(echo -n 00; dd bs=1 count=5 if=/dev/urandom 2>/dev/null |hexdump -v -e '/1 ":%02X"')
+FAKE_HWADDR1=$(echo -n 00; dd bs=1 count=5 if=/dev/urandom 2>/dev/null | hexdump -v -e '/1 ":%02X"')
+FAKE_HWADDR2=$(echo -n 00; dd bs=1 count=5 if=/dev/urandom 2>/dev/null | hexdump -v -e '/1 ":%02X"')
GW=$(route -n | grep "^0.0.0.0" | awk '{print $2}')
+PKTGEN_IPADDR=$(cat /opt/config/pktgen_ipaddr.txt)
+PKTGEN_MAC=$(cat /opt/config/pktgen_mac.txt)
+VIP=$(cat /opt/config/vip.txt)
-ifconfig eth0 down
-ifconfig eth0 hw ether $FAKE_HWADDR1
-ip addr flush dev eth0
-ifconfig eth0 up
+ifconfig eth3 down
+ifconfig eth3 hw ether $FAKE_HWADDR1
+ip addr flush dev eth3
+ifconfig eth3 up
vppctl tap connect tappub hwaddr $HWADDR1
-vppctl set int ip address tap-0 $IPADDR1"/"$IPADDR1_CIDR
+vppctl set int ip address tap-0 $VIP"/"$IPADDR1_CIDR
vppctl set int state tap-0 up
brctl addbr br0
brctl addif br0 tappub
-brctl addif br0 eth0
+brctl addif br0 eth3
ifconfig br0 up
ifconfig eth1 down
@@ -66,13 +69,16 @@ sleep 1
vppctl lb conf ip4-src-address $IPADDR2
vppctl lb vip $IPADDR1"/32" encap gre4
-vppctl ip route add 0.0.0.0/0 via $GW
sleep 1
+vppctl set ip arp proxy $IPADDR1" - "$IPADDR1
+vppctl set interface proxy-arp tap-0 enable
+vppctl set ip arp tap-0 $PKTGEN_IPADDR $PKTGEN_MAC
+
cd /opt/FDserver
./dnsmembership.sh &>/dev/null &disown
# Start VES client
cd /opt/VES/code/evel_training/VESreporting/
echo 0 > active_dns.txt
-./go-client.sh &>/dev/null &disown
+./go-client.sh &>/dev/null &disown \ No newline at end of file
diff --git a/vnfs/vLB/scripts/v_lb_install.sh b/vnfs/vLB/scripts/v_lb_install.sh
index 394a6c8c..a6577c4a 100644
--- a/vnfs/vLB/scripts/v_lb_install.sh
+++ b/vnfs/vLB/scripts/v_lb_install.sh
@@ -25,7 +25,7 @@ then
MTU=$(/sbin/ifconfig | grep MTU | sed 's/.*MTU://' | sed 's/ .*//' | sort -n | head -1)
- IP=$(cat /opt/config/local_private_ipaddr.txt)
+ IP=$(cat /opt/config/ip_to_dns_net.txt)
BITS=$(cat /opt/config/vlb_private_net_cidr.txt | cut -d"/" -f2)
NETMASK=$(cdr2mask $BITS)
echo "auto eth1" >> /etc/network/interfaces
@@ -43,18 +43,24 @@ then
echo " netmask $NETMASK" >> /etc/network/interfaces
echo " mtu $MTU" >> /etc/network/interfaces
- ifup eth1
- ifup eth2
+ IP=$(cat /opt/config/ip_to_pktgen_net.txt)
+ BITS=$(cat /opt/config/pktgen_private_net_cidr.txt | cut -d"/" -f2)
+ NETMASK=$(cdr2mask $BITS)
+ echo "auto eth3" >> /etc/network/interfaces
+ echo "iface eth3 inet static" >> /etc/network/interfaces
+ echo " address $IP" >> /etc/network/interfaces
+ echo " netmask $NETMASK" >> /etc/network/interfaces
+ echo " mtu $MTU" >> /etc/network/interfaces
fi
# Download required dependencies
-add-apt-repository -y ppa:openjdk-r/ppa
+echo "deb http://ppa.launchpad.net/openjdk-r/ppa/ubuntu $(lsb_release -c -s) main" >> /etc/apt/sources.list.d/java.list
+echo "deb-src http://ppa.launchpad.net/openjdk-r/ppa/ubuntu $(lsb_release -c -s) main" >> /etc/apt/sources.list.d/java.list
apt-get update
-apt-get install -y make gcc wget openjdk-8-jdk bridge-utils libcurl4-openssl-dev apt-transport-https ca-certificates
+apt-get install --allow-unauthenticated -y make gcc wget openjdk-8-jdk bridge-utils libcurl4-openssl-dev apt-transport-https ca-certificates
sleep 1
# Download vLB demo code for load balancer
-mkdir /opt/config
mkdir /opt/FDserver
cd /opt
@@ -67,9 +73,9 @@ wget $REPO_URL_ARTIFACTS/org/onap/demo/vnf/vlb/dns-manager/$DEMO_ARTIFACTS_VERSI
wget $REPO_URL_ARTIFACTS/org/onap/demo/vnf/ves/ves/$DEMO_ARTIFACTS_VERSION/ves-$DEMO_ARTIFACTS_VERSION-demo.tar.gz
wget $REPO_URL_ARTIFACTS/org/onap/demo/vnf/ves/ves_vlb_reporting/$DEMO_ARTIFACTS_VERSION/ves_vlb_reporting-$DEMO_ARTIFACTS_VERSION-demo.tar.gz
-tar -zxvf ves-$DEMO_ARTIFACTS_VERSION-demo.tar.gz
+tar -zmxvf ves-$DEMO_ARTIFACTS_VERSION-demo.tar.gz
mv ves-$DEMO_ARTIFACTS_VERSION VES
-tar -zxvf ves_vlb_reporting-$DEMO_ARTIFACTS_VERSION-demo.tar.gz
+tar -zmxvf ves_vlb_reporting-$DEMO_ARTIFACTS_VERSION-demo.tar.gz
mv ves_vlb_reporting-$DEMO_ARTIFACTS_VERSION VESreporting_vLB
mv VESreporting_vLB /opt/VES/code/evel_training/VESreporting
@@ -86,16 +92,9 @@ chmod +x /opt/FDserver/dnsmembership.sh
chmod +x /opt/FDserver/add_dns.sh
chmod +x /opt/FDserver/remove_dns.sh
-# Create a file with public IP of the VM if it doesn't exist. This is for VMs directly attached to the external network.
-if [ ! -e /opt/config/local_public_ipaddr.txt ]
-then
- IP_ADDRESS=$(ifconfig eth0 | grep "inet addr" | tr -s ' ' | cut -d' ' -f3 | cut -d':' -f2)
- echo $IP_ADDRESS > /opt/config/local_public_ipaddr.txt
-fi
-
# Install VPP
-export UBUNTU="trusty"
-export RELEASE=".stable.1609"
+export UBUNTU="xenial"
+export RELEASE=".stable.1707"
rm /etc/apt/sources.list.d/99fd.io.list
echo "deb [trusted=yes] https://nexus.fd.io/content/repositories/fd.io$RELEASE.ubuntu.$UBUNTU.main/ ./" | sudo tee -a /etc/apt/sources.list.d/99fd.io.list
apt-get update
@@ -112,4 +111,17 @@ sleep 1
cd /opt
mv vlb.sh /etc/init.d
update-rc.d vlb.sh defaults
+
+# Rename network interface in openstack Ubuntu 16.04 images. Then, reboot the VM to pick up changes
+if [[ $CLOUD_ENV != "rackspace" ]]
+then
+ sed -i "s/GRUB_CMDLINE_LINUX=.*/GRUB_CMDLINE_LINUX=\"net.ifnames=0 biosdevname=0\"/g" /etc/default/grub
+ grub-mkconfig -o /boot/grub/grub.cfg
+ sed -i "s/ens[0-9]*/eth0/g" /etc/network/interfaces.d/*.cfg
+ sed -i "s/ens[0-9]*/eth0/g" /etc/udev/rules.d/70-persistent-net.rules
+ echo 'network: {config: disabled}' >> /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg
+ echo "APT::Periodic::Unattended-Upgrade \"0\";" >> /etc/apt/apt.conf.d/10periodic
+ reboot
+fi
+
./v_lb_init.sh \ No newline at end of file
diff --git a/vnfs/vLB/scripts/v_packetgen_for_dns_demo_init.sh b/vnfs/vLB/scripts/v_packetgen_init.sh
index 9e7879bc..3e0de3e6 100644
--- a/vnfs/vLB/scripts/v_packetgen_for_dns_demo_init.sh
+++ b/vnfs/vLB/scripts/v_packetgen_init.sh
@@ -1,7 +1,7 @@
#!/bin/bash
# Start VPP
-start vpp
+systemctl start vpp
sleep 1
# Compute the network CIDR from the Netmask
@@ -25,51 +25,37 @@ mask2cidr() {
echo "$nbits"
}
-IPADDR1_MASK=$(ifconfig eth0 | grep "Mask" | awk '{print $4}' | awk -F ":" '{print $2}')
+IPADDR1_MASK=$(ifconfig eth1 | grep "Mask" | awk '{print $4}' | awk -F ":" '{print $2}')
IPADDR1_CIDR=$(mask2cidr $IPADDR1_MASK)
# Configure VPP for vPacketGenerator
-IPADDR1=$(ifconfig eth0 | grep "inet addr" | tr -s ' ' | cut -d' ' -f3 | cut -d':' -f2)
-HWADDR1=$(ifconfig eth0 | grep HWaddr | tr -s ' ' | cut -d' ' -f5)
+IPADDR1=$(ifconfig eth1 | grep "inet addr" | tr -s ' ' | cut -d' ' -f3 | cut -d':' -f2)
+HWADDR1=$(ifconfig eth1 | grep HWaddr | tr -s ' ' | cut -d' ' -f5)
FAKE_HWADDR1=$(echo -n 00; dd bs=1 count=5 if=/dev/urandom 2>/dev/null | hexdump -v -e '/1 ":%02X"')
VLB_IPADDR=$(cat /opt/config/vlb_ipaddr.txt)
+VLB_MAC=$(cat /opt/config/vlb_mac.txt)
GW=$(route -n | grep "^0.0.0.0" | awk '{print $2}')
-ifconfig eth0 down
-ifconfig eth0 hw ether $FAKE_HWADDR1
-ip addr flush dev eth0
-ifconfig eth0 up
+ifconfig eth1 down
+ifconfig eth1 hw ether $FAKE_HWADDR1
+ip addr flush dev eth1
+ifconfig eth1 up
vppctl tap connect tap111 hwaddr $HWADDR1
vppctl set int ip address tap-0 $IPADDR1"/"$IPADDR1_CIDR
vppctl set int state tap-0 up
brctl addbr br0
brctl addif br0 tap111
-brctl addif br0 eth0
+brctl addif br0 eth1
ifconfig br0 up
vppctl ip route add 0.0.0.0/0 via $GW
sleep 1
-
# Set br0 with public IP and valid MAC so that Linux will have public network access
ifconfig br0 hw ether $HWADDR1
ifconfig br0 $IPADDR1 netmask $IPADDR1_MASK
route add default gw $GW
-
-#Adding static arp entry for VPP so that it will be able to send packets to default GW
-ping -c 1 $VLB_IPADDR &>/dev/null &disown
-sleep 3
-
-GW_MAC=$(arp -n | grep -w $GW | tr -s ' ' | cut -d' ' -f3)
-VLB_MAC=$(arp -n | grep -w $VLB_IPADDR | tr -s ' ' | cut -d' ' -f3)
-
-# If VLB is in our network, we will use its MAC
-if [ ! -z "$VLB_MAC" ]
-then
- vppctl set ip arp tap-0 $VLB_IPADDR $VLB_MAC
-fi
-
-# Add arp entry for default GW
-vppctl set ip arp tap-0 $GW $GW_MAC
+sleep 1
+vppctl set ip arp tap-0 $VLB_IPADDR $VLB_MAC
# Install packet streams
sed -i -e "0,/UDP/ s/UDP:.*/UDP: "$IPADDR1" -> "$VLB_IPADDR"/" /opt/dns_streams/stream_dns1
@@ -104,17 +90,11 @@ vppctl exec /opt/dns_streams/stream_dns7
vppctl exec /opt/dns_streams/stream_dns8
vppctl exec /opt/dns_streams/stream_dns9
vppctl exec /opt/dns_streams/stream_dns10
-sleep 1
-# Start HoneyComb
-VERSION=$(cat /opt/config/demo_artifacts_version.txt)
-echo "" > /var/lib/honeycomb/persist/context/data.json
-echo "" > /var/lib/honeycomb/persist/config/data.json
-/opt/honeycomb/sample-distribution-$VERSION/honeycomb &>/dev/null &disown
-sleep 20
+vppctl set int ip address pg0 $(cat /opt/config/pg_int.txt)"/"$IPADDR1_CIDR
+sleep 1
# Enable traffic flows
cd /opt
chmod +x run_streams_dns.sh
-./run_streams_dns.sh &>/dev/null &disown
-
+./run_streams_dns.sh &>/dev/null &disown \ No newline at end of file
diff --git a/vnfs/vLB/scripts/v_packetgen_install.sh b/vnfs/vLB/scripts/v_packetgen_install.sh
index 2a2d7a24..ca2957a7 100644
--- a/vnfs/vLB/scripts/v_packetgen_install.sh
+++ b/vnfs/vLB/scripts/v_packetgen_install.sh
@@ -6,6 +6,14 @@ DEMO_ARTIFACTS_VERSION=$(cat /opt/config/demo_artifacts_version.txt)
INSTALL_SCRIPT_VERSION=$(cat /opt/config/install_script_version.txt)
CLOUD_ENV=$(cat /opt/config/cloud_env.txt)
+# Convert Network CIDR to Netmask
+cdr2mask () {
+ # Number of args to shift, 255..255, first non-255 byte, zeroes
+ set -- $(( 5 - ($1 / 8) )) 255 255 255 255 $(( (255 << (8 - ($1 % 8))) & 255 )) 0 0 0
+ [ $1 -gt 1 ] && shift $1 || shift
+ echo ${1-0}.${2-0}.${3-0}.${4-0}
+}
+
# OpenStack network configuration
if [[ $CLOUD_ENV == "openstack" ]]
then
@@ -14,40 +22,54 @@ then
# Allow remote login as root
mv /root/.ssh/authorized_keys /root/.ssh/authorized_keys.bk
cp /home/ubuntu/.ssh/authorized_keys /root/.ssh
+
+ MTU=$(/sbin/ifconfig | grep MTU | sed 's/.*MTU://' | sed 's/ .*//' | sort -n | head -1)
+
+ IP=$(cat /opt/config/local_private_ipaddr.txt)
+ BITS=$(cat /opt/config/pktgen_private_net_cidr.txt | cut -d"/" -f2)
+ NETMASK=$(cdr2mask $BITS)
+ echo "auto eth1" >> /etc/network/interfaces
+ echo "iface eth1 inet static" >> /etc/network/interfaces
+ echo " address $IP" >> /etc/network/interfaces
+ echo " netmask $NETMASK" >> /etc/network/interfaces
+ echo " mtu $MTU" >> /etc/network/interfaces
+
+ IP=$(cat /opt/config/oam_private_ipaddr.txt)
+ BITS=$(cat /opt/config/onap_private_net_cidr.txt | cut -d"/" -f2)
+ NETMASK=$(cdr2mask $BITS)
+ echo "auto eth2" >> /etc/network/interfaces
+ echo "iface eth2 inet static" >> /etc/network/interfaces
+ echo " address $IP" >> /etc/network/interfaces
+ echo " netmask $NETMASK" >> /etc/network/interfaces
+ echo " mtu $MTU" >> /etc/network/interfaces
fi
# Download required dependencies
-add-apt-repository -y ppa:openjdk-r/ppa
+echo "deb http://ppa.launchpad.net/openjdk-r/ppa/ubuntu $(lsb_release -c -s) main" >> /etc/apt/sources.list.d/java.list
+echo "deb-src http://ppa.launchpad.net/openjdk-r/ppa/ubuntu $(lsb_release -c -s) main" >> /etc/apt/sources.list.d/java.list
apt-get update
-apt-get install -y make wget openjdk-8-jdk gcc libcurl4-openssl-dev python-pip bridge-utils apt-transport-https ca-certificates
+apt-get install --allow-unauthenticated -y make wget openjdk-8-jdk gcc libcurl4-openssl-dev python-pip bridge-utils apt-transport-https ca-certificates
pip install jsonschema
# Download vFirewall demo code for packet generator
-mkdir /opt/config
-mkdir /opt/honeycomb
cd /opt
-wget $REPO_URL_BLOB/org.onap.demo/vnfs/vlb/$INSTALL_SCRIPT_VERSION/v_packetgen_for_dns_demo_init.sh
-wget $REPO_URL_BLOB/org.onap.demo/vnfs/vlb/$INSTALL_SCRIPT_VERSION/vpacketgenfordnsdemo.sh
+wget $REPO_URL_BLOB/org.onap.demo/vnfs/vlb/$INSTALL_SCRIPT_VERSION/v_packetgen_init.sh
+wget $REPO_URL_BLOB/org.onap.demo/vnfs/vlb/$INSTALL_SCRIPT_VERSION/vpacketgen.sh
wget $REPO_URL_BLOB/org.onap.demo/vnfs/vlb/$INSTALL_SCRIPT_VERSION/run_streams_dns.sh
wget $REPO_URL_BLOB/org.onap.demo/vnfs/vlb/$INSTALL_SCRIPT_VERSION/vdnspacketgen_change_streams_ports.sh
-wget $REPO_URL_ARTIFACTS/org/onap/demo/vnf/sample-distribution/$DEMO_ARTIFACTS_VERSION/sample-distribution-$DEMO_ARTIFACTS_VERSION-hc.tar.gz
wget $REPO_URL_ARTIFACTS/org/onap/demo/vnf/vlb/vlb_dns_streams/$DEMO_ARTIFACTS_VERSION/vlb_dns_streams-$DEMO_ARTIFACTS_VERSION-demo.tar.gz
-tar -zxvf vpp.tar.gz
-tar -zxvf sample-distribution-$DEMO_ARTIFACTS_VERSION-hc.tar.gz
-mv sample-distribution-$DEMO_ARTIFACTS_VERSION honeycomb
-sed -i 's/"restconf-binding-address": "127.0.0.1",/"restconf-binding-address": "0.0.0.0",/g' honeycomb/sample-distribution-$DEMO_ARTIFACTS_VERSION/config/honeycomb.json
-tar -zxvf vlb_dns_streams-$DEMO_ARTIFACTS_VERSION-demo.tar.gz
+tar -zmxvf vlb_dns_streams-$DEMO_ARTIFACTS_VERSION-demo.tar.gz
mv vlb_dns_streams-$DEMO_ARTIFACTS_VERSION dns_streams
rm *.tar.gz
-chmod +x v_packetgen_for_dns_demo_init.sh
-chmod +x vpacketgenfordnsdemo.sh
+chmod +x v_packetgen_init.sh
+chmod +x vpacketgen.sh
chmod +x run_streams_dns.sh
chmod +x vdnspacketgen_change_streams_ports.sh
# Install VPP
-export UBUNTU="trusty"
-export RELEASE=".stable.1609"
+export UBUNTU="xenial"
+export RELEASE=".stable.1707"
rm /etc/apt/sources.list.d/99fd.io.list
echo "deb [trusted=yes] https://nexus.fd.io/content/repositories/fd.io$RELEASE.ubuntu.$UBUNTU.main/ ./" | sudo tee -a /etc/apt/sources.list.d/99fd.io.list
apt-get update
@@ -56,6 +78,22 @@ sleep 1
# Run instantiation script
cd /opt
-mv vpacketgenfordnsdemo.sh /etc/init.d
-update-rc.d vpacketgenfordnsdemo.sh defaults
-./v_packetgen_for_dns_demo_init.sh
+mv vpacketgen.sh /etc/init.d
+update-rc.d vpacketgen.sh defaults
+
+# Rename network interface in openstack Ubuntu 16.04 images. Then, reboot the VM to pick up changes
+if [[ $CLOUD_ENV != "rackspace" ]]
+then
+ sed -i "s/GRUB_CMDLINE_LINUX=.*/GRUB_CMDLINE_LINUX=\"net.ifnames=0 biosdevname=0\"/g" /etc/default/grub
+ grub-mkconfig -o /boot/grub/grub.cfg
+ sed -i "s/ens[0-9]*/eth0/g" /etc/network/interfaces.d/*.cfg
+ sed -i "s/ens[0-9]*/eth0/g" /etc/udev/rules.d/70-persistent-net.rules
+ echo 'network: {config: disabled}' >> /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg
+ echo "APT::Periodic::Unattended-Upgrade \"0\";" >> /etc/apt/apt.conf.d/10periodic
+ reboot
+fi
+
+# Install a cron job that restart streams every minute. This allows to map streams to different vDNSs when we scale out the VNF
+echo "* * * * * /opt/vdnspacketgen_change_streams_ports.sh" | crontab
+
+./v_packetgen_init.sh
diff --git a/vnfs/vLB/scripts/vdnspacketgen_change_streams_ports.sh b/vnfs/vLB/scripts/vdnspacketgen_change_streams_ports.sh
index 9bd77162..e4723880 100644
--- a/vnfs/vLB/scripts/vdnspacketgen_change_streams_ports.sh
+++ b/vnfs/vLB/scripts/vdnspacketgen_change_streams_ports.sh
@@ -1,7 +1,7 @@
#!/bin/bash
-#Disable all streams via Honeycomb (so that it will in consistent state)
-curl -X PUT -H "Authorization: Basic YWRtaW46YWRtaW4=" -H "Content-Type: application/json" -H "Cache-Control: no-cache" -d '{"pg-streams":{"pg-stream": []}}' "http://localhost:8183/restconf/config/sample-plugin:sample-plugin/pg-streams"
+#Disable all streams
+killall -9 run_streams_dns.sh
vppctl pac del dns1
vppctl pac del dns2
@@ -14,10 +14,9 @@ vppctl pac del dns8
vppctl pac del dns9
vppctl pac del dns10
-
#Update destination (vLB) IP
VLB_IPADDR=$(cat /opt/config/vlb_ipaddr.txt)
-IPADDR1=$(ifconfig br0 | grep "inet addr" | tr -s ' ' | cut -d' ' -f3 | cut -d':' -f2)
+IPADDR1=$(cat /opt/config/local_private_ipaddr.txt)
sed -i -e "0,/UDP/ s/UDP:.*/UDP: "$IPADDR1" -> "$VLB_IPADDR"/" /opt/dns_streams/stream_dns1
sed -i -e "0,/UDP/ s/UDP:.*/UDP: "$IPADDR1" -> "$VLB_IPADDR"/" /opt/dns_streams/stream_dns2
sed -i -e "0,/UDP/ s/UDP:.*/UDP: "$IPADDR1" -> "$VLB_IPADDR"/" /opt/dns_streams/stream_dns3
@@ -50,4 +49,8 @@ vppctl exec /opt/dns_streams/stream_dns6
vppctl exec /opt/dns_streams/stream_dns7
vppctl exec /opt/dns_streams/stream_dns8
vppctl exec /opt/dns_streams/stream_dns9
-vppctl exec /opt/dns_streams/stream_dns10 \ No newline at end of file
+vppctl exec /opt/dns_streams/stream_dns10
+
+#Resume stream execution
+cd /opt
+./run_streams_dns.sh &>/dev/null &disown \ No newline at end of file
diff --git a/vnfs/vLB/scripts/vpacketgenfordnsdemo.sh b/vnfs/vLB/scripts/vpacketgen.sh
index 427e5337..1d00fd9c 100644
--- a/vnfs/vLB/scripts/vpacketgenfordnsdemo.sh
+++ b/vnfs/vLB/scripts/vpacketgen.sh
@@ -10,7 +10,7 @@
### END INIT INFO
dir="/opt"
-cmd="./v_packetgen_for_dns_demo_init.sh"
+cmd="./v_packetgen_init.sh"
user="root"
name=`basename $0`