From e1f2a2dd75b5a83f83d2d72c9f4fa8b02cbca95a Mon Sep 17 00:00:00 2001 From: Qi Luo Date: Wed, 2 Aug 2017 20:28:00 -0700 Subject: [PATCH 1/8] [lldp] No need to config on port with no minigraph_neighbor, such as port in vlan (#864) --- dockers/docker-lldp-sv2/lldpd.conf.j2 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dockers/docker-lldp-sv2/lldpd.conf.j2 b/dockers/docker-lldp-sv2/lldpd.conf.j2 index e3d37d0911..4cfe48065e 100644 --- a/dockers/docker-lldp-sv2/lldpd.conf.j2 +++ b/dockers/docker-lldp-sv2/lldpd.conf.j2 @@ -1,3 +1,5 @@ {% for member in minigraph_ports.keys() %} +{% if member in minigraph_neighbors %} configure ports {{ member }} lldp portidsubtype local {{ minigraph_ports[member]['alias'] }} description {{ minigraph_neighbors[member]['name'] }}:{{ minigraph_neighbors[member]['port'] }} +{% endif %} {% endfor %} From d0c8e2d12708e6ee90103e32cac73a445e29e80f Mon Sep 17 00:00:00 2001 From: Oleksandr Ivantsiv Date: Fri, 4 Aug 2017 15:05:15 +0300 Subject: [PATCH 2/8] [mellanox]: Query required FW version from FW file. (#866) This simplifies FW upgrade procedure and allows to specify required version only in one place (fw recipe). --- platform/mellanox/mlnx-fw-upgrade.sh | 35 +++++++++++++--------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/platform/mellanox/mlnx-fw-upgrade.sh b/platform/mellanox/mlnx-fw-upgrade.sh index b27d7095e2..d84265e02d 100755 --- a/platform/mellanox/mlnx-fw-upgrade.sh +++ b/platform/mellanox/mlnx-fw-upgrade.sh @@ -1,7 +1,6 @@ #!/bin/bash query_retry_count_max="10" -required_fw_version="13.1224.0140" fw_file=/etc/mlnx/fw-SPC.mfa run_or_fail() { @@ -14,37 +13,35 @@ run_or_fail() { # wait until devices will be available query_retry_count="0" -mlxfwmanager --query > /dev/null +query_cmd="mlxfwmanager --query -i ${fw_file}" +${query_cmd} > /dev/null while [[ (${query_retry_count} -lt ${query_retry_count_max}) && ($? -ne "0") ]]; do sleep 1 query_retry_count=$[${query_retry_count}+1] - mlxfwmanager --query > /dev/null + ${query_cmd} > /dev/null done -run_or_fail "mlxfwmanager --query" > /tmp/mlnxfwmanager-query.txt +run_or_fail "${query_cmd}" > /tmp/mlnxfwmanager-query.txt -# get current firmware version -found_fw=false -for word in `cat /tmp/mlnxfwmanager-query.txt` -do - if [[ ${found_fw} == true ]]; then - fw_version=${word} - break - fi - if [[ ${word} == FW ]]; then - found_fw=true - fi -done +# get current firmware version and required version +fw_info=$(grep FW /tmp/mlnxfwmanager-query.txt) +fw_current=$(echo $fw_info | cut -f2 -d' ') +fw_required=$(echo $fw_info | cut -f3 -d' ') -if [[ -z ${fw_version} ]]; then +if [[ -z ${fw_current} ]]; then echo "Could not retreive current FW version." exit 1 fi -if [[ ${required_fw_version} == ${fw_version} ]]; then +if [[ -z ${fw_required} ]]; then + echo "Could not retreive required FW version." + exit 1 +fi + +if [[ ${fw_current} == ${fw_required} ]]; then echo "Mellanox firmware is up to date." else - echo "Mellanox firmware required version is ${required_fw_version}. Installing compatible version..." + echo "Mellanox firmware required version is ${fw_required}. Installing compatible version..." run_or_fail "mlxfwmanager -i ${fw_file} -u -f -y" fi From 97e4360d9bb9417ca82c28b291d274e44c28eecd Mon Sep 17 00:00:00 2001 From: Samuel Angebault Date: Sat, 5 Aug 2017 20:56:32 -0700 Subject: [PATCH 3/8] [platform] Add support for Arista DCS-7260CX3-64 (#863) * Update sonic-platform-modules-arista submodule * Update boot0 to handle DCS-7260CX3-64 * Add sys eeprom plugin for DCS-7260CX3-64 * Add sfputil plugin for DCS-7260CX3-64 * Add sensors config for DCS-7260CX3-64 * Add Arista-7260CX3-64 HwSku port_config * Handle slow flash partition re-read * Add minigraph.xml for DCS-7260CX3-64 64x100G --- .../Arista-7260CX3-64/port_config.ini | 67 ++ .../Arista-7260CX3-64/sai.profile | 1 + .../x86_64-arista_7260cx3_64/minigraph.xml | 848 ++++++++++++++++++ .../plugins/eeprom.py | 13 + .../plugins/sfputil.py | 8 + .../x86_64-arista_7260cx3_64/sensors.conf | 53 ++ files/Aboot/boot0.j2 | 16 +- files/initramfs-tools/arista-convertfs.j2 | 2 +- .../broadcom/sonic-platform-modules-arista | 2 +- 9 files changed, 1006 insertions(+), 4 deletions(-) create mode 100644 device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-64/port_config.ini create mode 100644 device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-64/sai.profile create mode 100644 device/arista/x86_64-arista_7260cx3_64/minigraph.xml create mode 100644 device/arista/x86_64-arista_7260cx3_64/plugins/eeprom.py create mode 100644 device/arista/x86_64-arista_7260cx3_64/plugins/sfputil.py create mode 100644 device/arista/x86_64-arista_7260cx3_64/sensors.conf diff --git a/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-64/port_config.ini b/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-64/port_config.ini new file mode 100644 index 0000000000..c0213576d0 --- /dev/null +++ b/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-64/port_config.ini @@ -0,0 +1,67 @@ +# name lanes alias port +Ethernet0 77,78,79,80 Ethernet1/1 1 +Ethernet4 65,66,67,68 Ethernet2/1 2 +Ethernet8 85,86,87,88 Ethernet3/1 3 +Ethernet12 89,90,91,92 Ethernet4/1 4 +Ethernet16 109,110,111,112 Ethernet5/1 5 +Ethernet20 97,98,99,100 Ethernet6/1 6 +Ethernet24 117,118,119,120 Ethernet7/1 7 +Ethernet28 5,6,7,8 Ethernet8/1 8 +Ethernet32 17,18,19,20 Ethernet9/1 9 +Ethernet36 13,14,15,16 Ethernet10/1 10 +Ethernet40 29,30,31,32 Ethernet11/1 11 +Ethernet44 37,38,39,40 Ethernet12/1 12 +Ethernet48 49,50,51,52 Ethernet13/1 13 +Ethernet52 45,46,47,48 Ethernet14/1 14 +Ethernet56 61,62,63,64 Ethernet15/1 15 +Ethernet60 121,122,123,124 Ethernet16/1 16 +Ethernet64 193,194,195,196 Ethernet17/1 17 +Ethernet68 133,134,135,136 Ethernet18/1 18 +Ethernet72 205,206,207,208 Ethernet19/1 19 +Ethernet76 213,214,215,216 Ethernet20/1 20 +Ethernet80 225,226,227,228 Ethernet21/1 21 +Ethernet84 221,222,223,224 Ethernet22/1 22 +Ethernet88 237,238,239,240 Ethernet23/1 23 +Ethernet92 245,246,247,248 Ethernet24/1 24 +Ethernet96 141,142,143,144 Ethernet25/1 25 +Ethernet100 249,250,251,252 Ethernet26/1 26 +Ethernet104 149,150,151,152 Ethernet27/1 27 +Ethernet108 153,154,155,156 Ethernet28/1 28 +Ethernet112 173,174,175,176 Ethernet29/1 29 +Ethernet116 161,162,163,164 Ethernet30/1 30 +Ethernet120 181,182,183,184 Ethernet31/1 31 +Ethernet124 185,186,187,188 Ethernet32/1 32 +Ethernet128 69,70,71,72 Ethernet33/1 33 +Ethernet132 73,74,75,76 Ethernet34/1 34 +Ethernet136 93,94,95,96 Ethernet35/1 35 +Ethernet140 81,82,83,84 Ethernet36/1 36 +Ethernet144 101,102,103,104 Ethernet37/1 37 +Ethernet148 105,106,107,108 Ethernet38/1 38 +Ethernet152 1,2,3,4 Ethernet39/1 39 +Ethernet156 113,114,115,116 Ethernet40/1 40 +Ethernet160 9,10,11,12 Ethernet41/1 41 +Ethernet164 21,22,23,24 Ethernet42/1 42 +Ethernet168 33,34,35,36 Ethernet43/1 43 +Ethernet172 25,26,27,28 Ethernet44/1 44 +Ethernet176 41,42,43,44 Ethernet45/1 45 +Ethernet180 53,54,55,56 Ethernet46/1 46 +Ethernet184 125,126,127,128 Ethernet47/1 47 +Ethernet188 57,58,59,60 Ethernet48/1 48 +Ethernet192 129,130,131,132 Ethernet49/1 49 +Ethernet196 197,198,199,200 Ethernet50/1 50 +Ethernet200 209,210,211,212 Ethernet51/1 51 +Ethernet204 201,202,203,204 Ethernet52/1 52 +Ethernet208 217,218,219,220 Ethernet53/1 53 +Ethernet212 229,230,231,232 Ethernet54/1 54 +Ethernet216 241,242,243,244 Ethernet55/1 55 +Ethernet220 233,234,235,236 Ethernet56/1 56 +Ethernet224 253,254,255,256 Ethernet57/1 57 +Ethernet228 137,138,139,140 Ethernet58/1 58 +Ethernet232 157,158,159,160 Ethernet59/1 59 +Ethernet236 145,146,147,148 Ethernet60/1 60 +Ethernet240 165,166,167,168 Ethernet61/1 61 +Ethernet244 169,170,171,172 Ethernet62/1 62 +Ethernet248 189,190,191,192 Ethernet63/1 63 +Ethernet252 177,178,179,180 Ethernet64/1 64 +Ethernet256 257 Ethernet65 65 +Ethernet260 259 Ethernet66 66 diff --git a/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-64/sai.profile b/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-64/sai.profile new file mode 100644 index 0000000000..d6fbf6e9c6 --- /dev/null +++ b/device/arista/x86_64-arista_7260cx3_64/Arista-7260CX3-64/sai.profile @@ -0,0 +1 @@ +SAI_INIT_CONFIG_FILE=/etc/bcm/th2-a7260cx3-64-64x100G.config.bcm diff --git a/device/arista/x86_64-arista_7260cx3_64/minigraph.xml b/device/arista/x86_64-arista_7260cx3_64/minigraph.xml new file mode 100644 index 0000000000..957b60822b --- /dev/null +++ b/device/arista/x86_64-arista_7260cx3_64/minigraph.xml @@ -0,0 +1,848 @@ + + + + + + + + + + + + + + HostIP + Loopback0 + + 10.1.0.32/32 + + 10.1.0.32/32 + + + + + + + + sonic + + + + + + Ethernet1/1 + 10.0.0.0/31 + + + + Ethernet2/1 + 10.0.0.2/31 + + + + Ethernet3/1 + 10.0.0.4/31 + + + + Ethernet4/1 + 10.0.0.6/31 + + + + Ethernet5/1 + 10.0.0.8/31 + + + + Ethernet6/1 + 10.0.0.10/31 + + + + Ethernet7/1 + 10.0.0.12/31 + + + + Ethernet8/1 + 10.0.0.14/31 + + + + Ethernet9/1 + 10.0.0.16/31 + + + + Ethernet10/1 + 10.0.0.18/31 + + + + Ethernet11/1 + 10.0.0.20/31 + + + + Ethernet12/1 + 10.0.0.22/31 + + + + Ethernet13/1 + 10.0.0.24/31 + + + + Ethernet14/1 + 10.0.0.26/31 + + + + Ethernet15/1 + 10.0.0.28/31 + + + + Ethernet16/1 + 10.0.0.30/31 + + + + Ethernet17/1 + 10.0.0.32/31 + + + + Ethernet18/1 + 10.0.0.34/31 + + + + Ethernet19/1 + 10.0.0.36/31 + + + + Ethernet20/1 + 10.0.0.38/31 + + + + Ethernet21/1 + 10.0.0.40/31 + + + + Ethernet22/1 + 10.0.0.42/31 + + + + Ethernet23/1 + 10.0.0.44/31 + + + + Ethernet24/1 + 10.0.0.46/31 + + + + Ethernet25/1 + 10.0.0.48/31 + + + + Ethernet26/1 + 10.0.0.50/31 + + + + Ethernet27/1 + 10.0.0.52/31 + + + + Ethernet28/1 + 10.0.0.54/31 + + + + Ethernet29/1 + 10.0.0.56/31 + + + + Ethernet30/1 + 10.0.0.58/31 + + + + Ethernet31/1 + 10.0.0.60/31 + + + + Ethernet32/1 + 10.0.0.62/31 + + + + Ethernet33/1 + 10.0.0.64/31 + + + + Ethernet34/1 + 10.0.0.66/31 + + + + Ethernet35/1 + 10.0.0.68/31 + + + + Ethernet36/1 + 10.0.0.70/31 + + + + Ethernet37/1 + 10.0.0.72/31 + + + + Ethernet38/1 + 10.0.0.74/31 + + + + Ethernet39/1 + 10.0.0.76/31 + + + + Ethernet40/1 + 10.0.0.78/31 + + + + Ethernet41/1 + 10.0.0.80/31 + + + + Ethernet42/1 + 10.0.0.82/31 + + + + Ethernet43/1 + 10.0.0.84/31 + + + + Ethernet44/1 + 10.0.0.86/31 + + + + Ethernet45/1 + 10.0.0.88/31 + + + + Ethernet46/1 + 10.0.0.90/31 + + + + Ethernet47/1 + 10.0.0.92/31 + + + + Ethernet48/1 + 10.0.0.94/31 + + + + Ethernet49/1 + 10.0.0.96/31 + + + + Ethernet50/1 + 10.0.0.98/31 + + + + Ethernet51/1 + 10.0.0.100/31 + + + + Ethernet52/1 + 10.0.0.102/31 + + + + Ethernet53/1 + 10.0.0.104/31 + + + + Ethernet54/1 + 10.0.0.106/31 + + + + Ethernet55/1 + 10.0.0.108/31 + + + + Ethernet56/1 + 10.0.0.110/31 + + + + Ethernet57/1 + 10.0.0.112/31 + + + + Ethernet58/1 + 10.0.0.114/31 + + + + Ethernet59/1 + 10.0.0.116/31 + + + + Ethernet60/1 + 10.0.0.118/31 + + + + Ethernet61/1 + 10.0.0.120/31 + + + + Ethernet62/1 + 10.0.0.122/31 + + + + Ethernet63/1 + 10.0.0.124/31 + + + + Ethernet64/1 + 10.0.0.126/31 + + + + + + + + + + + + DeviceInterfaceLink + sonic-target + Ethernet1/1 + sonic + Ethernet1/1 + + + DeviceInterfaceLink + sonic-target + Ethernet2/1 + sonic + Ethernet2/1 + + + DeviceInterfaceLink + sonic-target + Ethernet3/1 + sonic + Ethernet3/1 + + + DeviceInterfaceLink + sonic-target + Ethernet4/1 + sonic + Ethernet4/1 + + + DeviceInterfaceLink + sonic-target + Ethernet5/1 + sonic + Ethernet5/1 + + + DeviceInterfaceLink + sonic-target + Ethernet6/1 + sonic + Ethernet6/1 + + + DeviceInterfaceLink + sonic-target + Ethernet7/1 + sonic + Ethernet7/1 + + + DeviceInterfaceLink + sonic-target + Ethernet8/1 + sonic + Ethernet8/1 + + + DeviceInterfaceLink + sonic-target + Ethernet9/1 + sonic + Ethernet9/1 + + + DeviceInterfaceLink + sonic-target + Ethernet10/1 + sonic + Ethernet10/1 + + + DeviceInterfaceLink + sonic-target + Ethernet11/1 + sonic + Ethernet11/1 + + + DeviceInterfaceLink + sonic-target + Ethernet12/1 + sonic + Ethernet12/1 + + + DeviceInterfaceLink + sonic-target + Ethernet13/1 + sonic + Ethernet13/1 + + + DeviceInterfaceLink + sonic-target + Ethernet14/1 + sonic + Ethernet14/1 + + + DeviceInterfaceLink + sonic-target + Ethernet15/1 + sonic + Ethernet15/1 + + + DeviceInterfaceLink + sonic-target + Ethernet16/1 + sonic + Ethernet16/1 + + + DeviceInterfaceLink + sonic-target + Ethernet17/1 + sonic + Ethernet17/1 + + + DeviceInterfaceLink + sonic-target + Ethernet18/1 + sonic + Ethernet18/1 + + + DeviceInterfaceLink + sonic-target + Ethernet19/1 + sonic + Ethernet19/1 + + + DeviceInterfaceLink + sonic-target + Ethernet20/1 + sonic + Ethernet20/1 + + + DeviceInterfaceLink + sonic-target + Ethernet21/1 + sonic + Ethernet21/1 + + + DeviceInterfaceLink + sonic-target + Ethernet22/1 + sonic + Ethernet22/1 + + + DeviceInterfaceLink + sonic-target + Ethernet23/1 + sonic + Ethernet23/1 + + + DeviceInterfaceLink + sonic-target + Ethernet24/1 + sonic + Ethernet24/1 + + + DeviceInterfaceLink + sonic-target + Ethernet25/1 + sonic + Ethernet25/1 + + + DeviceInterfaceLink + sonic-target + Ethernet26/1 + sonic + Ethernet26/1 + + + DeviceInterfaceLink + sonic-target + Ethernet27/1 + sonic + Ethernet27/1 + + + DeviceInterfaceLink + sonic-target + Ethernet28/1 + sonic + Ethernet28/1 + + + DeviceInterfaceLink + sonic-target + Ethernet29/1 + sonic + Ethernet29/1 + + + DeviceInterfaceLink + sonic-target + Ethernet30/1 + sonic + Ethernet30/1 + + + DeviceInterfaceLink + sonic-target + Ethernet31/1 + sonic + Ethernet31/1 + + + DeviceInterfaceLink + sonic-target + Ethernet32/1 + sonic + Ethernet32/1 + + + DeviceInterfaceLink + sonic-target + Ethernet33/1 + sonic + Ethernet33/1 + + + DeviceInterfaceLink + sonic-target + Ethernet34/1 + sonic + Ethernet34/1 + + + DeviceInterfaceLink + sonic-target + Ethernet35/1 + sonic + Ethernet35/1 + + + DeviceInterfaceLink + sonic-target + Ethernet36/1 + sonic + Ethernet36/1 + + + DeviceInterfaceLink + sonic-target + Ethernet37/1 + sonic + Ethernet37/1 + + + DeviceInterfaceLink + sonic-target + Ethernet38/1 + sonic + Ethernet38/1 + + + DeviceInterfaceLink + sonic-target + Ethernet39/1 + sonic + Ethernet39/1 + + + DeviceInterfaceLink + sonic-target + Ethernet40/1 + sonic + Ethernet40/1 + + + DeviceInterfaceLink + sonic-target + Ethernet41/1 + sonic + Ethernet41/1 + + + DeviceInterfaceLink + sonic-target + Ethernet42/1 + sonic + Ethernet42/1 + + + DeviceInterfaceLink + sonic-target + Ethernet43/1 + sonic + Ethernet43/1 + + + DeviceInterfaceLink + sonic-target + Ethernet44/1 + sonic + Ethernet44/1 + + + DeviceInterfaceLink + sonic-target + Ethernet45/1 + sonic + Ethernet45/1 + + + DeviceInterfaceLink + sonic-target + Ethernet46/1 + sonic + Ethernet46/1 + + + DeviceInterfaceLink + sonic-target + Ethernet47/1 + sonic + Ethernet47/1 + + + DeviceInterfaceLink + sonic-target + Ethernet48/1 + sonic + Ethernet48/1 + + + DeviceInterfaceLink + sonic-target + Ethernet49/1 + sonic + Ethernet49/1 + + + DeviceInterfaceLink + sonic-target + Ethernet50/1 + sonic + Ethernet50/1 + + + DeviceInterfaceLink + sonic-target + Ethernet51/1 + sonic + Ethernet51/1 + + + DeviceInterfaceLink + sonic-target + Ethernet52/1 + sonic + Ethernet52/1 + + + DeviceInterfaceLink + sonic-target + Ethernet53/1 + sonic + Ethernet53/1 + + + DeviceInterfaceLink + sonic-target + Ethernet54/1 + sonic + Ethernet54/1 + + + DeviceInterfaceLink + sonic-target + Ethernet55/1 + sonic + Ethernet55/1 + + + DeviceInterfaceLink + sonic-target + Ethernet56/1 + sonic + Ethernet56/1 + + + DeviceInterfaceLink + sonic-target + Ethernet57/1 + sonic + Ethernet57/1 + + + DeviceInterfaceLink + sonic-target + Ethernet58/1 + sonic + Ethernet58/1 + + + DeviceInterfaceLink + sonic-target + Ethernet59/1 + sonic + Ethernet59/1 + + + DeviceInterfaceLink + sonic-target + Ethernet60/1 + sonic + Ethernet60/1 + + + DeviceInterfaceLink + sonic-target + Ethernet61/1 + sonic + Ethernet61/1 + + + DeviceInterfaceLink + sonic-target + Ethernet62/1 + sonic + Ethernet62/1 + + + DeviceInterfaceLink + sonic-target + Ethernet63/1 + sonic + Ethernet63/1 + + + DeviceInterfaceLink + sonic-target + Ethernet64/1 + sonic + Ethernet64/1 + + + + + sonic + Arista-7260CX3-64 + + + + + + + sonic + + + DhcpResources + + + + + NtpResources + + 0.debian.pool.ntp.org;1.debian.pool.ntp.org;2.debian.pool.ntp.org;3.debian.pool.ntp.org + + + SyslogResources + + + + + ErspanDestinationIpv4 + + 2.2.2.2 + + + + + + + sonic + Arista-7260CX3-64 + diff --git a/device/arista/x86_64-arista_7260cx3_64/plugins/eeprom.py b/device/arista/x86_64-arista_7260cx3_64/plugins/eeprom.py new file mode 100644 index 0000000000..c4485e8959 --- /dev/null +++ b/device/arista/x86_64-arista_7260cx3_64/plugins/eeprom.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python + +""" +Arista 7260CX3-64 eeprom plugin +Uses the arista driver library to obtain the TlvInfoDecoder +""" + +try: + import arista.utils.sonic_eeprom as arista_eeprom +except ImportError, e: + raise ImportError (str(e) + "- required module not found") + +board = arista_eeprom.getTlvInfoDecoder() diff --git a/device/arista/x86_64-arista_7260cx3_64/plugins/sfputil.py b/device/arista/x86_64-arista_7260cx3_64/plugins/sfputil.py new file mode 100644 index 0000000000..ce60de2b38 --- /dev/null +++ b/device/arista/x86_64-arista_7260cx3_64/plugins/sfputil.py @@ -0,0 +1,8 @@ +#!/usr/bin/env python + +try: + import arista.utils.sonic_sfputil as arista_sfputil +except ImportError, e: + raise ImportError (str(e) + "- required module not found") + +sfputil = arista_sfputil.getSfpUtil() diff --git a/device/arista/x86_64-arista_7260cx3_64/sensors.conf b/device/arista/x86_64-arista_7260cx3_64/sensors.conf new file mode 100644 index 0000000000..e0ad4b4349 --- /dev/null +++ b/device/arista/x86_64-arista_7260cx3_64/sensors.conf @@ -0,0 +1,53 @@ +# libsensors configuration file for DCS-7260CX3-64 +# ------------------------------------------------# + +bus "i2c-1" "SCD 0000:06:00.0 SMBus master 0 bus 0" +bus "i2c-3" "SCD 0000:06:00.0 SMBus master 0 bus 2" +bus "i2c-4" "SCD 0000:06:00.0 SMBus master 0 bus 3" +bus "i2c-73" "SCD 0000:ff:0b.3 SMBus master 0 bus 0" +bus "i2c-88" "SCD 0000:ff:0b.3 SMBus master 3 bus 3" + +chip "max6658-i2c-1-4c" + label temp1 "Temp sensor near TH2" + + set temp1_max 65 + set temp1_crit 75 + + ignore temp2 + +chip "pmbus-i2c-3-58" + label temp1 "PSU1 primary hotspot temp" + label temp2 "PSU1 inlet temp" + label temp3 "PSU1 exhaust temp" + + # setting maximum and critical thresholds is not supported for this psu + # fault and warning limits defined internally by hardware + + ignore fan2 + ignore fan3 + +chip "pmbus-i2c-4-58" + label temp1 "PSU2 primary hotspot temp" + label temp2 "PSU2 inlet temp" + label temp3 "PSU2 exhaust temp" + + # setting maximum and critical thresholds is not supported for this psu + # fault and warning limits defined internally by hardware + + ignore fan2 + ignore fan3 + +chip "max6658-i2c-73-4c" + label temp1 "Rear air temp1" + label temp2 "Rear air temp2" + + set temp1_max 65 + set temp1_crit 75 + set temp2_max 65 + set temp2_crit 75 + +chip "lm73-i2c-88-48" + label temp1 "Front air temp" + + set temp1_max 65 + set temp1_crit 75 diff --git a/files/Aboot/boot0.j2 b/files/Aboot/boot0.j2 index f278f1070f..b88c0ec35b 100644 --- a/files/Aboot/boot0.j2 +++ b/files/Aboot/boot0.j2 @@ -65,6 +65,9 @@ extract_image() { ## vfat does not support symbol link if [ -n "$sonic_upgrade" ] || [ "$rootfs_type" != "vfat" ]; then + ## on ext4, other doesn't have access to the flash by default + chmod o+rx "$target_path" + mkdir -p "$image_path/{{ DOCKERFS_DIR }}" if [ -n "$sonic_upgrade" ]; then @@ -108,7 +111,7 @@ platform_specific() { local sid="$(grep -Eo 'sid=[^ ]+' /etc/cmdline | cut -f2 -d=)" # set varlog size to 100MB - echo "varlog_size=100" >>/tmp/append + local varlog_size=100 # This is temporary as the platform= and sid= parameters don't provide enough # information to identify the SKU @@ -122,10 +125,19 @@ platform_specific() { aboot_machine=arista_7050_qx32s echo "modprobe.blacklist=radeon" >>/tmp/append fi - if [ "$sid" = "Upperlake" ]; then + if [ "$sid" = "Upperlake" ] || [ "$sid" = "UpperlakeES" ]; then aboot_machine=arista_7060_cx32s echo "amd_iommu=off" >> /tmp/append fi + if [ "$sid" = "Gardena" ] || [ "$sid" = "GardenaSsd" ]; then + aboot_machine=arista_7260cx3_64 + fi + if [ "$platform" = "rook" ]; then + varlog_size=200 + readprefdl -f /tmp/.system-prefdl -d > /mnt/flash/.system-prefdl + fi + + echo "varlog_size=$varlog_size" >>/tmp/append } # check the hash file in the image, and determine to install or just skip diff --git a/files/initramfs-tools/arista-convertfs.j2 b/files/initramfs-tools/arista-convertfs.j2 index a15233615f..81c6d9d194 100644 --- a/files/initramfs-tools/arista-convertfs.j2 +++ b/files/initramfs-tools/arista-convertfs.j2 @@ -178,7 +178,7 @@ umount "$root_mnt" # Create a new partition table (content in flash_dev will be deleted) err_msg="Error: repartitioning $flash_dev failed" -cmd="echo ';' | sfdisk $flash_dev" +cmd="echo ';' | sfdisk $flash_dev || (sleep 3; blockdev --rereadpt $flash_dev && fdisk -l $flash_dev | grep -q ${root_dev}.*Linux)" run_cmd "$cmd" "$err_msg" sleep 5 diff --git a/platform/broadcom/sonic-platform-modules-arista b/platform/broadcom/sonic-platform-modules-arista index 75e8473768..a90b9fc5b0 160000 --- a/platform/broadcom/sonic-platform-modules-arista +++ b/platform/broadcom/sonic-platform-modules-arista @@ -1 +1 @@ -Subproject commit 75e84737680f5451eb9c947d01968b972d989bb3 +Subproject commit a90b9fc5b085cdb99d10d338a23daa66c7f351b2 From afbf1ee2fb0e6c2ef3a64a87592ac63ae36842c4 Mon Sep 17 00:00:00 2001 From: Marian Pritsak Date: Tue, 8 Aug 2017 10:21:54 +0300 Subject: [PATCH 4/8] [sonic-slave]: Split user commands from generic. (#868) In case when more than one user builds SONiC on same machine, we can keep generic part that installs all packages to slave image apart from creating user and calling user-related commands. Then generic base image will be built only once, allowing other users to build only smaller specific to them layers. Signed-off-by: marian-pritsak --- Makefile | 19 +++++++++++++++++-- sonic-slave/Dockerfile | 28 ---------------------------- sonic-slave/Dockerfile.user | 29 +++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 30 deletions(-) create mode 100644 sonic-slave/Dockerfile.user diff --git a/Makefile b/Makefile index ee3c292732..d779c30718 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,9 @@ $(shell rm -f .screen) MAKEFLAGS += -B -SLAVE_TAG = $(shell shasum sonic-slave/Dockerfile | awk '{print substr($$1,0,11);}') +SLAVE_BASE_TAG = $(shell shasum sonic-slave/Dockerfile | awk '{print substr($$1,0,11);}') +SLAVE_TAG = $(shell shasum sonic-slave/Dockerfile.user | awk '{print substr($$1,0,11);}') +SLAVE_BASE_IMAGE = sonic-slave-base SLAVE_IMAGE = sonic-slave-$(USER) DOCKER_RUN := docker run --rm=true --privileged \ @@ -20,12 +22,18 @@ DOCKER_RUN := docker run --rm=true --privileged \ -w /sonic \ -i$(if $(TERM),t,) +DOCKER_BASE_BUILD = docker build --no-cache \ + -t $(SLAVE_BASE_IMAGE) \ + sonic-slave && \ + docker tag $(SLAVE_BASE_IMAGE):latest $(SLAVE_BASE_IMAGE):$(SLAVE_BASE_TAG) + DOCKER_BUILD = docker build --no-cache \ --build-arg user=$(USER) \ --build-arg uid=$(shell id -u) \ --build-arg guid=$(shell id -g) \ --build-arg hostname=$(shell echo $$HOSTNAME) \ -t $(SLAVE_IMAGE) \ + -f sonic-slave/Dockerfile.user \ sonic-slave && \ docker tag $(SLAVE_IMAGE):latest $(SLAVE_IMAGE):$(SLAVE_TAG) @@ -34,6 +42,9 @@ DOCKER_BUILD = docker build --no-cache \ .DEFAULT_GOAL := all %:: + @docker inspect --type image $(SLAVE_BASE_IMAGE):$(SLAVE_BASE_TAG) &> /dev/null || \ + { echo Image $(SLAVE_BASE_IMAGE):$(SLAVE_BASE_TAG) not found. Building... ; \ + $(DOCKER_BASE_BUILD) ; } @docker inspect --type image $(SLAVE_IMAGE):$(SLAVE_TAG) &> /dev/null || \ { echo Image $(SLAVE_IMAGE):$(SLAVE_TAG) not found. Building... ; \ $(DOCKER_BUILD) ; } @@ -49,9 +60,13 @@ DOCKER_BUILD = docker build --no-cache \ $@ sonic-slave-build : - @$(DOCKER_BUILD) + $(DOCKER_BASE_BUILD) + $(DOCKER_BUILD) sonic-slave-bash : + @docker inspect --type image $(SLAVE_BASE_IMAGE):$(SLAVE_BASE_TAG) &> /dev/null || \ + { echo Image $(SLAVE_BASE_IMAGE):$(SLAVE_BASE_TAG) not found. Building... ; \ + $(DOCKER_BASE_BUILD) ; } @docker inspect --type image $(SLAVE_IMAGE):$(SLAVE_TAG) &> /dev/null || \ { echo Image $(SLAVE_IMAGE):$(SLAVE_TAG) not found. Building... ; \ $(DOCKER_BUILD) ; } diff --git a/sonic-slave/Dockerfile b/sonic-slave/Dockerfile index 38fe431a04..826a7129a7 100644 --- a/sonic-slave/Dockerfile +++ b/sonic-slave/Dockerfile @@ -254,31 +254,3 @@ RUN add-apt-repository \ RUN apt-get update RUN apt-get install -y docker-ce=17.03.2~ce-0~debian-jessie RUN echo "DOCKER_OPTS=\"--experimental\"" >> /etc/default/docker - -# Add user -ARG user -ARG uid -ARG guid -ARG hostname - -ENV BUILD_HOSTNAME $hostname -ENV USER $user - -RUN groupadd -f -r -g $guid g$user - -RUN useradd $user -l -u $uid -g $guid -d /var/$user -m -s /bin/bash - -RUN gpasswd -a $user docker - -# Config git for stg -RUN su $user -c "git config --global user.name $user" -RUN su $user -c "git config --global user.email $user@contoso.com" - -COPY sonic-jenkins-id_rsa.pub /var/$user/.ssh/authorized_keys2 -RUN chown $user /var/$user/.ssh -R -RUN chmod go= /var/$user/.ssh -R - -# Add user to sudoers -RUN echo "$user ALL=(ALL) NOPASSWD:ALL" >>/etc/sudoers - -USER $user diff --git a/sonic-slave/Dockerfile.user b/sonic-slave/Dockerfile.user new file mode 100644 index 0000000000..ff01f88a76 --- /dev/null +++ b/sonic-slave/Dockerfile.user @@ -0,0 +1,29 @@ +FROM sonic-slave-base + +# Add user +ARG user +ARG uid +ARG guid +ARG hostname + +ENV BUILD_HOSTNAME $hostname +ENV USER $user + +RUN groupadd -f -r -g $guid g$user + +RUN useradd $user -l -u $uid -g $guid -d /var/$user -m -s /bin/bash + +RUN gpasswd -a $user docker + +# Config git for stg +RUN su $user -c "git config --global user.name $user" +RUN su $user -c "git config --global user.email $user@contoso.com" + +COPY sonic-jenkins-id_rsa.pub /var/$user/.ssh/authorized_keys2 +RUN chown $user /var/$user/.ssh -R +RUN chmod go= /var/$user/.ssh -R + +# Add user to sudoers +RUN echo "$user ALL=(ALL) NOPASSWD:ALL" >>/etc/sudoers + +USER $user From a2fe0212be487d173830a07d6999d74589136993 Mon Sep 17 00:00:00 2001 From: Taoyu Li Date: Tue, 8 Aug 2017 16:23:58 -0700 Subject: [PATCH 5/8] [ConfigDB] Move all BGP configuration into DB (#861) - BGP data read from minigraph.py now match DB schema - BGP templates are updated - bgpcfgd can now deal with runtime neighbor create/delete --- dockers/docker-fpm-frr/bgpd.conf.j2 | 16 ++-- dockers/docker-fpm-frr/isolate.j2 | 10 +-- dockers/docker-fpm-frr/unisolate.j2 | 10 +-- dockers/docker-fpm-gobgp/gobgpd.conf.j2 | 8 +- dockers/docker-fpm-gobgp/isolate.j2 | 20 ----- dockers/docker-fpm-gobgp/unisolate.j2 | 19 ----- dockers/docker-fpm-quagga/bgpcfgd | 75 ++++++++++++------- dockers/docker-fpm-quagga/bgpd.conf.j2 | 30 ++++---- dockers/docker-fpm-quagga/isolate.j2 | 10 +-- dockers/docker-fpm-quagga/start.sh | 6 +- dockers/docker-fpm-quagga/unisolate.j2 | 10 +-- .../build_templates/sonic_debian_extension.j2 | 2 +- files/image_config/platform/rc.local | 12 +++ files/image_config/updategraph/updategraph | 7 ++ src/sonic-config-engine/minigraph.py | 31 ++++---- src/sonic-config-engine/sonic-cfggen | 58 ++++++-------- src/sonic-config-engine/tests/test_cfggen.py | 2 +- src/sonic-utilities | 2 +- 18 files changed, 159 insertions(+), 169 deletions(-) diff --git a/dockers/docker-fpm-frr/bgpd.conf.j2 b/dockers/docker-fpm-frr/bgpd.conf.j2 index 9b81959434..d04f6ac623 100644 --- a/dockers/docker-fpm-frr/bgpd.conf.j2 +++ b/dockers/docker-fpm-frr/bgpd.conf.j2 @@ -18,7 +18,7 @@ log facility local4 ! ! bgp multiple-instance ! -router bgp {{ minigraph_bgp_asn }} +router bgp {{ DEVICE_METADATA['localhost']['bgp_asn'] }} bgp log-neighbor-changes bgp bestpath as-path multipath-relax {# TODO: use lo[0] for backward compatibility, will revisit the case with multiple lo interfaces #} @@ -46,16 +46,16 @@ router bgp {{ minigraph_bgp_asn }} {% endfor %} {% endblock vlan_advertisement %} {% block bgp_sessions %} -{% for bgp_session in minigraph_bgp %} +{% for neighbor_addr, bgp_session in BGP_NEIGHBOR.iteritems() %} {% if bgp_session['asn'] != 0 %} - neighbor {{ bgp_session['addr'] }} remote-as {{ bgp_session['asn'] }} - neighbor {{ bgp_session['addr'] }} description {{ bgp_session['name'] }} + neighbor {{ neighbor_addr }} remote-as {{ bgp_session['asn'] }} + neighbor {{ neighbor_addr }} description {{ bgp_session['name'] }} {% if minigraph_devices[inventory_hostname]['type'] == 'ToRRouter' %} - neighbor {{ bgp_session['addr'] }} allowas-in 1 + neighbor {{ neighbor_addr }} allowas-in 1 {% endif %} -{% if bgp_session['addr'] | ipv6 %} +{% if neighbor_addr | ipv6 %} address-family ipv6 - neighbor {{ bgp_session['addr'] }} activate + neighbor {{ neighbor_addr }} activate maximum-paths 64 exit-address-family {% endif %} @@ -66,5 +66,5 @@ router bgp {{ minigraph_bgp_asn }} maximum-paths 64 ! route-map ISOLATE permit 10 -set as-path prepend {{ minigraph_bgp_asn }} +set as-path prepend {{ DEVICE_METADATA['localhost']['bgp_asn'] }} ! diff --git a/dockers/docker-fpm-frr/isolate.j2 b/dockers/docker-fpm-frr/isolate.j2 index 35ef5bbc02..7b7fecf9fa 100755 --- a/dockers/docker-fpm-frr/isolate.j2 +++ b/dockers/docker-fpm-frr/isolate.j2 @@ -8,13 +8,13 @@ exit $? ## vtysh script start from next line, which line number MUST eqaul in 'sed' command above configure terminal - router bgp {{ minigraph_bgp_asn }} -{% for bgp_session in minigraph_bgp %} - neighbor {{ bgp_session['addr'] }} route-map ISOLATE out + router bgp {{ DEVICE_METADATA['localhost']['bgp_asn'] }} +{% for neighbor_addr in BGP_NEIGHBOR %} + neighbor {{ neighbor_addr }} route-map ISOLATE out {% endfor %} exit exit -{% for bgp_session in minigraph_bgp %} -clear ip bgp {{ bgp_session['addr'] }} soft out +{% for neighbor_addr in BGP_NEIGHBOR %} +clear ip bgp {{ neighbor_addr }} soft out {% endfor %} diff --git a/dockers/docker-fpm-frr/unisolate.j2 b/dockers/docker-fpm-frr/unisolate.j2 index c113a74fab..f212955674 100755 --- a/dockers/docker-fpm-frr/unisolate.j2 +++ b/dockers/docker-fpm-frr/unisolate.j2 @@ -8,13 +8,13 @@ exit $? ## vtysh script start from next line, which line number MUST eqaul in 'sed' command above configure terminal - router bgp {{ minigraph_bgp_asn }} -{% for bgp_session in minigraph_bgp %} - no neighbor {{ bgp_session['addr'] }} route-map ISOLATE out + router bgp {{ DEVICE_METADATA['localhost']['bgp_asn'] }} +{% for neighbor_ip in BGP_NEIGHBOR %} + no neighbor {{ neighbor_ip }} route-map ISOLATE out {% endfor %} exit exit -{% for bgp_session in minigraph_bgp %} -clear ip bgp {{ bgp_session['addr'] }} soft out +{% for neighbor_ip in BGP_NEIGHBOR %} +clear ip bgp {{ neighbor_ip }} soft out {% endfor %} diff --git a/dockers/docker-fpm-gobgp/gobgpd.conf.j2 b/dockers/docker-fpm-gobgp/gobgpd.conf.j2 index adbc063cfc..c6ec7a4fd1 100644 --- a/dockers/docker-fpm-gobgp/gobgpd.conf.j2 +++ b/dockers/docker-fpm-gobgp/gobgpd.conf.j2 @@ -1,17 +1,17 @@ [global.config] - as = {{ minigraph_bgp_asn }} + as = {{ DEVICE_METADATA['localhost']['bgp_asn'] }} router-id = "{{ minigraph_lo_interfaces[0]['addr'] }}" -{% for bgp_session in minigraph_bgp %} +{% for neighbor_addr, bgp_session in BGP_NEIGHBOR.iteritems() %} {% if bgp_session['asn'] != 0 %} [[neighbors]] [neighbors.config] peer-as = {{ bgp_session['asn'] }} - neighbor-address = "{{ bgp_session['addr'] }}" + neighbor-address = "{{ neighbor_addr }}" [neighbors.graceful-restart.config] enabled = true [[neighbors.afi-safis]] [neighbors.afi-safis.config] -{% if bgp_session['addr'] | ipv6 %} +{% if neighbor_addr | ipv6 %} afi-safi-name = "ipv6-unicast" {% else %} afi-safi-name = "ipv4-unicast" diff --git a/dockers/docker-fpm-gobgp/isolate.j2 b/dockers/docker-fpm-gobgp/isolate.j2 index e587623e98..4502ff8957 100755 --- a/dockers/docker-fpm-gobgp/isolate.j2 +++ b/dockers/docker-fpm-gobgp/isolate.j2 @@ -2,23 +2,3 @@ echo Not implemented yet exit - -## vtysh only accepts script in stdin, so cannot be directly used in shebang -## Cut the tail of this script and feed vtysh stdin -sed -n -e '9,$p' < "$0" | vtysh "$@" -## Exit with vtysh return code -exit $? - -## vtysh script start from next line, which line number MUST eqaul in 'sed' command above - -configure terminal - router bgp {{ minigraph_bgp_asn }} -{% for bgp_session in minigraph_bgp %} - neighbor {{ bgp_session['addr'] }} route-map ISOLATE out -{% endfor %} - exit -exit - -{% for bgp_session in minigraph_bgp %} -clear ip bgp {{ bgp_session['addr'] }} soft out -{% endfor %} diff --git a/dockers/docker-fpm-gobgp/unisolate.j2 b/dockers/docker-fpm-gobgp/unisolate.j2 index d1310114d9..69172744ba 100755 --- a/dockers/docker-fpm-gobgp/unisolate.j2 +++ b/dockers/docker-fpm-gobgp/unisolate.j2 @@ -3,22 +3,3 @@ echo Not implemented yet exit -## vtysh only accepts script in stdin, so cannot be directly used in shebang -## Cut the tail of this script and feed vtysh stdin -sed -n -e '9,$p' < "$0" | vtysh "$@" -## Exit with vtysh return code -exit $? - -## vtysh script start from next line, which line number MUST eqaul in 'sed' command above - -configure terminal - router bgp {{ minigraph_bgp_asn }} -{% for bgp_session in minigraph_bgp %} - no neighbor {{ bgp_session['addr'] }} route-map ISOLATE out -{% endfor %} - exit -exit - -{% for bgp_session in minigraph_bgp %} -clear ip bgp {{ bgp_session['addr'] }} soft out -{% endfor %} diff --git a/dockers/docker-fpm-quagga/bgpcfgd b/dockers/docker-fpm-quagga/bgpcfgd index 2bcecb13f9..012a766c20 100755 --- a/dockers/docker-fpm-quagga/bgpcfgd +++ b/dockers/docker-fpm-quagga/bgpcfgd @@ -6,37 +6,60 @@ import subprocess import syslog from swsssdk import ConfigDBConnector -# Returns BGP ASN as a string -def _get_bgp_asn_from_minigraph(): - # Get BGP ASN from minigraph - proc = subprocess.Popen( - ['sonic-cfggen', '-m', '/etc/sonic/minigraph.xml', '-v', 'minigraph_bgp_asn'], - stdout=subprocess.PIPE, - shell=False, - stderr=subprocess.STDOUT) - stdout = proc.communicate()[0] - proc.wait() - return stdout.rstrip('\n') +class BGPConfigDaemon: -def bgp_config(asn, ip, config): - syslog.syslog(syslog.LOG_INFO, '[bgp cfgd] value for {} changed to {}'.format(ip, config)) - # Currently dynamic config is supported only for bgp admin status - if config.has_key('admin_status'): - command_mod = 'no ' if config['admin_status'] == 'up' else '' - command = "vtysh -c 'configure terminal' -c 'router bgp {}' -c '{}neighbor {} shutdown'".format(asn, command_mod, ip) - + def __init__(self): + self.config_db = ConfigDBConnector() + self.config_db.connect() + self.bgp_asn = self.config_db.get_entry('DEVICE_METADATA', 'localhost')['bgp_asn'] + self.bgp_neighbor = self.config_db.get_table('BGP_NEIGHBOR') + + def __run_command(self, command): +# print command p = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE) stdout = p.communicate()[0] p.wait() if p.returncode != 0: syslog.syslog(syslog.LOG_ERR, '[bgp cfgd] command execution returned {}. Command: "{}", stdout: "{}"'.format(p.returncode, command, stdout)) -def main(): - sub = ConfigDBConnector() - bgp_asn = _get_bgp_asn_from_minigraph() - handler = lambda table, key, data: bgp_config(bgp_asn, key, data) - sub.subscribe('BGP_NEIGHBOR', handler) - sub.connect() - sub.listen() + def metadata_handler(self, key, data): + if key == 'localhost' and data.has_key('bgp_asn'): + if data['bgp_asn'] != self.bgp_asn: + syslog.syslog(syslog.LOG_INFO, '[bgp cfgd] ASN changed to {} from {}, restart BGP...'.format(data['bgp_asn'], self.bgp_asn)) + self.__run_command("supervisorctl restart start.sh") + self.__run_command("service quagga restart") + self.bgp_asn = data['bgp_asn'] -main() + def bgp_handler(self, key, data): + syslog.syslog(syslog.LOG_INFO, '[bgp cfgd] value for {} changed to {}'.format(key, data)) + if not data: + # Neighbor is deleted + command = "vtysh -c 'configure terminal' -c 'router bgp {}' -c 'no neighbor {}'".format(self.bgp_asn, key) + self.__run_command(command) + self.bgp_neighbor.pop(key) + else: + command = "vtysh -c 'configure terminal' -c 'router bgp {}' -c 'neighbor {} remote-as {}'".format(self.bgp_asn, key, data['asn']) + self.__run_command(command) + if data.has_key('name'): + command = "vtysh -c 'configure terminal' -c 'router bgp {}' -c 'neighbor {} description {}'".format(self.bgp_asn, key, data['name']) + self.__run_command(command) + if data.has_key('admin_status'): + command_mod = 'no ' if data['admin_status'] == 'up' else '' + command = "vtysh -c 'configure terminal' -c 'router bgp {}' -c '{}neighbor {} shutdown'".format(self.bgp_asn, command_mod, key) + self.__run_command(command) + self.bgp_neighbor[key] = data + + def start(self): + self.config_db.subscribe('BGP_NEIGHBOR', + lambda table, key, data: self.bgp_handler(key, data)) + self.config_db.subscribe('DEVICE_METADATA', + lambda table, key, data: self.metadata_handler(key, data)) + self.config_db.listen() + + +def main(): + daemon = BGPConfigDaemon() + daemon.start() + +if __name__ == "__main__": + main() diff --git a/dockers/docker-fpm-quagga/bgpd.conf.j2 b/dockers/docker-fpm-quagga/bgpd.conf.j2 index ceb866edd0..a5c317aa2e 100644 --- a/dockers/docker-fpm-quagga/bgpd.conf.j2 +++ b/dockers/docker-fpm-quagga/bgpd.conf.j2 @@ -14,7 +14,7 @@ log facility local4 ! enable password {# {{ en_passwd }} TODO: param needed #} {% endblock system_init %} ! -{% if minigraph_bgp_asn is not none %} +{% if DEVICE_METADATA['localhost'].has_key('bgp_asn') %} {% block bgp_init %} ! ! bgp multiple-instance @@ -23,7 +23,7 @@ route-map FROM_BGP_SPEAKER_V4 permit 10 ! route-map TO_BGP_SPEAKER_V4 deny 10 ! -router bgp {{ minigraph_bgp_asn }} +router bgp {{ DEVICE_METADATA['localhost']['bgp_asn'] }} bgp log-neighbor-changes bgp bestpath as-path multipath-relax {# Advertise graceful restart capability for ToR #} @@ -50,24 +50,24 @@ router bgp {{ minigraph_bgp_asn }} {% endfor %} {% endblock vlan_advertisement %} {% block bgp_sessions %} -{% for bgp_session in minigraph_bgp %} +{% for neighbor_addr, bgp_session in BGP_NEIGHBOR.iteritems() %} {% if bgp_session['asn'] != 0 %} - neighbor {{ bgp_session['addr'] }} remote-as {{ bgp_session['asn'] }} - neighbor {{ bgp_session['addr'] }} description {{ bgp_session['name'] }} -{% if bgp_admin_state and bgp_admin_state.has_key(bgp_session['addr']) and bgp_admin_state[bgp_session['addr']]==False or bgp_admin_state and not bgp_admin_state.has_key(bgp_session['addr']) and bgp_admin_state.has_key('all') and bgp_admin_state['all']==False %} - neighbor {{ bgp_session['addr'] }} shutdown + neighbor {{ neighbor_addr }} remote-as {{ bgp_session['asn'] }} + neighbor {{ neighbor_addr }} description {{ bgp_session['name'] }} +{% if bgp_session.has_key('admin_status') and bgp_session['admin_status'] == 'down' or not bgp_session.has_key('admin_status') and DEVICE_METADATA['localhost'].has_key('default_bgp_status') and DEVICE_METADATA['localhost']['default_bgp_status'] == 'down' %} + neighbor {{ neighbor_addr }} shutdown {% endif %} -{% if bgp_session['addr'] | ipv4 %} +{% if neighbor_addr | ipv4 %} {% if minigraph_devices[inventory_hostname]['type'] == 'ToRRouter' %} - neighbor {{ bgp_session['addr'] }} allowas-in 1 + neighbor {{ neighbor_addr }} allowas-in 1 {% endif %} {% endif %} -{% if bgp_session['addr'] | ipv6 %} +{% if neighbor_addr | ipv6 %} address-family ipv6 {% if minigraph_devices[inventory_hostname]['type'] == 'ToRRouter' %} - neighbor {{ bgp_session['addr'] }} allowas-in 1 + neighbor {{ neighbor_addr }} allowas-in 1 {% endif %} - neighbor {{ bgp_session['addr'] }} activate + neighbor {{ neighbor_addr }} activate maximum-paths 64 exit-address-family {% endif %} @@ -75,7 +75,7 @@ router bgp {{ minigraph_bgp_asn }} {% endfor %} {% endblock bgp_sessions %} {% block bgp_peers_with_range %} -{% for bgp_peer in minigraph_bgp_peers_with_range %} +{% for bgp_peer in BGP_PEER_RANGE.values() %} neighbor {{ bgp_peer['name'] }} peer-group neighbor {{ bgp_peer['name'] }} passive neighbor {{ bgp_peer['name'] }} remote-as {{deployment_id_asn_map[deployment_id] }} @@ -90,10 +90,10 @@ router bgp {{ minigraph_bgp_asn }} {% endfor %} {% endblock bgp_peers_with_range %} ! -{% if minigraph_bgp_asn is not none %} +{% if DEVICE_METADATA['localhost'].has_key('bgp_asn') %} maximum-paths 64 ! route-map ISOLATE permit 10 -set as-path prepend {{ minigraph_bgp_asn }} +set as-path prepend {{ DEVICE_METADATA['localhost']['bgp_asn'] }} {% endif %} ! diff --git a/dockers/docker-fpm-quagga/isolate.j2 b/dockers/docker-fpm-quagga/isolate.j2 index 35ef5bbc02..7b7fecf9fa 100755 --- a/dockers/docker-fpm-quagga/isolate.j2 +++ b/dockers/docker-fpm-quagga/isolate.j2 @@ -8,13 +8,13 @@ exit $? ## vtysh script start from next line, which line number MUST eqaul in 'sed' command above configure terminal - router bgp {{ minigraph_bgp_asn }} -{% for bgp_session in minigraph_bgp %} - neighbor {{ bgp_session['addr'] }} route-map ISOLATE out + router bgp {{ DEVICE_METADATA['localhost']['bgp_asn'] }} +{% for neighbor_addr in BGP_NEIGHBOR %} + neighbor {{ neighbor_addr }} route-map ISOLATE out {% endfor %} exit exit -{% for bgp_session in minigraph_bgp %} -clear ip bgp {{ bgp_session['addr'] }} soft out +{% for neighbor_addr in BGP_NEIGHBOR %} +clear ip bgp {{ neighbor_addr }} soft out {% endfor %} diff --git a/dockers/docker-fpm-quagga/start.sh b/dockers/docker-fpm-quagga/start.sh index 892c1f6ea9..ca876efe18 100755 --- a/dockers/docker-fpm-quagga/start.sh +++ b/dockers/docker-fpm-quagga/start.sh @@ -3,13 +3,13 @@ mkdir -p /etc/quagga sonic-cfggen -m -d -y /etc/sonic/deployment_id_asn_map.yml -t /usr/share/sonic/templates/bgpd.conf.j2 > /etc/quagga/bgpd.conf -sonic-cfggen -m /etc/sonic/minigraph.xml -t /usr/share/sonic/templates/zebra.conf.j2 > /etc/quagga/zebra.conf +sonic-cfggen -m -d -t /usr/share/sonic/templates/zebra.conf.j2 > /etc/quagga/zebra.conf -sonic-cfggen -m /etc/sonic/minigraph.xml -t /usr/share/sonic/templates/isolate.j2 > /usr/sbin/bgp-isolate +sonic-cfggen -m -d -t /usr/share/sonic/templates/isolate.j2 > /usr/sbin/bgp-isolate chown root:root /usr/sbin/bgp-isolate chmod 0755 /usr/sbin/bgp-isolate -sonic-cfggen -m /etc/sonic/minigraph.xml -t /usr/share/sonic/templates/unisolate.j2 > /usr/sbin/bgp-unisolate +sonic-cfggen -m -d -t /usr/share/sonic/templates/unisolate.j2 > /usr/sbin/bgp-unisolate chown root:root /usr/sbin/bgp-unisolate chmod 0755 /usr/sbin/bgp-unisolate diff --git a/dockers/docker-fpm-quagga/unisolate.j2 b/dockers/docker-fpm-quagga/unisolate.j2 index c113a74fab..f212955674 100755 --- a/dockers/docker-fpm-quagga/unisolate.j2 +++ b/dockers/docker-fpm-quagga/unisolate.j2 @@ -8,13 +8,13 @@ exit $? ## vtysh script start from next line, which line number MUST eqaul in 'sed' command above configure terminal - router bgp {{ minigraph_bgp_asn }} -{% for bgp_session in minigraph_bgp %} - no neighbor {{ bgp_session['addr'] }} route-map ISOLATE out + router bgp {{ DEVICE_METADATA['localhost']['bgp_asn'] }} +{% for neighbor_ip in BGP_NEIGHBOR %} + no neighbor {{ neighbor_ip }} route-map ISOLATE out {% endfor %} exit exit -{% for bgp_session in minigraph_bgp %} -clear ip bgp {{ bgp_session['addr'] }} soft out +{% for neighbor_ip in BGP_NEIGHBOR %} +clear ip bgp {{ neighbor_ip }} soft out {% endfor %} diff --git a/files/build_templates/sonic_debian_extension.j2 b/files/build_templates/sonic_debian_extension.j2 index 3c0804f7ab..fc84191e3c 100644 --- a/files/build_templates/sonic_debian_extension.j2 +++ b/files/build_templates/sonic_debian_extension.j2 @@ -132,7 +132,7 @@ sudo bash -c "echo dhcp_as_static=true >> $FILESYSTEM_ROOT/etc/sonic/updategraph sudo bash -c "echo enabled=false > $FILESYSTEM_ROOT/etc/sonic/updategraph.conf" {% endif %} {% if shutdown_bgp_on_start == "y" %} -sudo bash -c "echo '{ \"bgp_admin_state\": { \"all\": false } }' >> $FILESYSTEM_ROOT/etc/sonic/config_db.json" +sudo bash -c "echo '{ \"DEVICE_METADATA\": { \"localhost\": { \"default_bgp_status\": \"down\" } } }' >> $FILESYSTEM_ROOT/etc/sonic/init_cfg.json" {% endif %} # Copy SNMP configuration files sudo cp $IMAGE_CONFIGS/snmp/snmp.yml $FILESYSTEM_ROOT/etc/sonic/ diff --git a/files/image_config/platform/rc.local b/files/image_config/platform/rc.local index dad2510ce7..49b2ed6e1b 100755 --- a/files/image_config/platform/rc.local +++ b/files/image_config/platform/rc.local @@ -35,8 +35,20 @@ if [ -f /host/image-$sonic_version/platform/firsttime ]; then mv -f /host/old_config/* /etc/sonic/ elif [ -f /host/minigraph.xml ]; then mv /host/minigraph.xml /etc/sonic/ + # Combine information in minigraph and init_cfg.json to form initiate config DB dump file. + # TODO: After moving all information from minigraph to DB, sample config DB dump should be provide + if [ -f /etc/sonic/init_cfg.json ]; then + sonic-cfggen -m -j /etc/sonic/init_cfg.json --print-data > /etc/sonic/config_db.json + else + sonic-cfggen -m --print-data > /etc/sonic/config_db.json + fi else cp /usr/share/sonic/device/$platform/minigraph.xml /etc/sonic/ + if [ -f /etc/sonic/init_cfg.json ]; then + sonic-cfggen -m -j /etc/sonic/init_cfg.json --print-data > /etc/sonic/config_db.json + else + sonic-cfggen -m --print-data > /etc/sonic/config_db.json + fi fi if [ -d /host/image-$sonic_version/platform/$platform ]; then diff --git a/files/image_config/updategraph/updategraph b/files/image_config/updategraph/updategraph index 7240d913c7..4e9846fba0 100755 --- a/files/image_config/updategraph/updategraph +++ b/files/image_config/updategraph/updategraph @@ -68,6 +68,13 @@ while true; do sleep 5 done +echo "Regenerating config DB from minigraph..." +if [ -f /etc/sonic/init_cfg.json ]; then + sonic-cfggen -m -j /etc/sonic/init_cfg.json --print-data > /etc/sonic/config_db.json +else + sonic-cfggen -m --print-data > /etc/sonic/config_db.json +fi + # Mark as disabled after graph is successfully downloaded sed -i "/enabled=/d" /etc/sonic/updategraph.conf echo "enabled=false" >> /etc/sonic/updategraph.conf diff --git a/src/sonic-config-engine/minigraph.py b/src/sonic-config-engine/minigraph.py index 65738a0508..6dbf0d570d 100644 --- a/src/sonic-config-engine/minigraph.py +++ b/src/sonic-config-engine/minigraph.py @@ -249,9 +249,9 @@ def parse_dpg(dpg, hname): def parse_cpg(cpg, hname): - bgp_sessions = [] + bgp_sessions = {} myasn = None - bgp_peers_with_range = [] + bgp_peers_with_range = {} for child in cpg: tag = child.tag if tag == str(QName(ns, "PeeringSessions")): @@ -261,17 +261,15 @@ def parse_cpg(cpg, hname): end_router = session.find(str(QName(ns, "EndRouter"))).text end_peer = session.find(str(QName(ns, "EndPeer"))).text if end_router == hname: - bgp_sessions.append({ + bgp_sessions[start_peer] = { 'name': start_router, - 'addr': start_peer, - 'peer_addr': end_peer - }) + 'local_addr': end_peer + } else: - bgp_sessions.append({ + bgp_sessions[end_peer] = { 'name': end_router, - 'addr': end_peer, - 'peer_addr': start_peer - }) + 'local_addr': start_peer + } elif child.tag == str(QName(ns, "Routers")): for router in child.findall(str(QName(ns1, "BGPRouterDeclaration"))): asn = router.find(str(QName(ns1, "ASN"))).text @@ -285,12 +283,13 @@ def parse_cpg(cpg, hname): name = bgpPeer.find(str(QName(ns1, "Name"))).text ip_range = bgpPeer.find(str(QName(ns1, "PeersRange"))).text ip_range_group = ip_range.split(';') if ip_range and ip_range != "" else [] - bgp_peers_with_range.append({ + bgp_peers_with_range[name] = { 'name': name, 'ip_range': ip_range_group - }) + } else: - for bgp_session in bgp_sessions: + for peer in bgp_sessions: + bgp_session = bgp_sessions[peer] if hostname == bgp_session['name']: bgp_session['asn'] = int(asn) @@ -447,9 +446,9 @@ def parse_xml(filename, platform=None, port_config_file=None): # sorting by lambdas are not easily done without custom filters. # TODO: add jinja2 filter to accept a lambda to sort a list of dictionaries by attribute. # TODO: alternatively (preferred), implement class containers for multiple-attribute entries, enabling sort by attr - results['minigraph_bgp'] = sorted(bgp_sessions, key=lambda x: x['addr']) - results['minigraph_bgp_asn'] = bgp_asn - results['minigraph_bgp_peers_with_range'] = bgp_peers_with_range + results['BGP_NEIGHBOR'] = bgp_sessions + results['DEVICE_METADATA'] = {'localhost': { 'bgp_asn': bgp_asn }} + results['BGP_PEER_RANGE'] = bgp_peers_with_range # TODO: sort does not work properly on all interfaces of varying lengths. Need to sort by integer group(s). phyport_intfs = [] diff --git a/src/sonic-config-engine/sonic-cfggen b/src/sonic-config-engine/sonic-cfggen index d93b4a6a41..070b3100ea 100755 --- a/src/sonic-config-engine/sonic-cfggen +++ b/src/sonic-config-engine/sonic-cfggen @@ -73,37 +73,25 @@ TODO(taoyl): Current version of config db only supports BGP admin states. """ @staticmethod def db_to_output(db_data): - data_bgp_admin = {} - for table_name, content in db_data.iteritems(): - if table_name == 'BGP_NEIGHBOR': - for key, value in content.iteritems(): - if value.has_key('admin_status'): - data_bgp_admin[key] = (value['admin_status'] == 'up') - elif table_name == 'DEVICE_METADATA': - if content['localhost'].has_key('bgp_default_status'): - data_bgp_admin['all'] = (content['localhost']['bgp_default_status'] == 'up') - - output_data = {'bgp_admin_state': data_bgp_admin} if data_bgp_admin else {} - return output_data + return db_data @staticmethod def output_to_db(output_data): db_data = {} - for key, value in output_data.iteritems(): - if key == 'bgp_admin_state': - for neighbor, state in value.iteritems(): - if neighbor == 'all': - if not db_data.has_key('DEVICE_METADATA'): - db_data['DEVICE_METADATA'] = {'localhost': {}} - db_data['DEVICE_METADATA']['localhost']['bgp_default_status'] = 'up' if state else 'down' - else: - if not db_data.has_key('BGP_NEIGHBOR'): - db_data['BGP_NEIGHBOR'] = {} - if not db_data['BGP_NEIGHBOR'].has_key(neighbor): - db_data['BGP_NEIGHBOR'][neighbor] = {} - db_data['BGP_NEIGHBOR'][neighbor]['admin_status'] = 'up' if state else 'down' + for table_name in output_data: + if table_name == 'BGP_NEIGHBOR' or table_name == 'BGP_PEER_RANGE' or table_name == 'DEVICE_METADATA': + db_data[table_name] = output_data[table_name] return db_data +def deep_update(dst, src): + for key, value in src.iteritems(): + if isinstance(value, dict): + node = dst.setdefault(key, {}) + deep_update(node, value) + else: + dst[key] = value + return dst + def main(): parser=argparse.ArgumentParser(description="Render configuration file from minigraph data and jinja2 template.") @@ -126,7 +114,7 @@ def main(): data = {} machine_info = get_machine_info() if machine_info != None: - data.update(machine_info) + deep_update(data, machine_info) platform_info = get_platform_info(machine_info) if platform_info != None: data['platform'] = platform_info @@ -135,34 +123,34 @@ def main(): minigraph = args.minigraph if data.has_key('platform'): if args.port_config != None: - data.update(parse_xml(minigraph, data['platform'], args.port_config)) + deep_update(data, parse_xml(minigraph, data['platform'], args.port_config)) else: - data.update(parse_xml(minigraph, data['platform'])) + deep_update(data, parse_xml(minigraph, data['platform'])) else: if args.port_config != None: - data.update(parse_xml(minigraph, port_config_file=args.port_config)) + deep_update(data, parse_xml(minigraph, port_config_file=args.port_config)) else: - data.update(parse_xml(minigraph)) + deep_update(data, parse_xml(minigraph)) if args.device_description != None: - data.update(parse_device_desc_xml(args.device_description)) + deep_update(data, parse_device_desc_xml(args.device_description)) for yaml_file in args.yaml: with open(yaml_file, 'r') as stream: additional_data = yaml.load(stream) - data.update(additional_data) + deep_update(data, additional_data) for json_file in args.json: with open(json_file, 'r') as stream: - data.update(json.load(stream)) + deep_update(data, json.load(stream)) if args.additional_data != None: - data.update(json.loads(args.additional_data)) + deep_update(data, json.loads(args.additional_data)) if args.from_db: configdb = ConfigDBConnector() configdb.connect() - data.update(FormatConverter.db_to_output(configdb.get_config())) + deep_update(data, FormatConverter.db_to_output(configdb.get_config())) if args.template != None: template_file = os.path.abspath(args.template) diff --git a/src/sonic-config-engine/tests/test_cfggen.py b/src/sonic-config-engine/tests/test_cfggen.py index 6835c60e27..d3ff3e8b9f 100644 --- a/src/sonic-config-engine/tests/test_cfggen.py +++ b/src/sonic-config-engine/tests/test_cfggen.py @@ -111,7 +111,7 @@ class TestCfgGen(TestCase): self.assertEqual(output.strip(), "{'Ethernet116': {'name': 'ARISTA02T1', 'port': 'Ethernet1/1'}, 'Ethernet124': {'name': 'ARISTA04T1', 'port': 'Ethernet1/1'}, 'Ethernet112': {'name': 'ARISTA01T1', 'port': 'Ethernet1/1'}, 'Ethernet120': {'name': 'ARISTA03T1', 'port': 'Ethernet1/1'}}") def test_minigraph_peers_with_range(self): - argument = '-m "' + self.sample_graph_bgp_speaker + '" -p "' + self.port_config + '" -v minigraph_bgp_peers_with_range' + argument = '-m "' + self.sample_graph_bgp_speaker + '" -p "' + self.port_config + '" -v BGP_PEER_RANGE.values\(\)' output = self.run_script(argument) self.assertEqual(output.strip(), "[{'name': 'BGPSLBPassive', 'ip_range': ['10.10.10.10/26', '100.100.100.100/26']}]") diff --git a/src/sonic-utilities b/src/sonic-utilities index 6c7e22362f..e4f7161b05 160000 --- a/src/sonic-utilities +++ b/src/sonic-utilities @@ -1 +1 @@ -Subproject commit 6c7e22362fbc05ba455e7e336e2a88430de0de18 +Subproject commit e4f7161b055a345813424004f17b116a055d590a From 96636e2124c55700f7542d3f3581ab4b28242770 Mon Sep 17 00:00:00 2001 From: Polly Hsu Date: Wed, 9 Aug 2017 12:19:50 +0800 Subject: [PATCH 6/8] [device/accton]: Update Accton-AS7712-32X (#776) * [device/accton]: Update Accton-AS7712-32X * Add Broadcom LED microprocessor / pre-emphasis initialization Signed-off-by: polly_hsu@accton.com * Update start.sh * Update start.sh * [device/accton]: Update Accton-AS7712-32X * Add Broadcom LED microprocessor (Remove pre-emphasis initialization) Signed-off-by: polly_hsu@accton.com --- .../led_proc_init.soc | 41 +++++++++++++++++++ platform/broadcom/docker-syncd-brcm/start.sh | 9 ++-- 2 files changed, 47 insertions(+), 3 deletions(-) create mode 100755 device/accton/x86_64-accton_as7712_32x-r0/led_proc_init.soc diff --git a/device/accton/x86_64-accton_as7712_32x-r0/led_proc_init.soc b/device/accton/x86_64-accton_as7712_32x-r0/led_proc_init.soc new file mode 100755 index 0000000000..719cb77771 --- /dev/null +++ b/device/accton/x86_64-accton_as7712_32x-r0/led_proc_init.soc @@ -0,0 +1,41 @@ +m CMIC_LEDUP0_PORT_ORDER_REMAP_0_3 REMAP_PORT_0=31 REMAP_PORT_1=30 REMAP_PORT_2=29 REMAP_PORT_3=28 +m CMIC_LEDUP0_PORT_ORDER_REMAP_4_7 REMAP_PORT_4=27 REMAP_PORT_5=26 REMAP_PORT_6=25 REMAP_PORT_7=24 +m CMIC_LEDUP0_PORT_ORDER_REMAP_8_11 REMAP_PORT_8=23 REMAP_PORT_9=22 REMAP_PORT_10=21 REMAP_PORT_11=20 +m CMIC_LEDUP0_PORT_ORDER_REMAP_12_15 REMAP_PORT_12=19 REMAP_PORT_13=18 REMAP_PORT_14=17 REMAP_PORT_15=16 +m CMIC_LEDUP0_PORT_ORDER_REMAP_16_19 REMAP_PORT_16=63 REMAP_PORT_17=62 REMAP_PORT_18=61 REMAP_PORT_19=60 +m CMIC_LEDUP0_PORT_ORDER_REMAP_20_23 REMAP_PORT_20=59 REMAP_PORT_21=58 REMAP_PORT_22=57 REMAP_PORT_23=56 +m CMIC_LEDUP0_PORT_ORDER_REMAP_24_27 REMAP_PORT_24=55 REMAP_PORT_25=54 REMAP_PORT_26=53 REMAP_PORT_27=52 +m CMIC_LEDUP0_PORT_ORDER_REMAP_28_31 REMAP_PORT_28=51 REMAP_PORT_29=50 REMAP_PORT_30=49 REMAP_PORT_31=48 +m CMIC_LEDUP0_PORT_ORDER_REMAP_32_35 REMAP_PORT_32=47 REMAP_PORT_33=46 REMAP_PORT_34=45 REMAP_PORT_35=44 +m CMIC_LEDUP0_PORT_ORDER_REMAP_36_39 REMAP_PORT_36=43 REMAP_PORT_37=42 REMAP_PORT_38=41 REMAP_PORT_39=40 +m CMIC_LEDUP0_PORT_ORDER_REMAP_40_43 REMAP_PORT_40=39 REMAP_PORT_41=38 REMAP_PORT_42=37 REMAP_PORT_43=36 +m CMIC_LEDUP0_PORT_ORDER_REMAP_44_47 REMAP_PORT_44=35 REMAP_PORT_45=34 REMAP_PORT_46=33 REMAP_PORT_47=32 +m CMIC_LEDUP0_PORT_ORDER_REMAP_48_51 REMAP_PORT_48=15 REMAP_PORT_49=14 REMAP_PORT_50=13 REMAP_PORT_51=12 +m CMIC_LEDUP0_PORT_ORDER_REMAP_52_55 REMAP_PORT_52=11 REMAP_PORT_53=10 REMAP_PORT_54=9 REMAP_PORT_55=8 +m CMIC_LEDUP0_PORT_ORDER_REMAP_56_59 REMAP_PORT_56=7 REMAP_PORT_57=6 REMAP_PORT_58=5 REMAP_PORT_59=4 +m CMIC_LEDUP0_PORT_ORDER_REMAP_60_63 REMAP_PORT_60=3 REMAP_PORT_61=2 REMAP_PORT_62=1 REMAP_PORT_63=0 + +m CMIC_LEDUP1_PORT_ORDER_REMAP_0_3 REMAP_PORT_0=35 REMAP_PORT_1=34 REMAP_PORT_2=33 REMAP_PORT_3=32 +m CMIC_LEDUP1_PORT_ORDER_REMAP_4_7 REMAP_PORT_4=39 REMAP_PORT_5=38 REMAP_PORT_6=37 REMAP_PORT_7=36 +m CMIC_LEDUP1_PORT_ORDER_REMAP_8_11 REMAP_PORT_8=43 REMAP_PORT_9=42 REMAP_PORT_10=41 REMAP_PORT_11=40 +m CMIC_LEDUP1_PORT_ORDER_REMAP_12_15 REMAP_PORT_12=47 REMAP_PORT_13=46 REMAP_PORT_14=45 REMAP_PORT_15=44 +m CMIC_LEDUP1_PORT_ORDER_REMAP_16_19 REMAP_PORT_16=3 REMAP_PORT_17=2 REMAP_PORT_18=1 REMAP_PORT_19=0 +m CMIC_LEDUP1_PORT_ORDER_REMAP_20_23 REMAP_PORT_20=7 REMAP_PORT_21=6 REMAP_PORT_22=5 REMAP_PORT_23=4 +m CMIC_LEDUP1_PORT_ORDER_REMAP_24_27 REMAP_PORT_24=11 REMAP_PORT_25=10 REMAP_PORT_26=9 REMAP_PORT_27=8 +m CMIC_LEDUP1_PORT_ORDER_REMAP_28_31 REMAP_PORT_28=15 REMAP_PORT_29=14 REMAP_PORT_30=13 REMAP_PORT_31=12 +m CMIC_LEDUP1_PORT_ORDER_REMAP_32_35 REMAP_PORT_32=19 REMAP_PORT_33=18 REMAP_PORT_34=17 REMAP_PORT_35=16 +m CMIC_LEDUP1_PORT_ORDER_REMAP_36_39 REMAP_PORT_36=23 REMAP_PORT_37=22 REMAP_PORT_38=21 REMAP_PORT_39=20 +m CMIC_LEDUP1_PORT_ORDER_REMAP_40_43 REMAP_PORT_40=27 REMAP_PORT_41=26 REMAP_PORT_42=25 REMAP_PORT_43=24 +m CMIC_LEDUP1_PORT_ORDER_REMAP_44_47 REMAP_PORT_44=31 REMAP_PORT_45=30 REMAP_PORT_46=29 REMAP_PORT_47=28 +m CMIC_LEDUP1_PORT_ORDER_REMAP_48_51 REMAP_PORT_48=51 REMAP_PORT_49=50 REMAP_PORT_50=49 REMAP_PORT_51=48 +m CMIC_LEDUP1_PORT_ORDER_REMAP_52_55 REMAP_PORT_52=55 REMAP_PORT_53=54 REMAP_PORT_54=53 REMAP_PORT_55=52 +m CMIC_LEDUP1_PORT_ORDER_REMAP_56_59 REMAP_PORT_56=59 REMAP_PORT_57=58 REMAP_PORT_58=57 REMAP_PORT_59=56 +m CMIC_LEDUP1_PORT_ORDER_REMAP_60_63 REMAP_PORT_60=63 REMAP_PORT_61=62 REMAP_PORT_62=61 REMAP_PORT_63=60 + +led 0 prog 02 FD 42 80 02 FF 42 00 02 FE 42 00 02 FA 42 E0 02 FB 42 40 06 F9 D2 00 74 1E 02 F9 42 03 67 AC 67 C3 67 52 86 FE 67 C3 67 52 86 FE 67 C3 67 52 86 FE 67 C3 67 52 86 FE 06 FB D6 FE 74 1E 86 FC 3E FA 06 FE 88 4A 03 71 4C 67 84 57 67 84 57 67 98 57 06 FE 88 80 4A 00 27 97 75 4F 90 4A 00 27 4A 01 27 B7 97 71 69 77 42 06 F9 D6 FC 74 7C 02 F9 4A 07 37 4E 07 02 FC 42 00 4E 07 06 F9 0A 07 71 4F 77 42 16 FF 06 FD 17 4D DA 07 74 95 12 FF 52 00 86 FD 57 86 FF 57 16 FF 06 FD 07 4D DA 07 74 A9 12 FF 52 00 86 FD 57 86 FF 57 06 FE C2 FC 98 98 12 F4 50 C2 FC 98 98 F2 F0 14 06 F4 C2 03 88 77 D1 06 FE C2 FC 98 98 F2 E0 14 06 FE C2 03 88 18 71 E2 80 18 71 DD 67 98 67 98 57 67 84 67 98 57 80 18 71 EB 67 98 67 84 57 67 84 67 84 57 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +led 0 start + +led 1 prog 02 FD 42 80 02 FF 42 00 02 FE 42 00 02 FA 42 E0 02 FB 42 40 06 F9 D2 00 74 1E 02 F9 42 03 67 AC 67 C3 67 52 86 FE 67 C3 67 52 86 FE 67 C3 67 52 86 FE 67 C3 67 52 86 FE 06 FB D6 FE 74 1E 86 FC 3E FA 06 FE 88 4A 03 71 4C 67 84 57 67 84 57 67 98 57 06 FE 88 80 4A 00 27 97 75 4F 90 4A 00 27 4A 01 27 B7 97 71 69 77 42 06 F9 D6 FC 74 7C 02 F9 4A 07 37 4E 07 02 FC 42 00 4E 07 06 F9 0A 07 71 4F 77 42 16 FF 06 FD 17 4D DA 07 74 95 12 FF 52 00 86 FD 57 86 FF 57 16 FF 06 FD 07 4D DA 07 74 A9 12 FF 52 00 86 FD 57 86 FF 57 06 FE C2 FC 98 98 12 F4 50 C2 FC 98 98 F2 F0 14 06 F4 C2 03 88 77 D1 06 FE C2 FC 98 98 F2 E0 14 06 FE C2 03 88 18 71 E2 80 18 71 DD 67 98 67 98 57 67 84 67 98 57 80 18 71 EB 67 98 67 84 57 67 84 67 84 57 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 +led 1 start + +led auto on \ No newline at end of file diff --git a/platform/broadcom/docker-syncd-brcm/start.sh b/platform/broadcom/docker-syncd-brcm/start.sh index 930609a195..e06a29b2b2 100755 --- a/platform/broadcom/docker-syncd-brcm/start.sh +++ b/platform/broadcom/docker-syncd-brcm/start.sh @@ -8,15 +8,18 @@ supervisorctl start rsyslogd supervisorctl start syncd -# If this platform has an initialization file for the Broadcom LED microprocessor, load it -if [ -r ${PLATFORM_DIR}/led_proc_init.soc ]; then - # Wait until syncd has created the socket for bcmcmd to connect to +# Function: wait until syncd has created the socket for bcmcmd to connect to +wait_syncd() { while true; do if [ -e /var/run/sswsyncd/sswsyncd.socket ]; then break fi sleep 1 done +} +# If this platform has an initialization file for the Broadcom LED microprocessor, load it +if [ -r ${PLATFORM_DIR}/led_proc_init.soc ]; then + wait_syncd /usr/bin/bcmcmd -t 60 "rcload ${PLATFORM_DIR}/led_proc_init.soc" fi From 847a9480698f0098315b86c3216c65e039e91a02 Mon Sep 17 00:00:00 2001 From: Taoyu Li Date: Tue, 8 Aug 2017 21:40:31 -0700 Subject: [PATCH 7/8] Update sonic-utilities pointer to support reload minigraph (#871) --- src/sonic-utilities | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sonic-utilities b/src/sonic-utilities index e4f7161b05..c7f6ff677b 160000 --- a/src/sonic-utilities +++ b/src/sonic-utilities @@ -1 +1 @@ -Subproject commit e4f7161b055a345813424004f17b116a055d590a +Subproject commit c7f6ff677b54eb401e7b2fd3a3d9c4072325bb78 From 9d5adb993ae34d9ce64de3320b0a4654af94af26 Mon Sep 17 00:00:00 2001 From: Joe LeVeque Date: Thu, 10 Aug 2017 16:24:57 -0700 Subject: [PATCH 8/8] [System logs]: Improvements to prevent filling /var/log partition (#865) - Force log rotation at size thresholds only (no longer also rotating logs daily), allowing for more consistent archived log size - Eliminate remaining duplicate log messages - Cron facility now only logs to cron.log (was also logging to syslog) - Debug, mail, news and user log facilities only log to syslog; no longer creating separate log files for these facilities - Cron job that calls logrotate every minute now uses the main /etc/logrotate.conf file so as to check/rotate all logs every minute, not just the logs specified in the rsyslog file. Also redirecting output of this command to /dev/null to prevent "(CRON) info (No MTA installed, discarding output)" messages in cron.log due to lack of a mail service - Delete archive files based on remaining /var/log partition space. Note that this solution currently requires a minimum /var/log partition size of 32MB to function correctly - Update sonic-sairedis and sonic-swss submodules to incorporate recording file name changes - Add .screen file to .gitignore (unrelated) --- .gitignore | 1 + .../build_templates/sonic_debian_extension.j2 | 2 +- files/image_config/cron.d/logrotate | 2 +- files/image_config/logrotate.d/rsyslog | 62 ------------ files/image_config/logrotate/logrotate.conf | 32 +++++++ files/image_config/logrotate/logrotate.d/apt | 15 +++ files/image_config/logrotate/logrotate.d/dpkg | 18 ++++ .../image_config/logrotate/logrotate.d/monit | 12 +++ .../logrotate/logrotate.d/rsyslog | 96 +++++++++++++++++++ .../rsyslog/rsyslog.d/99-default.conf | 51 +--------- src/sonic-sairedis | 2 +- src/sonic-swss | 2 +- 12 files changed, 182 insertions(+), 113 deletions(-) delete mode 100644 files/image_config/logrotate.d/rsyslog create mode 100644 files/image_config/logrotate/logrotate.conf create mode 100644 files/image_config/logrotate/logrotate.d/apt create mode 100644 files/image_config/logrotate/logrotate.d/dpkg create mode 100644 files/image_config/logrotate/logrotate.d/monit create mode 100644 files/image_config/logrotate/logrotate.d/rsyslog diff --git a/.gitignore b/.gitignore index 16d7b53f60..9ca9d2ff1a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ # Build system related .platform +.screen # Build artifacts fsroot/ diff --git a/files/build_templates/sonic_debian_extension.j2 b/files/build_templates/sonic_debian_extension.j2 index fc84191e3c..0b1d19b6e1 100644 --- a/files/build_templates/sonic_debian_extension.j2 +++ b/files/build_templates/sonic_debian_extension.j2 @@ -106,7 +106,7 @@ sudo cp $IMAGE_CONFIGS/rsyslog/rsyslog.conf.j2 $FILESYSTEM_ROOT/usr/share/sonic/ sudo cp $IMAGE_CONFIGS/rsyslog/rsyslog.d/* $FILESYSTEM_ROOT/etc/rsyslog.d/ # Copy logrotate.d configuration files -sudo cp -f $IMAGE_CONFIGS/logrotate.d/rsyslog $FILESYSTEM_ROOT/etc/logrotate.d/ +sudo cp -f $IMAGE_CONFIGS/logrotate/logrotate.d/* $FILESYSTEM_ROOT/etc/logrotate.d/ # Copy systemd-journald configuration files sudo cp -f $IMAGE_CONFIGS/systemd/journald.conf $FILESYSTEM_ROOT/etc/systemd/ diff --git a/files/image_config/cron.d/logrotate b/files/image_config/cron.d/logrotate index 9e1335cbd4..d0c2e0829b 100644 --- a/files/image_config/cron.d/logrotate +++ b/files/image_config/cron.d/logrotate @@ -1,2 +1,2 @@ # Attempt to rotate system logs once per minute -* * * * * root /usr/sbin/logrotate /etc/logrotate.d/rsyslog +* * * * * root /usr/sbin/logrotate /etc/logrotate.conf > /dev/null 2>&1 diff --git a/files/image_config/logrotate.d/rsyslog b/files/image_config/logrotate.d/rsyslog deleted file mode 100644 index 5101b0e41f..0000000000 --- a/files/image_config/logrotate.d/rsyslog +++ /dev/null @@ -1,62 +0,0 @@ -/var/log/syslog -/var/log/quagga/*.log -/var/log/teamd.log -{ - rotate 7 - daily - maxsize 100M - missingok - notifempty - compress - delaycompress - postrotate - # Calling kill directly instead of 'service rsyslog rotate >/dev/null' due - # to bug in init-system-helpers. Bug has apparently been fixed in v1.47. - # However, Debian Jessie is still using v1.22. - # See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=672218 - kill -HUP $(cat /var/run/rsyslogd.pid) - endscript -} -/var/log/swss/*.rec -{ - rotate 7 - daily - maxsize 20M - missingok - notifempty - compress - delaycompress - sharedscripts - postrotate - pgrep -x orchagent | xargs /bin/kill -HUP 2>/dev/null || true - endscript -} -/var/log/mail.info -/var/log/mail.warn -/var/log/mail.err -/var/log/mail.log -/var/log/daemon.log -/var/log/kern.log -/var/log/auth.log -/var/log/user.log -/var/log/lpr.log -/var/log/cron.log -/var/log/debug -/var/log/messages -{ - rotate 4 - daily - maxsize 50M - missingok - notifempty - compress - delaycompress - sharedscripts - postrotate - # Calling kill directly instead of 'service rsyslog rotate >/dev/null' due - # to bug in init-system-helpers. Bug has apparently been fixed in v1.47. - # However, Debian Jessie is still using v1.22. - # See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=672218 - kill -HUP $(cat /var/run/rsyslogd.pid) - endscript -} diff --git a/files/image_config/logrotate/logrotate.conf b/files/image_config/logrotate/logrotate.conf new file mode 100644 index 0000000000..6f107e2098 --- /dev/null +++ b/files/image_config/logrotate/logrotate.conf @@ -0,0 +1,32 @@ +# see "man logrotate" for details +# Rotate log files daily by default +daily + +# Keep 4 days worth of backlogs by default +rotate 4 + +# create new (empty) log files after rotating old ones +create + +# uncomment this if you want your log files compressed +#compress + +# packages drop log rotation information into this directory +include /etc/logrotate.d + +# no packages own wtmp, or btmp -- we'll rotate them here +/var/log/wtmp { + missingok + size 100k + create 0664 root utmp + rotate 1 +} + +/var/log/btmp { + missingok + size 100k + create 0660 root utmp + rotate 1 +} + +# system-specific logs may be configured here diff --git a/files/image_config/logrotate/logrotate.d/apt b/files/image_config/logrotate/logrotate.d/apt new file mode 100644 index 0000000000..7584dcacc8 --- /dev/null +++ b/files/image_config/logrotate/logrotate.d/apt @@ -0,0 +1,15 @@ +/var/log/apt/term.log { + size 100k + rotate 1 + compress + missingok + notifempty +} + +/var/log/apt/history.log { + size 100k + rotate 1 + compress + missingok + notifempty +} diff --git a/files/image_config/logrotate/logrotate.d/dpkg b/files/image_config/logrotate/logrotate.d/dpkg new file mode 100644 index 0000000000..5e24c7ed74 --- /dev/null +++ b/files/image_config/logrotate/logrotate.d/dpkg @@ -0,0 +1,18 @@ +/var/log/dpkg.log { + size 100k + rotate 1 + compress + delaycompress + missingok + notifempty + create 644 root root +} +/var/log/alternatives.log { + size 100k + rotate 1 + compress + delaycompress + missingok + notifempty + create 644 root root +} diff --git a/files/image_config/logrotate/logrotate.d/monit b/files/image_config/logrotate/logrotate.d/monit new file mode 100644 index 0000000000..7846dfadb7 --- /dev/null +++ b/files/image_config/logrotate/logrotate.d/monit @@ -0,0 +1,12 @@ +/var/log/monit.log { + size 100k + rotate 1 + missingok + create 640 root adm + notifempty + compress + delaycompress + postrotate + invoke-rc.d monit reload > /dev/null + endscript +} diff --git a/files/image_config/logrotate/logrotate.d/rsyslog b/files/image_config/logrotate/logrotate.d/rsyslog new file mode 100644 index 0000000000..ba550dcd24 --- /dev/null +++ b/files/image_config/logrotate/logrotate.d/rsyslog @@ -0,0 +1,96 @@ +# These logs should no longer get created. However, in case they do get created, +# we should keep them to a small size and rotate them also. +/var/log/mail.info +/var/log/mail.warn +/var/log/mail.err +/var/log/mail.log +/var/log/daemon.log +/var/log/kern.log +/var/log/user.log +/var/log/lpr.log +/var/log/debug +/var/log/messages +{ + size 10k + rotate 1 + missingok + notifempty + compress + delaycompress + sharedscripts + postrotate + # calling kill directly instead of 'service rsyslog rotate >/dev/null' due + # to bug in init-system-helpers. bug has apparently been fixed in v1.47. + # however, debian jessie is still using v1.22. + # see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=672218 + kill -hup $(cat /var/run/rsyslogd.pid) + endscript +} + +/var/log/auth.log +/var/log/cron.log +/var/log/syslog +/var/log/teamd.log +/var/log/quagga/bgpd.log +/var/log/quagga/zebra.log +/var/log/swss/sairedis.rec +/var/log/swss/swss.rec +{ + size 1M + rotate 5000 + missingok + notifempty + compress + delaycompress + nosharedscripts + prerotate + # Adjust NUM_LOGS_TO_ROTATE to reflect number of log files that trigger this block specified above + NUM_LOGS_TO_ROTATE=8 + + # Adjust LOG_FILE_ROTATE_SIZE_KB to reflect the "size" parameter specified above, in kB + LOG_FILE_ROTATE_SIZE_KB=1024 + + # Reserve space for btmp, wtmp, dpkg.log, monit.log, etc., as well as logs that + # should be disabled, just in case they get created and rotated + RESERVED_SPACE_KB=4096 + + VAR_LOG_SIZE_KB=$(df -k /var/log | sed -n 2p | awk '{ print $2 }') + + # Limit usable space to 95% of the partition minus the reserved space for other logs + USABLE_SPACE_KB=$(( (VAR_LOG_SIZE_KB * 95 / 100) - RESERVED_SPACE_KB)) + + # Set our threshold so as to maintain enough space to write all logs from empty to full + # Most likely, some logs will have non-zero size when this is called, so this errs on the side + # of caution, giving us a bit of a cushion if a log grows quickly and passes its rotation size + THRESHOLD_KB=$((USABLE_SPACE_KB - (NUM_LOGS_TO_ROTATE * LOG_FILE_ROTATE_SIZE_KB * 2))) + + while true; do + USED_KB=$(du -s /var/log | awk '{ print $1; }') + + if [ $USED_KB -lt $THRESHOLD_KB ]; then + break + else + OLDEST_ARCHIVE_FILE=$(find /var/log -type f -printf '%T+ %p\n' | grep -E '.+\.[0-9]+(\.gz)?$' | sort | head -n 1 | awk '{ print $2; }') + + if [ -z "$OLDEST_ARCHIVE_FILE" ]; then + logger -p syslog.err -t "logrotate" "No archive file to delete -- potential for filling up /var/log partition!" + break + fi + + logger -p syslog.info -t "logrotate" "Deleting archive file $OLDEST_ARCHIVE_FILE to free up space" + rm -rf "$OLDEST_ARCHIVE_FILE" + fi + done + endscript + postrotate + if [ $(echo $1 | grep -c "/var/log/swss/") -gt 0 ]; then + pgrep -x orchagent | xargs /bin/kill -HUP 2>/dev/null || true + else + # Calling kill directly instead of 'service rsyslog rotate >/dev/null' due + # to bug in init-system-helpers. Bug has apparently been fixed in v1.47. + # However, Debian Jessie is still using v1.22. + # See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=672218 + kill -HUP $(cat /var/run/rsyslogd.pid) + fi + endscript +} diff --git a/files/image_config/rsyslog/rsyslog.d/99-default.conf b/files/image_config/rsyslog/rsyslog.d/99-default.conf index 51049e7473..06a40ca648 100644 --- a/files/image_config/rsyslog/rsyslog.d/99-default.conf +++ b/files/image_config/rsyslog/rsyslog.d/99-default.conf @@ -1,61 +1,18 @@ # # First some standard log files. Log by facility. # + +# Log all facilities to /var/log/syslog except cron, auth +# and authpriv. They are noisy - log them to their own files +*.*;cron,auth,authpriv.none -/var/log/syslog auth,authpriv.* /var/log/auth.log -*.*;auth,authpriv.none -/var/log/syslog cron.* /var/log/cron.log -# Do not redirect daemon, kernel or lpr logs to -# their own files. Let them log to /var/log/syslog -#daemon.* -/var/log/daemon.log -#kern.* -/var/log/kern.log -#kern.* -/var/persist/log/kern.log -#lpr.* -/var/log/lpr.log -mail.* -/var/log/mail.log -user.* -/var/log/user.log -# -# Logging for the mail system. Split it up so that -# it is easy to write scripts to parse these files. -# -mail.info -/var/log/mail.info -mail.warn -/var/log/mail.warn -mail.err /var/log/mail.err - -# -# Logging for INN news system. -# -news.crit /var/log/news/news.crit -news.err /var/log/news/news.err -news.notice -/var/log/news/news.notice - -# -# Some "catch-all" log files. -# -*.=debug;\ - auth,authpriv.none;\ - news.none;mail.none -/var/log/debug -# -# Removed as duplicates: -#*.=info;*.=notice;*.=warn;\ -# auth,authpriv.none;\ -# cron,daemon.none;\ -# mail,news.none -/var/log/messages -# -*.=crit;*.=alert;*.=emerg -/var/persist/log/alarms # # Emergencies are sent to everybody logged in. # *.emerg :omusrmsg:* -# -# I like to have messages displayed on the console, but only on a virtual -# console I usually leave idle. -# -#daemon,mail.*;\ -# news.=crit;news.=err;news.=notice;\ -# *.=debug;*.=info;\ -# *.=notice;*.=warn /dev/tty8 - # The named pipe /dev/xconsole is for the `xconsole' utility. To use it, # you must invoke `xconsole' with the `-file' option: # diff --git a/src/sonic-sairedis b/src/sonic-sairedis index b865912105..7e70b4d630 160000 --- a/src/sonic-sairedis +++ b/src/sonic-sairedis @@ -1 +1 @@ -Subproject commit b865912105f2f80ee2516899e6367f863d5f6235 +Subproject commit 7e70b4d63020fc9ea1aa009c264e4effab7bcda0 diff --git a/src/sonic-swss b/src/sonic-swss index 27c49a0bf3..ab31a9af7e 160000 --- a/src/sonic-swss +++ b/src/sonic-swss @@ -1 +1 @@ -Subproject commit 27c49a0bf3a71556b553aa30fe2a7c1cdb996142 +Subproject commit ab31a9af7ef2c5ea9fe5f0f89f0a61b3ec0f83bf