Skip to content
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

[sonic_cli]: Fix bash completion for 'show' command #12

Merged
merged 2 commits into from Mar 1, 2017
Merged

[sonic_cli]: Fix bash completion for 'show' command #12

merged 2 commits into from Mar 1, 2017

Conversation

jleveque
Copy link
Contributor

@jleveque jleveque commented Feb 28, 2017

Fix bash completion for 'show' command

@jleveque jleveque changed the title Fix bash completion for 'show' command [sonic_cli]: Fix bash completion for 'show' command Feb 28, 2017
@@ -0,0 +1,57 @@
# System-wide .bashrc file for interactive bash(1) shells.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems to be the same as the one in the bash package. Can you remove it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's different. The bash-completion section is uncommented.

@jleveque
Copy link
Contributor Author

jleveque commented Mar 1, 2017

Removed bash.bashrc so there is no need to install by passing the non-standard "--force-overwrite" flag to dpkg.

bash.bashrc file will instead by copied into place in sonic-buildimage as part of the SONiC extension.

@jleveque jleveque merged commit ce84e28 into sonic-net:master Mar 1, 2017
@jleveque jleveque deleted the bash_completion branch March 1, 2017 22:35
@jleveque jleveque added the Bug label Mar 24, 2017
praveen-li pushed a commit to praveen-li/sonic-utilities that referenced this pull request Feb 10, 2020
…load commands. (sonic-net#12)

Signed-off-by: Praveen Chaudhary pchaudhary@linkedin.com
lguohan pushed a commit that referenced this pull request Nov 4, 2020
…1215)

route_check.py will report an ERROR in syslog if route mismatch is
found, which is out control of monit config file. This commit add an
option (-s) to control whether error will be reported in syslog.

**- How to verify it**
The update is verified on Arista-7260.
1. Add a static route whose nexthop is not reachable.

```
ip route add 1.1.1.1 via 192.168.1.101
```
2. Run ```route_check.py```, and error msg is only printed on stdout. Nothing is writen to syslog
3. Run ```route_check.py -s```. and error msg is writen to both stdout and syslog
4. Wait for 15 minutes, and confirm that monit will report the error
```
Nov  4 09:30:36.917367 str-7260cx3-acs-2 ERR monit[631]: 'routeCheck' status failed (255) -- results: { {#12    "missed_ROUTE_TABLE_routes": [#12        "1.1.1.1/32"#12    ]#12} }#12 Failed. Look at reported mismatches above
```

Signed-off-by: bingwang <bingwang@microsoft.com>
lguohan pushed a commit that referenced this pull request Dec 17, 2020
This commit fix the exception thrown by struct.pack when attempting to pack a unicode string.
The script ```fast-reboot-dump.py``` will throw an exception in python3 because ```struct.pack``` requires ```bytes``` for ```s```.
```
Traceback: Traceback (most recent call last):
#12  File "/usr/local/bin/fast-reboot-dump.py", line 299, in <module>
#12    res = main()
#12  File "/usr/local/bin/fast-reboot-dump.py", line 292, in main
#12    send_garp_nd(neighbor_entries, map_mac_ip_per_vlan)
#12  File "/usr/local/bin/fast-reboot-dump.py", line 221, in send_garp_nd
#12    src_ip_addrs = {vlan_name:get_iface_ip_addr(vlan_name) for vlan_name,_,_ in neighbor_entries}
#12  File "/usr/local/bin/fast-reboot-dump.py", line 221, in <dictcomp>
#12    src_ip_addrs = {vlan_name:get_iface_ip_addr(vlan_name) for vlan_name,_,_ in neighbor_entries}
#12  File "/usr/local/bin/fast-reboot-dump.py", line 195, in get_iface_ip_addr
#12    return get_if(iff, SIOCGIFADDR)[20:24]
#12  File "/usr/local/bin/fast-reboot-dump.py", line 185, in get_if
#12    ifreq = ioctl(s, cmd, struct.pack("16s16x",iff))
#12  struct.error: argument for 's' must be a bytes object
```

Signed-off-by: bingwang <bingwang@microsoft.com>
anand-kumar-subramanian pushed a commit to anand-kumar-subramanian/sonic-utilities that referenced this pull request Mar 2, 2021
This commit fix the exception thrown by struct.pack when attempting to pack a unicode string.
The script ```fast-reboot-dump.py``` will throw an exception in python3 because ```struct.pack``` requires ```bytes``` for ```s```.
```
Traceback: Traceback (most recent call last):
sonic-net#12  File "/usr/local/bin/fast-reboot-dump.py", line 299, in <module>
sonic-net#12    res = main()
sonic-net#12  File "/usr/local/bin/fast-reboot-dump.py", line 292, in main
sonic-net#12    send_garp_nd(neighbor_entries, map_mac_ip_per_vlan)
sonic-net#12  File "/usr/local/bin/fast-reboot-dump.py", line 221, in send_garp_nd
sonic-net#12    src_ip_addrs = {vlan_name:get_iface_ip_addr(vlan_name) for vlan_name,_,_ in neighbor_entries}
sonic-net#12  File "/usr/local/bin/fast-reboot-dump.py", line 221, in <dictcomp>
sonic-net#12    src_ip_addrs = {vlan_name:get_iface_ip_addr(vlan_name) for vlan_name,_,_ in neighbor_entries}
sonic-net#12  File "/usr/local/bin/fast-reboot-dump.py", line 195, in get_iface_ip_addr
sonic-net#12    return get_if(iff, SIOCGIFADDR)[20:24]
sonic-net#12  File "/usr/local/bin/fast-reboot-dump.py", line 185, in get_if
sonic-net#12    ifreq = ioctl(s, cmd, struct.pack("16s16x",iff))
sonic-net#12  struct.error: argument for 's' must be a bytes object
```

Signed-off-by: bingwang <bingwang@microsoft.com>
vdahiya12 pushed a commit to vdahiya12/sonic-utilities that referenced this pull request Jul 23, 2021
siqbal1986 pushed a commit that referenced this pull request May 4, 2023
cisco sonic router will hit below error message from route_check
str3-8101-02 ERR monit[519]: 'routeCheck' status failed (255) –
Failure results: #12 "Unaccounted_ROUTE_ENTRY_TABLE_entries": #12 "fddd:a150:a0::a66:1/128",#12 "fddd:a150:a0::a67:1/128",#12 "fddd:a150:a0::a71:1/128",#12 "fddd:a150:a0::a78:1/128",#12 "fddd:a150:a0::a80:1/128"#12
#12#012Failed. Look at reported mismatches above#012add: []#012del: []

the parser will only cut the chars before : regardless it is the IPv6 format.
For instance,
route_check: "fddd:a150:a0::a21:1/128
Will be parsed as “fddd" ONLY
Vnet_v6_in_v4-0: : a150:a0::a21:1/128"
solution:
fix the parsing scheme on route check when APPL_DB refers IPv6 format.
yxieca pushed a commit that referenced this pull request May 17, 2023
cisco sonic router will hit below error message from route_check
str3-8101-02 ERR monit[519]: 'routeCheck' status failed (255) –
Failure results: #12 "Unaccounted_ROUTE_ENTRY_TABLE_entries": #12 "fddd:a150:a0::a66:1/128",#12 "fddd:a150:a0::a67:1/128",#12 "fddd:a150:a0::a71:1/128",#12 "fddd:a150:a0::a78:1/128",#12 "fddd:a150:a0::a80:1/128"#12
#12#012Failed. Look at reported mismatches above#012add: []#012del: []

the parser will only cut the chars before : regardless it is the IPv6 format.
For instance,
route_check: "fddd:a150:a0::a21:1/128
Will be parsed as “fddd" ONLY
Vnet_v6_in_v4-0: : a150:a0::a21:1/128"
solution:
fix the parsing scheme on route check when APPL_DB refers IPv6 format.
qiluo-msft pushed a commit that referenced this pull request May 25, 2023
cisco sonic router will hit below error message from route_check
str3-8101-02 ERR monit[519]: 'routeCheck' status failed (255) –
Failure results: #12 "Unaccounted_ROUTE_ENTRY_TABLE_entries": #12 "fddd:a150:a0::a66:1/128",#12 "fddd:a150:a0::a67:1/128",#12 "fddd:a150:a0::a71:1/128",#12 "fddd:a150:a0::a78:1/128",#12 "fddd:a150:a0::a80:1/128"#12
#12#012Failed. Look at reported mismatches above#012add: []#012del: []

the parser will only cut the chars before : regardless it is the IPv6 format.
For instance,
route_check: "fddd:a150:a0::a21:1/128
Will be parsed as “fddd" ONLY
Vnet_v6_in_v4-0: : a150:a0::a21:1/128"
solution:
fix the parsing scheme on route check when APPL_DB refers IPv6 format.
pdhruv-marvell pushed a commit to pdhruv-marvell/sonic-utilities that referenced this pull request Aug 23, 2023
cisco sonic router will hit below error message from route_check
str3-8101-02 ERR monit[519]: 'routeCheck' status failed (255) –
Failure results: sonic-net#12 "Unaccounted_ROUTE_ENTRY_TABLE_entries": sonic-net#12 "fddd:a150:a0::a66:1/128",sonic-net#12 "fddd:a150:a0::a67:1/128",sonic-net#12 "fddd:a150:a0::a71:1/128",sonic-net#12 "fddd:a150:a0::a78:1/128",sonic-net#12 "fddd:a150:a0::a80:1/128"sonic-net#12
sonic-net#12#012Failed. Look at reported mismatches above#012add: []#012del: []

the parser will only cut the chars before : regardless it is the IPv6 format.
For instance,
route_check: "fddd:a150:a0::a21:1/128
Will be parsed as “fddd" ONLY
Vnet_v6_in_v4-0: : a150:a0::a21:1/128"
solution:
fix the parsing scheme on route check when APPL_DB refers IPv6 format.
yxieca pushed a commit that referenced this pull request Aug 29, 2023
cisco sonic router will hit below error message from route_check
str3-8101-02 ERR monit[519]: 'routeCheck' status failed (255) –
Failure results: #12 "Unaccounted_ROUTE_ENTRY_TABLE_entries": #12 "fddd:a150:a0::a66:1/128",#12 "fddd:a150:a0::a67:1/128",#12 "fddd:a150:a0::a71:1/128",#12 "fddd:a150:a0::a78:1/128",#12 "fddd:a150:a0::a80:1/128"#12
#12#012Failed. Look at reported mismatches above#012add: []#012del: []

the parser will only cut the chars before : regardless it is the IPv6 format.
For instance,
route_check: "fddd:a150:a0::a21:1/128
Will be parsed as “fddd" ONLY
Vnet_v6_in_v4-0: : a150:a0::a21:1/128"
solution:
fix the parsing scheme on route check when APPL_DB refers IPv6 format.
mihirpat1 pushed a commit to mihirpat1/sonic-utilities that referenced this pull request Sep 15, 2023
Signed-off-by: Guohan Lu <gulv@microsoft.com>
saiarcot895 pushed a commit that referenced this pull request Nov 16, 2023
…ng (#3030)

* [fast-reboot-filter-routes.py] Remove click and improve error reporting

1. Removed click usage from a script since there is no active click
context therefore we saw these error messages:

```
ERR fast-reboot-filter-routes: Got an exception There is no active click context.: Traceback: Traceback (most recent call last):#12  File "/usr/local/bin/fast-reboot-filter-routes.py", line 18, in get_connected_routes#012    output, ret = clicommon.run_command(cmd, return_cmd=True)#12  File "/usr/local/lib/python3.9/dist-packages/utilities_common/cli.py", line 545, in run_command#012    proc = subprocess.Popen(command, shell=shell, text=True, stdout=subprocess.PIPE)#12  File "/usr/lib/python3.9/subprocess.py", line 951, in __init__#012    self._execute_child(args, executable, preexec_fn, close_fds,#12  File "/usr/lib/python3.9/subprocess.py", line 1823, in _execute_child#012    raise child_exception_type(errno_num, err_msg, err_filename)#012FileNotFoundError: [Errno 2] No such file or directory: 'sudo vtysh -c "show ip route connected json"'#12#012During handling of the above exception, another exception occurred:#12#012Traceback (most recent call last):#12  File "/usr/local/lib/python3.9/dist-packages/click/globals.py", line 23, in get_current_context#012    return getattr(_local, 'stack')[-1]#012AttributeError: '_thread._local' object has no attribute 'stack'#12#012During handling of the above exception, another exception occurred:#12#012Traceback (most recent call last):#12  File "/usr/local/bin/fast-reboot-filter-routes.py", line 79, in <module>#12    res = main()#12  File "/usr/local/bin/fast-reboot-filter-routes.py", line 70, in main#012    connected_routes = get_connected_routes()#12  File "/usr/local/bin/fast-reboot-filter-routes.py", line 27, in get_connected_routes#012    ctx = click.get_current_context()#12  File "/usr/local/lib/python3.9/dist-packages/click/globals.py", line 26, in get_current_context#012    raise RuntimeError('There is no active click context.')#012RuntimeError: There is no active click context.
```

2. Improved error reporting so that when an error occurs when we run a
command it will report it via terminal and syslog:

stdout:
```
Failed to execute sudo vtysh -c show ip route connected jsson: % Unknown command: show ip route connected jsson
```

syslog:
```
Oct 17 11:53:10.620788 arc-switch1025 ERR fast-reboot-filter-routes: Got an exception: Failed to execute sudo vtysh -c show ip route connected jsson: % Unknown command: show ip route connected jsson: Traceback: Traceback (most recent call last):#12  File "/home/admin/fast-reboot-filter-routes.py", line 73, in <module>#12    res = main()#12  File "/home/admin/fast-reboot-filter-routes.py", line 64, in main#012    connected_routes = get_connected_routes()#12  File "/home/admin/fast-reboot-filter-routes.py", line 18, in get_connected_routes#012    raise Exception("Failed to execute {}: {}".format(" ".join(cmd), output.rstrip('\n')))#012Exception: Failed to execute sudo vtysh -c show ip route connected jsson: % Unknown command: show ip route connected jsson
```

Signed-off-by: Stepan Blyschak <stepanb@nvidia.com>

* add a test for command failure

Signed-off-by: Stepan Blyschak <stepanb@nvidia.com>

* Increase coverage

Signed-off-by: Stepan Blyschak <stepanb@nvidia.com>

---------

Signed-off-by: Stepan Blyschak <stepanb@nvidia.com>
StormLiangMS pushed a commit that referenced this pull request Nov 19, 2023
…ng (#3030)

* [fast-reboot-filter-routes.py] Remove click and improve error reporting

1. Removed click usage from a script since there is no active click
context therefore we saw these error messages:

```
ERR fast-reboot-filter-routes: Got an exception There is no active click context.: Traceback: Traceback (most recent call last):#12  File "/usr/local/bin/fast-reboot-filter-routes.py", line 18, in get_connected_routes#012    output, ret = clicommon.run_command(cmd, return_cmd=True)#12  File "/usr/local/lib/python3.9/dist-packages/utilities_common/cli.py", line 545, in run_command#012    proc = subprocess.Popen(command, shell=shell, text=True, stdout=subprocess.PIPE)#12  File "/usr/lib/python3.9/subprocess.py", line 951, in __init__#012    self._execute_child(args, executable, preexec_fn, close_fds,#12  File "/usr/lib/python3.9/subprocess.py", line 1823, in _execute_child#012    raise child_exception_type(errno_num, err_msg, err_filename)#012FileNotFoundError: [Errno 2] No such file or directory: 'sudo vtysh -c "show ip route connected json"'#12#012During handling of the above exception, another exception occurred:#12#012Traceback (most recent call last):#12  File "/usr/local/lib/python3.9/dist-packages/click/globals.py", line 23, in get_current_context#012    return getattr(_local, 'stack')[-1]#012AttributeError: '_thread._local' object has no attribute 'stack'#12#012During handling of the above exception, another exception occurred:#12#012Traceback (most recent call last):#12  File "/usr/local/bin/fast-reboot-filter-routes.py", line 79, in <module>#12    res = main()#12  File "/usr/local/bin/fast-reboot-filter-routes.py", line 70, in main#012    connected_routes = get_connected_routes()#12  File "/usr/local/bin/fast-reboot-filter-routes.py", line 27, in get_connected_routes#012    ctx = click.get_current_context()#12  File "/usr/local/lib/python3.9/dist-packages/click/globals.py", line 26, in get_current_context#012    raise RuntimeError('There is no active click context.')#012RuntimeError: There is no active click context.
```

2. Improved error reporting so that when an error occurs when we run a
command it will report it via terminal and syslog:

stdout:
```
Failed to execute sudo vtysh -c show ip route connected jsson: % Unknown command: show ip route connected jsson
```

syslog:
```
Oct 17 11:53:10.620788 arc-switch1025 ERR fast-reboot-filter-routes: Got an exception: Failed to execute sudo vtysh -c show ip route connected jsson: % Unknown command: show ip route connected jsson: Traceback: Traceback (most recent call last):#12  File "/home/admin/fast-reboot-filter-routes.py", line 73, in <module>#12    res = main()#12  File "/home/admin/fast-reboot-filter-routes.py", line 64, in main#012    connected_routes = get_connected_routes()#12  File "/home/admin/fast-reboot-filter-routes.py", line 18, in get_connected_routes#012    raise Exception("Failed to execute {}: {}".format(" ".join(cmd), output.rstrip('\n')))#012Exception: Failed to execute sudo vtysh -c show ip route connected jsson: % Unknown command: show ip route connected jsson
```

Signed-off-by: Stepan Blyschak <stepanb@nvidia.com>

* add a test for command failure

Signed-off-by: Stepan Blyschak <stepanb@nvidia.com>

* Increase coverage

Signed-off-by: Stepan Blyschak <stepanb@nvidia.com>

---------

Signed-off-by: Stepan Blyschak <stepanb@nvidia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants