-
Notifications
You must be signed in to change notification settings - Fork 5.5k
nilrt_ip: network module for older nilrt #48400
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
nilrt_ip: network module for older nilrt #48400
Conversation
salt/modules/nilrt_ip.py
Outdated
from salt.ext import six | ||
from salt.ext.six.moves import configparser | ||
# pylint: enable=import-error,redefined-builtin,no-name-in-module | ||
try: | ||
import pyconnman |
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.
salt seems to standardize on a different way of doing this:
try:
..import pyconnman
except ImportError:
..pyconnman = None
and then instead of:
if not HAS_PYCONNMAN:
just do:
if not pyconnman:
We should fix all those imports
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.
I changed all third-party imports
96dfabd
to
a53e9d4
Compare
@gtmanfred May you please take a look at this ? |
salt/modules/nilrt_ip.py
Outdated
try: | ||
import configparser | ||
except ImportError: | ||
configparser = None |
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.
This still needs to be imported from six.
from salt.ext.six.moves import configparser
Because the name changed between py2 and py3
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.
configparser needs to still be imported from salt.ext.six.moves.
Otherthan that, this looks fine
a53e9d4
to
ecbbade
Compare
salt/modules/nilrt_ip.py
Outdated
|
||
# Import salt libs | ||
import salt.exceptions | ||
import salt.utils.files | ||
import salt.utils.validate.net | ||
|
||
# Import 3rd-party libs | ||
# pylint: disable=import-error,redefined-builtin,no-name-in-module | ||
from salt.ext.six.moves import map, range |
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.
so, you don't need a try except loop for configparser, it just needs to be added to the imports on this line.
salt/modules/nilrt_ip.py
Outdated
try: | ||
from salt.ext.six.moves import configparser | ||
except ImportError: | ||
configparser = None |
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.
This will be unneeded.
salt/modules/nilrt_ip.py
Outdated
try: | ||
msg = 'The nilrt_ip module could not be loaded: unsupported OS family' | ||
_assume_condition(__grains__['os_family'] == 'NILinuxRT', msg) | ||
_assume_condition(configparser, 'The python package configparser is not installed') |
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.
again, unneeded, because it will always be in salt.ext.six.moves
Make nilrt_ip compatible with older nilrt. Since connman isn't pressent in older nilrt distros, use available tools (nirtcfg, ip, ifconfig) instead, to make this module partial compatible with newer nilrt part. The functionality available for older nilrt distros is: - enable/disable the interfaces - get details about sigle interface - information about all interfaces - set dhcp with linklocal fallback - set dhcp only - set linklocal only - set static configuration Signed-off-by: Heghedus Razvan <razvan.heghedus@ni.com> Signed-off-by: Alexandru Vasiu <alexandru.vasiu@ni.com> Signed-off-by: Rares POP <rares.pop@ni.com>
ecbbade
to
ffeab5e
Compare
@gtmanfred I changed that import for |
Make nilrt_ip compatible with older nilrt. Since connman isn't pressent
in older nilrt distros, use available tools (nirtcfg, ip, ifconfig)
instead, to make this module partial compatible with newer nilrt part.
The functionality available for older nilrt distros is:
- enable/disable the interfaces
- get details about sigle interface
- information about all interfaces
- set dhcp with linklocal fallback
- set dhcp only
- set linklocal only
- set static configuration
Signed-off-by: Heghedus Razvan razvan.heghedus@ni.com
Signed-off-by: Alexandru Vasiu alexandru.vasiu@ni.com
Signed-off-by: Rares POP rares.pop@ni.com