mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Fix ipaddress imports
This commit is contained in:
parent
b4f1a72bbb
commit
0498e946f9
11 changed files with 21 additions and 49 deletions
|
@ -145,7 +145,11 @@ def string_io(data=None): # cStringIO can't handle unicode
|
|||
except (UnicodeEncodeError, TypeError):
|
||||
return StringIO(data)
|
||||
|
||||
if PY3:
|
||||
import ipaddress
|
||||
else:
|
||||
import salt.ext.ipaddress as ipaddress
|
||||
|
||||
try:
|
||||
if PY3:
|
||||
import ipaddress
|
||||
else:
|
||||
import salt.ext.ipaddress as ipaddress
|
||||
except ImportError:
|
||||
ipaddress = None
|
||||
|
|
|
@ -27,10 +27,7 @@ import salt.utils.cloud
|
|||
import salt.config as config
|
||||
import salt.client
|
||||
import salt.ext.six as six
|
||||
if six.PY3:
|
||||
import ipaddress
|
||||
else:
|
||||
import salt.ext.ipaddress as ipaddress
|
||||
from salt._compat import ipaddress
|
||||
|
||||
from salt.exceptions import SaltCloudException, SaltCloudSystemExit
|
||||
|
||||
|
|
|
@ -26,10 +26,8 @@ import salt.utils
|
|||
import salt.config as config
|
||||
import salt.client
|
||||
import salt.ext.six as six
|
||||
if six.PY3:
|
||||
import ipaddress
|
||||
else:
|
||||
import salt.ext.ipaddress as ipaddress
|
||||
from salt._compat import ipaddress
|
||||
|
||||
from salt.exceptions import SaltCloudException, SaltCloudSystemExit, \
|
||||
SaltInvocationError
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ from __future__ import absolute_import
|
|||
import socket
|
||||
import ctypes
|
||||
import os
|
||||
import ipaddress
|
||||
from salt._compat import ipaddress
|
||||
import salt.ext.six as six
|
||||
|
||||
|
||||
|
|
|
@ -26,10 +26,7 @@ from binascii import crc32
|
|||
# Import Salt Libs
|
||||
# pylint: disable=import-error,no-name-in-module,redefined-builtin
|
||||
from salt.ext import six
|
||||
if six.PY3:
|
||||
import ipaddress
|
||||
else:
|
||||
import salt.ext.ipaddress as ipaddress
|
||||
from salt._compat import ipaddress
|
||||
from salt.ext.six.moves import range
|
||||
from salt.utils.zeromq import zmq, ZMQDefaultLoop, install_zmq, ZMQ_VERSION_INFO
|
||||
|
||||
|
|
|
@ -13,10 +13,7 @@ from salt.ext.six.moves import map, range
|
|||
import salt.utils.path
|
||||
|
||||
# Import third-party libs
|
||||
if six.PY3:
|
||||
import ipaddress
|
||||
else:
|
||||
import salt.ext.ipaddress as ipaddress
|
||||
from salt._compat import ipaddress
|
||||
|
||||
# Set up logging
|
||||
log = logging.getLogger(__name__)
|
||||
|
|
|
@ -26,10 +26,7 @@ from salt.exceptions import CommandExecutionError
|
|||
# Import 3rd-party libs
|
||||
from salt.ext import six
|
||||
from salt.ext.six.moves import range # pylint: disable=import-error,no-name-in-module,redefined-builtin
|
||||
if six.PY3:
|
||||
import ipaddress
|
||||
else:
|
||||
import salt.ext.ipaddress as ipaddress
|
||||
from salt._compat import ipaddress
|
||||
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
|
|
@ -39,11 +39,7 @@ import salt.utils.path
|
|||
import salt.utils.stringutils
|
||||
from salt.exceptions import CommandExecutionError, SaltInvocationError
|
||||
import salt.ext.six as six
|
||||
|
||||
if six.PY3:
|
||||
import ipaddress
|
||||
else:
|
||||
import salt.ext.ipaddress as ipaddress
|
||||
from salt._compat import ipaddress
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
|
|
@ -26,10 +26,7 @@ import salt.cache
|
|||
from salt.ext import six
|
||||
|
||||
# Import 3rd-party libs
|
||||
if six.PY3:
|
||||
import ipaddress
|
||||
else:
|
||||
import salt.ext.ipaddress as ipaddress
|
||||
from salt._compat import ipaddress
|
||||
HAS_RANGE = False
|
||||
try:
|
||||
import seco.range # pylint: disable=import-error
|
||||
|
|
|
@ -33,10 +33,7 @@ import salt.grains.core as core
|
|||
|
||||
# Import 3rd-party libs
|
||||
from salt.ext import six
|
||||
if six.PY3:
|
||||
import ipaddress
|
||||
else:
|
||||
import salt.ext.ipaddress as ipaddress
|
||||
from salt._compat import ipaddress
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
|
|
@ -25,15 +25,7 @@ import salt.utils.network
|
|||
import salt.utils.path
|
||||
import salt.modules.network as network
|
||||
from salt.exceptions import CommandExecutionError
|
||||
if six.PY2:
|
||||
import salt.ext.ipaddress as ipaddress
|
||||
HAS_IPADDRESS = True
|
||||
else:
|
||||
try:
|
||||
import ipaddress
|
||||
HAS_IPADDRESS = True
|
||||
except ImportError:
|
||||
HAS_IPADDRESS = False
|
||||
from salt._compat import ipaddress
|
||||
|
||||
|
||||
@skipIf(NO_MOCK, NO_MOCK_REASON)
|
||||
|
@ -276,7 +268,7 @@ class NetworkTestCase(TestCase, LoaderModuleMockMixin):
|
|||
self.assertDictEqual(network.connect('host', 'port'),
|
||||
{'comment': ret, 'result': True})
|
||||
|
||||
@skipIf(HAS_IPADDRESS is False, 'unable to import \'ipaddress\'')
|
||||
@skipIf(bool(ipaddress), 'unable to import \'ipaddress\'')
|
||||
def test_is_private(self):
|
||||
'''
|
||||
Test for Check if the given IP address is a private address
|
||||
|
@ -288,7 +280,7 @@ class NetworkTestCase(TestCase, LoaderModuleMockMixin):
|
|||
return_value=True):
|
||||
self.assertTrue(network.is_private('::1'))
|
||||
|
||||
@skipIf(HAS_IPADDRESS is False, 'unable to import \'ipaddress\'')
|
||||
@skipIf(bool(ipaddress), 'unable to import \'ipaddress\'')
|
||||
def test_is_loopback(self):
|
||||
'''
|
||||
Test for Check if the given IP address is a loopback address
|
||||
|
|
Loading…
Add table
Reference in a new issue