summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorSam Doran <sdoran@redhat.com>2019-04-09 13:17:59 -0400
committerSloane Hertel <shertel@redhat.com>2019-04-09 13:17:59 -0400
commit3cd98a9fccdd8ac7f241e7b64718e8dedd6cd7fd (patch)
treebe13bf5f718429ed50419acd5955f932798d4801 /contrib
parent97f706810c021e87b97f123cd27872b5e40b4cf0 (diff)
downloadansible-3cd98a9fccdd8ac7f241e7b64718e8dedd6cd7fd.tar.gz
Use ansible.module_utils.six in inventory scripts (#55000)
* Use six from ansible.module_utils for inventory scripts Remove skips from sanity test * Change all imports of ConfigParser to use module_utils.six.moves * Remove commented out lines * Fix six imports
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/inventory/abiquo.py2
-rwxr-xr-xcontrib/inventory/apache-libcloud.py4
-rwxr-xr-xcontrib/inventory/azure_rm.py8
-rwxr-xr-xcontrib/inventory/brook.py5
-rwxr-xr-xcontrib/inventory/cobbler.py4
-rwxr-xr-xcontrib/inventory/collins.py6
-rwxr-xr-xcontrib/inventory/consul_io.py7
-rwxr-xr-xcontrib/inventory/ec2.py4
-rwxr-xr-xcontrib/inventory/foreman.py7
-rwxr-xr-xcontrib/inventory/freeipa.py2
-rwxr-xr-xcontrib/inventory/gce.py5
-rwxr-xr-xcontrib/inventory/linode.py2
-rwxr-xr-xcontrib/inventory/lxd.py6
-rwxr-xr-xcontrib/inventory/mdt_dynamic_inventory.py5
-rwxr-xr-xcontrib/inventory/nagios_livestatus.py6
-rwxr-xr-xcontrib/inventory/nagios_ndo.py6
-rwxr-xr-xcontrib/inventory/nsot.py2
-rwxr-xr-xcontrib/inventory/openshift.py2
-rwxr-xr-xcontrib/inventory/ovirt.py2
-rwxr-xr-xcontrib/inventory/ovirt4.py5
-rwxr-xr-xcontrib/inventory/packet_net.py4
-rwxr-xr-xcontrib/inventory/proxmox.py4
-rwxr-xr-xcontrib/inventory/rax.py4
-rwxr-xr-xcontrib/inventory/rudder.py2
-rwxr-xr-xcontrib/inventory/scaleway.py4
-rwxr-xr-xcontrib/inventory/spacewalk.py4
-rwxr-xr-xcontrib/inventory/vmware.py5
-rwxr-xr-xcontrib/inventory/vmware_inventory.py5
-rwxr-xr-xcontrib/inventory/zabbix.py5
-rwxr-xr-xcontrib/vault/azure_vault.py7
30 files changed, 45 insertions, 89 deletions
diff --git a/contrib/inventory/abiquo.py b/contrib/inventory/abiquo.py
index 90d52d3c6c..5a7950bd70 100755
--- a/contrib/inventory/abiquo.py
+++ b/contrib/inventory/abiquo.py
@@ -44,10 +44,10 @@ imagetemplate: Creates a host group for each image template containing all hosts
import os
import sys
import time
-import ConfigParser
import json
+from ansible.module_utils.six.moves import configparser as ConfigParser
from ansible.module_utils.urls import open_url
diff --git a/contrib/inventory/apache-libcloud.py b/contrib/inventory/apache-libcloud.py
index 5d3fe9a2e0..3857d2f934 100755
--- a/contrib/inventory/apache-libcloud.py
+++ b/contrib/inventory/apache-libcloud.py
@@ -35,9 +35,9 @@ import os
import argparse
import re
from time import time
-import ConfigParser
-from six import iteritems, string_types
+from ansible.module_utils.six import iteritems, string_types
+from ansible.module_utils.six.moves import configparser as ConfigParser
from libcloud.compute.types import Provider
from libcloud.compute.providers import get_driver
import libcloud.security as sec
diff --git a/contrib/inventory/azure_rm.py b/contrib/inventory/azure_rm.py
index a83558cd49..7dc438f6a2 100755
--- a/contrib/inventory/azure_rm.py
+++ b/contrib/inventory/azure_rm.py
@@ -201,14 +201,8 @@ import re
import sys
import inspect
-try:
- # python2
- import ConfigParser as cp
-except ImportError:
- # python3
- import configparser as cp
-
from os.path import expanduser
+from ansible.module_utils.six.moves import configparser as cp
import ansible.module_utils.six.moves.urllib.parse as urlparse
HAS_AZURE = True
diff --git a/contrib/inventory/brook.py b/contrib/inventory/brook.py
index b8c4bd7341..236571315b 100755
--- a/contrib/inventory/brook.py
+++ b/contrib/inventory/brook.py
@@ -79,10 +79,7 @@ Version: 0.2
import sys
import os
-try:
- from ConfigParser import SafeConfigParser as ConfigParser
-except ImportError:
- from configparser import ConfigParser
+from ansible.module_utils.six.moves.configparser import SafeConfigParser as ConfigParser
import json
diff --git a/contrib/inventory/cobbler.py b/contrib/inventory/cobbler.py
index eff9318967..a3b94b7a96 100755
--- a/contrib/inventory/cobbler.py
+++ b/contrib/inventory/cobbler.py
@@ -59,7 +59,6 @@ Changelog:
######################################################################
import argparse
-import ConfigParser
import os
import re
from time import time
@@ -67,7 +66,8 @@ import xmlrpclib
import json
-from six import iteritems
+from ansible.module_utils.six import iteritems
+from ansible.module_utils.six.moves import configparser as ConfigParser
# NOTE -- this file assumes Ansible is being accessed FROM the cobbler
# server, so it does not attempt to login with a username and password.
diff --git a/contrib/inventory/collins.py b/contrib/inventory/collins.py
index b768f6b3f9..39f6c4b447 100755
--- a/contrib/inventory/collins.py
+++ b/contrib/inventory/collins.py
@@ -67,7 +67,6 @@ Tested against Ansible 1.8.2 and Collins 1.3.0.
import argparse
-import ConfigParser
import logging
import os
import re
@@ -77,8 +76,9 @@ import traceback
import json
-from six import iteritems
-from six.moves.urllib.parse import urlencode
+from ansible.module_utils.six import iteritems
+from ansible.module_utils.six.moves import configparser as ConfigParser
+from ansible.module_utils.six.moves.urllib.parse import urlencode
from ansible.module_utils.urls import open_url
diff --git a/contrib/inventory/consul_io.py b/contrib/inventory/consul_io.py
index 113f3c99a8..4dad3eeec1 100755
--- a/contrib/inventory/consul_io.py
+++ b/contrib/inventory/consul_io.py
@@ -136,10 +136,7 @@ import re
import argparse
import sys
-try:
- import configparser
-except ImportError:
- import ConfigParser as configparser
+from ansible.module_utils.six.moves import configparser
def get_log_filename():
@@ -201,7 +198,7 @@ except ImportError as e:
sys.exit("""failed=True msg='python-consul required for this module.
See https://python-consul.readthedocs.io/en/latest/#installation'""")
-from six import iteritems
+from ansible.module_utils.six import iteritems
class ConsulInventory(object):
diff --git a/contrib/inventory/ec2.py b/contrib/inventory/ec2.py
index 1e9487d9bb..3d0ba3a245 100755
--- a/contrib/inventory/ec2.py
+++ b/contrib/inventory/ec2.py
@@ -166,9 +166,10 @@ from boto import rds
from boto import elasticache
from boto import route53
from boto import sts
-import six
+from ansible.module_utils import six
from ansible.module_utils import ec2 as ec2_utils
+from ansible.module_utils.six.moves import configparser
HAS_BOTO3 = False
try:
@@ -177,7 +178,6 @@ try:
except ImportError:
pass
-from six.moves import configparser
from collections import defaultdict
import json
diff --git a/contrib/inventory/foreman.py b/contrib/inventory/foreman.py
index f51d073b17..e3f98f360a 100755
--- a/contrib/inventory/foreman.py
+++ b/contrib/inventory/foreman.py
@@ -22,12 +22,6 @@
# Stdlib imports
# __future__ imports must occur at the beginning of file
from __future__ import print_function
-try:
- # Python 2 version
- import ConfigParser
-except ImportError:
- # Python 3 version
- import configparser as ConfigParser
import json
import argparse
import copy
@@ -47,6 +41,7 @@ if LooseVersion(requests.__version__) < LooseVersion('1.1.0'):
from requests.auth import HTTPBasicAuth
from ansible.module_utils._text import to_text
+from ansible.module_utils.six.moves import configparser as ConfigParser
def json_format_dict(data, pretty=False):
diff --git a/contrib/inventory/freeipa.py b/contrib/inventory/freeipa.py
index 8dac3382a0..cb5ccc071a 100755
--- a/contrib/inventory/freeipa.py
+++ b/contrib/inventory/freeipa.py
@@ -8,7 +8,7 @@ import json
import os
import sys
from ipalib import api, errors, __version__ as IPA_VERSION
-from six import u
+from ansible.module_utils.six import u
def initialize():
diff --git a/contrib/inventory/gce.py b/contrib/inventory/gce.py
index e030a5fb12..89a08fbd13 100755
--- a/contrib/inventory/gce.py
+++ b/contrib/inventory/gce.py
@@ -80,10 +80,7 @@ import argparse
from time import time
-if sys.version_info >= (3, 0):
- import configparser
-else:
- import ConfigParser as configparser
+from ansible.module_utils.six.moves import configparser
import logging
logging.getLogger('libcloud.common.google').addHandler(logging.NullHandler())
diff --git a/contrib/inventory/linode.py b/contrib/inventory/linode.py
index 427796be3c..f4ae302816 100755
--- a/contrib/inventory/linode.py
+++ b/contrib/inventory/linode.py
@@ -108,7 +108,7 @@ except Exception:
load_chube_config()
# Imports for ansible
-import ConfigParser
+from ansible.module_utils.six.moves import configparser as ConfigParser
class LinodeInventory(object):
diff --git a/contrib/inventory/lxd.py b/contrib/inventory/lxd.py
index 78a545a791..2cb1354277 100755
--- a/contrib/inventory/lxd.py
+++ b/contrib/inventory/lxd.py
@@ -27,10 +27,8 @@ from subprocess import Popen, PIPE
import distutils.spawn
import sys
import json
-try:
- import configparser
-except Exception:
- from six.moves import configparser
+
+from ansible.module_utils.six.moves import configparser
# Set up defaults
resource = 'local:'
diff --git a/contrib/inventory/mdt_dynamic_inventory.py b/contrib/inventory/mdt_dynamic_inventory.py
index 947091079a..154aac4f8d 100755
--- a/contrib/inventory/mdt_dynamic_inventory.py
+++ b/contrib/inventory/mdt_dynamic_inventory.py
@@ -27,10 +27,7 @@ maintainer: J Barnett (github @jbarnett1981)
import argparse
import json
import pymssql
-try:
- import configparser
-except ImportError:
- import ConfigParser as configparser
+from ansible.module_utils.six.moves import configparser
class MDTInventory(object):
diff --git a/contrib/inventory/nagios_livestatus.py b/contrib/inventory/nagios_livestatus.py
index 8f428000d8..25c043b5c0 100755
--- a/contrib/inventory/nagios_livestatus.py
+++ b/contrib/inventory/nagios_livestatus.py
@@ -36,11 +36,7 @@ import re
import argparse
import sys
-try:
- import configparser
-except ImportError:
- import ConfigParser
- configparser = ConfigParser
+from ansible.module_utils.six.moves import configparser
import json
try:
diff --git a/contrib/inventory/nagios_ndo.py b/contrib/inventory/nagios_ndo.py
index a4477e1e26..0f89ede659 100755
--- a/contrib/inventory/nagios_ndo.py
+++ b/contrib/inventory/nagios_ndo.py
@@ -29,11 +29,7 @@ Configuration is read from `nagios_ndo.ini`.
import os
import argparse
import sys
-try:
- import configparser
-except ImportError:
- import ConfigParser
- configparser = ConfigParser
+from ansible.module_utils.six.moves import configparser
import json
try:
diff --git a/contrib/inventory/nsot.py b/contrib/inventory/nsot.py
index cf1c1e1903..da5df40449 100755
--- a/contrib/inventory/nsot.py
+++ b/contrib/inventory/nsot.py
@@ -148,7 +148,7 @@ from pynsot.client import get_api_client
from pynsot.app import HttpServerError
from click.exceptions import UsageError
-from six import string_types
+from ansible.module_utils.six import string_types
def warning(*objs):
diff --git a/contrib/inventory/openshift.py b/contrib/inventory/openshift.py
index e6ba8ecfa2..c0aa4f1b89 100755
--- a/contrib/inventory/openshift.py
+++ b/contrib/inventory/openshift.py
@@ -32,10 +32,10 @@ import json
import os
import os.path
import sys
-import ConfigParser
import StringIO
from ansible.module_utils.urls import open_url
+from ansible.module_utils.six.moves import configparser as ConfigParser
configparser = None
diff --git a/contrib/inventory/ovirt.py b/contrib/inventory/ovirt.py
index 90729558ab..f97ab7a24a 100755
--- a/contrib/inventory/ovirt.py
+++ b/contrib/inventory/ovirt.py
@@ -68,8 +68,8 @@ USER_AGENT_VERSION = "v1"
import sys
import os
import argparse
-import ConfigParser
from collections import defaultdict
+from ansible.module_utils.six.moves import configparser as ConfigParser
import json
diff --git a/contrib/inventory/ovirt4.py b/contrib/inventory/ovirt4.py
index 71ce85582c..69c3cc3a05 100755
--- a/contrib/inventory/ovirt4.py
+++ b/contrib/inventory/ovirt4.py
@@ -65,10 +65,7 @@ import sys
from collections import defaultdict
-try:
- import ConfigParser as configparser
-except ImportError:
- import configparser
+from ansible.module_utils.six.moves import configparser
import json
diff --git a/contrib/inventory/packet_net.py b/contrib/inventory/packet_net.py
index 5368de4eb0..6672226f2b 100755
--- a/contrib/inventory/packet_net.py
+++ b/contrib/inventory/packet_net.py
@@ -43,9 +43,9 @@ import os
import argparse
import re
from time import time
-import six
-from six.moves import configparser
+from ansible.module_utils import six
+from ansible.module_utils.six.moves import configparser
try:
import packet
diff --git a/contrib/inventory/proxmox.py b/contrib/inventory/proxmox.py
index 351e55da09..0538ca8a9b 100755
--- a/contrib/inventory/proxmox.py
+++ b/contrib/inventory/proxmox.py
@@ -30,8 +30,8 @@ import os
import sys
from optparse import OptionParser
-from six import iteritems
-from six.moves.urllib.parse import urlencode
+from ansible.module_utils.six import iteritems
+from ansible.module_utils.six.moves.urllib.parse import urlencode
from ansible.module_utils.urls import open_url
diff --git a/contrib/inventory/rax.py b/contrib/inventory/rax.py
index dca3c80bf4..c6d512cd12 100755
--- a/contrib/inventory/rax.py
+++ b/contrib/inventory/rax.py
@@ -151,9 +151,9 @@ import sys
import argparse
import warnings
import collections
-import ConfigParser
-from six import iteritems
+from ansible.module_utils.six import iteritems
+from ansible.module_utils.six.moves import configparser as ConfigParser
import json
diff --git a/contrib/inventory/rudder.py b/contrib/inventory/rudder.py
index e361f22de6..4722fcf1e4 100755
--- a/contrib/inventory/rudder.py
+++ b/contrib/inventory/rudder.py
@@ -53,9 +53,9 @@ import sys
import os
import re
import argparse
-import six
import httplib2 as http
from time import time
+from ansible.module_utils import six
from ansible.module_utils.six.moves import configparser
from ansible.module_utils.six.moves.urllib.parse import urlparse
diff --git a/contrib/inventory/scaleway.py b/contrib/inventory/scaleway.py
index 756af89931..32999cc0e7 100755
--- a/contrib/inventory/scaleway.py
+++ b/contrib/inventory/scaleway.py
@@ -41,8 +41,8 @@ all: Contains all hosts defined in Scaleway.
import copy
import os
import requests
-import six
-from six.moves import configparser
+from ansible.module_utils import six
+from ansible.module_utils.six.moves import configparser
import sys
import time
import traceback
diff --git a/contrib/inventory/spacewalk.py b/contrib/inventory/spacewalk.py
index 3d6d00b8f5..e94298c308 100755
--- a/contrib/inventory/spacewalk.py
+++ b/contrib/inventory/spacewalk.py
@@ -47,10 +47,10 @@ import os
import time
from optparse import OptionParser
import subprocess
-import ConfigParser
import json
-from six import iteritems
+from ansible.module_utils.six import iteritems
+from ansible.module_utils.six.moves import configparser as ConfigParser
base_dir = os.path.dirname(os.path.realpath(__file__))
diff --git a/contrib/inventory/vmware.py b/contrib/inventory/vmware.py
index de52e713d6..483fd42318 100755
--- a/contrib/inventory/vmware.py
+++ b/contrib/inventory/vmware.py
@@ -38,10 +38,9 @@ import ssl
import sys
import time
-from six import integer_types, text_type, string_types
-from six.moves import configparser
-
from ansible.module_utils.common._collections_compat import MutableMapping
+from ansible.module_utils.six import integer_types, text_type, string_types
+from ansible.module_utils.six.moves import configparser
# Disable logging message trigged by pSphere/suds.
try:
diff --git a/contrib/inventory/vmware_inventory.py b/contrib/inventory/vmware_inventory.py
index e6472d1fb6..2f5e4a8d07 100755
--- a/contrib/inventory/vmware_inventory.py
+++ b/contrib/inventory/vmware_inventory.py
@@ -39,8 +39,9 @@ import uuid
from time import time
from jinja2 import Environment
-from six import integer_types, PY3
-from six.moves import configparser
+
+from ansible.module_utils.six import integer_types, PY3
+from ansible.module_utils.six.moves import configparser
try:
import argparse
diff --git a/contrib/inventory/zabbix.py b/contrib/inventory/zabbix.py
index 43a539a006..acdf38e704 100755
--- a/contrib/inventory/zabbix.py
+++ b/contrib/inventory/zabbix.py
@@ -38,10 +38,7 @@ from __future__ import print_function
import os
import sys
import argparse
-try:
- import ConfigParser as configparser
-except ImportError:
- import configparser
+from ansible.module_utils.six.moves import configparser
try:
from zabbix_api import ZabbixAPI
diff --git a/contrib/vault/azure_vault.py b/contrib/vault/azure_vault.py
index 8c118cc0fc..5f15b2d40e 100755
--- a/contrib/vault/azure_vault.py
+++ b/contrib/vault/azure_vault.py
@@ -122,12 +122,7 @@ import sys
import inspect
from azure.keyvault import KeyVaultClient
-try:
- # python2
- import ConfigParser as cp
-except ImportError:
- # python3
- import configparser as cp
+from ansible.module_utils.six.moves import configparser as cp
from os.path import expanduser
import ansible.module_utils.six.moves.urllib.parse as urlparse