CLOUD_ENV=$(cat /opt/config/cloud_env.txt)
MUX_GW_IP=$(cat /opt/config/mux_gw_net_ipaddr.txt)
MUX_GW_CIDR=$(cat /opt/config/mux_gw_net_cidr.txt)
-BNG_MUX_IP=$(cat /opt/config/bng_mux_net_ipaddr.txt)
+MUX_TO_BNG_IP=$(cat /opt/config/mux_to_bng_net_ipaddr.txt)
BNG_MUX_CIDR=$(cat /opt/config/bng_mux_net_cidr.txt)
+BRG_BNG_CIDR=$(cat /opt/config/brg_bng_net_cidr.txt)
+BNG_TO_MUX_IP=$(cat /opt/config/bng_to_mux_net_ipaddr.txt)
# Build states are:
# 'build' - just build the code
EOF
- cat > /etc/vpp/setup.gate << EOF
-set int state GigabitEthernet0/4/0 up
-set int ip address GigabitEthernet0/4/0 ${BNG_MUX_IP}/${BNG_MUX_CIDR#*/}
+ # Get list of network device PCI bus addresses
+ get_nic_pci_list() {
+ while read -r line ; do
+ if [ "$line" != "${line#*network device}" ]; then
+ echo -n "${line%% *} "
+ fi
+ done < <(lspci)
+ }
+
+ NICS=$(get_nic_pci_list)
+ NICS=`echo ${NICS} | sed 's/[0]\+\([0-9]\)/\1/g' | sed 's/[.:]/\//g'`
+
+ BNG_MUX_NIC=GigabitEthernet`echo ${NICS} | cut -d " " -f 2` # second interface in list
+ MUX_GW_NIC=GigabitEthernet`echo ${NICS} | cut -d " " -f 4` # fourth interface in list
-set int state GigabitEthernet0/6/0 up
-set int ip address GigabitEthernet0/6/0 ${MUX_GW_IP}/${MUX_GW_CIDR#*/}
+ cat > /etc/vpp/setup.gate << EOF
+set int state ${BNG_MUX_NIC} up
+set int ip address ${BNG_MUX_NIC} ${MUX_TO_BNG_IP}/${BNG_MUX_CIDR#*/}
-create vxlan tunnel src ${MUX_GW_IP} dst 10.5.0.21 vni 100
+set int state ${MUX_GW_NIC} up
+set int ip address ${MUX_GW_NIC} ${MUX_GW_IP}/${MUX_GW_CIDR#*/}
+ip route add ${BRG_BNG_CIDR} via ${BNG_TO_MUX_IP} ${BNG_MUX_NIC}
EOF
fi # endif BUILD_STATE != "build"
l_version=$(echo "${l_version#*>}")
mv vpp-integration/minimal-distribution/target/vpp-integration-distribution-${l_version}-hc/vpp-integration-distribution-${l_version} /opt/honeycomb
sed -i 's/127.0.0.1/0.0.0.0/g' /opt/honeycomb/config/honeycomb.json
+
+ # Disable automatic upgrades
+ if [[ $CLOUD_ENV != "rackspace" ]]
+ then
+ echo "APT::Periodic::Unattended-Upgrade \"0\";" >> /etc/apt/apt.conf.d/10periodic
+ sed -i 's/\(APT::Periodic::Unattended-Upgrade\) "1"/\1 "0"/' /etc/apt/apt.conf.d/20auto-upgrades
+ fi
fi # endif BUILD_STATE != "done"
if [[ $BUILD_STATE != "build" ]]
[Service]
ExecStart=/opt/honeycomb/honeycomb
+ExecStop=/opt/reset_ves_mode.sh
Restart=always
RestartSec=10
EOF
systemctl enable /etc/systemd/system/honeycomb.service
+ # Create script that is used to reset the ves mode configuration
+ # when the honeycomb service is stopped
+ cat > /opt/reset_ves_mode.sh << EOF
+#!/bin/bash
+mode_data=\$(curl -X GET -u admin:admin http://127.0.0.1:8183/restconf/config/vesagent:vesagent/mode 2>/dev/null | sed s/\"base-packet-loss\":[0-9]\*,/\"base-packet-loss\":0,/)
+if [[ "\${mode_data}" != "" ]]
+then
+ curl -X DELETE -u admin:admin http://127.0.0.1:8183/restconf/config/vesagent:vesagent/mode
+ curl -H "Content-Type:application/json" --data "\${mode_data}" -X POST -u admin:admin http://127.0.0.1:8183/restconf/config/vesagent:vesagent
+fi
+EOF
+ chmod a+x /opt/reset_ves_mode.sh
+
#Create a systemd service for auto-save
cat > /usr/bin/save_config << EOF
#!/bin/bash
fi
}
-# Saves the VES agent configuration to the startup script.
-#
-# Get the current VES agent configuration from the bash command:
-# \$vppctl show ves agent
-# Server Addr Server Port Interval Enabled
-# 127.0.0.1 8080 10 True
-# Set the VES agent configuration with the bash command:
-# \$vppctl set ves agent server 127.0.0.1 port 8080 intval 10
-#
-save_ves_config()
-{
- local server=""
- local port=""
- local intval=""
-
- local ves_config=\`vppctl show ves agent | head -2 | tail -1\`
- if [ "\${ves_config}" != "" ] ;then
- server=\`echo \${ves_config} | awk '{ print \$1 }'\`
- port=\`echo \${ves_config} | awk '{ print \$2 }'\`
- intval=\`echo \${ves_config} | awk '{ print \$3 }'\`
- write_startup_scripts add "set ves agent server \${server} port \${port} intval \${intval}"
- fi
-}
-
# Save the VxLAN Tunnel Configuration to the startup script.
#
# Get the current VxLAN tunnel configuration with bash command:
################################# MAIN ###################################
-save_ves_config
-
save_vxlan_tunnel
save_vxlan_xconnect
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