Thiyagarajan Subramani | e84935d | 2020-04-23 17:45:44 +0530 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | #Copyright 2018-present Open Networking Foundation |
| 4 | # |
| 5 | #Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | #you may not use this file except in compliance with the License. |
| 7 | #You may obtain a copy of the License at |
| 8 | # |
| 9 | #http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | #Unless required by applicable law or agreed to in writing, software |
| 12 | #distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | #WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | #See the License for the specific language governing permissions and |
| 15 | #limitations under the License. |
| 16 | |
| 17 | ### BEGIN INIT INFO |
| 18 | # Provides: start_inband_oltservices.sh |
| 19 | # Required-Start: $all |
| 20 | # Required-Stop: $network $local_fs $syslog |
| 21 | # Default-Start: 2 3 4 5 |
| 22 | # Default-Stop: 0 1 6 |
| 23 | # Short-Description: Sets up inband management channel and starts device management and Openolt services |
| 24 | # Description: |
| 25 | # This script does the following things |
| 26 | # 1) Extracts bal package and keep the files in appropriate paths. |
| 27 | # 2) Starts svk_init which installs required drivers needed by the MAC devices |
| 28 | # 3) Starts device management daemon which initializes all maple, qumran chip sets |
| 29 | # and brings up access terminal. |
| 30 | # 4) Sets up inband management channel |
| 31 | # 5) Creates inband vlan tagged interface which will be used to communicate to |
| 32 | # Openolt service from vOLTHA via NNI |
| 33 | # 6) Sets up dhcp-client-identifier in "/etc/dhcp/dhclient.conf" for each inband |
| 34 | # tagged interface so that it can obtain IP address from DHCP server |
| 35 | # 7) Sets up DHCP IP configuration in "/etc/network/interfaces" for inband tagged |
| 36 | # interface so that it can initiate DHCPREQUEST to DHCP server once network |
| 37 | # restart triggered. |
| 38 | # 8) Starts openolt service which enables all PON and NNI interfaces and creates |
| 39 | # respective PON and NNI schedulers and Queues. |
| 40 | ### END INIT INFO |
| 41 | |
| 42 | #------------------------------------------------------------------------------ |
| 43 | # GLOBAL VARIABLES |
| 44 | #------------------------------------------------------------------------------ |
| 45 | |
| 46 | # Root path where required bal directories are located |
| 47 | BRCM_OPT_DIR='/opt/bcm68620' |
| 48 | BRCM_DIR='/broadcom' |
| 49 | |
| 50 | # olt service files |
| 51 | SVK_INIT_FILE="${BRCM_OPT_DIR}/svk_init.sh" |
| 52 | |
Girish Gowdra | 6e74552 | 2020-07-15 15:52:13 -0700 | [diff] [blame] | 53 | # inband config file |
| 54 | INBAND_CONFIG_FILE="${BRCM_DIR}/inband.config" |
Thiyagarajan Subramani | e84935d | 2020-04-23 17:45:44 +0530 | [diff] [blame] | 55 | DHCLIENT_CONF="/etc/dhcp/dhclient.conf" |
| 56 | |
| 57 | # olt serial number |
| 58 | SERIAL_NUMBER="/sys/devices/virtual/dmi/id/product_serial" |
| 59 | |
| 60 | OLT_MODEL=$(cat /sys/devices/virtual/dmi/id/board_name) |
| 61 | NETWORK_INTERFACE="/etc/network/interfaces" |
| 62 | BAL_OPENOLT_DEB_16="/openolt_asfvolt16.deb" |
| 63 | BAL_OPENOLT_DEB_64="/openolt_asgvolt64.deb" |
| 64 | |
| 65 | DEV_MGMT_DAEMON="dev_mgmt_daemon -d -pcie" |
| 66 | OPENOLT="openolt" |
| 67 | ASFVOLT16="asfvolt16" |
| 68 | ASGVOLT64="asgvolt64" |
| 69 | ASF16_MODEL="ASXvOLT16" |
Humera Kouser | 4a663fe | 2020-09-23 04:33:54 -0400 | [diff] [blame] | 70 | EDGECORE="edgecore" |
Thiyagarajan Subramani | e84935d | 2020-04-23 17:45:44 +0530 | [diff] [blame] | 71 | |
| 72 | # vlan id for asfvolt16 |
| 73 | ASFVOLT16_VLAN_ID_ETH2= |
| 74 | |
| 75 | # vlan id for asgvolt64 |
| 76 | ASGVOLT64_VLAN_ID_ETH1= |
| 77 | |
| 78 | # File used to set/get argument to openolt service |
| 79 | OPENOLT_ARG_INPUT_FILE=/etc/default/openolt |
| 80 | |
Thiyagarajan Subramani | e84935d | 2020-04-23 17:45:44 +0530 | [diff] [blame] | 81 | #------------------------------------------------------------------------------ |
| 82 | # Function Name: does_logger_exist |
| 83 | # Description: |
| 84 | # This function check if logger exist and executable. |
| 85 | # |
| 86 | # Globals: |
| 87 | # None |
| 88 | # |
| 89 | # Arguments: |
| 90 | # None |
| 91 | # |
| 92 | # Returns: |
| 93 | # returns 0 if exist and executable else 1 |
| 94 | #------------------------------------------------------------------------------ |
| 95 | does_logger_exist() { |
| 96 | cmd=/usr/bin/logger |
| 97 | if [ -x ${cmd} ]; then |
| 98 | return 0 |
| 99 | else |
| 100 | return 1 |
| 101 | fi |
| 102 | } |
| 103 | |
| 104 | #------------------------------------------------------------------------------ |
| 105 | # Function Name: info_message |
| 106 | # Description: |
| 107 | # This function print the info message information to the console |
| 108 | # |
| 109 | # Globals: |
| 110 | # None |
| 111 | # |
| 112 | # Arguments: |
| 113 | # string message |
| 114 | # |
| 115 | # Returns: |
| 116 | # None |
| 117 | #------------------------------------------------------------------------------ |
| 118 | info_message() { |
| 119 | echo "INFO: $1" |
| 120 | logger -p user.info "$1" |
| 121 | } |
| 122 | |
| 123 | #------------------------------------------------------------------------------ |
| 124 | # Function Name: error_message |
| 125 | # Description: |
| 126 | # This function print the error message information to the console |
| 127 | # |
| 128 | # Globals: |
| 129 | # None |
| 130 | # |
| 131 | # Arguments: |
| 132 | # string message |
| 133 | # |
| 134 | # Returns: |
| 135 | # returns 1 |
| 136 | #------------------------------------------------------------------------------ |
| 137 | error_message() { |
| 138 | echo "ERROR: $1" |
| 139 | logger -p user.err "$1" |
| 140 | return 1 |
| 141 | } |
| 142 | |
| 143 | #------------------------------------------------------------------------------ |
| 144 | # Function Name: get_vlan_ids |
| 145 | # Description: |
Girish Gowdra | 6e74552 | 2020-07-15 15:52:13 -0700 | [diff] [blame] | 146 | # This function facilitates to fetch vlan id from inband configuration file |
| 147 | # located at /broadcom/inband.config |
Thiyagarajan Subramani | e84935d | 2020-04-23 17:45:44 +0530 | [diff] [blame] | 148 | # |
| 149 | # Globals: |
Girish Gowdra | 6e74552 | 2020-07-15 15:52:13 -0700 | [diff] [blame] | 150 | # INBAND_CONFIG_FILE, ASFVOLT16_VLAN_ID_ETH2, ASFVOLT16_VLAN_ID_ETH3, |
Thiyagarajan Subramani | e84935d | 2020-04-23 17:45:44 +0530 | [diff] [blame] | 151 | # ASGVOLT64_VLAN_ID_ETH1, ASGVOLT64_VLAN_ID_ETH2 |
| 152 | # |
| 153 | # Arguments: |
| 154 | # None |
| 155 | # |
| 156 | # Returns: |
| 157 | # None |
| 158 | #------------------------------------------------------------------------------ |
| 159 | get_vlan_ids() { |
Girish Gowdra | 6e74552 | 2020-07-15 15:52:13 -0700 | [diff] [blame] | 160 | # Read inband.config file to fetch vlan id information |
| 161 | if [ -f ${INBAND_CONFIG_FILE} ]; then |
| 162 | ASFVOLT16_VLAN_ID_ETH2=$(awk '/asfvolt16_vlan_id_eth2/{print $0}' ${INBAND_CONFIG_FILE} | awk -F "=" '{print $2}') |
| 163 | ASGVOLT64_VLAN_ID_ETH1=$(awk '/asgvolt64_vlan_id_eth1/{print $0}' ${INBAND_CONFIG_FILE} | awk -F "=" '{print $2}') |
Thiyagarajan Subramani | e84935d | 2020-04-23 17:45:44 +0530 | [diff] [blame] | 164 | if [ -z ${ASFVOLT16_VLAN_ID_ETH2} ] || [ -z ${ASGVOLT64_VLAN_ID_ETH1} ]; then |
| 165 | error_message "ERROR: vlan ids not valid" |
| 166 | exit 1 |
| 167 | fi |
| 168 | else |
Girish Gowdra | 6e74552 | 2020-07-15 15:52:13 -0700 | [diff] [blame] | 169 | error_message "ERROR: ${INBAND_CONFIG_FILE} not found, using default value 4093" |
| 170 | fi |
| 171 | } |
| 172 | |
| 173 | #------------------------------------------------------------------------------ |
| 174 | # Function Name: is_out_band_connection_enabled |
| 175 | # Description: |
| 176 | # This function checks if out-of-band connection is enabled by reading |
| 177 | # the enable_out_of_band_connection value in file /broadcom/inband.config |
| 178 | # |
| 179 | # Globals: |
| 180 | # |
| 181 | # Arguments: |
| 182 | # None |
| 183 | # |
| 184 | # Returns: |
| 185 | # true if out-of-band connection enabled, else false |
| 186 | #------------------------------------------------------------------------------ |
| 187 | is_out_band_connection_enabled() { |
| 188 | # Read inband.config file to fetch configurtion to enable or not the out-of-band connection to the OLT. |
| 189 | if [ -f ${INBAND_CONFIG_FILE} ]; then |
| 190 | ob_cfg=$(awk '/enable_out_of_band_connection/{print $0}' ${INBAND_CONFIG_FILE} | awk -F "=" '{print $2}') |
| 191 | if [ -z ${ob_cfg} ]; then |
| 192 | error_message "ERROR: missing configuration to enable out-of-band connection to OLT. Default to false" |
Humera Kouser | 9c2bd9f | 2020-09-25 02:41:29 -0400 | [diff] [blame] | 193 | echo "no" |
| 194 | elif [ "${ob_cfg}" = "yes" ]; then |
| 195 | echo "yes" |
Girish Gowdra | 6e74552 | 2020-07-15 15:52:13 -0700 | [diff] [blame] | 196 | elif [ "${ob_cfg}" = "no" ]; then |
Humera Kouser | 9c2bd9f | 2020-09-25 02:41:29 -0400 | [diff] [blame] | 197 | echo "no" |
Girish Gowdra | 6e74552 | 2020-07-15 15:52:13 -0700 | [diff] [blame] | 198 | else |
| 199 | error_message "ERROR: Invalid configuration to enable out-of-band connection -> ${ob_cfg}" |
Humera Kouser | 9c2bd9f | 2020-09-25 02:41:29 -0400 | [diff] [blame] | 200 | echo "no" |
Girish Gowdra | 6e74552 | 2020-07-15 15:52:13 -0700 | [diff] [blame] | 201 | fi |
Humera Kouser | 9c2bd9f | 2020-09-25 02:41:29 -0400 | [diff] [blame] | 202 | else |
| 203 | echo "no" |
Thiyagarajan Subramani | e84935d | 2020-04-23 17:45:44 +0530 | [diff] [blame] | 204 | fi |
| 205 | } |
| 206 | |
| 207 | #------------------------------------------------------------------------------ |
| 208 | # Function Name: setup_nw_configuration |
| 209 | # Description: |
Girish Gowdra | 6e74552 | 2020-07-15 15:52:13 -0700 | [diff] [blame] | 210 | # This function read the "/broadcom/inband.config" file to get VLAND IDs |
Thiyagarajan Subramani | e84935d | 2020-04-23 17:45:44 +0530 | [diff] [blame] | 211 | # for the interface eth1 and eth2 based on the OLT model and update |
| 212 | # these VLAN ID to /etc/network/interfaces file for dhcp request. |
| 213 | # Globals: |
Girish Gowdra | 6e74552 | 2020-07-15 15:52:13 -0700 | [diff] [blame] | 214 | # INBAND_CONFIG_FILE, ASFVOLT16_VLAN_ID_ETH2, ASGVOLT64_VLAN_ID_ETH1 |
Thiyagarajan Subramani | e84935d | 2020-04-23 17:45:44 +0530 | [diff] [blame] | 215 | # |
| 216 | # Arguments: |
| 217 | # None |
| 218 | # |
| 219 | # Returns: |
| 220 | # None |
| 221 | #------------------------------------------------------------------------------ |
| 222 | setup_nw_configuration() { |
| 223 | # Dynamic vlan entry in /etc/network/interfaces file |
Humera Kouser | 9c2bd9f | 2020-09-25 02:41:29 -0400 | [diff] [blame] | 224 | local is_out_band=$(is_out_band_connection_enabled) |
| 225 | if [ "${is_out_band}" = "yes" ]; then |
Girish Gowdra | 6e74552 | 2020-07-15 15:52:13 -0700 | [diff] [blame] | 226 | # This interface is used for out-of-band connection for the OLT |
| 227 | # This is not a mandatory requirement for in-band management of the OLT |
| 228 | set_dhcp_ip_configuration ma1 |
| 229 | fi |
| 230 | |
| 231 | # These interfaces are used for in-band management of the OLT |
Thiyagarajan Subramani | e84935d | 2020-04-23 17:45:44 +0530 | [diff] [blame] | 232 | if [ "${OLT_MODEL}" = ${ASF16_MODEL} ]; then |
| 233 | set_dhcp_ip_configuration eth2 ${ASFVOLT16_VLAN_ID_ETH2} |
| 234 | else |
| 235 | set_dhcp_ip_configuration eth1 ${ASGVOLT64_VLAN_ID_ETH1} |
| 236 | fi |
| 237 | # Restart the networking services |
| 238 | /etc/init.d/networking restart |
| 239 | } |
| 240 | |
| 241 | #------------------------------------------------------------------------------ |
| 242 | # Function Name: set_dhcp_ip_configuration |
| 243 | # Description: |
| 244 | # This function facilitates setup_nw_configuration function and accepts interface |
| 245 | # vlan id as an argumnet to modify network interfaces file |
| 246 | # |
| 247 | # Globals: |
| 248 | # None |
| 249 | # |
| 250 | # Arguments: |
| 251 | # None |
| 252 | # |
| 253 | # Returns: |
| 254 | # None |
| 255 | #------------------------------------------------------------------------------ |
| 256 | set_dhcp_ip_configuration() { |
| 257 | interface=$1 |
| 258 | vlan_id=$2 |
| 259 | grep -q "iface ${interface}.${vlan_id}" $NETWORK_INTERFACE |
| 260 | if [ $? -ne 0 ]; then |
Girish Gowdra | 6e74552 | 2020-07-15 15:52:13 -0700 | [diff] [blame] | 261 | if [ -z ${vlan_id} ]; then |
| 262 | echo "auto ${interface}" >>${NETWORK_INTERFACE} |
| 263 | echo "iface ${interface} inet dhcp" >>${NETWORK_INTERFACE} |
| 264 | else |
| 265 | echo "auto ${interface}.${vlan_id}" >>${NETWORK_INTERFACE} |
| 266 | echo "iface ${interface}.${vlan_id} inet dhcp" >>${NETWORK_INTERFACE} |
| 267 | fi |
Thiyagarajan Subramani | e84935d | 2020-04-23 17:45:44 +0530 | [diff] [blame] | 268 | fi |
| 269 | } |
| 270 | |
| 271 | #------------------------------------------------------------------------------ |
Girish Gowdra | 6e74552 | 2020-07-15 15:52:13 -0700 | [diff] [blame] | 272 | # Function Name: disable_autostart_of_openolt_and_dev_mgmt_daemon_processes |
| 273 | # Description: |
| 274 | # Disables autostart of openolt processes (openolt and dev_mgmt_daemon). |
| 275 | # The start of these openolt processes is now controlled through this script |
| 276 | # |
| 277 | # Globals: |
| 278 | # |
| 279 | # Arguments: |
| 280 | # None |
| 281 | # |
| 282 | # Returns: |
| 283 | # None |
| 284 | #------------------------------------------------------------------------------ |
| 285 | disable_autostart_of_openolt_and_dev_mgmt_daemon_processes() { |
| 286 | update-rc.d dev_mgmt_daemon disable |
| 287 | update-rc.d openolt disable |
| 288 | } |
| 289 | |
| 290 | #------------------------------------------------------------------------------ |
| 291 | # Function Name: stop_openolt_and_dev_mgmt_daemon_processes |
| 292 | # Description: |
| 293 | # Stop openolt processes (openolt and dev_mgmt_daemon) if they were running |
| 294 | # before |
| 295 | # |
| 296 | # Globals: |
| 297 | # |
| 298 | # Arguments: |
| 299 | # None |
| 300 | # |
| 301 | # Returns: |
| 302 | # None |
| 303 | #------------------------------------------------------------------------------ |
| 304 | stop_openolt_and_dev_mgmt_daemon_processes() { |
| 305 | service dev_mgmt_daemon stop |
| 306 | service openolt stop |
| 307 | } |
| 308 | |
| 309 | #------------------------------------------------------------------------------ |
| 310 | # Function Name: start_openolt_dev_mgmt_daemon_process_watchdog |
| 311 | # Description: |
| 312 | # Start openolt and dev_mgmt_daemon process watchdog |
| 313 | # |
| 314 | # Globals: |
| 315 | # |
| 316 | # Arguments: |
| 317 | # None |
| 318 | # |
| 319 | # Returns: |
| 320 | # None |
| 321 | #------------------------------------------------------------------------------ |
| 322 | start_openolt_dev_mgmt_daemon_process_watchdog() { |
| 323 | nohup bash /opt/openolt/openolt_dev_mgmt_daemon_process_watchdog & |
| 324 | } |
| 325 | |
| 326 | #------------------------------------------------------------------------------ |
Thiyagarajan Subramani | e84935d | 2020-04-23 17:45:44 +0530 | [diff] [blame] | 327 | # Function Name: start_dev_mgmt_service |
| 328 | # Description: |
| 329 | # This function starts svk_init.sh script and device management service. |
| 330 | # Device management service initializes all maple, qumran chip sets and |
| 331 | # brings up access terminal. |
| 332 | # |
| 333 | # Globals: |
| 334 | # SVK_INIT_FILE, BRCM_DIR, DEV_MGMT_DAEMON |
| 335 | # |
| 336 | # Arguments: |
| 337 | # None |
| 338 | # |
| 339 | # Returns: |
| 340 | # None |
| 341 | #------------------------------------------------------------------------------ |
| 342 | start_dev_mgmt_service() { |
| 343 | info_message "Starting device management service" |
| 344 | chmod +x ${SVK_INIT_FILE} |
| 345 | ${SVK_INIT_FILE} |
| 346 | |
| 347 | # starts the device_management deamon and openolt services |
| 348 | service dev_mgmt_daemon start |
| 349 | service dev_mgmt_daemon status |
| 350 | if [ $? -eq 0 ]; then |
| 351 | info_message "${DEV_MGMT_DAEMON} service is running" |
| 352 | setup_inband_mgmt_channel |
| 353 | else |
| 354 | error_message "${DEV_MGMT_DAEMON} is not running" |
| 355 | exit 1 |
| 356 | fi |
| 357 | } |
| 358 | |
| 359 | #------------------------------------------------------------------------------ |
| 360 | # Function Name: setup_inband_mgmt_channel |
| 361 | # Description: |
| 362 | # This function sets up inband management channel. |
| 363 | # |
| 364 | # Globals: |
| 365 | # BRCM_DIR, ASFVOLT16_VLAN_ID_ETH2, ASGVOLT64_VLAN_ID_ETH1 |
| 366 | # |
| 367 | # Arguments: |
| 368 | # None |
| 369 | # |
| 370 | # Returns: |
| 371 | # None |
| 372 | #------------------------------------------------------------------------------ |
| 373 | setup_inband_mgmt_channel() { |
| 374 | local interface_type="inband" |
| 375 | |
| 376 | # Extracting vlan ids from file |
| 377 | get_vlan_ids |
| 378 | |
| 379 | cd ${BRCM_DIR} |
| 380 | if [ "${OLT_MODEL}" = ${ASF16_MODEL} ]; then |
| 381 | # Waiting till interface eth2 get initialized & RUNNING state |
| 382 | check_interface_is_up eth2 $interface_type |
| 383 | |
| 384 | # wait for BAL to get ready |
Thiyagarajan Subramani | ef0aadb | 2020-06-24 16:47:49 +0530 | [diff] [blame] | 385 | sleep $WAIT_TIME_BAL_READY |
Thiyagarajan Subramani | e84935d | 2020-04-23 17:45:44 +0530 | [diff] [blame] | 386 | |
| 387 | # enabling in-band communication through broadcom API on NIC interface id 14 for eth2 interface |
| 388 | echo "/Api/Set object=inband_mgmt_channel id=0 nni_intf={intf_type=nni intf_id=0} nic_intf_id=14 \ |
| 389 | vlan_id=${ASFVOLT16_VLAN_ID_ETH2} action=none" | ./example_user_appl |
| 390 | if [ $? -ne 0 ]; then |
| 391 | error_message "Failed to enable in-band channel on NIC interface id 14 with vlan ${ASFVOLT16_VLAN_ID_ETH2}" |
| 392 | fi |
| 393 | else |
| 394 | # Waiting till interface eth1 get initialized & RUNNING state |
| 395 | check_interface_is_up eth1 $interface_type |
| 396 | # wait for BAL to get ready |
Thiyagarajan Subramani | ef0aadb | 2020-06-24 16:47:49 +0530 | [diff] [blame] | 397 | sleep $WAIT_TIME_BAL_READY |
Thiyagarajan Subramani | e84935d | 2020-04-23 17:45:44 +0530 | [diff] [blame] | 398 | # enabling in-band communication through broadcom API on NIC interface id 14 for eth1 interface |
| 399 | echo "/Api/Set object=inband_mgmt_channel id=0 nni_intf={intf_type=nni intf_id=0} nic_intf_id=14 \ |
| 400 | vlan_id=${ASGVOLT64_VLAN_ID_ETH1} action=none" | ./example_user_appl |
| 401 | if [ $? -ne 0 ]; then |
| 402 | error_message "Failed to enable in-band channel on NIC interface id 14 with vlan ${ASGVOLT64_VLAN_ID_ETH1}" |
| 403 | fi |
| 404 | fi |
| 405 | } |
| 406 | |
| 407 | #------------------------------------------------------------------------------ |
| 408 | # Function Name: create_vlan_tagged_Iface |
| 409 | # Description: |
| 410 | # This function create the VLAN interfaces and brings them UP. |
| 411 | # |
| 412 | # Globals: |
| 413 | # ASFVOLT16_VLAN_ID_ETH2, ASGVOLT64_VLAN_ID_ETH1 |
| 414 | # |
| 415 | # Arguments: |
| 416 | # None |
| 417 | # |
| 418 | # Returns: |
| 419 | # None |
| 420 | #------------------------------------------------------------------------------ |
| 421 | create_vlan_tagged_Iface() { |
| 422 | if [ "${OLT_MODEL}" = ${ASF16_MODEL} ]; then |
| 423 | # Adding vlan to the interface eth2 |
| 424 | ip link add link eth2 name eth2.${ASFVOLT16_VLAN_ID_ETH2} type vlan id ${ASFVOLT16_VLAN_ID_ETH2} |
| 425 | ifconfig eth2.${ASFVOLT16_VLAN_ID_ETH2} up |
| 426 | else |
| 427 | # Adding vlan to the interface eth1 |
| 428 | ip link add link eth1 name eth1.${ASGVOLT64_VLAN_ID_ETH1} type vlan id ${ASGVOLT64_VLAN_ID_ETH1} |
| 429 | ifconfig eth1.${ASGVOLT64_VLAN_ID_ETH1} up |
| 430 | fi |
| 431 | info_message "Inband tagged interfaces created succesfully" |
| 432 | } |
| 433 | |
| 434 | #------------------------------------------------------------------------------ |
| 435 | # Function Name: setup_dhcpd_configuration |
| 436 | # Description: |
| 437 | # This function updates /etc/dhcp/dhclient.conf file for dhcp |
| 438 | # request for eth2.ASFVOLT16_VLAN_ID_ETH2, eth3.ASFVOLT16_VLAN_ID_ETH3, |
| 439 | # eth1.ASGVOLT64_VLAN_ID_ETH1 and eth2.ASGVOLT64_VLAN_ID_ETH2 interfaces |
| 440 | # |
| 441 | # Globals: |
| 442 | # ASFVOLT16_VLAN_ID_ETH2, ASFVOLT16_VLAN_ID_ETH3, ASGVOLT64_VLAN_ID_ETH1, |
| 443 | # ASGVOLT64_VLAN_ID_ETH2, DHCLIENT_CONF |
| 444 | # |
| 445 | # Arguments: |
| 446 | # None |
| 447 | # |
| 448 | # Returns: |
| 449 | # None |
| 450 | #------------------------------------------------------------------------------ |
| 451 | setup_dhcpd_configuration() { |
| 452 | if [ -f ${DHCLIENT_CONF} ]; then |
| 453 | if [ -f ${SERIAL_NUMBER} ]; then |
| 454 | serial_num=$(cat ${SERIAL_NUMBER}) |
| 455 | if [ "${OLT_MODEL}" = ${ASF16_MODEL} ]; then |
| 456 | # dhcient.conf file should have only one entry for eth2.<ASFVOLT16_VLAN_ID_ETH2> interface |
| 457 | set_dhclient_configuration eth2 ${ASFVOLT16_VLAN_ID_ETH2} |
| 458 | else |
| 459 | # dhcient.conf file should have only one entry for eth1.<ASGVOLT64_VLAN_ID_ETH1> interface |
| 460 | set_dhclient_configuration eth1 ${ASGVOLT64_VLAN_ID_ETH1} |
| 461 | fi |
| 462 | else |
| 463 | error_message "ERROR: serial number of olt not found" |
| 464 | fi |
| 465 | else |
| 466 | error_message "ERROR: DHCP config file not found" |
| 467 | fi |
| 468 | } |
| 469 | |
| 470 | #------------------------------------------------------------------------------ |
| 471 | # Function Name: set_dhclient_configuration |
| 472 | # Description: |
| 473 | # This function updates dhclient conf file with in-band interfaces. |
| 474 | # |
| 475 | # Globals: |
| 476 | # None |
| 477 | # |
| 478 | # Arguments: |
| 479 | # None |
| 480 | # |
| 481 | # Returns: |
| 482 | # None |
| 483 | #------------------------------------------------------------------------------ |
| 484 | set_dhclient_configuration() { |
| 485 | interface=$1 |
| 486 | vlan_id=$2 |
| 487 | grep -q "interface \"${interface}.${vlan_id}\"" $DHCLIENT_CONF |
| 488 | if [ $? -ne 0 ]; then |
| 489 | echo "interface \"${interface}.${vlan_id}\" {" >>$DHCLIENT_CONF |
| 490 | echo " send dhcp-client-identifier \"${serial_num}.${vlan_id}\";" >>$DHCLIENT_CONF |
Humera Kouser | 4a663fe | 2020-09-23 04:33:54 -0400 | [diff] [blame] | 491 | echo " send vendor-class-identifier \"${EDGECORE}\";" >>$DHCLIENT_CONF |
Thiyagarajan Subramani | e84935d | 2020-04-23 17:45:44 +0530 | [diff] [blame] | 492 | echo "}" >>$DHCLIENT_CONF |
| 493 | fi |
| 494 | } |
| 495 | |
| 496 | #------------------------------------------------------------------------------ |
| 497 | # Function Name: check_interface_is_up |
| 498 | # Description: |
| 499 | # This function checks if provided inband interface is up and running |
| 500 | # |
| 501 | # Globals: |
| 502 | # None |
| 503 | # |
| 504 | # Arguments: |
| 505 | # None |
| 506 | # |
| 507 | # Returns: |
| 508 | # None |
| 509 | #------------------------------------------------------------------------------ |
| 510 | check_interface_is_up() |
| 511 | { |
| 512 | interface=$1 |
| 513 | interface_type=$2 |
| 514 | count=0 |
| 515 | |
| 516 | while true; do |
| 517 | if [ $interface_type = "inband" ]; then |
| 518 | ifconfig ${interface} | grep 'RUNNING' &>/dev/null |
| 519 | if [ $? -eq 0 ]; then |
| 520 | info_message "${interface} is up and running" |
| 521 | break |
| 522 | fi |
| 523 | elif [ $interface_type = "inband-tagged" ]; then |
| 524 | while true; do |
| 525 | ifconfig ${interface} | grep 'RUNNING' &>/dev/null |
| 526 | if [ $? -eq 0 ]; then |
| 527 | ip=$(ifconfig $interface | grep "inet addr" | cut -d ':' -f 2 | cut -d ' ' -f 1) |
| 528 | if [ ! -z "$ip" ]; then |
| 529 | info_message "${interface} is up and running with valid IP address" |
| 530 | return 0 |
| 531 | else |
| 532 | info_message "Inband interface ${interface} is not up, continuously retrying for DHCP IP assignment" |
| 533 | info_message "Inband interface ${interface} is not up with valid IP hence not starting openolt service" |
Girish Gowdra | 70feafd | 2020-08-06 20:08:26 -0700 | [diff] [blame] | 534 | sleep 5 |
Thiyagarajan Subramani | e84935d | 2020-04-23 17:45:44 +0530 | [diff] [blame] | 535 | continue |
| 536 | fi |
| 537 | fi |
| 538 | done |
| 539 | fi |
| 540 | done |
| 541 | } |
| 542 | |
| 543 | #------------------------------------------------------------------------------ |
| 544 | # Function Name: stop_olt_services |
| 545 | # Description: |
| 546 | # This function informs about inband interface error status and stops device management service. |
| 547 | # |
| 548 | # Globals: |
| 549 | # None |
| 550 | # |
| 551 | # Arguments: |
| 552 | # None |
| 553 | # |
| 554 | # Returns: |
| 555 | # None |
| 556 | #------------------------------------------------------------------------------ |
| 557 | stop_olt_services() |
| 558 | { |
| 559 | error_message "Inband tagged interface $1 is not up with valid IP address" |
| 560 | info_message "Not starting openolt service and stopping device menagement service" |
| 561 | service dev_mgmt_daemon stop |
| 562 | exit 1 |
| 563 | } |
| 564 | |
| 565 | #------------------------------------------------------------------------------ |
| 566 | # Function Name: start_openolt_service |
| 567 | # Description: |
| 568 | # This function checks whether inband interfaces are up with IP address, then |
| 569 | # appends inband interface name to a file which later will be used by openolt |
| 570 | # service as command line option then starts openolt service. |
| 571 | # Openolt service enables all PON and NNI interfaces and creates respective PON |
| 572 | # and NNI schedulers and Queues. |
| 573 | # |
| 574 | # Globals: |
| 575 | # None |
| 576 | # |
| 577 | # Arguments: |
| 578 | # None |
| 579 | # |
| 580 | # Returns: |
| 581 | # None |
| 582 | #------------------------------------------------------------------------------ |
| 583 | start_openolt_service() |
| 584 | { |
| 585 | info_message "Starting openolt service" |
| 586 | local interface_type="inband-tagged" |
| 587 | |
| 588 | if [ "${OLT_MODEL}" = ${ASF16_MODEL} ]; then |
| 589 | check_interface_is_up eth2.${ASFVOLT16_VLAN_ID_ETH2} $interface_type |
| 590 | if [ $? -ne 0 ]; then stop_olt_services eth2.${ASFVOLT16_VLAN_ID_ETH2}; fi |
| 591 | openolt_grpc_interface=eth2.${ASFVOLT16_VLAN_ID_ETH2} |
| 592 | else |
| 593 | check_interface_is_up eth1.${ASGVOLT64_VLAN_ID_ETH1} $interface_type |
| 594 | if [ $? -ne 0 ]; then stop_olt_services eth1.${ASGVOLT64_VLAN_ID_ETH1}; fi |
| 595 | openolt_grpc_interface=eth1.${ASGVOLT64_VLAN_ID_ETH1} |
| 596 | fi |
| 597 | |
| 598 | # Inband interface name appended to this file. Interface name will be |
| 599 | # used as command line argument by openolt service while running the binary. |
| 600 | if [ -f "$OPENOLT_ARG_INPUT_FILE" ]; then |
| 601 | info_message "$OPENOLT_ARG_INPUT_FILE exist" |
| 602 | echo "gRPC_interface=$openolt_grpc_interface" > $OPENOLT_ARG_INPUT_FILE |
| 603 | else |
| 604 | info_message "$OPENOLT_ARG_INPUT_FILE does not exist, creating it" |
| 605 | touch $OPENOLT_ARG_INPUT_FILE |
| 606 | echo "gRPC_interface=$openolt_grpc_interface" > $OPENOLT_ARG_INPUT_FILE |
| 607 | fi |
| 608 | |
| 609 | service openolt start |
| 610 | service openolt status |
| 611 | if [ $? -eq 0 ]; then |
| 612 | info_message "${OPENOLT} service is running" |
| 613 | else |
| 614 | error_message "${OPENOLT} is not running" |
| 615 | exit 1 |
| 616 | fi |
| 617 | } |
| 618 | |
| 619 | #------------------------------------------------------------------------------ |
| 620 | # Function Name: start_olt_services |
| 621 | # Description: |
| 622 | # This function triggers services to create vlan interfaces, to run BAL services |
| 623 | # and to trigger DHCP requets on eth2.VLAN_ID_1 and eth3.VLAN_ID_2 interfaces. |
| 624 | # |
| 625 | # Globals: |
| 626 | # None |
| 627 | # |
| 628 | # Arguments: |
| 629 | # None |
| 630 | # |
| 631 | # Returns: |
| 632 | # None |
| 633 | #------------------------------------------------------------------------------ |
| 634 | start_olt_services() { |
Girish Gowdra | 6e74552 | 2020-07-15 15:52:13 -0700 | [diff] [blame] | 635 | # First stop any openolt processes if they were running before |
| 636 | # and also disable auto start of these processes (since they are in /etc/init.d) |
| 637 | stop_openolt_and_dev_mgmt_daemon_processes |
| 638 | disable_autostart_of_openolt_and_dev_mgmt_daemon_processes |
| 639 | |
Thiyagarajan Subramani | e84935d | 2020-04-23 17:45:44 +0530 | [diff] [blame] | 640 | start_dev_mgmt_service |
Girish Gowdra | 6e74552 | 2020-07-15 15:52:13 -0700 | [diff] [blame] | 641 | start_openolt_dev_mgmt_daemon_process_watchdog |
Thiyagarajan Subramani | e84935d | 2020-04-23 17:45:44 +0530 | [diff] [blame] | 642 | create_vlan_tagged_Iface |
| 643 | setup_dhcpd_configuration |
| 644 | setup_nw_configuration |
| 645 | start_openolt_service |
| 646 | } |
| 647 | |
| 648 | #------------------------------------------------------------------------------ |
| 649 | # Function Name: copy_config_files |
| 650 | # Description: |
| 651 | # This function copy config files to /broadcom directory |
| 652 | # |
| 653 | # Globals: |
| 654 | # BRCM_DIR |
| 655 | # |
| 656 | # Arguments: |
| 657 | # None |
| 658 | # |
| 659 | # Returns: |
| 660 | # None |
| 661 | #------------------------------------------------------------------------------ |
| 662 | copy_config_files() { |
| 663 | info_message "copying config files to ${BRCM_DIR}" |
| 664 | # if [ "${OLT_MODEL}" != ${ASF16_MODEL} ]; then |
| 665 | # [ -f /qax.soc ] && cp "/qax.soc" "${BRCM_DIR}/" |
| 666 | # fi |
| 667 | # [ -f /config.bcm ] && cp "/config.bcm" "${BRCM_DIR}/" |
Girish Gowdra | 6e74552 | 2020-07-15 15:52:13 -0700 | [diff] [blame] | 668 | [ -f /inband.config ] && cp "/inband.config" "${BRCM_DIR}/" |
Thiyagarajan Subramani | e84935d | 2020-04-23 17:45:44 +0530 | [diff] [blame] | 669 | } |
| 670 | |
| 671 | # Execution starts from here |
| 672 | does_logger_exist |
| 673 | if [ $? -eq 0 ]; then |
| 674 | if [ "${OLT_MODEL}" = ${ASF16_MODEL} ]; then |
| 675 | # check if debian package is already installed. |
| 676 | dpkg -l | grep ${ASFVOLT16} |
| 677 | if [ $? -ne 0 ]; then |
| 678 | # installs openolt debian package for asfvolt16 model |
| 679 | dpkg -i ${BAL_OPENOLT_DEB_16} |
| 680 | fi |
| 681 | else |
| 682 | dpkg -l | grep ${ASGVOLT64} |
| 683 | if [ $? -ne 0 ]; then |
| 684 | # installs openolt debian package for asgvolt64 model |
| 685 | dpkg -i ${BAL_OPENOLT_DEB_64} |
| 686 | fi |
| 687 | fi |
| 688 | copy_config_files |
Humera Kouser | 9c2bd9f | 2020-09-25 02:41:29 -0400 | [diff] [blame] | 689 | # Wait time for BAL to get ready |
| 690 | WAIT_TIME_BAL_READY=$(awk '/wait_time_bal_ready/{print $0}' ${INBAND_CONFIG_FILE} | awk -F "=" '{print $2}') |
| 691 | |
Thiyagarajan Subramani | e84935d | 2020-04-23 17:45:44 +0530 | [diff] [blame] | 692 | start_olt_services |
| 693 | else |
| 694 | error_message "logger does not exist" |
| 695 | exit 1 |
| 696 | fi |