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

[config][mclag] Fix import statement in mclag.py #2168

Open
wants to merge 3 commits into
base: 202111
Choose a base branch
from

Conversation

bratashX
Copy link
Contributor

@bratashX bratashX commented May 13, 2022

It`s cherry-pick from master branch: #2073

What I did
Fixed import error
Added unit test for that case

How I did it
Used relative import to import file from the current package.

How to verify it
Try to configure mclag with Port as peer interface
sudo config mclag add 1 192.168.3.1 192.168.3.2 Ethernet12
Previous command output (if the output of a command-line utility has changed)

admin@sonic:~$ sudo config mclag add 1 192.168.3.1 192.168.3.2 Ethernet12
Traceback (most recent call last):
  File "/usr/local/bin/config", line 8, in <module>
    sys.exit(config())
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/config/mclag.py", line 140, in add_mclag_domain
    if (peer_ifname.startswith("Ethernet") is True) and (check_if_interface_is_valid(db, peer_ifname) is False):
  File "/usr/local/lib/python3.9/dist-packages/config/mclag.py", line 89, in check_if_interface_is_valid
    from main import interface_name_is_valid
ModuleNotFoundError: No module named 'main'

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

admin@sonic:~$ sudo config mclag add 1 192.168.3.1 192.168.3.2 Ethernet12
admin@sonic:~$

@bratashX bratashX changed the title Fix import statement in mclag.py (#2073) [config][mclag] Fix import statement in mclag.py May 13, 2022
#### What I did
Fixed import error
Added unit test for that case

#### How I did it
Used relative import to import file from the current package.

#### How to verify it
Try to configure mclag with Port as peer interface 
```
sudo config mclag add 1 192.168.3.1 192.168.3.2 Ethernet12
```

#### Previous command output (if the output of a command-line utility has changed)
```
admin@sonic:~$ sudo config mclag add 1 192.168.3.1 192.168.3.2 Ethernet12
Traceback (most recent call last):
  File "/usr/local/bin/config", line 8, in <module>
    sys.exit(config())
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/config/mclag.py", line 140, in add_mclag_domain
    if (peer_ifname.startswith("Ethernet") is True) and (check_if_interface_is_valid(db, peer_ifname) is False):
  File "/usr/local/lib/python3.9/dist-packages/config/mclag.py", line 89, in check_if_interface_is_valid
    from main import interface_name_is_valid
ModuleNotFoundError: No module named 'main'
```
#### New command output (if the output of a command-line utility has changed)
```
admin@sonic:~$ sudo config mclag add 1 192.168.3.1 192.168.3.2 Ethernet12
admin@sonic:~$
```
@bratashX
Copy link
Contributor Author

bratashX commented Jun 6, 2022

@prsunny @lguohan please review and merge

@bratashX
Copy link
Contributor Author

@prsunny @lguohan @akokhan please review and merge

@bratashX
Copy link
Contributor Author

@prsunny @lguohan @akokhan please take a look

@bratashX
Copy link
Contributor Author

bratashX commented Aug 9, 2022

/easycla

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Aug 9, 2022

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: msosyak / name: Myron Sosyak (4626a72)
  • ✅ login: bratashX / name: Petro Bratash (077c74a, d8c4af7)

@bratashX
Copy link
Contributor Author

bratashX commented Aug 9, 2022

@prsunny @lguohan please review and merge

@bratashX
Copy link
Contributor Author

@prsunny @lguohan @prgeor please review and merge

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.

1 participant