-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[sonic-py-common] Add interface utilities (#5113)
* Add sonic_interface.py in sonic-py-common for sonic interface utilities to keep this SONIC PREFIX naming convention in one place in py-common and all modules/applications use the functions defined here.
- Loading branch information
1 parent
4487abd
commit 52fe7ae
Showing
2 changed files
with
46 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
""" | ||
Dictionary of SONIC interface name prefixes. Each entry in the format | ||
"Human readable interface string":"Sonic interface prefix" | ||
Currently this is a static mapping, but in future could be stored as metadata in DB. | ||
""" | ||
|
||
SONIC_INTERFACE_PREFIXES = { | ||
"Ethernet-FrontPanel": "Ethernet", | ||
"PortChannel": "PortChannel", | ||
"Vlan": "Vlan", | ||
"Loopback": "Loopback", | ||
"Ethernet-Backplane": "Ethernet-BP" | ||
} | ||
|
||
def front_panel_prefix(): | ||
""" | ||
Retrieves the SONIC front panel interface name prefix. | ||
""" | ||
return SONIC_INTERFACE_PREFIXES["Ethernet-FrontPanel"] | ||
|
||
def backplane_prefix(): | ||
""" | ||
Retrieves the SONIC backplane interface name prefix. | ||
""" | ||
return SONIC_INTERFACE_PREFIXES["Ethernet-Backplane"] | ||
|
||
def portchannel_prefix(): | ||
""" | ||
Retrieves the SONIC PortChannel interface name prefix. | ||
""" | ||
return SONIC_INTERFACE_PREFIXES["PortChannel"] | ||
|
||
def vlan_prefix(): | ||
""" | ||
Retrieves the SONIC Vlan interface name prefix. | ||
""" | ||
return SONIC_INTERFACE_PREFIXES["Vlan"] | ||
|
||
def loopback_prefix(): | ||
""" | ||
Retrieves the SONIC Loopback interface name prefix. | ||
""" | ||
return SONIC_INTERFACE_PREFIXES["Loopback"] |