From 471a3a8067166e4bef637d1f5e08c09b70a36482 Mon Sep 17 00:00:00 2001 From: mssonicbld <79238446+mssonicbld@users.noreply.github.com> Date: Mon, 7 Aug 2023 09:26:45 +0800 Subject: [PATCH] Add support data for fabric monitoring in CONFIG_DB. (#14170) (#16045) Added support data for fabric monitoring in CONFIG_DB The CONFIG_DB now has the FABRIC_MONITOR|FABRIC_MONITOR_DATA table for default value for fabric port monitoring. An example output of getting this table is: sonic-db-cli CONFIG_DB hgetall "FABRIC_MONITOR|FABRIC_MONITOR_DATA" {'monErrThreshCrcCells': '1', 'monErrThreshRxCells': '61035156', 'monPollThreshIsolation': '1', 'monPollThreshRecovery': '8'} The CONFIG_DB now also has a table for each fabric port for its isolate status. An example output of getting this table is: sonic-db-cli CONFIG_DB hgetall "FABRIC_PORT|Fabric20" {'alias': 'Fabric20', 'isolateStatus': 'False', 'lanes': '20'} Co-authored-by: jfeng-arista <98421150+jfeng-arista@users.noreply.github.com> --- .../fabric_monitor_config.json | 8 + .../Arista-7804R3-FM/fabric_port_config.ini | 193 ++++++++++++++++++ .../fabric_monitor_config.json | 8 + .../Arista-7808R3-FM/fabric_port_config.ini | 193 ++++++++++++++++++ .../fabric_monitor_config.json | 8 + .../Arista-7808R3A-FM/fabric_port_config.ini | 193 ++++++++++++++++++ .../fabric_monitor_config.json | 8 + .../fabric_port_config.ini | 113 ++++++++++ .../fabric_monitor_config.json | 8 + .../fabric_port_config.ini | 113 ++++++++++ .../fabric_monitor_config.json | 8 + .../fabric_port_config.ini | 113 ++++++++++ .../fabric_monitor_config.json | 8 + .../fabric_port_config.ini | 113 ++++++++++ .../fabric_monitor_config.json | 8 + .../fabric_port_config.ini | 193 ++++++++++++++++++ src/sonic-config-engine/minigraph.py | 15 +- src/sonic-config-engine/portconfig.py | 68 ++++++ .../sonic_py_common/device_info.py | 113 ++++++++++ 19 files changed, 1482 insertions(+), 2 deletions(-) create mode 100644 device/arista/x86_64-arista_7800_sup/Arista-7804R3-FM/fabric_monitor_config.json create mode 100644 device/arista/x86_64-arista_7800_sup/Arista-7804R3-FM/fabric_port_config.ini create mode 100644 device/arista/x86_64-arista_7800_sup/Arista-7808R3-FM/fabric_monitor_config.json create mode 100644 device/arista/x86_64-arista_7800_sup/Arista-7808R3-FM/fabric_port_config.ini create mode 100644 device/arista/x86_64-arista_7800_sup/Arista-7808R3A-FM/fabric_monitor_config.json create mode 100644 device/arista/x86_64-arista_7800_sup/Arista-7808R3A-FM/fabric_port_config.ini create mode 100644 device/arista/x86_64-arista_7800r3_48cq2_lc/Arista-7800R3-48CQ2-C48/fabric_monitor_config.json create mode 100644 device/arista/x86_64-arista_7800r3_48cq2_lc/Arista-7800R3-48CQ2-C48/fabric_port_config.ini create mode 100644 device/arista/x86_64-arista_7800r3_48cq2_lc/fabric_monitor_config.json create mode 100644 device/arista/x86_64-arista_7800r3_48cq2_lc/fabric_port_config.ini create mode 100644 device/arista/x86_64-arista_7800r3_48cqm2_lc/Arista-7800R3-48CQM2-C48/fabric_monitor_config.json create mode 100644 device/arista/x86_64-arista_7800r3_48cqm2_lc/Arista-7800R3-48CQM2-C48/fabric_port_config.ini create mode 100644 device/arista/x86_64-arista_7800r3_48cqm2_lc/fabric_monitor_config.json create mode 100644 device/arista/x86_64-arista_7800r3_48cqm2_lc/fabric_port_config.ini create mode 100644 device/arista/x86_64-arista_7800r3a_36d2_lc/Arista-7800R3A-36D2-C72/fabric_monitor_config.json create mode 100644 device/arista/x86_64-arista_7800r3a_36d2_lc/Arista-7800R3A-36D2-C72/fabric_port_config.ini diff --git a/device/arista/x86_64-arista_7800_sup/Arista-7804R3-FM/fabric_monitor_config.json b/device/arista/x86_64-arista_7800_sup/Arista-7804R3-FM/fabric_monitor_config.json new file mode 100644 index 0000000000..653b25d1e2 --- /dev/null +++ b/device/arista/x86_64-arista_7800_sup/Arista-7804R3-FM/fabric_monitor_config.json @@ -0,0 +1,8 @@ +{ + "FABRIC_MONITOR_DATA": { + "monErrThreshCrcCells": 1, + "monErrThreshRxCells": 61035156, + "monPollThreshRecovery": 8, + "monPollThreshIsolation": 1 + } +} diff --git a/device/arista/x86_64-arista_7800_sup/Arista-7804R3-FM/fabric_port_config.ini b/device/arista/x86_64-arista_7800_sup/Arista-7804R3-FM/fabric_port_config.ini new file mode 100644 index 0000000000..f9a60d04e5 --- /dev/null +++ b/device/arista/x86_64-arista_7800_sup/Arista-7804R3-FM/fabric_port_config.ini @@ -0,0 +1,193 @@ +# name lanes isolateStatus +Fabric0 0 False +Fabric1 1 False +Fabric2 2 False +Fabric3 3 False +Fabric4 4 False +Fabric5 5 False +Fabric6 6 False +Fabric7 7 False +Fabric8 8 False +Fabric9 9 False +Fabric10 10 False +Fabric11 11 False +Fabric12 12 False +Fabric13 13 False +Fabric14 14 False +Fabric15 15 False +Fabric16 16 False +Fabric17 17 False +Fabric18 18 False +Fabric19 19 False +Fabric20 20 False +Fabric21 21 False +Fabric22 22 False +Fabric23 23 False +Fabric24 24 False +Fabric25 25 False +Fabric26 26 False +Fabric27 27 False +Fabric28 28 False +Fabric29 29 False +Fabric30 30 False +Fabric31 31 False +Fabric32 32 False +Fabric33 33 False +Fabric34 34 False +Fabric35 35 False +Fabric36 36 False +Fabric37 37 False +Fabric38 38 False +Fabric39 39 False +Fabric40 40 False +Fabric41 41 False +Fabric42 42 False +Fabric43 43 False +Fabric44 44 False +Fabric45 45 False +Fabric46 46 False +Fabric47 47 False +Fabric48 48 False +Fabric49 49 False +Fabric50 50 False +Fabric51 51 False +Fabric52 52 False +Fabric53 53 False +Fabric54 54 False +Fabric55 55 False +Fabric56 56 False +Fabric57 57 False +Fabric58 58 False +Fabric59 59 False +Fabric60 60 False +Fabric61 61 False +Fabric62 62 False +Fabric63 63 False +Fabric64 64 False +Fabric65 65 False +Fabric66 66 False +Fabric67 67 False +Fabric68 68 False +Fabric69 69 False +Fabric70 70 False +Fabric71 71 False +Fabric72 72 False +Fabric73 73 False +Fabric74 74 False +Fabric75 75 False +Fabric76 76 False +Fabric77 77 False +Fabric78 78 False +Fabric79 79 False +Fabric80 80 False +Fabric81 81 False +Fabric82 82 False +Fabric83 83 False +Fabric84 84 False +Fabric85 85 False +Fabric86 86 False +Fabric87 87 False +Fabric88 88 False +Fabric89 89 False +Fabric90 90 False +Fabric91 91 False +Fabric92 92 False +Fabric93 93 False +Fabric94 94 False +Fabric95 95 False +Fabric96 96 False +Fabric97 97 False +Fabric98 98 False +Fabric99 99 False +Fabric100 100 False +Fabric101 101 False +Fabric102 102 False +Fabric103 103 False +Fabric104 104 False +Fabric105 105 False +Fabric106 106 False +Fabric107 107 False +Fabric108 108 False +Fabric109 109 False +Fabric110 110 False +Fabric111 111 False +Fabric112 112 False +Fabric113 113 False +Fabric114 114 False +Fabric115 115 False +Fabric116 116 False +Fabric117 117 False +Fabric118 118 False +Fabric119 119 False +Fabric120 120 False +Fabric121 121 False +Fabric122 122 False +Fabric123 123 False +Fabric124 124 False +Fabric125 125 False +Fabric126 126 False +Fabric127 127 False +Fabric128 128 False +Fabric129 129 False +Fabric130 130 False +Fabric131 131 False +Fabric132 132 False +Fabric133 133 False +Fabric134 134 False +Fabric135 135 False +Fabric136 136 False +Fabric137 137 False +Fabric138 138 False +Fabric139 139 False +Fabric140 140 False +Fabric141 141 False +Fabric142 142 False +Fabric143 143 False +Fabric144 144 False +Fabric145 145 False +Fabric146 146 False +Fabric147 147 False +Fabric148 148 False +Fabric149 149 False +Fabric150 150 False +Fabric151 151 False +Fabric152 152 False +Fabric153 153 False +Fabric154 154 False +Fabric155 155 False +Fabric156 156 False +Fabric157 157 False +Fabric158 158 False +Fabric159 159 False +Fabric160 160 False +Fabric161 161 False +Fabric162 162 False +Fabric163 163 False +Fabric164 164 False +Fabric165 165 False +Fabric166 166 False +Fabric167 167 False +Fabric168 168 False +Fabric169 169 False +Fabric170 170 False +Fabric171 171 False +Fabric172 172 False +Fabric173 173 False +Fabric174 174 False +Fabric175 175 False +Fabric176 176 False +Fabric177 177 False +Fabric178 178 False +Fabric179 179 False +Fabric180 180 False +Fabric181 181 False +Fabric182 182 False +Fabric183 183 False +Fabric184 184 False +Fabric185 185 False +Fabric186 186 False +Fabric187 187 False +Fabric188 188 False +Fabric189 189 False +Fabric190 190 False +Fabric191 191 False diff --git a/device/arista/x86_64-arista_7800_sup/Arista-7808R3-FM/fabric_monitor_config.json b/device/arista/x86_64-arista_7800_sup/Arista-7808R3-FM/fabric_monitor_config.json new file mode 100644 index 0000000000..653b25d1e2 --- /dev/null +++ b/device/arista/x86_64-arista_7800_sup/Arista-7808R3-FM/fabric_monitor_config.json @@ -0,0 +1,8 @@ +{ + "FABRIC_MONITOR_DATA": { + "monErrThreshCrcCells": 1, + "monErrThreshRxCells": 61035156, + "monPollThreshRecovery": 8, + "monPollThreshIsolation": 1 + } +} diff --git a/device/arista/x86_64-arista_7800_sup/Arista-7808R3-FM/fabric_port_config.ini b/device/arista/x86_64-arista_7800_sup/Arista-7808R3-FM/fabric_port_config.ini new file mode 100644 index 0000000000..f9a60d04e5 --- /dev/null +++ b/device/arista/x86_64-arista_7800_sup/Arista-7808R3-FM/fabric_port_config.ini @@ -0,0 +1,193 @@ +# name lanes isolateStatus +Fabric0 0 False +Fabric1 1 False +Fabric2 2 False +Fabric3 3 False +Fabric4 4 False +Fabric5 5 False +Fabric6 6 False +Fabric7 7 False +Fabric8 8 False +Fabric9 9 False +Fabric10 10 False +Fabric11 11 False +Fabric12 12 False +Fabric13 13 False +Fabric14 14 False +Fabric15 15 False +Fabric16 16 False +Fabric17 17 False +Fabric18 18 False +Fabric19 19 False +Fabric20 20 False +Fabric21 21 False +Fabric22 22 False +Fabric23 23 False +Fabric24 24 False +Fabric25 25 False +Fabric26 26 False +Fabric27 27 False +Fabric28 28 False +Fabric29 29 False +Fabric30 30 False +Fabric31 31 False +Fabric32 32 False +Fabric33 33 False +Fabric34 34 False +Fabric35 35 False +Fabric36 36 False +Fabric37 37 False +Fabric38 38 False +Fabric39 39 False +Fabric40 40 False +Fabric41 41 False +Fabric42 42 False +Fabric43 43 False +Fabric44 44 False +Fabric45 45 False +Fabric46 46 False +Fabric47 47 False +Fabric48 48 False +Fabric49 49 False +Fabric50 50 False +Fabric51 51 False +Fabric52 52 False +Fabric53 53 False +Fabric54 54 False +Fabric55 55 False +Fabric56 56 False +Fabric57 57 False +Fabric58 58 False +Fabric59 59 False +Fabric60 60 False +Fabric61 61 False +Fabric62 62 False +Fabric63 63 False +Fabric64 64 False +Fabric65 65 False +Fabric66 66 False +Fabric67 67 False +Fabric68 68 False +Fabric69 69 False +Fabric70 70 False +Fabric71 71 False +Fabric72 72 False +Fabric73 73 False +Fabric74 74 False +Fabric75 75 False +Fabric76 76 False +Fabric77 77 False +Fabric78 78 False +Fabric79 79 False +Fabric80 80 False +Fabric81 81 False +Fabric82 82 False +Fabric83 83 False +Fabric84 84 False +Fabric85 85 False +Fabric86 86 False +Fabric87 87 False +Fabric88 88 False +Fabric89 89 False +Fabric90 90 False +Fabric91 91 False +Fabric92 92 False +Fabric93 93 False +Fabric94 94 False +Fabric95 95 False +Fabric96 96 False +Fabric97 97 False +Fabric98 98 False +Fabric99 99 False +Fabric100 100 False +Fabric101 101 False +Fabric102 102 False +Fabric103 103 False +Fabric104 104 False +Fabric105 105 False +Fabric106 106 False +Fabric107 107 False +Fabric108 108 False +Fabric109 109 False +Fabric110 110 False +Fabric111 111 False +Fabric112 112 False +Fabric113 113 False +Fabric114 114 False +Fabric115 115 False +Fabric116 116 False +Fabric117 117 False +Fabric118 118 False +Fabric119 119 False +Fabric120 120 False +Fabric121 121 False +Fabric122 122 False +Fabric123 123 False +Fabric124 124 False +Fabric125 125 False +Fabric126 126 False +Fabric127 127 False +Fabric128 128 False +Fabric129 129 False +Fabric130 130 False +Fabric131 131 False +Fabric132 132 False +Fabric133 133 False +Fabric134 134 False +Fabric135 135 False +Fabric136 136 False +Fabric137 137 False +Fabric138 138 False +Fabric139 139 False +Fabric140 140 False +Fabric141 141 False +Fabric142 142 False +Fabric143 143 False +Fabric144 144 False +Fabric145 145 False +Fabric146 146 False +Fabric147 147 False +Fabric148 148 False +Fabric149 149 False +Fabric150 150 False +Fabric151 151 False +Fabric152 152 False +Fabric153 153 False +Fabric154 154 False +Fabric155 155 False +Fabric156 156 False +Fabric157 157 False +Fabric158 158 False +Fabric159 159 False +Fabric160 160 False +Fabric161 161 False +Fabric162 162 False +Fabric163 163 False +Fabric164 164 False +Fabric165 165 False +Fabric166 166 False +Fabric167 167 False +Fabric168 168 False +Fabric169 169 False +Fabric170 170 False +Fabric171 171 False +Fabric172 172 False +Fabric173 173 False +Fabric174 174 False +Fabric175 175 False +Fabric176 176 False +Fabric177 177 False +Fabric178 178 False +Fabric179 179 False +Fabric180 180 False +Fabric181 181 False +Fabric182 182 False +Fabric183 183 False +Fabric184 184 False +Fabric185 185 False +Fabric186 186 False +Fabric187 187 False +Fabric188 188 False +Fabric189 189 False +Fabric190 190 False +Fabric191 191 False diff --git a/device/arista/x86_64-arista_7800_sup/Arista-7808R3A-FM/fabric_monitor_config.json b/device/arista/x86_64-arista_7800_sup/Arista-7808R3A-FM/fabric_monitor_config.json new file mode 100644 index 0000000000..653b25d1e2 --- /dev/null +++ b/device/arista/x86_64-arista_7800_sup/Arista-7808R3A-FM/fabric_monitor_config.json @@ -0,0 +1,8 @@ +{ + "FABRIC_MONITOR_DATA": { + "monErrThreshCrcCells": 1, + "monErrThreshRxCells": 61035156, + "monPollThreshRecovery": 8, + "monPollThreshIsolation": 1 + } +} diff --git a/device/arista/x86_64-arista_7800_sup/Arista-7808R3A-FM/fabric_port_config.ini b/device/arista/x86_64-arista_7800_sup/Arista-7808R3A-FM/fabric_port_config.ini new file mode 100644 index 0000000000..f9a60d04e5 --- /dev/null +++ b/device/arista/x86_64-arista_7800_sup/Arista-7808R3A-FM/fabric_port_config.ini @@ -0,0 +1,193 @@ +# name lanes isolateStatus +Fabric0 0 False +Fabric1 1 False +Fabric2 2 False +Fabric3 3 False +Fabric4 4 False +Fabric5 5 False +Fabric6 6 False +Fabric7 7 False +Fabric8 8 False +Fabric9 9 False +Fabric10 10 False +Fabric11 11 False +Fabric12 12 False +Fabric13 13 False +Fabric14 14 False +Fabric15 15 False +Fabric16 16 False +Fabric17 17 False +Fabric18 18 False +Fabric19 19 False +Fabric20 20 False +Fabric21 21 False +Fabric22 22 False +Fabric23 23 False +Fabric24 24 False +Fabric25 25 False +Fabric26 26 False +Fabric27 27 False +Fabric28 28 False +Fabric29 29 False +Fabric30 30 False +Fabric31 31 False +Fabric32 32 False +Fabric33 33 False +Fabric34 34 False +Fabric35 35 False +Fabric36 36 False +Fabric37 37 False +Fabric38 38 False +Fabric39 39 False +Fabric40 40 False +Fabric41 41 False +Fabric42 42 False +Fabric43 43 False +Fabric44 44 False +Fabric45 45 False +Fabric46 46 False +Fabric47 47 False +Fabric48 48 False +Fabric49 49 False +Fabric50 50 False +Fabric51 51 False +Fabric52 52 False +Fabric53 53 False +Fabric54 54 False +Fabric55 55 False +Fabric56 56 False +Fabric57 57 False +Fabric58 58 False +Fabric59 59 False +Fabric60 60 False +Fabric61 61 False +Fabric62 62 False +Fabric63 63 False +Fabric64 64 False +Fabric65 65 False +Fabric66 66 False +Fabric67 67 False +Fabric68 68 False +Fabric69 69 False +Fabric70 70 False +Fabric71 71 False +Fabric72 72 False +Fabric73 73 False +Fabric74 74 False +Fabric75 75 False +Fabric76 76 False +Fabric77 77 False +Fabric78 78 False +Fabric79 79 False +Fabric80 80 False +Fabric81 81 False +Fabric82 82 False +Fabric83 83 False +Fabric84 84 False +Fabric85 85 False +Fabric86 86 False +Fabric87 87 False +Fabric88 88 False +Fabric89 89 False +Fabric90 90 False +Fabric91 91 False +Fabric92 92 False +Fabric93 93 False +Fabric94 94 False +Fabric95 95 False +Fabric96 96 False +Fabric97 97 False +Fabric98 98 False +Fabric99 99 False +Fabric100 100 False +Fabric101 101 False +Fabric102 102 False +Fabric103 103 False +Fabric104 104 False +Fabric105 105 False +Fabric106 106 False +Fabric107 107 False +Fabric108 108 False +Fabric109 109 False +Fabric110 110 False +Fabric111 111 False +Fabric112 112 False +Fabric113 113 False +Fabric114 114 False +Fabric115 115 False +Fabric116 116 False +Fabric117 117 False +Fabric118 118 False +Fabric119 119 False +Fabric120 120 False +Fabric121 121 False +Fabric122 122 False +Fabric123 123 False +Fabric124 124 False +Fabric125 125 False +Fabric126 126 False +Fabric127 127 False +Fabric128 128 False +Fabric129 129 False +Fabric130 130 False +Fabric131 131 False +Fabric132 132 False +Fabric133 133 False +Fabric134 134 False +Fabric135 135 False +Fabric136 136 False +Fabric137 137 False +Fabric138 138 False +Fabric139 139 False +Fabric140 140 False +Fabric141 141 False +Fabric142 142 False +Fabric143 143 False +Fabric144 144 False +Fabric145 145 False +Fabric146 146 False +Fabric147 147 False +Fabric148 148 False +Fabric149 149 False +Fabric150 150 False +Fabric151 151 False +Fabric152 152 False +Fabric153 153 False +Fabric154 154 False +Fabric155 155 False +Fabric156 156 False +Fabric157 157 False +Fabric158 158 False +Fabric159 159 False +Fabric160 160 False +Fabric161 161 False +Fabric162 162 False +Fabric163 163 False +Fabric164 164 False +Fabric165 165 False +Fabric166 166 False +Fabric167 167 False +Fabric168 168 False +Fabric169 169 False +Fabric170 170 False +Fabric171 171 False +Fabric172 172 False +Fabric173 173 False +Fabric174 174 False +Fabric175 175 False +Fabric176 176 False +Fabric177 177 False +Fabric178 178 False +Fabric179 179 False +Fabric180 180 False +Fabric181 181 False +Fabric182 182 False +Fabric183 183 False +Fabric184 184 False +Fabric185 185 False +Fabric186 186 False +Fabric187 187 False +Fabric188 188 False +Fabric189 189 False +Fabric190 190 False +Fabric191 191 False diff --git a/device/arista/x86_64-arista_7800r3_48cq2_lc/Arista-7800R3-48CQ2-C48/fabric_monitor_config.json b/device/arista/x86_64-arista_7800r3_48cq2_lc/Arista-7800R3-48CQ2-C48/fabric_monitor_config.json new file mode 100644 index 0000000000..653b25d1e2 --- /dev/null +++ b/device/arista/x86_64-arista_7800r3_48cq2_lc/Arista-7800R3-48CQ2-C48/fabric_monitor_config.json @@ -0,0 +1,8 @@ +{ + "FABRIC_MONITOR_DATA": { + "monErrThreshCrcCells": 1, + "monErrThreshRxCells": 61035156, + "monPollThreshRecovery": 8, + "monPollThreshIsolation": 1 + } +} diff --git a/device/arista/x86_64-arista_7800r3_48cq2_lc/Arista-7800R3-48CQ2-C48/fabric_port_config.ini b/device/arista/x86_64-arista_7800r3_48cq2_lc/Arista-7800R3-48CQ2-C48/fabric_port_config.ini new file mode 100644 index 0000000000..e07e256dc1 --- /dev/null +++ b/device/arista/x86_64-arista_7800r3_48cq2_lc/Arista-7800R3-48CQ2-C48/fabric_port_config.ini @@ -0,0 +1,113 @@ +# name lanes isolateStatus +Fabric0 0 False +Fabric1 1 False +Fabric2 2 False +Fabric3 3 False +Fabric4 4 False +Fabric5 5 False +Fabric6 6 False +Fabric7 7 False +Fabric8 8 False +Fabric9 9 False +Fabric10 10 False +Fabric11 11 False +Fabric12 12 False +Fabric13 13 False +Fabric14 14 False +Fabric15 15 False +Fabric16 16 False +Fabric17 17 False +Fabric18 18 False +Fabric19 19 False +Fabric20 20 False +Fabric21 21 False +Fabric22 22 False +Fabric23 23 False +Fabric24 24 False +Fabric25 25 False +Fabric26 26 False +Fabric27 27 False +Fabric28 28 False +Fabric29 29 False +Fabric30 30 False +Fabric31 31 False +Fabric32 32 False +Fabric33 33 False +Fabric34 34 False +Fabric35 35 False +Fabric36 36 False +Fabric37 37 False +Fabric38 38 False +Fabric39 39 False +Fabric40 40 False +Fabric41 41 False +Fabric42 42 False +Fabric43 43 False +Fabric44 44 False +Fabric45 45 False +Fabric46 46 False +Fabric47 47 False +Fabric48 48 False +Fabric49 49 False +Fabric50 50 False +Fabric51 51 False +Fabric52 52 False +Fabric53 53 False +Fabric54 54 False +Fabric55 55 False +Fabric56 56 False +Fabric57 57 False +Fabric58 58 False +Fabric59 59 False +Fabric60 60 False +Fabric61 61 False +Fabric62 62 False +Fabric63 63 False +Fabric64 64 False +Fabric65 65 False +Fabric66 66 False +Fabric67 67 False +Fabric68 68 False +Fabric69 69 False +Fabric70 70 False +Fabric71 71 False +Fabric72 72 False +Fabric73 73 False +Fabric74 74 False +Fabric75 75 False +Fabric76 76 False +Fabric77 77 False +Fabric78 78 False +Fabric79 79 False +Fabric80 80 False +Fabric81 81 False +Fabric82 82 False +Fabric83 83 False +Fabric84 84 False +Fabric85 85 False +Fabric86 86 False +Fabric87 87 False +Fabric88 88 False +Fabric89 89 False +Fabric90 90 False +Fabric91 91 False +Fabric92 92 False +Fabric93 93 False +Fabric94 94 False +Fabric95 95 False +Fabric96 96 False +Fabric97 97 False +Fabric98 98 False +Fabric99 99 False +Fabric100 100 False +Fabric101 101 False +Fabric102 102 False +Fabric103 103 False +Fabric104 104 False +Fabric105 105 False +Fabric106 106 False +Fabric107 107 False +Fabric108 108 False +Fabric109 109 False +Fabric110 110 False +Fabric111 111 False diff --git a/device/arista/x86_64-arista_7800r3_48cq2_lc/fabric_monitor_config.json b/device/arista/x86_64-arista_7800r3_48cq2_lc/fabric_monitor_config.json new file mode 100644 index 0000000000..653b25d1e2 --- /dev/null +++ b/device/arista/x86_64-arista_7800r3_48cq2_lc/fabric_monitor_config.json @@ -0,0 +1,8 @@ +{ + "FABRIC_MONITOR_DATA": { + "monErrThreshCrcCells": 1, + "monErrThreshRxCells": 61035156, + "monPollThreshRecovery": 8, + "monPollThreshIsolation": 1 + } +} diff --git a/device/arista/x86_64-arista_7800r3_48cq2_lc/fabric_port_config.ini b/device/arista/x86_64-arista_7800r3_48cq2_lc/fabric_port_config.ini new file mode 100644 index 0000000000..e07e256dc1 --- /dev/null +++ b/device/arista/x86_64-arista_7800r3_48cq2_lc/fabric_port_config.ini @@ -0,0 +1,113 @@ +# name lanes isolateStatus +Fabric0 0 False +Fabric1 1 False +Fabric2 2 False +Fabric3 3 False +Fabric4 4 False +Fabric5 5 False +Fabric6 6 False +Fabric7 7 False +Fabric8 8 False +Fabric9 9 False +Fabric10 10 False +Fabric11 11 False +Fabric12 12 False +Fabric13 13 False +Fabric14 14 False +Fabric15 15 False +Fabric16 16 False +Fabric17 17 False +Fabric18 18 False +Fabric19 19 False +Fabric20 20 False +Fabric21 21 False +Fabric22 22 False +Fabric23 23 False +Fabric24 24 False +Fabric25 25 False +Fabric26 26 False +Fabric27 27 False +Fabric28 28 False +Fabric29 29 False +Fabric30 30 False +Fabric31 31 False +Fabric32 32 False +Fabric33 33 False +Fabric34 34 False +Fabric35 35 False +Fabric36 36 False +Fabric37 37 False +Fabric38 38 False +Fabric39 39 False +Fabric40 40 False +Fabric41 41 False +Fabric42 42 False +Fabric43 43 False +Fabric44 44 False +Fabric45 45 False +Fabric46 46 False +Fabric47 47 False +Fabric48 48 False +Fabric49 49 False +Fabric50 50 False +Fabric51 51 False +Fabric52 52 False +Fabric53 53 False +Fabric54 54 False +Fabric55 55 False +Fabric56 56 False +Fabric57 57 False +Fabric58 58 False +Fabric59 59 False +Fabric60 60 False +Fabric61 61 False +Fabric62 62 False +Fabric63 63 False +Fabric64 64 False +Fabric65 65 False +Fabric66 66 False +Fabric67 67 False +Fabric68 68 False +Fabric69 69 False +Fabric70 70 False +Fabric71 71 False +Fabric72 72 False +Fabric73 73 False +Fabric74 74 False +Fabric75 75 False +Fabric76 76 False +Fabric77 77 False +Fabric78 78 False +Fabric79 79 False +Fabric80 80 False +Fabric81 81 False +Fabric82 82 False +Fabric83 83 False +Fabric84 84 False +Fabric85 85 False +Fabric86 86 False +Fabric87 87 False +Fabric88 88 False +Fabric89 89 False +Fabric90 90 False +Fabric91 91 False +Fabric92 92 False +Fabric93 93 False +Fabric94 94 False +Fabric95 95 False +Fabric96 96 False +Fabric97 97 False +Fabric98 98 False +Fabric99 99 False +Fabric100 100 False +Fabric101 101 False +Fabric102 102 False +Fabric103 103 False +Fabric104 104 False +Fabric105 105 False +Fabric106 106 False +Fabric107 107 False +Fabric108 108 False +Fabric109 109 False +Fabric110 110 False +Fabric111 111 False diff --git a/device/arista/x86_64-arista_7800r3_48cqm2_lc/Arista-7800R3-48CQM2-C48/fabric_monitor_config.json b/device/arista/x86_64-arista_7800r3_48cqm2_lc/Arista-7800R3-48CQM2-C48/fabric_monitor_config.json new file mode 100644 index 0000000000..653b25d1e2 --- /dev/null +++ b/device/arista/x86_64-arista_7800r3_48cqm2_lc/Arista-7800R3-48CQM2-C48/fabric_monitor_config.json @@ -0,0 +1,8 @@ +{ + "FABRIC_MONITOR_DATA": { + "monErrThreshCrcCells": 1, + "monErrThreshRxCells": 61035156, + "monPollThreshRecovery": 8, + "monPollThreshIsolation": 1 + } +} diff --git a/device/arista/x86_64-arista_7800r3_48cqm2_lc/Arista-7800R3-48CQM2-C48/fabric_port_config.ini b/device/arista/x86_64-arista_7800r3_48cqm2_lc/Arista-7800R3-48CQM2-C48/fabric_port_config.ini new file mode 100644 index 0000000000..e07e256dc1 --- /dev/null +++ b/device/arista/x86_64-arista_7800r3_48cqm2_lc/Arista-7800R3-48CQM2-C48/fabric_port_config.ini @@ -0,0 +1,113 @@ +# name lanes isolateStatus +Fabric0 0 False +Fabric1 1 False +Fabric2 2 False +Fabric3 3 False +Fabric4 4 False +Fabric5 5 False +Fabric6 6 False +Fabric7 7 False +Fabric8 8 False +Fabric9 9 False +Fabric10 10 False +Fabric11 11 False +Fabric12 12 False +Fabric13 13 False +Fabric14 14 False +Fabric15 15 False +Fabric16 16 False +Fabric17 17 False +Fabric18 18 False +Fabric19 19 False +Fabric20 20 False +Fabric21 21 False +Fabric22 22 False +Fabric23 23 False +Fabric24 24 False +Fabric25 25 False +Fabric26 26 False +Fabric27 27 False +Fabric28 28 False +Fabric29 29 False +Fabric30 30 False +Fabric31 31 False +Fabric32 32 False +Fabric33 33 False +Fabric34 34 False +Fabric35 35 False +Fabric36 36 False +Fabric37 37 False +Fabric38 38 False +Fabric39 39 False +Fabric40 40 False +Fabric41 41 False +Fabric42 42 False +Fabric43 43 False +Fabric44 44 False +Fabric45 45 False +Fabric46 46 False +Fabric47 47 False +Fabric48 48 False +Fabric49 49 False +Fabric50 50 False +Fabric51 51 False +Fabric52 52 False +Fabric53 53 False +Fabric54 54 False +Fabric55 55 False +Fabric56 56 False +Fabric57 57 False +Fabric58 58 False +Fabric59 59 False +Fabric60 60 False +Fabric61 61 False +Fabric62 62 False +Fabric63 63 False +Fabric64 64 False +Fabric65 65 False +Fabric66 66 False +Fabric67 67 False +Fabric68 68 False +Fabric69 69 False +Fabric70 70 False +Fabric71 71 False +Fabric72 72 False +Fabric73 73 False +Fabric74 74 False +Fabric75 75 False +Fabric76 76 False +Fabric77 77 False +Fabric78 78 False +Fabric79 79 False +Fabric80 80 False +Fabric81 81 False +Fabric82 82 False +Fabric83 83 False +Fabric84 84 False +Fabric85 85 False +Fabric86 86 False +Fabric87 87 False +Fabric88 88 False +Fabric89 89 False +Fabric90 90 False +Fabric91 91 False +Fabric92 92 False +Fabric93 93 False +Fabric94 94 False +Fabric95 95 False +Fabric96 96 False +Fabric97 97 False +Fabric98 98 False +Fabric99 99 False +Fabric100 100 False +Fabric101 101 False +Fabric102 102 False +Fabric103 103 False +Fabric104 104 False +Fabric105 105 False +Fabric106 106 False +Fabric107 107 False +Fabric108 108 False +Fabric109 109 False +Fabric110 110 False +Fabric111 111 False diff --git a/device/arista/x86_64-arista_7800r3_48cqm2_lc/fabric_monitor_config.json b/device/arista/x86_64-arista_7800r3_48cqm2_lc/fabric_monitor_config.json new file mode 100644 index 0000000000..653b25d1e2 --- /dev/null +++ b/device/arista/x86_64-arista_7800r3_48cqm2_lc/fabric_monitor_config.json @@ -0,0 +1,8 @@ +{ + "FABRIC_MONITOR_DATA": { + "monErrThreshCrcCells": 1, + "monErrThreshRxCells": 61035156, + "monPollThreshRecovery": 8, + "monPollThreshIsolation": 1 + } +} diff --git a/device/arista/x86_64-arista_7800r3_48cqm2_lc/fabric_port_config.ini b/device/arista/x86_64-arista_7800r3_48cqm2_lc/fabric_port_config.ini new file mode 100644 index 0000000000..e07e256dc1 --- /dev/null +++ b/device/arista/x86_64-arista_7800r3_48cqm2_lc/fabric_port_config.ini @@ -0,0 +1,113 @@ +# name lanes isolateStatus +Fabric0 0 False +Fabric1 1 False +Fabric2 2 False +Fabric3 3 False +Fabric4 4 False +Fabric5 5 False +Fabric6 6 False +Fabric7 7 False +Fabric8 8 False +Fabric9 9 False +Fabric10 10 False +Fabric11 11 False +Fabric12 12 False +Fabric13 13 False +Fabric14 14 False +Fabric15 15 False +Fabric16 16 False +Fabric17 17 False +Fabric18 18 False +Fabric19 19 False +Fabric20 20 False +Fabric21 21 False +Fabric22 22 False +Fabric23 23 False +Fabric24 24 False +Fabric25 25 False +Fabric26 26 False +Fabric27 27 False +Fabric28 28 False +Fabric29 29 False +Fabric30 30 False +Fabric31 31 False +Fabric32 32 False +Fabric33 33 False +Fabric34 34 False +Fabric35 35 False +Fabric36 36 False +Fabric37 37 False +Fabric38 38 False +Fabric39 39 False +Fabric40 40 False +Fabric41 41 False +Fabric42 42 False +Fabric43 43 False +Fabric44 44 False +Fabric45 45 False +Fabric46 46 False +Fabric47 47 False +Fabric48 48 False +Fabric49 49 False +Fabric50 50 False +Fabric51 51 False +Fabric52 52 False +Fabric53 53 False +Fabric54 54 False +Fabric55 55 False +Fabric56 56 False +Fabric57 57 False +Fabric58 58 False +Fabric59 59 False +Fabric60 60 False +Fabric61 61 False +Fabric62 62 False +Fabric63 63 False +Fabric64 64 False +Fabric65 65 False +Fabric66 66 False +Fabric67 67 False +Fabric68 68 False +Fabric69 69 False +Fabric70 70 False +Fabric71 71 False +Fabric72 72 False +Fabric73 73 False +Fabric74 74 False +Fabric75 75 False +Fabric76 76 False +Fabric77 77 False +Fabric78 78 False +Fabric79 79 False +Fabric80 80 False +Fabric81 81 False +Fabric82 82 False +Fabric83 83 False +Fabric84 84 False +Fabric85 85 False +Fabric86 86 False +Fabric87 87 False +Fabric88 88 False +Fabric89 89 False +Fabric90 90 False +Fabric91 91 False +Fabric92 92 False +Fabric93 93 False +Fabric94 94 False +Fabric95 95 False +Fabric96 96 False +Fabric97 97 False +Fabric98 98 False +Fabric99 99 False +Fabric100 100 False +Fabric101 101 False +Fabric102 102 False +Fabric103 103 False +Fabric104 104 False +Fabric105 105 False +Fabric106 106 False +Fabric107 107 False +Fabric108 108 False +Fabric109 109 False +Fabric110 110 False +Fabric111 111 False diff --git a/device/arista/x86_64-arista_7800r3a_36d2_lc/Arista-7800R3A-36D2-C72/fabric_monitor_config.json b/device/arista/x86_64-arista_7800r3a_36d2_lc/Arista-7800R3A-36D2-C72/fabric_monitor_config.json new file mode 100644 index 0000000000..653b25d1e2 --- /dev/null +++ b/device/arista/x86_64-arista_7800r3a_36d2_lc/Arista-7800R3A-36D2-C72/fabric_monitor_config.json @@ -0,0 +1,8 @@ +{ + "FABRIC_MONITOR_DATA": { + "monErrThreshCrcCells": 1, + "monErrThreshRxCells": 61035156, + "monPollThreshRecovery": 8, + "monPollThreshIsolation": 1 + } +} diff --git a/device/arista/x86_64-arista_7800r3a_36d2_lc/Arista-7800R3A-36D2-C72/fabric_port_config.ini b/device/arista/x86_64-arista_7800r3a_36d2_lc/Arista-7800R3A-36D2-C72/fabric_port_config.ini new file mode 100644 index 0000000000..f9a60d04e5 --- /dev/null +++ b/device/arista/x86_64-arista_7800r3a_36d2_lc/Arista-7800R3A-36D2-C72/fabric_port_config.ini @@ -0,0 +1,193 @@ +# name lanes isolateStatus +Fabric0 0 False +Fabric1 1 False +Fabric2 2 False +Fabric3 3 False +Fabric4 4 False +Fabric5 5 False +Fabric6 6 False +Fabric7 7 False +Fabric8 8 False +Fabric9 9 False +Fabric10 10 False +Fabric11 11 False +Fabric12 12 False +Fabric13 13 False +Fabric14 14 False +Fabric15 15 False +Fabric16 16 False +Fabric17 17 False +Fabric18 18 False +Fabric19 19 False +Fabric20 20 False +Fabric21 21 False +Fabric22 22 False +Fabric23 23 False +Fabric24 24 False +Fabric25 25 False +Fabric26 26 False +Fabric27 27 False +Fabric28 28 False +Fabric29 29 False +Fabric30 30 False +Fabric31 31 False +Fabric32 32 False +Fabric33 33 False +Fabric34 34 False +Fabric35 35 False +Fabric36 36 False +Fabric37 37 False +Fabric38 38 False +Fabric39 39 False +Fabric40 40 False +Fabric41 41 False +Fabric42 42 False +Fabric43 43 False +Fabric44 44 False +Fabric45 45 False +Fabric46 46 False +Fabric47 47 False +Fabric48 48 False +Fabric49 49 False +Fabric50 50 False +Fabric51 51 False +Fabric52 52 False +Fabric53 53 False +Fabric54 54 False +Fabric55 55 False +Fabric56 56 False +Fabric57 57 False +Fabric58 58 False +Fabric59 59 False +Fabric60 60 False +Fabric61 61 False +Fabric62 62 False +Fabric63 63 False +Fabric64 64 False +Fabric65 65 False +Fabric66 66 False +Fabric67 67 False +Fabric68 68 False +Fabric69 69 False +Fabric70 70 False +Fabric71 71 False +Fabric72 72 False +Fabric73 73 False +Fabric74 74 False +Fabric75 75 False +Fabric76 76 False +Fabric77 77 False +Fabric78 78 False +Fabric79 79 False +Fabric80 80 False +Fabric81 81 False +Fabric82 82 False +Fabric83 83 False +Fabric84 84 False +Fabric85 85 False +Fabric86 86 False +Fabric87 87 False +Fabric88 88 False +Fabric89 89 False +Fabric90 90 False +Fabric91 91 False +Fabric92 92 False +Fabric93 93 False +Fabric94 94 False +Fabric95 95 False +Fabric96 96 False +Fabric97 97 False +Fabric98 98 False +Fabric99 99 False +Fabric100 100 False +Fabric101 101 False +Fabric102 102 False +Fabric103 103 False +Fabric104 104 False +Fabric105 105 False +Fabric106 106 False +Fabric107 107 False +Fabric108 108 False +Fabric109 109 False +Fabric110 110 False +Fabric111 111 False +Fabric112 112 False +Fabric113 113 False +Fabric114 114 False +Fabric115 115 False +Fabric116 116 False +Fabric117 117 False +Fabric118 118 False +Fabric119 119 False +Fabric120 120 False +Fabric121 121 False +Fabric122 122 False +Fabric123 123 False +Fabric124 124 False +Fabric125 125 False +Fabric126 126 False +Fabric127 127 False +Fabric128 128 False +Fabric129 129 False +Fabric130 130 False +Fabric131 131 False +Fabric132 132 False +Fabric133 133 False +Fabric134 134 False +Fabric135 135 False +Fabric136 136 False +Fabric137 137 False +Fabric138 138 False +Fabric139 139 False +Fabric140 140 False +Fabric141 141 False +Fabric142 142 False +Fabric143 143 False +Fabric144 144 False +Fabric145 145 False +Fabric146 146 False +Fabric147 147 False +Fabric148 148 False +Fabric149 149 False +Fabric150 150 False +Fabric151 151 False +Fabric152 152 False +Fabric153 153 False +Fabric154 154 False +Fabric155 155 False +Fabric156 156 False +Fabric157 157 False +Fabric158 158 False +Fabric159 159 False +Fabric160 160 False +Fabric161 161 False +Fabric162 162 False +Fabric163 163 False +Fabric164 164 False +Fabric165 165 False +Fabric166 166 False +Fabric167 167 False +Fabric168 168 False +Fabric169 169 False +Fabric170 170 False +Fabric171 171 False +Fabric172 172 False +Fabric173 173 False +Fabric174 174 False +Fabric175 175 False +Fabric176 176 False +Fabric177 177 False +Fabric178 178 False +Fabric179 179 False +Fabric180 180 False +Fabric181 181 False +Fabric182 182 False +Fabric183 183 False +Fabric184 184 False +Fabric185 185 False +Fabric186 186 False +Fabric187 187 False +Fabric188 188 False +Fabric189 189 False +Fabric190 190 False +Fabric191 191 False diff --git a/src/sonic-config-engine/minigraph.py b/src/sonic-config-engine/minigraph.py index b8c92b6c85..56ae7b737a 100644 --- a/src/sonic-config-engine/minigraph.py +++ b/src/sonic-config-engine/minigraph.py @@ -13,7 +13,7 @@ from lxml.etree import QName from natsort import natsorted, ns as natsortns -from portconfig import get_port_config +from portconfig import get_port_config, get_fabric_port_config, get_fabric_monitor_config from sonic_py_common.interface import backplane_prefix # TODO: Remove this once we no longer support Python 2 @@ -1436,7 +1436,7 @@ def select_mmu_profiles(profile, platform, hwsku): # Main functions # ############################################################################### -def parse_xml(filename, platform=None, port_config_file=None, asic_name=None, hwsku_config_file=None): +def parse_xml(filename, platform=None, port_config_file=None, asic_name=None, hwsku_config_file=None, fabric_port_config_file=None ): """ Parse minigraph xml file. Keyword arguments: @@ -1445,6 +1445,7 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None, hw port_config_file -- port config file name asic_name -- asic name; to parse multi-asic device minigraph to generate asic specific configuration. + fabric_port_config_file -- fabric port config file name """ root = ET.parse(filename).getroot() @@ -1873,6 +1874,16 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None, hw results['PORT'] = ports results['CONSOLE_PORT'] = console_ports + # Get the global fabric monitoring data + fabric_monitor = get_fabric_monitor_config(hwsku=hwsku, asic_name=asic_name) + if bool( fabric_monitor ): + results[ 'FABRIC_MONITOR' ] = fabric_monitor + + # parse fabric + fabric_ports = get_fabric_port_config(hwsku=hwsku, platform=platform, fabric_port_config_file=fabric_port_config_file, asic_name=asic_name, hwsku_config_file=hwsku_config_file) + if bool( fabric_ports ): + results['FABRIC_PORT'] = fabric_ports + if port_config_file: port_set = set(ports.keys()) for (pc_name, pc_member) in list(pc_members.keys()): diff --git a/src/sonic-config-engine/portconfig.py b/src/sonic-config-engine/portconfig.py index ea9985a3be..f1bb80460e 100644 --- a/src/sonic-config-engine/portconfig.py +++ b/src/sonic-config-engine/portconfig.py @@ -100,6 +100,74 @@ def get_hwsku_file_name(hwsku=None, platform=None): return candidate return None +def get_fabric_monitor_config(hwsku=None, asic_name=None): + config_db = db_connect_configdb(asic_name) + if config_db is not None: + fabric_monitor_global = config_db.get_table("FABRIC_MONITOR") + if bool( fabric_monitor_global ): + return fabric_monitor_global + + fabric_monitor_global = {} + if asic_name is not None: + asic_id = str(get_asic_id_from_name(asic_name)) + else: + asic_id = None + fabric_monitor_config_file = device_info.get_path_to_fabric_monitor_config_file(hwsku, asic_id) + if not fabric_monitor_config_file: + return fabric_monitor_global + with open( fabric_monitor_config_file, "r" ) as openfile: + fabric_monitor_global = json.load( openfile ) + openfile.close() + + return fabric_monitor_global + + +def get_fabric_port_config(hwsku=None, platform=None, fabric_port_config_file=None, hwsku_config_file=None, asic_name=None): + config_db = db_connect_configdb(asic_name) + if config_db is not None and fabric_port_config_file is None: + port_data = config_db.get_table("FABRIC_PORT") + if bool(port_data): + ports = ast.literal_eval(json.dumps(port_data)) + return ports + + if asic_name is not None: + asic_id = str(get_asic_id_from_name(asic_name)) + else: + asic_id = None + + if not fabric_port_config_file: + fabric_port_config_file = device_info.get_path_to_fabric_port_config_file(hwsku, asic_id) + if not fabric_port_config_file: + return {} + # else parse fabric_port_config.ini + ports = {} + + # Default column definition + # ../../device/arista/x86_64-arista_7800r3_48cq2_lc/Arista-7800R3-48CQ2-C48/fabric_port_config.ini + # # name lanes isolateStatus + # Fabric0 0 False + + titles = ['name', 'lanes', 'isolateStatus'] + with open(fabric_port_config_file) as data: + for line in data: + if line.startswith('#'): + if "name" in line: + titles = line.strip('#').split() + continue; + tokens = line.split() + if len(tokens) < 2: + continue + name_index = titles.index('name') + name = tokens[name_index] + data = {} + for i, item in enumerate(tokens): + if i == name_index: + continue + data[titles[i]] = item + data.setdefault('alias', name) + ports[name] = data + return ports + def get_port_config(hwsku=None, platform=None, port_config_file=None, hwsku_config_file=None, asic_name=None): config_db = db_connect_configdb(asic_name) # If available, Read from CONFIG DB first diff --git a/src/sonic-py-common/sonic_py_common/device_info.py b/src/sonic-py-common/sonic_py_common/device_info.py index f844c55e84..2a77134331 100644 --- a/src/sonic-py-common/sonic_py_common/device_info.py +++ b/src/sonic-py-common/sonic_py_common/device_info.py @@ -20,6 +20,12 @@ SONIC_VERSION_YAML_PATH = "/etc/sonic/sonic_version.yml" PORT_CONFIG_FILE = "port_config.ini" PLATFORM_JSON_FILE = "platform.json" +# Fabric port configuration file names +FABRIC_MONITOR_CONFIG_FILE = "fabric_monitor_config.json" + +# Fabric port configuration file names +FABRIC_PORT_CONFIG_FILE = "fabric_port_config.ini" + # HwSKU configuration file name HWSKU_JSON_FILE = 'hwsku.json' @@ -245,6 +251,113 @@ def get_path_to_hwsku_dir(): return hwsku_path +def get_path_to_fabric_monitor_config_file(hwsku=None, asic=None): + """ + Retrieves the path to the device's fabric monitor configuration file + + Args: + hwsku: a string, it is allowed to be passed in args because when loading the + initial configuration on the device, the HwSKU is not yet present in ConfigDB. + asic: a string , asic argument should be passed on multi-ASIC devices only, + it should be omitted on single-ASIC platforms. + + Returns: + A string containing the path the the device's fabric monitor configuration file + """ + + """ + This platform check is performed to make sure we return a None + in case of unit-tests within sonic-cfggen where platform is not expected to be + present because tests are not run on actual Hardware/Container. + TODO: refactor sonic-cfggen such that we can remove this check + """ + + platform = get_platform() + if not platform: + return None + + if hwsku: + try: + platform_path = get_path_to_platform_dir() + except OSError: + return None + hwsku_path = os.path.join(platform_path, hwsku) + else: + (platform_path, hwsku_path) = get_paths_to_platform_and_hwsku_dirs() + + fabric_monitor_config_candidates = [] + + # Check for 'hwsku.json' file presence first + hwsku_json_file = os.path.join(hwsku_path, HWSKU_JSON_FILE) + + # Check for 'fabric_monitor_config.json' file presence + fabric_monitor_config_candidates.append(os.path.join(hwsku_path, FABRIC_MONITOR_CONFIG_FILE)) + + for candidate in fabric_monitor_config_candidates: + if os.path.isfile(candidate): + return candidate + + return None + + +def get_path_to_fabric_port_config_file(hwsku=None, asic=None): + """ + Retrieves the path to the device's fabric port configuration file + + Args: + hwsku: a string, it is allowed to be passed in args because when loading the + initial configuration on the device, the HwSKU is not yet present in ConfigDB. + asic: a string , asic argument should be passed on multi-ASIC devices only, + it should be omitted on single-ASIC platforms. + + Returns: + A string containing the path the the device's fabric port configuration file + """ + + """ + This platform check is performed to make sure we return a None + in case of unit-tests within sonic-cfggen where platform is not expected to be + present because tests are not run on actual Hardware/Container. + TODO: refactor sonic-cfggen such that we can remove this check + """ + + platform = get_platform() + if not platform: + return None + + if hwsku: + try: + platform_path = get_path_to_platform_dir() + except OSError: + return None + hwsku_path = os.path.join(platform_path, hwsku) + else: + (platform_path, hwsku_path) = get_paths_to_platform_and_hwsku_dirs() + + fabric_port_config_candidates = [] + + # Check for 'hwsku.json' file presence first + hwsku_json_file = os.path.join(hwsku_path, HWSKU_JSON_FILE) + + # if 'hwsku.json' file is available, Check for 'platform.json' file presence, + # if 'platform.json' is available, APPEND it. Otherwise, SKIP it. + + # Check for 'fabric_port_config.ini' file presence in a few locations + if asic: + # Check if there is a file that is specific for the asic. + fabric_port_config_candidates.append(os.path.join(hwsku_path, asic, FABRIC_PORT_CONFIG_FILE)) + # Check if there is a file for the hardware type. + fabric_port_config_candidates.append(os.path.join(hwsku_path, FABRIC_PORT_CONFIG_FILE)) + else: + fabric_port_config_candidates.append(os.path.join(hwsku_path, FABRIC_PORT_CONFIG_FILE)) + + for candidate in fabric_port_config_candidates: + if os.path.isfile(candidate): + return candidate + + return None + + def get_paths_to_platform_and_hwsku_dirs(): """ Retreives the paths to the device's platform and hardware SKU data