VOL-3371:
- Miscellaneous fixes and enhancements for in-band script
- watchdog script for openolt and dev_mgmt_daemon processes
Change-Id: I993c95b15ceb23154646fe8b3a875ec09369e6ce
diff --git a/agent/Makefile.in b/agent/Makefile.in
index e699a70..ad1a0b9 100644
--- a/agent/Makefile.in
+++ b/agent/Makefile.in
@@ -321,6 +321,7 @@
cp $(BUILD_DIR)/libstdc++.so.6 device/$(OPENOLTDEVICE)/mkdebian/debian
cp $(BUILD_DIR)/libbal_host_api.so device/$(OPENOLTDEVICE)/mkdebian/debian
cp -a scripts/init.d device/$(OPENOLTDEVICE)/mkdebian/debian
+ cp -a scripts/watchdog device/$(OPENOLTDEVICE)/mkdebian/debian
cd device/$(OPENOLTDEVICE)/mkdebian && ./build_$(OPENOLTDEVICE)_deb.sh
mv device/$(OPENOLTDEVICE)/*.deb $(BUILD_DIR)/openolt_$(OPENOLTDEVICE)-$(VERSION)-$(LABEL_VCS_REF).deb
make deb-cleanup
@@ -344,14 +345,14 @@
exit 1; \
fi;
- # Update vlan.config file with VLAN ID argument passed
- sed -i 's/asfvolt16_vlan_id_eth2=.*/asfvolt16_vlan_id_eth2=$(VLAN_ID)/' $(TOP_DIR)/inband/config/vlan.config
- sed -i 's/asgvolt64_vlan_id_eth1=.*/asgvolt64_vlan_id_eth1=$(VLAN_ID)/' $(TOP_DIR)/inband/config/vlan.config
+ # Update inband.config file with VLAN ID argument passed
+ sed -i 's/asfvolt16_vlan_id_eth2=.*/asfvolt16_vlan_id_eth2=$(VLAN_ID)/' $(TOP_DIR)/inband/config/inband.config
+ sed -i 's/asgvolt64_vlan_id_eth1=.*/asgvolt64_vlan_id_eth1=$(VLAN_ID)/' $(TOP_DIR)/inband/config/inband.config
# Copy Inband config files and olt startup scripts to ONL source code and build
cd $(TOP_DIR) && mkdir -p $(ONL_DIR)/OpenNetworkLinux/bal_packages
cp $(TOP_DIR)/inband/scripts/* $(ONL_DIR)/OpenNetworkLinux/bal_packages
- cp $(TOP_DIR)/inband/config/vlan.config $(ONL_DIR)/OpenNetworkLinux/bal_packages
+ cp $(TOP_DIR)/inband/config/inband.config $(ONL_DIR)/OpenNetworkLinux/bal_packages
cp $(BUILD_DIR)/openolt_$(OPENOLTDEVICE)-$(VERSION)-$(LABEL_VCS_REF).deb $(ONL_DIR)/OpenNetworkLinux/bal_packages/openolt_$(OPENOLTDEVICE).deb
# Rebuild ONL packed with already built BAL+Openolt debian package
diff --git a/agent/device/asfvolt16/mkdebian/debian/asfvolt16.postinst b/agent/device/asfvolt16/mkdebian/debian/asfvolt16.postinst
index 8f0e380..87a0d19 100644
--- a/agent/device/asfvolt16/mkdebian/debian/asfvolt16.postinst
+++ b/agent/device/asfvolt16/mkdebian/debian/asfvolt16.postinst
@@ -20,11 +20,14 @@
tar zxf /tmp/release_asfvolt16_V3.4.3.3.202002100101.tar.gz -C / 2>&1 > /dev/null
grep -q '\/opt\/bcm68620\/svk_init.sh' /etc/rc.local || sed -i -e '$i \/opt\/bcm68620\/svk_init.sh' /etc/rc.local
rm -f /run/bcm68620
+mkdir -p /opt/openolt && cp /tmp/watchdog/openolt_dev_mgmt_daemon_process_watchdog /opt/openolt
+[ -f /opt/openolt/openolt_dev_mgmt_daemon_process_watchdog ] && grep -q '\/opt\/openolt\/openolt_dev_mgmt_daemon_process_watchdog' /etc/rc.local || sed -i -e '$i nohup bash \/opt\/openolt\/openolt_dev_mgmt_daemon_process_watchdog &' /etc/rc.local
cp /tmp/init.d/dev_mgmt_daemon /etc/init.d
cp /tmp/init.d/openolt /etc/init.d
cp /tmp/logrotate.d/openolt /etc/logrotate.d
chmod +x /etc/init.d/dev_mgmt_daemon
chmod +x /etc/init.d/openolt
+chmod +x /opt/openolt/openolt_dev_mgmt_daemon_process_watchdog
update-rc.d dev_mgmt_daemon defaults
update-rc.d openolt defaults
mv /tmp/openolt /broadcom
diff --git a/agent/device/asfvolt16/mkdebian/debian/asfvolt16.postrm b/agent/device/asfvolt16/mkdebian/debian/asfvolt16.postrm
index 2f514af..f799e09 100644
--- a/agent/device/asfvolt16/mkdebian/debian/asfvolt16.postrm
+++ b/agent/device/asfvolt16/mkdebian/debian/asfvolt16.postrm
@@ -16,6 +16,7 @@
rm -rf /opt/bcm68620
+rm -rf /opt/openolt
rm -rf /broadcom
sed -i '\/opt\/bcm68620\/svk_init.sh/d' /etc/rc.local
rm -rf /run/bcm68620
diff --git a/agent/device/asfvolt16/mkdebian/debian/rules b/agent/device/asfvolt16/mkdebian/debian/rules
index bf86af6..0869afa 100755
--- a/agent/device/asfvolt16/mkdebian/debian/rules
+++ b/agent/device/asfvolt16/mkdebian/debian/rules
@@ -34,6 +34,7 @@
cp -a $(CURDIR)/debian/openolt $(DEB_DH_INSTALL_SOURCEDIR)/tmp
cp -a $(CURDIR)/debian/init.d $(DEB_DH_INSTALL_SOURCEDIR)/tmp
cp -a $(CURDIR)/debian/logrotate.d $(DEB_DH_INSTALL_SOURCEDIR)/tmp
+ cp -a $(CURDIR)/debian/watchdog $(DEB_DH_INSTALL_SOURCEDIR)/tmp
#override_dh_shlibdeps:
# dh_shlibdeps --dpkg-shlibdeps-params=--ignore-missing-info -l$(ONLP_LIB_PATH):$(OFDPA_LIB_PATH)
diff --git a/agent/device/asgvolt64/mkdebian/debian/asgvolt64.postinst b/agent/device/asgvolt64/mkdebian/debian/asgvolt64.postinst
index 7e74326..72b4b19 100644
--- a/agent/device/asgvolt64/mkdebian/debian/asgvolt64.postinst
+++ b/agent/device/asgvolt64/mkdebian/debian/asgvolt64.postinst
@@ -20,11 +20,14 @@
tar zxf /tmp/release_asgvolt64_V3.4.3.3.202002100101.tar.gz -C / 2>&1 > /dev/null
grep -q '\/opt\/bcm68620\/svk_init.sh' /etc/rc.local || sed -i -e '$i \/opt\/bcm68620\/svk_init.sh' /etc/rc.local
rm -f /run/bcm68620
+mkdir -p /opt/openolt && cp /tmp/watchdog/openolt_dev_mgmt_daemon_process_watchdog /opt/openolt
+[ -f /opt/openolt/openolt_dev_mgmt_daemon_process_watchdog ] && grep -q '\/opt\/openolt\/openolt_dev_mgmt_daemon_process_watchdog' /etc/rc.local || sed -i -e '$i nohup bash \/opt\/openolt\/openolt_dev_mgmt_daemon_process_watchdog &' /etc/rc.local
cp /tmp/init.d/dev_mgmt_daemon /etc/init.d
cp /tmp/init.d/openolt /etc/init.d
cp /tmp/logrotate.d/openolt /etc/logrotate.d
chmod +x /etc/init.d/dev_mgmt_daemon
chmod +x /etc/init.d/openolt
+chmod +x /opt/openolt/openolt_dev_mgmt_daemon_process_watchdog
update-rc.d dev_mgmt_daemon defaults
update-rc.d openolt defaults
mv /tmp/openolt /broadcom
diff --git a/agent/device/asgvolt64/mkdebian/debian/asgvolt64.postrm b/agent/device/asgvolt64/mkdebian/debian/asgvolt64.postrm
index 2f514af..f799e09 100644
--- a/agent/device/asgvolt64/mkdebian/debian/asgvolt64.postrm
+++ b/agent/device/asgvolt64/mkdebian/debian/asgvolt64.postrm
@@ -16,6 +16,7 @@
rm -rf /opt/bcm68620
+rm -rf /opt/openolt
rm -rf /broadcom
sed -i '\/opt\/bcm68620\/svk_init.sh/d' /etc/rc.local
rm -rf /run/bcm68620
diff --git a/agent/device/asgvolt64/mkdebian/debian/rules b/agent/device/asgvolt64/mkdebian/debian/rules
index 7298161..561c092 100755
--- a/agent/device/asgvolt64/mkdebian/debian/rules
+++ b/agent/device/asgvolt64/mkdebian/debian/rules
@@ -34,6 +34,7 @@
cp -a $(CURDIR)/debian/openolt $(DEB_DH_INSTALL_SOURCEDIR)/tmp
cp -a $(CURDIR)/debian/init.d $(DEB_DH_INSTALL_SOURCEDIR)/tmp
cp -a $(CURDIR)/debian/logrotate.d $(DEB_DH_INSTALL_SOURCEDIR)/tmp
+ cp -a $(CURDIR)/debian/watchdog $(DEB_DH_INSTALL_SOURCEDIR)/tmp
#override_dh_shlibdeps:
# dh_shlibdeps --dpkg-shlibdeps-params=--ignore-missing-info -l$(ONLP_LIB_PATH):$(OFDPA_LIB_PATH)
diff --git a/agent/inband/config/inband.config b/agent/inband/config/inband.config
new file mode 100644
index 0000000..eb737a4
--- /dev/null
+++ b/agent/inband/config/inband.config
@@ -0,0 +1,18 @@
+### BEGIN INIT INFO
+# Description: This file utilized by olt inband init script and onl validation script to
+# know what VLAN configured by the user for inband CTRL and MGMT interface.
+# It also has configuration which indicates wether out-of-band connection
+# should be enabled on the OLT. This defaults to "no". To enable, it should
+# be set to "yes"
+# the OLT)
+#
+### END INIT INFO
+
+#asfvolt16
+asfvolt16_vlan_id_eth2=4093
+
+#asgvolt64
+asgvolt64_vlan_id_eth1=4093
+
+# enable out of band connection to OLT?
+enable_out_of_band_connection=no
diff --git a/agent/inband/config/vlan.config b/agent/inband/config/vlan.config
deleted file mode 100644
index e0dd6c2..0000000
--- a/agent/inband/config/vlan.config
+++ /dev/null
@@ -1,10 +0,0 @@
-### BEGIN INIT INFO
-# Description: This file utilized by olt inband init script and onl validation script to
-# know what VLAN configured by the user for inband CTRL and MGMT interface
-### END INIT INFO
-
-#asfvolt16
-asfvolt16_vlan_id_eth2=4093
-
-#asgvolt64
-asgvolt64_vlan_id_eth1=4093
diff --git a/agent/inband/patch/inband-72b95a7.patch b/agent/inband/patch/inband-72b95a7.patch
index 529bbf4..341ab48 100644
--- a/agent/inband/patch/inband-72b95a7.patch
+++ b/agent/inband/patch/inband-72b95a7.patch
@@ -34,7 +34,7 @@
+ mv "$workdir"/openolt* "$destdir"/
+ echo "INFO: Copying init scripts to init.d"
+ cp "$workdir"/start_inband_oltservices.sh "$destdir"/etc/init.d/
-+ cp "$workdir"/vlan.config "$destdir"/
++ cp "$workdir"/inband.config "$destdir"/
+ cd -
fi
+cat > "$destdir"/etc/rc.local <<- EOF
@@ -53,7 +53,7 @@
+
+chmod 0777 /etc/init.d/start_inband_oltservices.sh
+chmod 0777 /root/validate_onl_installation.sh
-+nohup sh /etc/init.d/start_inband_oltservices.sh > /var/log/startup.log &
++nohup sh /etc/init.d/start_inband_oltservices.sh >> /var/log/startup.log &
+exit 0
+
+EOF
diff --git a/agent/inband/scripts/fetch_olt_sw_hw_details.py b/agent/inband/scripts/fetch_olt_sw_hw_details.py
index 627a73c..25d28ae 100644
--- a/agent/inband/scripts/fetch_olt_sw_hw_details.py
+++ b/agent/inband/scripts/fetch_olt_sw_hw_details.py
@@ -64,8 +64,8 @@
# and openolt binaries are located.
BRCM_DIR = '/broadcom'
-# Path to vlan config file
-VLAN_CONFIG_FILE = BRCM_DIR+"/vlan.config"
+# Path to inband config file
+INBAND_CONFIG_FILE = BRCM_DIR+"/inband.config"
# Operating system name which is running at OLT.
# By default Open Network Linux (ONL) is used as operating
@@ -140,8 +140,8 @@
asg64_vlan = 'asgvolt64_vlan_id_eth1'
olt_model=get_olt_board_name()
try:
- if os.path.exists(VLAN_CONFIG_FILE):
- with open(VLAN_CONFIG_FILE, "r") as file_descriptor:
+ if os.path.exists(INBAND_CONFIG_FILE):
+ with open(INBAND_CONFIG_FILE, "r") as file_descriptor:
lines = file_descriptor.readlines()
for line in lines:
if olt_model == ASX_16:
@@ -151,7 +151,7 @@
if re.search(asg64_vlan, line):
eth_vlan = int(line.split('=')[1].strip())
else:
- syslog.syslog(syslog.LOG_ERR, "{}-file-does-not-exist".format(VLAN_CONFIG_FILE))
+ syslog.syslog(syslog.LOG_ERR, "{}-file-does-not-exist".format(INBAND_CONFIG_FILE))
return None, None
except(EnvironmentError, re.error) as exception:
syslog.syslog(syslog.LOG_ERR, "error-retreving-vlan-ids-{}".format(exception))
diff --git a/agent/inband/scripts/start_inband_oltservices.sh b/agent/inband/scripts/start_inband_oltservices.sh
index 5dfd1e8..016c1b7 100644
--- a/agent/inband/scripts/start_inband_oltservices.sh
+++ b/agent/inband/scripts/start_inband_oltservices.sh
@@ -50,8 +50,8 @@
# olt service files
SVK_INIT_FILE="${BRCM_OPT_DIR}/svk_init.sh"
-# vlan config file
-VLAN_CONFIG_FILE="${BRCM_DIR}/vlan.config"
+# inband config file
+INBAND_CONFIG_FILE="${BRCM_DIR}/inband.config"
DHCLIENT_CONF="/etc/dhcp/dhclient.conf"
# olt serial number
@@ -78,7 +78,7 @@
OPENOLT_ARG_INPUT_FILE=/etc/default/openolt
# Wait time for BAL to get ready
-WAIT_TIME_BAL_READY=120
+WAIT_TIME_BAL_READY=80
#------------------------------------------------------------------------------
# Function Name: does_logger_exist
@@ -145,11 +145,11 @@
#------------------------------------------------------------------------------
# Function Name: get_vlan_ids
# Description:
-# This function facilitates to fetch vlan id from vlan configuration file
-# located at /broadcom/vlan.config
+# This function facilitates to fetch vlan id from inband configuration file
+# located at /broadcom/inband.config
#
# Globals:
-# VLAN_CONFIG_FILE, ASFVOLT16_VLAN_ID_ETH2, ASFVOLT16_VLAN_ID_ETH3,
+# INBAND_CONFIG_FILE, ASFVOLT16_VLAN_ID_ETH2, ASFVOLT16_VLAN_ID_ETH3,
# ASGVOLT64_VLAN_ID_ETH1, ASGVOLT64_VLAN_ID_ETH2
#
# Arguments:
@@ -159,27 +159,61 @@
# None
#------------------------------------------------------------------------------
get_vlan_ids() {
- # Read vlan.config file to fetch vlan id information
- if [ -f ${VLAN_CONFIG_FILE} ]; then
- ASFVOLT16_VLAN_ID_ETH2=$(awk '/asfvolt16_vlan_id_eth2/{print $0}' ${VLAN_CONFIG_FILE} | awk -F "=" '{print $2}')
- ASGVOLT64_VLAN_ID_ETH1=$(awk '/asgvolt64_vlan_id_eth1/{print $0}' ${VLAN_CONFIG_FILE} | awk -F "=" '{print $2}')
+ # Read inband.config file to fetch vlan id information
+ if [ -f ${INBAND_CONFIG_FILE} ]; then
+ ASFVOLT16_VLAN_ID_ETH2=$(awk '/asfvolt16_vlan_id_eth2/{print $0}' ${INBAND_CONFIG_FILE} | awk -F "=" '{print $2}')
+ ASGVOLT64_VLAN_ID_ETH1=$(awk '/asgvolt64_vlan_id_eth1/{print $0}' ${INBAND_CONFIG_FILE} | awk -F "=" '{print $2}')
if [ -z ${ASFVOLT16_VLAN_ID_ETH2} ] || [ -z ${ASGVOLT64_VLAN_ID_ETH1} ]; then
error_message "ERROR: vlan ids not valid"
exit 1
fi
else
- error_message "ERROR: ${VLAN_CONFIG_FILE} not found, using default value 4093"
+ error_message "ERROR: ${INBAND_CONFIG_FILE} not found, using default value 4093"
+ fi
+}
+
+#------------------------------------------------------------------------------
+# Function Name: is_out_band_connection_enabled
+# Description:
+# This function checks if out-of-band connection is enabled by reading
+# the enable_out_of_band_connection value in file /broadcom/inband.config
+#
+# Globals:
+#
+# Arguments:
+# None
+#
+# Returns:
+# true if out-of-band connection enabled, else false
+#------------------------------------------------------------------------------
+is_out_band_connection_enabled() {
+ # Read inband.config file to fetch configurtion to enable or not the out-of-band connection to the OLT.
+ if [ -f ${INBAND_CONFIG_FILE} ]; then
+ ob_cfg=$(awk '/enable_out_of_band_connection/{print $0}' ${INBAND_CONFIG_FILE} | awk -F "=" '{print $2}')
+ if [ -z ${ob_cfg} ]; then
+ error_message "ERROR: missing configuration to enable out-of-band connection to OLT. Default to false"
+ return false
+ fi
+ else
+ if [ "${ob_cfg}" = "yes" ]; then
+ return true
+ elif [ "${ob_cfg}" = "no" ]; then
+ return false
+ else
+ error_message "ERROR: Invalid configuration to enable out-of-band connection -> ${ob_cfg}"
+ return false
+ fi
fi
}
#------------------------------------------------------------------------------
# Function Name: setup_nw_configuration
# Description:
-# This function read the "/broadcom/vlan.config" file to get VLAND IDs
+# This function read the "/broadcom/inband.config" file to get VLAND IDs
# for the interface eth1 and eth2 based on the OLT model and update
# these VLAN ID to /etc/network/interfaces file for dhcp request.
# Globals:
-# VLAN_CONFIG_FILE, ASFVOLT16_VLAN_ID_ETH2, ASGVOLT64_VLAN_ID_ETH1
+# INBAND_CONFIG_FILE, ASFVOLT16_VLAN_ID_ETH2, ASGVOLT64_VLAN_ID_ETH1
#
# Arguments:
# None
@@ -189,7 +223,14 @@
#------------------------------------------------------------------------------
setup_nw_configuration() {
# Dynamic vlan entry in /etc/network/interfaces file
- # Should have only one entry in the file in case of multiple reboot
+
+ if [ is_out_band_connection_enabled ]; then
+ # This interface is used for out-of-band connection for the OLT
+ # This is not a mandatory requirement for in-band management of the OLT
+ set_dhcp_ip_configuration ma1
+ fi
+
+ # These interfaces are used for in-band management of the OLT
if [ "${OLT_MODEL}" = ${ASF16_MODEL} ]; then
set_dhcp_ip_configuration eth2 ${ASFVOLT16_VLAN_ID_ETH2}
else
@@ -219,12 +260,72 @@
vlan_id=$2
grep -q "iface ${interface}.${vlan_id}" $NETWORK_INTERFACE
if [ $? -ne 0 ]; then
- echo "auto ${interface}.${vlan_id}" >>${NETWORK_INTERFACE}
- echo "iface ${interface}.${vlan_id} inet dhcp" >>${NETWORK_INTERFACE}
+ if [ -z ${vlan_id} ]; then
+ echo "auto ${interface}" >>${NETWORK_INTERFACE}
+ echo "iface ${interface} inet dhcp" >>${NETWORK_INTERFACE}
+ else
+ echo "auto ${interface}.${vlan_id}" >>${NETWORK_INTERFACE}
+ echo "iface ${interface}.${vlan_id} inet dhcp" >>${NETWORK_INTERFACE}
+ fi
fi
}
#------------------------------------------------------------------------------
+# Function Name: disable_autostart_of_openolt_and_dev_mgmt_daemon_processes
+# Description:
+# Disables autostart of openolt processes (openolt and dev_mgmt_daemon).
+# The start of these openolt processes is now controlled through this script
+#
+# Globals:
+#
+# Arguments:
+# None
+#
+# Returns:
+# None
+#------------------------------------------------------------------------------
+disable_autostart_of_openolt_and_dev_mgmt_daemon_processes() {
+ update-rc.d dev_mgmt_daemon disable
+ update-rc.d openolt disable
+}
+
+#------------------------------------------------------------------------------
+# Function Name: stop_openolt_and_dev_mgmt_daemon_processes
+# Description:
+# Stop openolt processes (openolt and dev_mgmt_daemon) if they were running
+# before
+#
+# Globals:
+#
+# Arguments:
+# None
+#
+# Returns:
+# None
+#------------------------------------------------------------------------------
+stop_openolt_and_dev_mgmt_daemon_processes() {
+ service dev_mgmt_daemon stop
+ service openolt stop
+}
+
+#------------------------------------------------------------------------------
+# Function Name: start_openolt_dev_mgmt_daemon_process_watchdog
+# Description:
+# Start openolt and dev_mgmt_daemon process watchdog
+#
+# Globals:
+#
+# Arguments:
+# None
+#
+# Returns:
+# None
+#------------------------------------------------------------------------------
+start_openolt_dev_mgmt_daemon_process_watchdog() {
+ nohup bash /opt/openolt/openolt_dev_mgmt_daemon_process_watchdog &
+}
+
+#------------------------------------------------------------------------------
# Function Name: start_dev_mgmt_service
# Description:
# This function starts svk_init.sh script and device management service.
@@ -532,7 +633,13 @@
# None
#------------------------------------------------------------------------------
start_olt_services() {
+ # First stop any openolt processes if they were running before
+ # and also disable auto start of these processes (since they are in /etc/init.d)
+ stop_openolt_and_dev_mgmt_daemon_processes
+ disable_autostart_of_openolt_and_dev_mgmt_daemon_processes
+
start_dev_mgmt_service
+ start_openolt_dev_mgmt_daemon_process_watchdog
create_vlan_tagged_Iface
setup_dhcpd_configuration
setup_nw_configuration
@@ -559,7 +666,7 @@
# [ -f /qax.soc ] && cp "/qax.soc" "${BRCM_DIR}/"
# fi
# [ -f /config.bcm ] && cp "/config.bcm" "${BRCM_DIR}/"
- [ -f /vlan.config ] && cp "/vlan.config" "${BRCM_DIR}/"
+ [ -f /inband.config ] && cp "/inband.config" "${BRCM_DIR}/"
}
# Execution starts from here
diff --git a/agent/inband/scripts/validate_onl_installation.sh b/agent/inband/scripts/validate_onl_installation.sh
index 8cbccbc..ab9d06c 100644
--- a/agent/inband/scripts/validate_onl_installation.sh
+++ b/agent/inband/scripts/validate_onl_installation.sh
@@ -48,8 +48,8 @@
# Root path where required bal directories are located
BRCM_DIR='/broadcom'
-# Path to vlan config file
-VLAN_CONFIG_FILE="${BRCM_DIR}/vlan.config"
+# Path to inband config file
+INBAND_CONFIG_FILE="${BRCM_DIR}/inband.config"
# vlan id for asfvolt16
ASFVOLT16_VLAN_ID_ETH2=
@@ -278,7 +278,7 @@
# in counter a number is equal to 20
#
# Globals:
-# VLAN_CONFIG_FILE, ASFVOLT16_VLAN_ID_ETH2, ASGVOLT64_VLAN_ID_ETH1,
+# INBAND_CONFIG_FILE, ASFVOLT16_VLAN_ID_ETH2, ASGVOLT64_VLAN_ID_ETH1,
# TIME_INTERVAL, ASFVOLT16
#
# Arguments:
@@ -289,9 +289,9 @@
#------------------------------------------------------------------------------
check_services()
{
- if [ -f ${VLAN_CONFIG_FILE} ]; then
- ASFVOLT16_VLAN_ID_ETH2=$(awk '/asfvolt16_vlan_id_eth2/{print $0}' ${VLAN_CONFIG_FILE} | awk -F "=" '{print $2}')
- ASGVOLT64_VLAN_ID_ETH1=$(awk '/asgvolt64_vlan_id_eth1/{print $0}' ${VLAN_CONFIG_FILE} | awk -F "=" '{print $2}')
+ if [ -f ${INBAND_CONFIG_FILE} ]; then
+ ASFVOLT16_VLAN_ID_ETH2=$(awk '/asfvolt16_vlan_id_eth2/{print $0}' ${INBAND_CONFIG_FILE} | awk -F "=" '{print $2}')
+ ASGVOLT64_VLAN_ID_ETH1=$(awk '/asgvolt64_vlan_id_eth1/{print $0}' ${INBAND_CONFIG_FILE} | awk -F "=" '{print $2}')
if [ "${OLT_MODEL}" = ${ASF16_MODEL} ]; then
if [ ${ASFVOLT16_VLAN_ID_ETH2} -gt 4094 ] || [ ${ASFVOLT16_VLAN_ID_ETH2} -lt 1 ]; then
error_message "vlan ids not in range"
@@ -304,7 +304,7 @@
fi
fi
else
- error_message "${VLAN_CONFIG_FILE} does not exist"
+ error_message "${INBAND_CONFIG_FILE} does not exist"
exit 1
fi
echo "*********************************************************************"
diff --git a/agent/scripts/watchdog/openolt_dev_mgmt_daemon_process_watchdog b/agent/scripts/watchdog/openolt_dev_mgmt_daemon_process_watchdog
new file mode 100755
index 0000000..54d1f82
--- /dev/null
+++ b/agent/scripts/watchdog/openolt_dev_mgmt_daemon_process_watchdog
@@ -0,0 +1,253 @@
+#!/bin/bash
+
+#Copyright 2020-present Open Networking Foundation
+#
+#Licensed under the Apache License, Version 2.0 (the "License");
+#you may not use this file except in compliance with the License.
+#You may obtain a copy of the License at
+#
+#http://www.apache.org/licenses/LICENSE-2.0
+#
+#Unless required by applicable law or agreed to in writing, software
+#distributed under the License is distributed on an "AS IS" BASIS,
+#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#See the License for the specific language governing permissions and
+#limitations under the License.
+
+# This script is a watchdog to monitor openolt and dev_mgmt_daemon processes
+# It restarts the processes when they crash
+# When OLT is working in in-band mode, it just monitors the dev_mgmt_daemon
+# process to start with. Once the openolt processes is also up, it starts
+# monitoring both the processes.
+# When OLT is working in out-of-band, it monitors both the processes to start
+# with. When either of the processes crash, it restarts both the processes.
+
+PID_MONITOR_INTERVAL=1 # in seconds
+MAX_WAIT_TIMER_FOR_OPENOLT_PROCESS_TO_START=120
+
+WATCHDOG_LOG_FILE="/var/log/openolt_process_watchdog.log"
+
+# inband config file
+INBAND_CONFIG_FILE="${BRCM_DIR}/inband.config"
+
+OLT_MODEL=$(cat /sys/devices/virtual/dmi/id/board_name)
+
+ASF16_MODEL="ASXvOLT16"
+
+# vlan id for asfvolt16
+ASFVOLT16_VLAN_ID_ETH2=
+
+# vlan id for asgvolt64
+ASGVOLT64_VLAN_ID_ETH1=
+
+
+#------------------------------------------------------------------------------
+# Function Name: LOG
+# Description:
+# Logs to WATCHDOG_LOG_FILE
+#
+# Globals:
+# None
+#
+# Arguments:
+# string to be logged
+#
+# Returns:
+# None
+#------------------------------------------------------------------------------
+LOG() {
+ echo `date`" $1" >> ${WATCHDOG_LOG_FILE}
+}
+
+#------------------------------------------------------------------------------
+# Function Name: get_vlan_ids
+# Description:
+# This function facilitates to fetch vlan id from inband configuration file
+# located at /broadcom/inband.config
+#
+# Globals:
+# INBAND_CONFIG_FILE, ASFVOLT16_VLAN_ID_ETH2, ASFVOLT16_VLAN_ID_ETH3,
+# ASGVOLT64_VLAN_ID_ETH1, ASGVOLT64_VLAN_ID_ETH2
+#
+# Arguments:
+# None
+#
+# Returns:
+# None
+#------------------------------------------------------------------------------
+get_vlan_ids() {
+ # Read inband.config file to fetch vlan id information
+ if [ -f ${INBAND_CONFIG_FILE} ]; then
+ if [ "${OLT_MODEL}" = ${ASF16_MODEL} ]; then
+ ASFVOLT16_VLAN_ID_ETH2=$(awk '/asfvolt16_vlan_id_eth2/{print $0}' ${INBAND_CONFIG_FILE} | awk -F "=" '{print $2}')
+ else
+ ASGVOLT64_VLAN_ID_ETH1=$(awk '/asgvolt64_vlan_id_eth1/{print $0}' ${INBAND_CONFIG_FILE} | awk -F "=" '{print $2}')
+ fi
+
+ if [ -z ${ASFVOLT16_VLAN_ID_ETH2} ] || [ -z ${ASGVOLT64_VLAN_ID_ETH1} ]; then
+ LOG "ERROR: vlan ids not valid"
+ exit 1
+ fi
+ else
+ LOG "ERROR: ${INBAND_CONFIG_FILE} not found, using default value 4093"
+ fi
+}
+
+#------------------------------------------------------------------------------
+# Function Name: monitor_openolt_and_dev_mgmt_daemon_process
+# Description:
+# Monitors openolt and dev_mgmt_daemon processes in an infinite loop.
+# Restarts both the processes if either of them exits
+#
+# Globals:
+# None
+#
+# Arguments:
+# None
+#
+# Returns:
+#
+#------------------------------------------------------------------------------
+monitor_openolt_and_dev_mgmt_daemon_process() {
+ LOG "start monitor openolt and dev_mgmt_daemon processes"
+
+ # This is builtin bash variable that tracks the number of seconds
+ # elapsed since the shell started. We can reset to 0 and the timer
+ # starts from here
+ SECONDS=0
+
+ while true; do
+
+ DEV_MGMT_DAEMON_PID=`pidof /broadcom/dev_mgmt_daemon`
+ OPENOLT_PID=$(pidof /broadcom/openolt)
+ if [ -z ${OPENOLT_PID} ] || [ -z ${DEV_MGMT_DAEMON_PID} ];then
+
+ if [ -z ${DEV_MGMT_DAEMON_PID} ]; then
+ LOG "dev_mgmt_daemon processes not available"
+ fi
+
+ if [ -z ${OPENOLT_PID} ]; then
+ LOG "openolt processes not available"
+ fi
+
+ # Reboot OLT so that everything recovers in the right state
+ reboot -n
+ exit 1
+ fi
+
+ sleep ${PID_MONITOR_INTERVAL}
+
+ if [ $(is_olt_in_inband_mode; echo $?) -eq 1 ]; then
+ if [ "${OLT_MODEL}" = ${ASF16_MODEL} ]; then
+ INBAND_IF_IP_ADDR=`ip -o -4 addr list eth2.${ASFVOLT16_VLAN_ID_ETH2} | awk '{print $4}' | cut -d/ -f1`
+ else
+ INBAND_IF_IP_ADDR=`ip -o -4 addr list eth1.${ASGVOLT64_VLAN_ID_ETH1} | awk '{print $4}' | cut -d/ -f1`
+ fi
+
+ if [ -z ${INBAND_IF_IP_ADDR} ] && [ ${SECONDS} -gt 60 ]; then
+ # If the in-band interface does not have an IP for more than 60s, reboot the OLT
+ LOG "in-band interface does not have IP for more than 60s, rebooting OLT"
+ reboot -n
+ exit 1
+ elif [ ${#INBAND_IF_IP_ADDR} -gt 0 ]; then
+ # This is case where we have an IP address on the in-band interface
+
+ # Reset timer if the in-band interface has an IP address
+ SECONDS=0
+ fi
+ fi
+ done
+}
+
+#------------------------------------------------------------------------------
+# Function Name: monitor_dev_mgmt_daemon_process
+# Description:
+# Monitors dev_mgmt_daemon in an infinite loop. The loop breaks if openolt
+# agent process starts
+#
+# Globals:
+# None
+#
+# Arguments:
+# None
+#
+# Returns:
+#
+#------------------------------------------------------------------------------
+monitor_dev_mgmt_daemon_process() {
+
+ # This is builtin bash variable that tracks the number of seconds
+ # elapsed since the shell started. We can reset to 0 and the timer
+ # starts from here
+ SECONDS=0
+ while true; do
+ DEV_MGMT_DAEMON_PID=$(pidof /broadcom/dev_mgmt_daemon)
+ if [ -z ${DEV_MGMT_DAEMON_PID} ];then
+ # Reboot OLT so that everything recovers in the right state
+ LOG "dev_mgmt_daemon process crashed or not available in in-band mode of OLT, rebooting OLT"
+ reboot -n
+ fi
+
+ sleep ${PID_MONITOR_INTERVAL}
+
+ OPENOLT_PID=$(pidof /broadcom/openolt)
+ if [ ${OPENOLT_PID} ]; then
+ LOG "openolt process has started. start monitoring both dev_mgmt_daemon and openolt processes"
+ break
+ elif [ ${SECONDS} -ge ${MAX_WAIT_TIMER_FOR_OPENOLT_PROCESS_TO_START} ]; then
+ # Typically the openolt process is supposed to start within MAX_WAIT_TIMER_FOR_OPENOLT_PROCESS_TO_START
+ # If that does not happen, reboot the OLT.
+ LOG "openolt process did not start for more than ${MAX_WAIT_TIMER_FOR_OPENOLT_PROCESS_TO_START} seconds, rebooting OLT"
+ reboot -n
+ exit 1
+ fi
+ done
+}
+
+#------------------------------------------------------------------------------
+# Function Name: is_olt_in_inband_mode
+# Description:
+# Checks if OLT is working in in-band mode
+# Presence of in-band startup scripts indicates in-band mode. These scripts
+# are not packaged as part of the debian package or the ONL when OLT is working
+# in out-of-band mode.
+#
+# Globals:
+# None
+#
+# Arguments:
+# None
+#
+# Returns:
+#
+#------------------------------------------------------------------------------
+is_olt_in_inband_mode() {
+ ! [ -f "/etc/init.d/start_inband_oltservices.sh" ]
+}
+
+
+# Execution starts here
+LOG "---- watchdog started ----"
+
+# Source watchdog configuration
+ . /opt/openolt/watchdog.config
+
+if [ ${enable_watchdog} = "yes" ]; then
+ LOG "watchdog is enabled"
+else
+ LOG "watchdog is disabled - exiting"
+ exit 0
+fi
+
+# If OLT is working in out-of-band start with monitoring only dev_mgmt_daemon process
+if [ $(is_olt_in_inband_mode; echo $?) -eq 1 ]; then
+ LOG "openolt working in in-band mode, starting to monitor dev_mgmt_daemon process first"
+ monitor_dev_mgmt_daemon_process
+ # If we are here, that means the openolt process has just started and we now need to
+ # monitor both dev_mgmt_daemon and openolt process
+else
+ sleep ${watchdog_startup_timer} # Allow some time for openolt and dev_mgmt_daemon process to start
+ LOG "openolt working in out-of-band mode"
+fi
+
+monitor_openolt_and_dev_mgmt_daemon_process
diff --git a/agent/scripts/watchdog/watchdog.config b/agent/scripts/watchdog/watchdog.config
new file mode 100644
index 0000000..7e864c2
--- /dev/null
+++ b/agent/scripts/watchdog/watchdog.config
@@ -0,0 +1,14 @@
+###
+# Description: This file utilized by openolt_dev_mgmt_daemon_process_watchdog script
+# read the watchdog config
+#
+###
+
+# Enable watchdog or not. yes to enable, no or other string to disable.
+enable_watchdog=no
+
+# watchdog startup timer - this is the time watchdog waits before starting
+# to monitor the openolt and dev_mgmt_daemon process when working in
+# out-of-band mode. This gives the buffer time for openolt and dev_mgmt_daemon
+# processes to start for the first time after OLT boot.
+watchdog_startup_timer=30