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

nilrt_ip: network module for older nilrt #48400

Merged
merged 1 commit into from Jul 12, 2018

Conversation

alexvasiu
Copy link
Contributor

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

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
Copy link
Contributor

@rares-pop rares-pop Jul 4, 2018

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

Copy link
Contributor Author

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

@alexvasiu
Copy link
Contributor Author

@gtmanfred May you please take a look at this ?

try:
import configparser
except ImportError:
configparser = None
Copy link
Contributor

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

Copy link
Contributor

@gtmanfred gtmanfred left a 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


# 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
Copy link
Contributor

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.

try:
from salt.ext.six.moves import configparser
except ImportError:
configparser = None
Copy link
Contributor

Choose a reason for hiding this comment

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

This will be unneeded.

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')
Copy link
Contributor

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>
@alexvasiu
Copy link
Contributor Author

@gtmanfred I changed that import for configparser and I removed all checks for it

@rallytime rallytime merged commit 570f76d into saltstack:develop Jul 12, 2018
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.

None yet

4 participants