VOL-2934: ONL In Band Management support
- Makefile changes to build Integrated ONL image with
BAL, Openolt agent and Inband startup scripts.
- Inband startup scripts enable single Inband channel, creates
inband tagged interfaces, allocates IP to them then start
dev_mgmt_daemon and Openolt services.
- Openolt gRPC server will be listening on inband interface IP.
- Readme file update with Inband ONL build procedure.
Change-Id: Ia441151d13fd55c331f74d2e8794b44d299549fd
diff --git a/README.md b/README.md
index a6b3082..465d6aa 100644
--- a/README.md
+++ b/README.md
@@ -145,6 +145,18 @@
* The two executables will remain open in the terminals, unless they are put
in background.
+## Inband ONL Note
+
+* Inband ONL image built by packaging Openolt debian package and some startup
+ scripts. The startup scripts serve to enable inband channels, create inband
+ tagged interfaces, install Openolt debian package and run dev_mgmt_daemon
+ and Openolt services.
+* Startup script named "start_inband_oltservices.sh" will be executed in
+ background after ONL installation. Script execution could be watched in a
+ log file located in /var/log/startup.log.
+* Follow the procedure specified below in Build OpenOLT section to build
+ integrated Inband ONL image.
+
### Connect from VOLTHA
At the VOLTHA CLI, preprovision and enable the OLT:
@@ -276,6 +288,27 @@
If the build process succeeds, a `.deb` package will be created as well in the
`openolt/agent/build` directory.
+Run make with inband option as specified below to build all-in-one ONL image
+packed with Openolt debian package and Inband OLT startup scripts(Scripts
+to enable Inband channel and start dev_mgmt_daemon and openolt services).
+This can take a while to complete the first time, since it builds
+ONL and the Broadcom SDKs. Following runs will be much faster, as they try to
+build OpenOLT agent source and Inband ONL with modified Openolt deb package.
+
+```shell
+make OPENOLTDEVICE=asfvolt16 INBAND=y VLAN_ID=<INBAND_VLAN>
+e.g:
+make OPENOLTDEVICE=asfvolt16 INBAND=y VLAN_ID=5
+```
+
+If no VLAN_ID is specified in above command it defaults to 4093.
+
+Note that the required INBAND ONL version `4.14` is built as part of the above
+build procedure and is available at path
+`build/onl/OpenNetworkLinux/RELEASE/jessie/amd64/ONL-onl-4.14_ONL-OS8_2020-04-22.
+2206-b4af32e_AMD64_INSTALLED_INSTALLER\.
+This ONL Installer should be used to flash the OS on the OLT.
+
NOTE: To compile for ASGvOLT 64 port GPON OLT, set `OPENOLTDEVICE` to
`asgvolt64` during build procedure like below.
diff --git a/VERSION b/VERSION
index 35cee72..79a6144 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.4.3
+2.4.4
diff --git a/agent/Makefile.in b/agent/Makefile.in
index 6068c4e..3cbe94d 100644
--- a/agent/Makefile.in
+++ b/agent/Makefile.in
@@ -44,6 +44,10 @@
# openolt.proto and tech_profile.proto
OPENOLT_PROTO_VER ?= v3.3.4
+# Variables used for Inband build
+INBAND = "n"
+VLAN_ID = 4093
+
#
# Build directory
BUILD_DIR = build
@@ -143,7 +147,11 @@
git clone https://github.com/opencomputeproject/OpenNetworkLinux.git $(ONL_DIR)/OpenNetworkLinux; \
cp download/Makefile.onl $(ONL_DIR)/Makefile; \
install -m 755 download/build-onl.sh $(ONL_DIR)/OpenNetworkLinux; \
- make -C $(ONL_DIR) onl-$(ONL_KERN_VER_MAJOR); \
+ make -C $(ONL_DIR) onl-$(ONL_KERN_VER_MAJOR) INBAND=n; \
+ else \
+ if [ "$(INBAND)" = n -a "$$(grep "inband" $(ONL_DIR)/onl_build.mode | cut -d= -f 2)" = y ]; then \
+ make -C $(ONL_DIR) onl-$(ONL_KERN_VER_MAJOR) INBAND=n; \
+ fi; \
fi;
onl-force:
make -C $(ONL_DIR) $(OPENOLTDEVICE)-$(ONL_KERN_VER_MAJOR)
@@ -294,6 +302,13 @@
ln -sf $(LIBGRPC_PATH)/libgrpc++.so.1 $(BUILD_DIR)/libgrpc++.so.1
ln -sf /usr/lib/x86_64-linux-gnu/libstdc++.so.6 $(BUILD_DIR)/libstdc++.so.6
strip $(BUILD_DIR)/openolt
+ echo "inband=n" > $(ONL_DIR)/onl_build.mode
+ if [ $(INBAND) = y ]; then \
+ echo "Building ONL+BAL+OpenoltAgent allinone image"; \
+ make deb; \
+ make inband-onl; \
+ fi;
+
src/%.o: src/%.cc
$(CXX) $(CXXFLAGS) $(CXXFLAGSDEVICE) $(CPPFLAGS) -I./common -c $< -o $@
@@ -309,6 +324,40 @@
mv device/$(OPENOLTDEVICE)/*.deb $(BUILD_DIR)/openolt_$(OPENOLTDEVICE)-$(VERSION)-$(LABEL_VCS_REF).deb
make deb-cleanup
+inband-onl:
+ # Clean previous ONL build and build freshly
+ sudo rm -rf $(ONL_DIR)
+ mkdir -p $(ONL_DIR)
+ git clone https://github.com/opencomputeproject/OpenNetworkLinux.git $(ONL_DIR)/OpenNetworkLinux
+ cp download/Makefile.onl $(ONL_DIR)/Makefile
+ install -m 755 download/build-onl.sh $(ONL_DIR)/OpenNetworkLinux
+
+ # Check ONL commit equals to Inband patch commit
+ ONL_COMMIT_ID=$(awk \'/COMMIT_ID = /{print $0}\' $(ONL_DIR)/Makefile | awk -F \"=\" \'{print $2}\')
+ INBAND_PATCH_COMMIT_ID=$(echo cp $(TOP_DIR)/inband/patch/*.patch | cut -d- -f 2 | cut -d. -f 1)
+ if [ "$(ONL_COMMIT_ID)" = "$(INBAND_PATCH_COMMIT_ID)" ]; then \
+ echo "ONL commit and inband patch commit matched."; \
+ cp $(TOP_DIR)/inband/patch/*.patch $(ONL_DIR)/OpenNetworkLinux; \
+ else \
+ echo "ONL commit and inband patch commit does not match. Exiting."; \
+ 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
+
+ # 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 $(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
+ make -C $(ONL_DIR) onl-$(ONL_KERN_VER_MAJOR) INBAND=y
+ echo "inband=y" > $(ONL_DIR)/onl_build.mode
+ make inband-onl-cleanup
+
src/%.o: %.cpp
$(CXX) -MMD -c $< -o $@
@@ -329,6 +378,10 @@
@rm -rf device/$(OPENOLTDEVICE)/mkdebian/debian/tmp/
@rm -f device/$(OPENOLTDEVICE)/$(OPENOLTDEVICE)_$(BAL_VER)+edgecore-V$(DEV_VER)_amd64.changes
+inband-onl-cleanup:
+ @rm -f $(ONL_DIR)/OpenNetworkLinux/*.patch
+ @rm -rf $(ONL_DIR)/OpenNetworkLinux/bal_packages
+
clean: protos-clean deb-cleanup
@rm -f $(OBJS) $(DEPS)
@rm -rf $(OPENOLT_PROTOS_DIR)/googleapis
@@ -345,4 +398,4 @@
distclean: clean-src clean
@rm -rf $(BUILD_DIR)
-.PHONY: onl sdk bal protos prereqs-system prereqs-local sim .FORCE
+.PHONY: onl sdk bal protos prereqs-system prereqs-local sim inband-onl .FORCE
diff --git a/agent/download/Makefile.onl b/agent/download/Makefile.onl
index b99f354..9f87264 100644
--- a/agent/download/Makefile.onl
+++ b/agent/download/Makefile.onl
@@ -13,6 +13,11 @@
# limitations under the License.
COMMIT_ID = 72b95a7
+INBAND = "n"
onl-4.14:
- cd OpenNetworkLinux && git checkout -b $@ $(COMMIT_ID) && docker/tools/onlbuilder --non-interactive -8 -c ./build-onl.sh
+ if [ $(INBAND) = y ]; then \
+ cd OpenNetworkLinux && git checkout -B $@ $(COMMIT_ID) && git apply inband-$(COMMIT_ID).patch && docker/tools/onlbuilder --non-interactive -8 -c ./build-onl.sh; \
+ else \
+ cd OpenNetworkLinux && git stash && git checkout -B $@ $(COMMIT_ID) && docker/tools/onlbuilder --non-interactive -8 -c ./build-onl.sh; \
+ fi;
diff --git a/agent/inband/config/vlan.config b/agent/inband/config/vlan.config
new file mode 100644
index 0000000..e0dd6c2
--- /dev/null
+++ b/agent/inband/config/vlan.config
@@ -0,0 +1,10 @@
+### 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
new file mode 100644
index 0000000..529bbf4
--- /dev/null
+++ b/agent/inband/patch/inband-72b95a7.patch
@@ -0,0 +1,94 @@
+diff --git a/builds/any/rootfs/jessie/common/all-base-packages.yml b/builds/any/rootfs/jessie/common/all-base-packages.yml
+index bbeab6b4..ca5a45cd 100644
+--- a/builds/any/rootfs/jessie/common/all-base-packages.yml
++++ b/builds/any/rootfs/jessie/common/all-base-packages.yml
+@@ -81,3 +81,7 @@
+ - sysstat
+ - ipmitool
+ - lm-sensors
++- python3.4
++- python3-yaml
++- cron
++- logrotate
+diff --git a/packages/base/all/initrds/loader-initrd-files/src/bin/swiprep b/packages/base/all/initrds/loader-initrd-files/src/bin/swiprep
+index d5a72f8e..0b0583e1 100755
+--- a/packages/base/all/initrds/loader-initrd-files/src/bin/swiprep
++++ b/packages/base/all/initrds/loader-initrd-files/src/bin/swiprep
+@@ -173,7 +173,46 @@ if test "$mode_install"; then
+ echo "*** invalid squashfs contents" 1>&2
+ exit 1
+ fi
++ cp "$swipath" "$workdir"/
++ cd "$workdir"
++ unzip "$swipath"
++ target=$(find . -name bal_packages)
++ for f in "$target"/*
++ do
++ main_file_name=$(basename $f)
++ full_path_name=$(echo $f | cut -c 3-)
++ cp $full_path_name "$workdir"/$main_file_name
++ done
++ echo "Moving validation script to /root/"
++ mv "$workdir"/validate_onl_installation.sh "$destdir"/root/
++ mv "$workdir"/fetch_olt_sw_hw_details.py "$destdir"/root/
++ 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"/
++ cd -
+ fi
++cat > "$destdir"/etc/rc.local <<- EOF
++#!/bin/sh -e
++#
++# rc.local
++#
++# This script is executed at the end of each multiuser runlevel.
++# Make sure that the script will "exit 0" on success or any other
++# value on error.
++#
++# In order to enable or disable this script just change the execution
++# bits.
++#
++# By default this script does nothing.
++
++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 &
++exit 0
++
++EOF
++
+ if test "$mode_overlay"; then
+ # keep the squashfs file around
+ mv $workdir/rootfs.sqsh /tmp/.rootfs
+diff --git a/tools/switool.py b/tools/switool.py
+index 26eb2fb1..6c783c3d 100755
+--- a/tools/switool.py
++++ b/tools/switool.py
+@@ -79,6 +79,26 @@ if ops.create or ops.overwrite:
+ swi = OnlSwitchImage(ops.swi, 'w')
+ swi.add_rootfs(ops.rootfs)
+ swi.add_manifest(ops.manifest)
++
++ try:
++ bal_files = []
++ onl_path = os.environ.get("ONL")
++ bal_package_path=onl_path+"/bal_packages"
++ cwd = os.getcwd()
++ if os.path.isdir(bal_package_path):
++ os.chdir(bal_package_path)
++ for root, dirs, files in os.walk(bal_package_path):
++ for file_name in files:
++ file_real_path = os.path.realpath(file_name)
++ bal_files.append(file_real_path)
++
++ os.chdir(cwd)
++ for f_name in bal_files:
++ print("INFO: File Name - ", f_name)
++ swi.add(f_name)
++ except KeyError:
++ print("Not exist environment value for %s" % "key_maybe_not_exist")
++
+ for f in ops.add_files:
+ swi.add(f, arcname=f)
+
diff --git a/agent/inband/scripts/fetch_olt_sw_hw_details.py b/agent/inband/scripts/fetch_olt_sw_hw_details.py
new file mode 100644
index 0000000..78f4d44
--- /dev/null
+++ b/agent/inband/scripts/fetch_olt_sw_hw_details.py
@@ -0,0 +1,297 @@
+#!/usr/bin/python
+
+"""
+Copyright 2018-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.
+"""
+
+"""
+:Description: Module for fetching OLT information.
+
+ This module is used to fetch OLT software and hardware information.
+ The OLT software information includes Operating system, OS Version,
+ and ONIE version.
+ The hardware information includes OLT Serial Number, OLT Hardware Model,
+ Vendor ID, OLT Hardware Part Number and In-band interfaces MAC addresses.
+
+ The gathered information will be output to the screen as a json string.
+ When passed through a JSON processor (like jq) the output would look
+ like below(sample output, the keys remain same and values change based on
+ OLT model and binary versions)
+ {
+ "hardware_information": {
+ "vendor": "Accton",
+ "hw_part_number": "FN1EC0816400Z",
+ "hw_version": "0.0.0.3",
+ "inband_interface": "34:12:78:56:01:00",
+ "hw_model": "ASXvOLT16-O-AC-F",
+ "serial_number": "EC1729003537"
+ },
+ "software_information": {
+ "onie_version": "2017.02.00.06",
+ "os_version": "3.7.10",
+ "os_name": "OpenNetworkLinux",
+ "openolt_version": "2.0.0",
+ "bal_version": "2.6.0.1"
+ }
+ }
+
+ This script exits with exit code 0 in case of success and 1 in case of failure.
+"""
+
+import os
+import re
+import json
+import syslog
+import yaml
+
+# dictionary containing OLT information with hardware_information and
+# software_information as keys and holds the respective data values
+OLT_INFORMATION = {}
+
+# Path where BAL libraries, configuration files, bal_core_dist
+# and openolt binaries are located.
+BRCM_DIR = '/broadcom'
+
+# Path to vlan config file
+VLAN_CONFIG_FILE = BRCM_DIR+"/vlan.config"
+
+# Operating system name which is running at OLT.
+# By default Open Network Linux (ONL) is used as operating
+# system at OLT
+OS_NAME = 'OpenNetworkLinux'
+
+# BAL library version running at OLT
+
+# openOLT version from OLT when available
+OPENOLT_VERSION = " "
+
+# in-band interface incase of device asgvolt64
+ETH_1 = 'eth1'
+
+# in-band interface incase of device asfvolt16
+ETH_2 = 'eth2'
+
+# Constants for the name of the keys in the JSON being printed
+VENDOR = "vendor"
+SERIAL_NUMBER = "serial_number"
+HARDWARE_MODEL = "hw_model"
+HARDWARE_PART_NUMBER = "hw_part_number"
+HARDWARE_VERSION = "hw_version"
+OPERATING_SYSTEM = "os_name"
+OPERATING_SYSTEM_VERSION = "os_version"
+ONIE_VERSION = "onie_version"
+SOFTWARE_INFORMATION = "software_information"
+HARDWARE_INFORMATION = "hardware_information"
+INBAND_INTERFACE = "inband_interface"
+BAL_VER = "bal_version"
+OPENOLT_VER = "openolt_version"
+OLT_MODEL=None
+ASX_16 = "ASXvOLT16"
+ASG_64 = "ASGvOLT64"
+
+# log to syslog
+syslog.openlog(facility=syslog.LOG_SYSLOG)
+
+def get_olt_board_name():
+ """
+ Reads the bal package name
+
+ This function fetchs bal package whether asfvolt16 or asgvolt64
+
+ :return : packge names if successful and None in case of failure.
+ :rtype : tuple of package name in case of success, else None in case of failure.
+ """
+
+ try:
+ OLT_MODEL = os.popen("cat /sys/devices/virtual/dmi/id/board_name").read().strip("\n")
+ syslog.syslog(syslog.LOG_INFO, "successfully-read-olt-board-name")
+ return OLT_MODEL
+ except (IOError, NameError) as exception:
+ syslog.syslog(syslog.LOG_ERR, "error-executing-command-{}".format(exception))
+ return None
+
+
+def retreive_vlan_id():
+ """
+ Retrieves VLAN ids of in-band interfaces.
+
+ This function fetchs vlan ids from OLT /broadcom/bal_config.ini file.
+
+ :return : vlan id of in-band interface if successfull and None in case of failure.
+ :rtype : integer(valid vlan_id) in case of success, else None in case of failure.
+ """
+
+ eth_vlan = None
+
+ # retrieving vlan ids based on the below two keys in bal_config.ini
+ asf16_vlan = 'asfvolt16_vlan_id_eth2'
+ 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:
+ lines = file_descriptor.readlines()
+ for line in lines:
+ if olt_model == ASX_16:
+ if re.search(asf16_vlan, line):
+ eth_vlan = int(line.split('=')[1].strip())
+ else if olt_model == ASG_64:
+ 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))
+ return None, None
+ except(EnvironmentError, re.error) as exception:
+ syslog.syslog(syslog.LOG_ERR, "error-retreving-vlan-ids-{}".format(exception))
+ return None, None
+
+ if eth_vlan > 4094 or eth_vlan < 1:
+ syslog.syslog(syslog.LOG_ERR, "vlan-id-not-in-range-{}-{}".format(eth_vlan, eth_vlan_2))
+ return None, None
+
+ return eth_vlan
+
+
+def get_olt_basic_info():
+ """
+ Fetch OLT basic information
+
+ This function retireves OLT's basic information using the command 'onlpdump -s'
+
+ :return: OLT's basic info in case of success and None in case of failure
+ :rtype: json if success and None if failure
+ """
+ # fetch OLT basic information
+ try:
+ olt_info = os.popen('onlpdump -s').read()
+ out = yaml.dump(yaml.load(olt_info)['System Information'])
+ json_data = json.dumps(yaml.load(out))
+ data = json.loads(json_data)
+ except (IOError, TypeError, ValueError, yaml.YAMLError, yaml.MarkedYAMLError) as exception:
+ syslog.syslog(syslog.LOG_ERR, "error-fetching-olt-information-{}".format(exception))
+ return None
+ return data
+
+def get_bal_openolt_version():
+ """
+ Fetch bal and openolt version
+
+ This function retireves OLT's basic information using the command 'onlpdump -s'
+
+ :return : bal and openolt version if successfull and None in case of failure.
+ :rtype : tuple of bal and opneolt version in case of success, else None in case of failure.
+ """
+ try:
+ os.chdir('/')
+ os.environ["LD_LIBRARY_PATH"] = "."
+ version_string = os.popen("./broadcom/openolt --version").read()
+ version_tuple = tuple(version_string.split("\n"))
+ openolt_v = version_tuple[0].split(":")
+ OPENOLT_VERSION = openolt_v[1].split(" ")
+ bal_v = version_tuple[1].split(":")
+ BAL_VERSION = bal_v[1].split(" ")
+ return OPENOLT_VERSION[1], BAL_VERSION[1]
+ except (IOError, NameError) as exception:
+ syslog.syslog(syslog.LOG_ERR, "error-executing-command-{}".format(exception))
+ return None, None
+
+
+def fetch_olt_info():
+ """
+ Gather OLT software and hardware information.
+
+ This function gather OLT information and returns OLT
+ software and hardware information.
+
+ :return: OLT's software and hardware information in case of successful execution
+ and returns None in case of failure
+ :rtype: JSON string in case of success and None in case of failure.
+ """
+
+ hw_facts = {}
+ sw_facts = {}
+
+ # fetch olt basic information
+ data = get_olt_basic_info()
+ if data is None:
+ return None
+
+ olt_model=get_olt_board_name()
+ # retrieving VLAN ids of in-band interfaces
+ vlan = retreive_vlan_id()
+ try:
+ if vlan is not None:
+ # Retreiving MAC address for in-band interfaces
+ if olt_model == ASX_16:
+ macaddr = os.popen("ifconfig " + ETH_2 + "." + str(vlan) +
+ " | grep -Po 'HWaddr " + r"\K.*$'").read().strip()
+ else if olt_model == ASG_64:
+ macaddr = os.popen("ifconfig " + ETH_1 + "." + str(vlan) +
+ " | grep -Po 'HWaddr " + r"\K.*$'").read().strip()
+ else:
+ return None
+
+ # get the operating system version details from olt
+ operating_sys = os.popen("uname -a").read()
+ os_tuple = tuple(operating_sys.split(" "))
+ os_and_version = os_tuple[2].split("-")
+ os_version = os_and_version[0]
+ except (IOError, NameError) as exception:
+ syslog.syslog(syslog.LOG_ERR, "error-executing-command-{}".format(exception))
+ return None
+
+ openolt_v, bal_v = get_bal_openolt_version()
+
+ # adding OLT hardware details to dictionary
+ try:
+ # adding OLT's in-band interfaces mac addresses
+ hw_facts[INBAND_INTERFACE] = macaddr
+ hw_facts[VENDOR] = data.get("Manufacturer", "")
+ hw_facts[SERIAL_NUMBER] = data.get("Serial Number", "")
+ hw_facts[HARDWARE_MODEL] = data.get("Product Name", "")
+ hw_facts[HARDWARE_PART_NUMBER] = data.get("Part Number", "")
+ hw_facts[HARDWARE_VERSION] = data.get("Diag Version", "")
+
+ # adding OLT software details to dictionary
+ sw_facts[OPERATING_SYSTEM] = OS_NAME
+ sw_facts[OPERATING_SYSTEM_VERSION] = os_version
+ sw_facts[ONIE_VERSION] = data.get('ONIE Version', "")
+ sw_facts[BAL_VER] = bal_v
+ sw_facts[OPENOLT_VER] = openolt_v
+
+ # adding OLT hardware and software information to OLT_INFORMATION dictionary
+ OLT_INFORMATION[SOFTWARE_INFORMATION] = sw_facts
+ OLT_INFORMATION[HARDWARE_INFORMATION] = hw_facts
+
+ # converting OLT information to json object
+ olt_json_string = json.dumps(OLT_INFORMATION)
+
+ except (TypeError, NameError) as exception:
+ syslog.syslog(syslog.LOG_ERR, "error-serializing-to-json-data-{}".format(exception))
+ return None
+
+ return olt_json_string
+
+
+if __name__ == "__main__":
+ str_data = fetch_olt_info()
+ if str_data is not None:
+ print(str_data)
+ syslog.syslog(syslog.LOG_INFO, "successfull-execution-printing-OLT-information")
+ exit(0)
+ else:
+ print("error-occurred-exiting")
+ syslog.syslog(syslog.LOG_ERR, "error-occurred-exiting")
+ exit(1)
diff --git a/agent/inband/scripts/start_inband_oltservices.sh b/agent/inband/scripts/start_inband_oltservices.sh
new file mode 100644
index 0000000..4a8b433
--- /dev/null
+++ b/agent/inband/scripts/start_inband_oltservices.sh
@@ -0,0 +1,587 @@
+#!/bin/bash
+
+#Copyright 2018-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.
+
+### BEGIN INIT INFO
+# Provides: start_inband_oltservices.sh
+# Required-Start: $all
+# Required-Stop: $network $local_fs $syslog
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Sets up inband management channel and starts device management and Openolt services
+# Description:
+# This script does the following things
+# 1) Extracts bal package and keep the files in appropriate paths.
+# 2) Starts svk_init which installs required drivers needed by the MAC devices
+# 3) Starts device management daemon which initializes all maple, qumran chip sets
+# and brings up access terminal.
+# 4) Sets up inband management channel
+# 5) Creates inband vlan tagged interface which will be used to communicate to
+# Openolt service from vOLTHA via NNI
+# 6) Sets up dhcp-client-identifier in "/etc/dhcp/dhclient.conf" for each inband
+# tagged interface so that it can obtain IP address from DHCP server
+# 7) Sets up DHCP IP configuration in "/etc/network/interfaces" for inband tagged
+# interface so that it can initiate DHCPREQUEST to DHCP server once network
+# restart triggered.
+# 8) Starts openolt service which enables all PON and NNI interfaces and creates
+# respective PON and NNI schedulers and Queues.
+### END INIT INFO
+
+#------------------------------------------------------------------------------
+# GLOBAL VARIABLES
+#------------------------------------------------------------------------------
+
+# Root path where required bal directories are located
+BRCM_OPT_DIR='/opt/bcm68620'
+BRCM_DIR='/broadcom'
+
+# olt service files
+SVK_INIT_FILE="${BRCM_OPT_DIR}/svk_init.sh"
+
+# vlan config file
+VLAN_CONFIG_FILE="${BRCM_DIR}/vlan.config"
+DHCLIENT_CONF="/etc/dhcp/dhclient.conf"
+
+# olt serial number
+SERIAL_NUMBER="/sys/devices/virtual/dmi/id/product_serial"
+
+OLT_MODEL=$(cat /sys/devices/virtual/dmi/id/board_name)
+NETWORK_INTERFACE="/etc/network/interfaces"
+BAL_OPENOLT_DEB_16="/openolt_asfvolt16.deb"
+BAL_OPENOLT_DEB_64="/openolt_asgvolt64.deb"
+
+DEV_MGMT_DAEMON="dev_mgmt_daemon -d -pcie"
+OPENOLT="openolt"
+ASFVOLT16="asfvolt16"
+ASGVOLT64="asgvolt64"
+ASF16_MODEL="ASXvOLT16"
+
+# vlan id for asfvolt16
+ASFVOLT16_VLAN_ID_ETH2=
+
+# vlan id for asgvolt64
+ASGVOLT64_VLAN_ID_ETH1=
+
+# File used to set/get argument to openolt service
+OPENOLT_ARG_INPUT_FILE=/etc/default/openolt
+
+# Wait time for BAL to get ready
+WAIT_TIME_BAL_READY=20
+
+#------------------------------------------------------------------------------
+# Function Name: does_logger_exist
+# Description:
+# This function check if logger exist and executable.
+#
+# Globals:
+# None
+#
+# Arguments:
+# None
+#
+# Returns:
+# returns 0 if exist and executable else 1
+#------------------------------------------------------------------------------
+does_logger_exist() {
+ cmd=/usr/bin/logger
+ if [ -x ${cmd} ]; then
+ return 0
+ else
+ return 1
+ fi
+}
+
+#------------------------------------------------------------------------------
+# Function Name: info_message
+# Description:
+# This function print the info message information to the console
+#
+# Globals:
+# None
+#
+# Arguments:
+# string message
+#
+# Returns:
+# None
+#------------------------------------------------------------------------------
+info_message() {
+ echo "INFO: $1"
+ logger -p user.info "$1"
+}
+
+#------------------------------------------------------------------------------
+# Function Name: error_message
+# Description:
+# This function print the error message information to the console
+#
+# Globals:
+# None
+#
+# Arguments:
+# string message
+#
+# Returns:
+# returns 1
+#------------------------------------------------------------------------------
+error_message() {
+ echo "ERROR: $1"
+ logger -p user.err "$1"
+ return 1
+}
+
+#------------------------------------------------------------------------------
+# Function Name: get_vlan_ids
+# Description:
+# This function facilitates to fetch vlan id from vlan configuration file
+# located at /broadcom/vlan.config
+#
+# Globals:
+# VLAN_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 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}')
+ 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"
+ fi
+}
+
+#------------------------------------------------------------------------------
+# Function Name: setup_nw_configuration
+# Description:
+# This function read the "/broadcom/vlan.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
+#
+# Arguments:
+# None
+#
+# Returns:
+# None
+#------------------------------------------------------------------------------
+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 [ "${OLT_MODEL}" = ${ASF16_MODEL} ]; then
+ set_dhcp_ip_configuration eth2 ${ASFVOLT16_VLAN_ID_ETH2}
+ else
+ set_dhcp_ip_configuration eth1 ${ASGVOLT64_VLAN_ID_ETH1}
+ fi
+ # Restart the networking services
+ /etc/init.d/networking restart
+}
+
+#------------------------------------------------------------------------------
+# Function Name: set_dhcp_ip_configuration
+# Description:
+# This function facilitates setup_nw_configuration function and accepts interface
+# vlan id as an argumnet to modify network interfaces file
+#
+# Globals:
+# None
+#
+# Arguments:
+# None
+#
+# Returns:
+# None
+#------------------------------------------------------------------------------
+set_dhcp_ip_configuration() {
+ interface=$1
+ 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}
+ fi
+}
+
+#------------------------------------------------------------------------------
+# Function Name: start_dev_mgmt_service
+# Description:
+# This function starts svk_init.sh script and device management service.
+# Device management service initializes all maple, qumran chip sets and
+# brings up access terminal.
+#
+# Globals:
+# SVK_INIT_FILE, BRCM_DIR, DEV_MGMT_DAEMON
+#
+# Arguments:
+# None
+#
+# Returns:
+# None
+#------------------------------------------------------------------------------
+start_dev_mgmt_service() {
+ info_message "Starting device management service"
+ chmod +x ${SVK_INIT_FILE}
+ ${SVK_INIT_FILE}
+
+ # starts the device_management deamon and openolt services
+ service dev_mgmt_daemon start
+ service dev_mgmt_daemon status
+ if [ $? -eq 0 ]; then
+ info_message "${DEV_MGMT_DAEMON} service is running"
+ setup_inband_mgmt_channel
+ else
+ error_message "${DEV_MGMT_DAEMON} is not running"
+ exit 1
+ fi
+}
+
+#------------------------------------------------------------------------------
+# Function Name: setup_inband_mgmt_channel
+# Description:
+# This function sets up inband management channel.
+#
+# Globals:
+# BRCM_DIR, ASFVOLT16_VLAN_ID_ETH2, ASGVOLT64_VLAN_ID_ETH1
+#
+# Arguments:
+# None
+#
+# Returns:
+# None
+#------------------------------------------------------------------------------
+setup_inband_mgmt_channel() {
+ local interface_type="inband"
+
+ # Extracting vlan ids from file
+ get_vlan_ids
+
+ cd ${BRCM_DIR}
+ if [ "${OLT_MODEL}" = ${ASF16_MODEL} ]; then
+ # Waiting till interface eth2 get initialized & RUNNING state
+ check_interface_is_up eth2 $interface_type
+
+ # wait for BAL to get ready
+ sleep WAIT_TIME_BAL_READY
+
+ # enabling in-band communication through broadcom API on NIC interface id 14 for eth2 interface
+ echo "/Api/Set object=inband_mgmt_channel id=0 nni_intf={intf_type=nni intf_id=0} nic_intf_id=14 \
+ vlan_id=${ASFVOLT16_VLAN_ID_ETH2} action=none" | ./example_user_appl
+ if [ $? -ne 0 ]; then
+ error_message "Failed to enable in-band channel on NIC interface id 14 with vlan ${ASFVOLT16_VLAN_ID_ETH2}"
+ fi
+ else
+ # Waiting till interface eth1 get initialized & RUNNING state
+ check_interface_is_up eth1 $interface_type
+ # wait for BAL to get ready
+ sleep WAIT_TIME_BAL_READY
+ # enabling in-band communication through broadcom API on NIC interface id 14 for eth1 interface
+ echo "/Api/Set object=inband_mgmt_channel id=0 nni_intf={intf_type=nni intf_id=0} nic_intf_id=14 \
+ vlan_id=${ASGVOLT64_VLAN_ID_ETH1} action=none" | ./example_user_appl
+ if [ $? -ne 0 ]; then
+ error_message "Failed to enable in-band channel on NIC interface id 14 with vlan ${ASGVOLT64_VLAN_ID_ETH1}"
+ fi
+ fi
+}
+
+#------------------------------------------------------------------------------
+# Function Name: create_vlan_tagged_Iface
+# Description:
+# This function create the VLAN interfaces and brings them UP.
+#
+# Globals:
+# ASFVOLT16_VLAN_ID_ETH2, ASGVOLT64_VLAN_ID_ETH1
+#
+# Arguments:
+# None
+#
+# Returns:
+# None
+#------------------------------------------------------------------------------
+create_vlan_tagged_Iface() {
+ if [ "${OLT_MODEL}" = ${ASF16_MODEL} ]; then
+ # Adding vlan to the interface eth2
+ ip link add link eth2 name eth2.${ASFVOLT16_VLAN_ID_ETH2} type vlan id ${ASFVOLT16_VLAN_ID_ETH2}
+ ifconfig eth2.${ASFVOLT16_VLAN_ID_ETH2} up
+ else
+ # Adding vlan to the interface eth1
+ ip link add link eth1 name eth1.${ASGVOLT64_VLAN_ID_ETH1} type vlan id ${ASGVOLT64_VLAN_ID_ETH1}
+ ifconfig eth1.${ASGVOLT64_VLAN_ID_ETH1} up
+ fi
+ info_message "Inband tagged interfaces created succesfully"
+}
+
+#------------------------------------------------------------------------------
+# Function Name: setup_dhcpd_configuration
+# Description:
+# This function updates /etc/dhcp/dhclient.conf file for dhcp
+# request for eth2.ASFVOLT16_VLAN_ID_ETH2, eth3.ASFVOLT16_VLAN_ID_ETH3,
+# eth1.ASGVOLT64_VLAN_ID_ETH1 and eth2.ASGVOLT64_VLAN_ID_ETH2 interfaces
+#
+# Globals:
+# ASFVOLT16_VLAN_ID_ETH2, ASFVOLT16_VLAN_ID_ETH3, ASGVOLT64_VLAN_ID_ETH1,
+# ASGVOLT64_VLAN_ID_ETH2, DHCLIENT_CONF
+#
+# Arguments:
+# None
+#
+# Returns:
+# None
+#------------------------------------------------------------------------------
+setup_dhcpd_configuration() {
+ if [ -f ${DHCLIENT_CONF} ]; then
+ if [ -f ${SERIAL_NUMBER} ]; then
+ serial_num=$(cat ${SERIAL_NUMBER})
+ if [ "${OLT_MODEL}" = ${ASF16_MODEL} ]; then
+ # dhcient.conf file should have only one entry for eth2.<ASFVOLT16_VLAN_ID_ETH2> interface
+ set_dhclient_configuration eth2 ${ASFVOLT16_VLAN_ID_ETH2}
+ else
+ # dhcient.conf file should have only one entry for eth1.<ASGVOLT64_VLAN_ID_ETH1> interface
+ set_dhclient_configuration eth1 ${ASGVOLT64_VLAN_ID_ETH1}
+ fi
+ else
+ error_message "ERROR: serial number of olt not found"
+ fi
+ else
+ error_message "ERROR: DHCP config file not found"
+ fi
+}
+
+#------------------------------------------------------------------------------
+# Function Name: set_dhclient_configuration
+# Description:
+# This function updates dhclient conf file with in-band interfaces.
+#
+# Globals:
+# None
+#
+# Arguments:
+# None
+#
+# Returns:
+# None
+#------------------------------------------------------------------------------
+set_dhclient_configuration() {
+ interface=$1
+ vlan_id=$2
+ grep -q "interface \"${interface}.${vlan_id}\"" $DHCLIENT_CONF
+ if [ $? -ne 0 ]; then
+ echo "interface \"${interface}.${vlan_id}\" {" >>$DHCLIENT_CONF
+ echo " send dhcp-client-identifier \"${serial_num}.${vlan_id}\";" >>$DHCLIENT_CONF
+ echo "}" >>$DHCLIENT_CONF
+ fi
+}
+
+#------------------------------------------------------------------------------
+# Function Name: check_interface_is_up
+# Description:
+# This function checks if provided inband interface is up and running
+#
+# Globals:
+# None
+#
+# Arguments:
+# None
+#
+# Returns:
+# None
+#------------------------------------------------------------------------------
+check_interface_is_up()
+{
+ interface=$1
+ interface_type=$2
+ count=0
+
+ while true; do
+ if [ $interface_type = "inband" ]; then
+ ifconfig ${interface} | grep 'RUNNING' &>/dev/null
+ if [ $? -eq 0 ]; then
+ info_message "${interface} is up and running"
+ break
+ fi
+ elif [ $interface_type = "inband-tagged" ]; then
+ while true; do
+ ifconfig ${interface} | grep 'RUNNING' &>/dev/null
+ if [ $? -eq 0 ]; then
+ ip=$(ifconfig $interface | grep "inet addr" | cut -d ':' -f 2 | cut -d ' ' -f 1)
+ if [ ! -z "$ip" ]; then
+ info_message "${interface} is up and running with valid IP address"
+ return 0
+ else
+ info_message "Inband interface ${interface} is not up, continuously retrying for DHCP IP assignment"
+ info_message "Inband interface ${interface} is not up with valid IP hence not starting openolt service"
+ sleep 10
+ continue
+ fi
+ fi
+ done
+ fi
+ done
+}
+
+#------------------------------------------------------------------------------
+# Function Name: stop_olt_services
+# Description:
+# This function informs about inband interface error status and stops device management service.
+#
+# Globals:
+# None
+#
+# Arguments:
+# None
+#
+# Returns:
+# None
+#------------------------------------------------------------------------------
+stop_olt_services()
+{
+ error_message "Inband tagged interface $1 is not up with valid IP address"
+ info_message "Not starting openolt service and stopping device menagement service"
+ service dev_mgmt_daemon stop
+ exit 1
+}
+
+#------------------------------------------------------------------------------
+# Function Name: start_openolt_service
+# Description:
+# This function checks whether inband interfaces are up with IP address, then
+# appends inband interface name to a file which later will be used by openolt
+# service as command line option then starts openolt service.
+# Openolt service enables all PON and NNI interfaces and creates respective PON
+# and NNI schedulers and Queues.
+#
+# Globals:
+# None
+#
+# Arguments:
+# None
+#
+# Returns:
+# None
+#------------------------------------------------------------------------------
+start_openolt_service()
+{
+ info_message "Starting openolt service"
+ local interface_type="inband-tagged"
+
+ if [ "${OLT_MODEL}" = ${ASF16_MODEL} ]; then
+ check_interface_is_up eth2.${ASFVOLT16_VLAN_ID_ETH2} $interface_type
+ if [ $? -ne 0 ]; then stop_olt_services eth2.${ASFVOLT16_VLAN_ID_ETH2}; fi
+ openolt_grpc_interface=eth2.${ASFVOLT16_VLAN_ID_ETH2}
+ else
+ check_interface_is_up eth1.${ASGVOLT64_VLAN_ID_ETH1} $interface_type
+ if [ $? -ne 0 ]; then stop_olt_services eth1.${ASGVOLT64_VLAN_ID_ETH1}; fi
+ openolt_grpc_interface=eth1.${ASGVOLT64_VLAN_ID_ETH1}
+ fi
+
+ # Inband interface name appended to this file. Interface name will be
+ # used as command line argument by openolt service while running the binary.
+ if [ -f "$OPENOLT_ARG_INPUT_FILE" ]; then
+ info_message "$OPENOLT_ARG_INPUT_FILE exist"
+ echo "gRPC_interface=$openolt_grpc_interface" > $OPENOLT_ARG_INPUT_FILE
+ else
+ info_message "$OPENOLT_ARG_INPUT_FILE does not exist, creating it"
+ touch $OPENOLT_ARG_INPUT_FILE
+ echo "gRPC_interface=$openolt_grpc_interface" > $OPENOLT_ARG_INPUT_FILE
+ fi
+
+ service openolt start
+ service openolt status
+ if [ $? -eq 0 ]; then
+ info_message "${OPENOLT} service is running"
+ else
+ error_message "${OPENOLT} is not running"
+ exit 1
+ fi
+}
+
+#------------------------------------------------------------------------------
+# Function Name: start_olt_services
+# Description:
+# This function triggers services to create vlan interfaces, to run BAL services
+# and to trigger DHCP requets on eth2.VLAN_ID_1 and eth3.VLAN_ID_2 interfaces.
+#
+# Globals:
+# None
+#
+# Arguments:
+# None
+#
+# Returns:
+# None
+#------------------------------------------------------------------------------
+start_olt_services() {
+ start_dev_mgmt_service
+ create_vlan_tagged_Iface
+ setup_dhcpd_configuration
+ setup_nw_configuration
+ start_openolt_service
+}
+
+#------------------------------------------------------------------------------
+# Function Name: copy_config_files
+# Description:
+# This function copy config files to /broadcom directory
+#
+# Globals:
+# BRCM_DIR
+#
+# Arguments:
+# None
+#
+# Returns:
+# None
+#------------------------------------------------------------------------------
+copy_config_files() {
+ info_message "copying config files to ${BRCM_DIR}"
+ # if [ "${OLT_MODEL}" != ${ASF16_MODEL} ]; then
+ # [ -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}/"
+}
+
+# Execution starts from here
+does_logger_exist
+if [ $? -eq 0 ]; then
+ if [ "${OLT_MODEL}" = ${ASF16_MODEL} ]; then
+ # check if debian package is already installed.
+ dpkg -l | grep ${ASFVOLT16}
+ if [ $? -ne 0 ]; then
+ # installs openolt debian package for asfvolt16 model
+ dpkg -i ${BAL_OPENOLT_DEB_16}
+ fi
+ else
+ dpkg -l | grep ${ASGVOLT64}
+ if [ $? -ne 0 ]; then
+ # installs openolt debian package for asgvolt64 model
+ dpkg -i ${BAL_OPENOLT_DEB_64}
+ fi
+ fi
+ copy_config_files
+ start_olt_services
+else
+ error_message "logger does not exist"
+ exit 1
+fi
diff --git a/agent/inband/scripts/validate_onl_installation.sh b/agent/inband/scripts/validate_onl_installation.sh
new file mode 100644
index 0000000..8cbccbc
--- /dev/null
+++ b/agent/inband/scripts/validate_onl_installation.sh
@@ -0,0 +1,338 @@
+#!/bin/bash
+
+#Copyright 2018-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.
+
+### BEGIN INIT INFO
+# Provides: validate_onl_installation.sh
+# Required-Start: $all
+# Required-Stop: $network $local_fs $syslog
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: This script validates ONL installation by checking if expected interfaces and
+# services are UP and RUNNING.
+# Description:
+# Following are the interafces and services considered for validation:
+# 1. Based on the device type(asfvolt16/asgvolt64) this script validates whether
+# eth2.<VLAN_ID>/eth1.<VLAN_ID> is up and running
+# 3. Validate system services
+# a. openolt driver
+# b. dev_mgmt_daemon
+# c. onlp
+# d. sshd
+# e. dhclient
+# returns the current status if service is up or not.
+### END INIT INFO
+
+#------------------------------------------------------------------------------
+# GLOBAL VARIABLES
+#------------------------------------------------------------------------------
+
+# Time interval in seconds to execute each function call for validation.
+TIME_INTERVAL=2
+
+# Total time required to validate all services.
+TOTAL_VALIDATION_TIME=20
+
+# Root path where required bal directories are located
+BRCM_DIR='/broadcom'
+
+# Path to vlan config file
+VLAN_CONFIG_FILE="${BRCM_DIR}/vlan.config"
+
+# vlan id for asfvolt16
+ASFVOLT16_VLAN_ID_ETH2=
+
+# vlan id for asgvolt64
+ASGVOLT64_VLAN_ID_ETH1=
+
+OLT_MODEL=$(cat /sys/devices/virtual/dmi/id/board_name)
+ASF16_MODEL="ASXvOLT16"
+# interfaces
+ETH1=eth1
+ETH2=eth2
+
+#------------------------------------------------------------------------------
+# Function Name: does_logger_exist
+# Description:
+# This function check if logger exist and executable.
+#
+# Globals:
+# None
+#
+# Arguments:
+# None
+#
+# Returns:
+# returns 0 if exist and executable else 1
+#------------------------------------------------------------------------------
+does_logger_exist()
+{
+cmd=/usr/bin/logger
+if [ -x ${cmd} ]; then
+ return 0
+ else
+ return 1
+ fi
+}
+
+#------------------------------------------------------------------------------
+# Function Name: info_message
+# Description:
+# This function print the info message information to the console
+#
+# Globals:
+# None
+#
+# Arguments:
+# string message
+#
+# Returns:
+# None
+#------------------------------------------------------------------------------
+info_message()
+{
+ echo "INFO: $1"
+ logger -p user.info "$1"
+}
+
+#------------------------------------------------------------------------------
+# Function Name: error_message
+# Description:
+# This function print the error message information to the console
+#
+# Globals:
+# None
+#
+# Arguments:
+# string message
+#
+# Returns:
+# returns 1
+#------------------------------------------------------------------------------
+error_message()
+{
+ echo "ERROR: $1"
+ logger -p user.err "$1"
+ return 1
+}
+
+#------------------------------------------------------------------------------
+# Function Name: is_interface_up_running
+# Description:
+# This function validate the interface whether it is UP and RUNNING or DOWN.
+#
+# Globals:
+# None
+#
+# Arguments:
+# interface name
+#
+# Returns:
+# returns 0 if interface is up and running and returns 1 if interface is down
+#------------------------------------------------------------------------------
+is_interface_up_running()
+{
+ info_message "Validating interface - $1"
+ interface_name=$1
+ ifconfig ${interface_name} | grep -q "UP BROADCAST RUNNING MULTICAST"
+ if [ $? -eq 0 ]; then
+ info_message "${interface_name} UP & RUNNING"
+ echo "---------------------------------------------------------------------"
+ return 0
+ else
+ error_message "${interface_name} is DOWN"
+ echo "---------------------------------------------------------------------"
+ return 1
+ fi
+}
+
+#------------------------------------------------------------------------------
+# Function Name : validate_interfaces
+# Description:
+# This function validate interfaces ${ETH2}.${ASFVOLT16_VLAN_ID_ETH2} and
+# ${ETH3}.${ASFVOLT16_VLAN_ID_ETH3} or ${ETH1}.${ASGVOLT64_VLAN_ID_ETH1} and
+# ${ETH2}.${ASGVOLT64_VLAN_ID_ETH2} based on OLT model.
+# Basically it validates if these interfaces are UP and RUNNING or not
+#
+# Globals:
+# ASFVOLT16_VLAN_ID_ETH2, ASFVOLT16_VLAN_ID_ETH3, ASGVOLT64_VLAN_ID_ETH1,
+# ASGVOLT64_VLAN_ID_ETH2, ETH1, ETH2, ETH3
+#
+#
+# Arguments:
+# None
+#
+# Returns:
+# return 1 if interface are down else returns 0
+#------------------------------------------------------------------------------
+validate_interfaces()
+{
+ # Validating interfaces whether they are UP and RUNNING or not
+ if [ "${OLT_MODEL}" = ${ASF16_MODEL} ]; then
+ is_interface_up_running ${ETH2}.${ASFVOLT16_VLAN_ID_ETH2}
+ if [ $? -eq 0 ]; then
+ return 0
+ else
+ return 1
+ fi
+ else
+ is_interface_up_running ${ETH1}.${ASGVOLT64_VLAN_ID_ETH1}
+ if [ $? -eq 0 ]; then
+ return 0
+ else
+ return 1
+ fi
+ fi
+}
+
+#------------------------------------------------------------------------------
+# Function Name: validate_system_services
+# Description:
+# This function checks if the below services/processes are running or not.
+# 1. dev_mgmt_daemon
+# 2. openolt
+# 3. onlp
+# 4. sshd
+# 5. dhclient
+# Globals:
+# ASFVOLT16_VLAN_ID_ETH2, ASFVOLT16_VLAN_ID_ETH3, ASGVOLT64_VLAN_ID_ETH1,
+# ASGVOLT64_VLAN_ID_ETH2, ETH1, ETH2, ETH3
+#
+#
+# Arguments:
+# None
+#
+# Returns:
+# returns 0
+#------------------------------------------------------------------------------
+validate_system_services()
+{
+ echo "---------------------------------------------------------------------"
+ echo "Validating Services"
+ echo "---------------------------------------------------------------------"
+
+ dhclient_interface dhclient_val1
+ for service_name in dev_mgmt_daemon openolt onlpd ssh ${dhclient_val1}
+ do
+ echo "---------------------------------------------------------------------"
+ ps -ef | grep -v grep | grep ${service_name}
+ #service ${service_name} status
+ if [ $? -eq 0 ]; then
+ info_message "${service_name} service is running"
+ else
+ error_message "${service_name} is not running"
+ return 1
+ fi
+ echo "---------------------------------------------------------------------"
+ done
+ return 0
+}
+
+#------------------------------------------------------------------------------
+# Function Name: dhclient_interface
+# Description:
+# This function sets values to which tagged interface dhclient service need
+# to be tested based on the OLT model package.
+#
+# Globals:
+# ASFVOLT16_VLAN_ID_ETH2, ASFVOLT16
+# ASGVOLT64_VLAN_ID_ETH1, ETH1, ETH2
+#
+# Arguments:
+# None
+#
+# Returns:
+# None
+#------------------------------------------------------------------------------
+dhclient_interface()
+{
+ local value1=$1
+ if [ "${OLT_MODEL}" = ${ASF16_MODEL} ]; then
+ dhclient1=dhclient.${ETH2}.${ASFVOLT16_VLAN_ID_ETH2}
+ eval $value1="'$dhclient1'"
+ else
+ dhclient2=dhclient.${ETH1}.${ASGVOLT64_VLAN_ID_ETH1}
+ eval $value1="'$dhclient2'"
+ fi
+
+}
+
+#------------------------------------------------------------------------------
+# Function Name: check_services
+# Description:
+# This function checks if the expected services like onlp, sshd, dev_mgmt_daemon, dhclient
+# and also checks that physical and vlan interfaces are up.
+# This script times out and returns an error code of 1 if all vaildations don't turn out to be successful
+# in counter a number is equal to 20
+#
+# Globals:
+# VLAN_CONFIG_FILE, ASFVOLT16_VLAN_ID_ETH2, ASGVOLT64_VLAN_ID_ETH1,
+# TIME_INTERVAL, ASFVOLT16
+#
+# Arguments:
+# None
+#
+# Returns:
+# None
+#------------------------------------------------------------------------------
+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 [ "${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"
+ exit 1
+ fi
+ else
+ if [ ${ASGVOLT64_VLAN_ID_ETH1} -gt 4094 ] || [ ${ASGVOLT64_VLAN_ID_ETH1} -lt 1 ]; then
+ error_message "vlan ids not in range"
+ exit 1
+ fi
+ fi
+ else
+ error_message "${VLAN_CONFIG_FILE} does not exist"
+ exit 1
+ fi
+ echo "*********************************************************************"
+ info_message "Validating ONL Installation"
+ echo "*********************************************************************"
+ for func_name in validate_interfaces validate_system_services
+ do
+ counter=0
+ while true; do
+ sleep ${TIME_INTERVAL}
+ $func_name
+ if [ $? -eq 0 ]; then
+ break
+ fi
+ if [ $counter -eq $TOTAL_VALIDATION_TIME ]; then
+ error_message "Time out ,vlan interfaces or all services may not be up"
+ return 1
+ fi
+ counter=$((counter+${TIME_INTERVAL}))
+ done
+ done
+ return 0
+}
+
+does_logger_exist
+if [ $? -eq 0 ]; then
+ check_services
+else
+ error_message "logger does not exist"
+ exit 1
+fi