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

Fix show ip interfaces #1129

Closed
wants to merge 1 commit into from
Closed

Conversation

msosyak
Copy link

@msosyak msosyak commented Sep 23, 2020

I faced the issue when call show ip interfaces on the latest SONiC image(03f82a0):

admin@sonic:~$ show ip interfaces 
sTraceback (most recent call last):
  File "/usr/local/bin/show", line 10, in <module>
    sys.exit(cli())
  File "/usr/lib/python2.7/dist-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python2.7/dist-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python2.7/dist-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python2.7/dist-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python2.7/dist-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/show/main.py", line 727, in interfaces
    netmask = netaddr.IPAddress(ipaddr['netmask']).netmask_bits()
NameError: global name 'netaddr' is not defined

In this PR netaddr was removed, but we need it to convert subnet mask to cidr here
- What I did
Fix NameError: global name 'netaddr' is not defined
- How I did it
import netaddr module
- How to verify it

  • build SONiC with this changes or manually apply them in the running SONiC image
  • run show ip interfaces
    - Previous command output (if the output of a command-line utility has changed)
admin@sonic:~$ show ip interfaces 
sTraceback (most recent call last):
  File "/usr/local/bin/show", line 10, in <module>
    sys.exit(cli())
  File "/usr/lib/python2.7/dist-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python2.7/dist-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python2.7/dist-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python2.7/dist-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python2.7/dist-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/show/main.py", line 727, in interfaces
    netmask = netaddr.IPAddress(ipaddr['netmask']).netmask_bits()
NameError: global name 'netaddr' is not defined

- New command output (if the output of a command-line utility has changed)

admin@sonic:~$ show ip interfaces 
Interface    Master    IPv4 address/mask    Admin/Oper    BGP Neighbor    Neighbor IP
-----------  --------  -------------------  ------------  --------------  -------------
Ethernet0              10.0.0.1/24          up/up         N/A             N/A
Ethernet4              20.0.0.1/24          up/up         N/A             N/A
Ethernet8              10.0.0.4/31          up/up         ARISTA03T2      10.0.0.5
 * * *

@msosyak
Copy link
Author

msosyak commented Sep 23, 2020

@arlakshm @jleveque Please review

Copy link
Contributor

@prsunny prsunny left a comment

Choose a reason for hiding this comment

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

Thanks for fixing this.

@prsunny
Copy link
Contributor

prsunny commented Sep 23, 2020

retest this please

@jleveque
Copy link
Contributor

Closing as a duplicate of #1126, in which the new import is added in alphabetical order, whereas in this PR it is not.

@jleveque jleveque closed this Sep 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants