-
Notifications
You must be signed in to change notification settings - Fork 756
Improved show ip interface cli performance by listing only interfaces… #4103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
3f2535f
8023377
a88c94f
b233515
14539cd
1e9d366
8f69213
bdc8f57
141d2f6
ce8dfd0
fb1209a
e8b09ff
d7cd50a
c267079
c5a69cb
c8dec75
6c4a030
098d3bf
daa91b6
95f42a3
e309c3a
d5a8783
470b3cc
9a098c7
651a5d3
e967f81
2e598d0
9a8ac9e
3eafbb6
82189b4
3df1fbe
4cecaf7
67c92a8
222894b
ef43e0a
22c6447
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -15,6 +15,8 @@ from utilities_common import constants | |||||
| from utilities_common.general import load_db_config | ||||||
| from utilities_common import multi_asic as multi_asic_util | ||||||
|
|
||||||
| # Minimal UT compatibility flag (keeps fast path in production) | ||||||
| TEST_MODE = os.environ.get("UTILITIES_UNIT_TESTING") == "2" | ||||||
|
|
||||||
| try: | ||||||
| if os.environ["UTILITIES_UNIT_TESTING"] == "2": | ||||||
|
|
@@ -145,25 +147,70 @@ def get_if_master(iface): | |||||
| return "" | ||||||
|
|
||||||
|
|
||||||
| def _addr_show(namespace, af, display): | ||||||
| """ | ||||||
| FAST address collector using `ip -o addr show`. | ||||||
| Returns: dict { ifname: [ ["", "CIDR"], ... ] } | ||||||
| """ | ||||||
| fam_opt = ["-f", "inet"] if af == netifaces.AF_INET else ["-f", "inet6"] | ||||||
| base_cmd = ["ip", "-o"] + fam_opt + ["addr", "show"] | ||||||
| cmd = base_cmd if namespace == constants.DEFAULT_NAMESPACE else ["sudo", "ip", "netns", "exec", namespace] + base_cmd | ||||||
|
|
||||||
| try: | ||||||
| out = subprocess.check_output(cmd, text=True, stderr=subprocess.DEVNULL) | ||||||
| except subprocess.CalledProcessError: | ||||||
| out = "" | ||||||
|
|
||||||
| addrs = {} | ||||||
| for line in out.splitlines(): | ||||||
| # Example: "12: Po101.1645@PortChannel101 inet 30.2.135.1/24 scope global Po101.1645" | ||||||
| colon = line.find(":") | ||||||
| if colon < 0: | ||||||
| continue | ||||||
| ifname = line[colon + 1:].lstrip().split()[0] | ||||||
|
|
||||||
| if namespace != constants.DEFAULT_NAMESPACE and skip_ip_intf_display(ifname, display): | ||||||
|
||||||
| if namespace != constants.DEFAULT_NAMESPACE and skip_ip_intf_display(ifname, display): | |
| if skip_ip_intf_display(ifname, display): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is option
--jsonto simply output parsing. Could you explore?