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

@alexvasiu alexvasiu commented Jul 2, 2018

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

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

@alexvasiu alexvasiu Jul 5, 2018

I changed all third-party imports

@alexvasiu alexvasiu force-pushed the dev/avasiu/older_nilrt_ip branch from 96dfabd to a53e9d4 Jul 5, 2018
@alexvasiu
Copy link
Contributor Author

@alexvasiu alexvasiu commented Jul 11, 2018

@gtmanfred May you please take a look at this ?

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

@gtmanfred gtmanfred Jul 11, 2018

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

configparser needs to still be imported from salt.ext.six.moves.

Otherthan that, this looks fine

@alexvasiu alexvasiu force-pushed the dev/avasiu/older_nilrt_ip branch from a53e9d4 to ecbbade Jul 11, 2018

# 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

@gtmanfred gtmanfred Jul 11, 2018

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

@gtmanfred gtmanfred Jul 11, 2018

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

@gtmanfred gtmanfred Jul 11, 2018

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 alexvasiu force-pushed the dev/avasiu/older_nilrt_ip branch from ecbbade to ffeab5e Jul 12, 2018
@alexvasiu
Copy link
Contributor Author

@alexvasiu alexvasiu commented Jul 12, 2018

@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
7 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants