Skip to content

Commit

Permalink
Merge branch '202205' of https://github.com/sonic-net/sonic-utilities
Browse files Browse the repository at this point in the history
…into 202205
  • Loading branch information
mssonicbld committed Jul 21, 2023
2 parents 5c7f8ca + 9986464 commit 4f14ee2
Show file tree
Hide file tree
Showing 8 changed files with 1,169 additions and 30 deletions.
503 changes: 503 additions & 0 deletions scripts/dualtor_neighbor_check.py

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions scripts/fast-reboot
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,11 @@ for service in ${SERVICES_TO_STOP}; do
sonic-db-cli FLEX_COUNTER_DB FLUSHDB > /dev/null
fi
if [[ "$REBOOT_TYPE" = "fast-reboot" ]]; then
# Flush RESTAPI_DB in fast-reboot to avoid stale status
sonic-db-cli RESTAPI_DB FLUSHDB > /dev/null
fi
# TODO: backup_database preserves FDB_TABLE
# need to cleanup as well for fastfast boot case
backup_database
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
'scripts/disk_check.py',
'scripts/dropconfig',
'scripts/dropstat',
'scripts/dualtor_neighbor_check.py',
'scripts/dump_nat_entries.py',
'scripts/ecnconfig',
'scripts/fabricstat',
Expand Down
14 changes: 12 additions & 2 deletions show/muxcable.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,13 @@ def create_table_dump_per_port_config(db ,print_data, per_npu_configdb, asic_id,
if soc_ipv4_value is not None:
port_list.append(soc_ipv4_value)
is_dualtor_active_active[0] = True
soc_ipv6_value = get_optional_value_for_key_in_config_tbl(per_npu_configdb[asic_id], port, "soc_ipv6", "MUX_CABLE")
if soc_ipv6_value is not None:
if cable_type is None:
port_list.append("")
if soc_ipv4_value is None:
port_list.append("")
port_list.append(soc_ipv6_value)
print_data.append(port_list)


Expand All @@ -587,6 +594,9 @@ def create_json_dump_per_port_config(db, port_status_dict, per_npu_configdb, asi
soc_ipv4_value = get_optional_value_for_key_in_config_tbl(per_npu_configdb[asic_id], port, "soc_ipv4", "MUX_CABLE")
if soc_ipv4_value is not None:
port_status_dict["MUX_CABLE"]["PORTS"][port_name]["SERVER"]["soc_ipv4"] = soc_ipv4_value
soc_ipv6_value = get_optional_value_for_key_in_config_tbl(per_npu_configdb[asic_id], port, "soc_ipv6", "MUX_CABLE")
if soc_ipv6_value is not None:
port_status_dict["MUX_CABLE"]["PORTS"][port_name]["SERVER"]["soc_ipv6"] = soc_ipv6_value

def get_tunnel_route_per_port(db, port_tunnel_route, per_npu_configdb, per_npu_appl_db, per_npu_asic_db, asic_id, port):

Expand Down Expand Up @@ -863,7 +873,7 @@ def config(db, port, json_output):
print_peer_tor.append(peer_tor_data)
click.echo(tabulate(print_peer_tor, headers=headers))
if is_dualtor_active_active[0]:
headers = ['port', 'state', 'ipv4', 'ipv6', 'cable_type', 'soc_ipv4']
headers = ['port', 'state', 'ipv4', 'ipv6', 'cable_type', 'soc_ipv4', 'soc_ipv6']
else:
headers = ['port', 'state', 'ipv4', 'ipv6']
click.echo(tabulate(print_data, headers=headers))
Expand Down Expand Up @@ -915,7 +925,7 @@ def config(db, port, json_output):
print_peer_tor.append(peer_tor_data)
click.echo(tabulate(print_peer_tor, headers=headers))
if is_dualtor_active_active[0]:
headers = ['port', 'state', 'ipv4', 'ipv6', 'cable_type', 'soc_ipv4']
headers = ['port', 'state', 'ipv4', 'ipv6', 'cable_type', 'soc_ipv4', 'soc_ipv6']
else:
headers = ['port', 'state', 'ipv4', 'ipv6']
click.echo(tabulate(print_data, headers=headers))
Expand Down
613 changes: 613 additions & 0 deletions tests/dualtor_neighbor_check_test.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tests/mock_tables/asic_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"SAI_ROUTE_ENTRY_ATTR_PACKET_ACTION": "SAI_PACKET_ACTION_FORWARD",
"SAI_ROUTE_ENTRY_ATTR_NEXT_HOP_ID": "oid:0x40000000015d8"
},
"ASIC_STATE:SAI_OBJECT_TYPE_ROUTE_ENTRY:{\"dest\":\"e801::47\",\"switch_id\":\"oid:0x21000000000000\",\"vr\":\"oid:0x300000000007c\"}": {
"ASIC_STATE:SAI_OBJECT_TYPE_ROUTE_ENTRY:{\"dest\":\"fc00::76\",\"switch_id\":\"oid:0x21000000000000\",\"vr\":\"oid:0x300000000007c\"}": {
"SAI_ROUTE_ENTRY_ATTR_PACKET_ACTION": "SAI_PACKET_ACTION_FORWARD",
"SAI_ROUTE_ENTRY_ATTR_NEXT_HOP_ID": "oid:0x40000000015d8"
}
Expand Down
17 changes: 9 additions & 8 deletions tests/mock_tables/config_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -1784,16 +1784,17 @@
},
"MUX_CABLE|Ethernet32": {
"state": "auto",
"server_ipv4": "10.1.1.1",
"server_ipv4": "10.1.1.1",
"cable_type": "active-active",
"soc_ipv4": "10.1.1.2",
"server_ipv6": "fc00::75"
"soc_ipv4": "10.1.1.2",
"soc_ipv6": "fc00::76",
"server_ipv6": "fc00::75"
},
"MUX_CABLE|Ethernet16": {
"state": "standby",
"server_ipv4": "10.1.1.1",
"server_ipv4": "10.1.1.1",
"cable_type": "active-standby",
"server_ipv6": "fc00::75"
"server_ipv6": "fc00::75"
},
"MUX_CABLE|Ethernet28": {
"state": "manual",
Expand All @@ -1807,9 +1808,9 @@
},
"MUX_CABLE|Ethernet4": {
"state": "auto",
"server_ipv4": "10.3.1.1",
"server_ipv6": "e801::46",
"soc_ipv6": "e801::47"
"server_ipv4": "10.3.1.1",
"server_ipv6": "e801::46",
"soc_ipv6": "e801::47"
},
"MUX_CABLE|Ethernet8": {
"state": "active",
Expand Down
44 changes: 25 additions & 19 deletions tests/muxcable_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,30 +150,30 @@
SWITCH_NAME PEER_TOR
------------- ----------
sonic-switch 10.2.2.2
port state ipv4 ipv6 cable_type soc_ipv4
---------- ------- -------- -------- -------------- ----------
port state ipv4 ipv6 cable_type soc_ipv4 soc_ipv6
---------- ------- -------- -------- -------------- ---------- ----------
Ethernet0 active 10.2.1.1 e800::46
Ethernet4 auto 10.3.1.1 e801::46
Ethernet4 auto 10.3.1.1 e801::46 e801::47
Ethernet8 active 10.4.1.1 e802::46
Ethernet12 active 10.4.1.1 e802::46
Ethernet16 standby 10.1.1.1 fc00::75 active-standby
Ethernet28 manual 10.1.1.1 fc00::75
Ethernet32 auto 10.1.1.1 fc00::75 active-active 10.1.1.2
Ethernet32 auto 10.1.1.1 fc00::75 active-active 10.1.1.2 fc00::76
"""

tabular_data_config_output_expected_alias = """\
SWITCH_NAME PEER_TOR
------------- ----------
sonic-switch 10.2.2.2
port state ipv4 ipv6 cable_type soc_ipv4
------ ------- -------- -------- -------------- ----------
port state ipv4 ipv6 cable_type soc_ipv4 soc_ipv6
------ ------- -------- -------- -------------- ---------- ----------
etp1 active 10.2.1.1 e800::46
etp2 auto 10.3.1.1 e801::46
etp2 auto 10.3.1.1 e801::46 e801::47
etp3 active 10.4.1.1 e802::46
etp4 active 10.4.1.1 e802::46
etp5 standby 10.1.1.1 fc00::75 active-standby
etp8 manual 10.1.1.1 fc00::75
etp9 auto 10.1.1.1 fc00::75 active-active 10.1.1.2
etp9 auto 10.1.1.1 fc00::75 active-active 10.1.1.2 fc00::76
"""

json_data_status_config_output_expected = """\
Expand All @@ -192,7 +192,8 @@
"STATE": "auto",
"SERVER": {
"IPv4": "10.3.1.1",
"IPv6": "e801::46"
"IPv6": "e801::46",
"soc_ipv6": "e801::47"
}
},
"Ethernet8": {
Expand Down Expand Up @@ -230,7 +231,8 @@
"IPv4": "10.1.1.1",
"IPv6": "fc00::75",
"cable_type": "active-active",
"soc_ipv4": "10.1.1.2"
"soc_ipv4": "10.1.1.2",
"soc_ipv6": "fc00::76"
}
}
}
Expand All @@ -254,7 +256,8 @@
"STATE": "auto",
"SERVER": {
"IPv4": "10.3.1.1",
"IPv6": "e801::46"
"IPv6": "e801::46",
"soc_ipv6": "e801::47"
}
},
"etp3": {
Expand Down Expand Up @@ -292,7 +295,8 @@
"IPv4": "10.1.1.1",
"IPv6": "fc00::75",
"cable_type": "active-active",
"soc_ipv4": "10.1.1.2"
"soc_ipv4": "10.1.1.2",
"soc_ipv6": "fc00::76"
}
}
}
Expand Down Expand Up @@ -580,9 +584,11 @@
"DEST": "10.3.1.1",
"kernel": 1,
"asic": false
},
}
},
"Ethernet32": {
"soc_ipv6": {
"DEST": "e801::47",
"DEST": "fc00::76",
"kernel": false,
"asic": 1
}
Expand All @@ -592,11 +598,11 @@
"""

show_muxcable_tunnel_route_expected_output="""\
PORT DEST_TYPE DEST_ADDRESS kernel asic
--------- ----------- -------------- -------- ------
Ethernet0 server_ipv4 10.2.1.1 added added
Ethernet4 server_ipv4 10.3.1.1 added -
Ethernet4 soc_ipv6 e801::47 - added
PORT DEST_TYPE DEST_ADDRESS kernel asic
---------- ----------- -------------- -------- ------
Ethernet0 server_ipv4 10.2.1.1 added added
Ethernet4 server_ipv4 10.3.1.1 added -
Ethernet32 soc_ipv6 fc00::76 - added
"""

show_muxcable_tunnel_route_expected_output_port_json="""\
Expand Down

0 comments on commit 4f14ee2

Please sign in to comment.