mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-02-04 07:51:50 +00:00
Remove all usage of ansible.module_utils.six from main branch (#10888)
* Get rid of all six.moves imports. * Get rid of iteritems. * Get rid of *_type(s) aliases. * Replace StringIO import. * Get rid of PY2/PY3 constants. * Get rid of raise_from. * Get rid of python_2_unicode_compatible. * Clean up global six imports. * Remove all usage of ansible.module_utils.six. * Linting. * Fix xml module. * Docs adjustments.
This commit is contained in:
parent
8f8a0e1d7c
commit
a8977afb04
113 changed files with 188 additions and 352 deletions
2
changelogs/fragments/10888-six.yml
Normal file
2
changelogs/fragments/10888-six.yml
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
bugfixes:
|
||||||
|
- "Remove all usage of ``ansible.module_utils.six`` (https://github.com/ansible-collections/community.general/pull/10888)."
|
||||||
|
|
@ -9,9 +9,9 @@ from __future__ import annotations
|
||||||
import copy
|
import copy
|
||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
|
from urllib import error as urllib_error
|
||||||
|
from urllib.parse import urlencode
|
||||||
|
|
||||||
from ansible.module_utils.six.moves.urllib import error as urllib_error
|
|
||||||
from ansible.module_utils.six.moves.urllib.parse import urlencode
|
|
||||||
from ansible.module_utils.urls import open_url
|
from ansible.module_utils.urls import open_url
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,10 +7,9 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import csv
|
import csv
|
||||||
from io import BytesIO, StringIO
|
from io import StringIO
|
||||||
|
|
||||||
from ansible.module_utils.common.text.converters import to_native
|
from ansible.module_utils.common.text.converters import to_native
|
||||||
from ansible.module_utils.six import PY3
|
|
||||||
|
|
||||||
|
|
||||||
class CustomDialectFailureError(Exception):
|
class CustomDialectFailureError(Exception):
|
||||||
|
|
@ -58,10 +57,7 @@ def read_csv(data, dialect, fieldnames=None):
|
||||||
if data.startswith(BOM):
|
if data.startswith(BOM):
|
||||||
data = data[len(BOM):]
|
data = data[len(BOM):]
|
||||||
|
|
||||||
if PY3:
|
fake_fh = StringIO(data)
|
||||||
fake_fh = StringIO(data)
|
|
||||||
else:
|
|
||||||
fake_fh = BytesIO(data)
|
|
||||||
|
|
||||||
reader = csv.DictReader(fake_fh, fieldnames=fieldnames, dialect=dialect)
|
reader = csv.DictReader(fake_fh, fieldnames=fieldnames, dialect=dialect)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,13 +13,13 @@
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import configparser
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
# (TODO: remove AnsibleModule from next line!)
|
# (TODO: remove AnsibleModule from next line!)
|
||||||
from ansible.module_utils.basic import AnsibleModule, missing_required_lib # noqa: F401, pylint: disable=unused-import
|
from ansible.module_utils.basic import AnsibleModule, missing_required_lib # noqa: F401, pylint: disable=unused-import
|
||||||
from ansible.module_utils.six.moves import configparser
|
|
||||||
from os.path import expanduser
|
from os.path import expanduser
|
||||||
from uuid import UUID
|
from uuid import UUID
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ from __future__ import annotations
|
||||||
|
|
||||||
from ansible.module_utils.basic import missing_required_lib
|
from ansible.module_utils.basic import missing_required_lib
|
||||||
from ansible.module_utils.common.text.converters import to_native
|
from ansible.module_utils.common.text.converters import to_native
|
||||||
from ansible.module_utils.six import integer_types, string_types
|
|
||||||
|
|
||||||
from ansible_collections.community.general.plugins.module_utils.version import LooseVersion
|
from ansible_collections.community.general.plugins.module_utils.version import LooseVersion
|
||||||
|
|
||||||
|
|
@ -144,7 +143,7 @@ def vars_to_variables(vars, module):
|
||||||
# transform old vars to new variables structure
|
# transform old vars to new variables structure
|
||||||
variables = list()
|
variables = list()
|
||||||
for item, value in vars.items():
|
for item, value in vars.items():
|
||||||
if isinstance(value, (string_types, integer_types, float)):
|
if isinstance(value, (str, int, float)):
|
||||||
variables.append(
|
variables.append(
|
||||||
{
|
{
|
||||||
"name": item,
|
"name": item,
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ from __future__ import annotations
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
from ansible.module_utils.six import string_types
|
|
||||||
|
|
||||||
|
|
||||||
def _create_regex_group_complement(s):
|
def _create_regex_group_complement(s):
|
||||||
|
|
@ -70,7 +69,7 @@ class HomebrewValidate(object):
|
||||||
- os.path.sep
|
- os.path.sep
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if isinstance(path, string_types):
|
if isinstance(path, str):
|
||||||
return not cls.INVALID_PATH_REGEX.search(path)
|
return not cls.INVALID_PATH_REGEX.search(path)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
@ -98,7 +97,7 @@ class HomebrewValidate(object):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
return isinstance(
|
return isinstance(
|
||||||
brew_path, string_types
|
brew_path, str
|
||||||
) and not cls.INVALID_BREW_PATH_REGEX.search(brew_path)
|
) and not cls.INVALID_BREW_PATH_REGEX.search(brew_path)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
@ -109,7 +108,7 @@ class HomebrewValidate(object):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
return isinstance(
|
return isinstance(
|
||||||
package, string_types
|
package, str
|
||||||
) and not cls.INVALID_PACKAGE_REGEX.search(package)
|
) and not cls.INVALID_PACKAGE_REGEX.search(package)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -126,7 +125,7 @@ def parse_brew_path(module):
|
||||||
if not HomebrewValidate.valid_path(path):
|
if not HomebrewValidate.valid_path(path):
|
||||||
module.fail_json(msg="Invalid path: {0}".format(path))
|
module.fail_json(msg="Invalid path: {0}".format(path))
|
||||||
|
|
||||||
if isinstance(path, string_types):
|
if isinstance(path, str):
|
||||||
paths = path.split(":")
|
paths = path.split(":")
|
||||||
elif isinstance(path, list):
|
elif isinstance(path, list):
|
||||||
paths = path
|
paths = path
|
||||||
|
|
|
||||||
|
|
@ -8,10 +8,10 @@ from __future__ import annotations
|
||||||
import json
|
import json
|
||||||
import traceback
|
import traceback
|
||||||
import copy
|
import copy
|
||||||
|
from urllib.parse import urlencode, quote
|
||||||
|
from urllib.error import HTTPError
|
||||||
|
|
||||||
from ansible.module_utils.urls import open_url
|
from ansible.module_utils.urls import open_url
|
||||||
from ansible.module_utils.six.moves.urllib.parse import urlencode, quote
|
|
||||||
from ansible.module_utils.six.moves.urllib.error import HTTPError
|
|
||||||
from ansible.module_utils.common.text.converters import to_native, to_text
|
from ansible.module_utils.common.text.converters import to_native, to_text
|
||||||
|
|
||||||
URL_REALM_INFO = "{url}/realms/{realm}"
|
URL_REALM_INFO = "{url}/realms/{realm}"
|
||||||
|
|
|
||||||
|
|
@ -18,10 +18,9 @@ import uuid
|
||||||
|
|
||||||
import re
|
import re
|
||||||
from ansible.module_utils.common.text.converters import to_bytes, to_native, to_text
|
from ansible.module_utils.common.text.converters import to_bytes, to_native, to_text
|
||||||
from ansible.module_utils.six import PY3
|
|
||||||
from ansible.module_utils.six.moves.urllib.parse import quote
|
|
||||||
from ansible.module_utils.urls import fetch_url, HAS_GSSAPI
|
from ansible.module_utils.urls import fetch_url, HAS_GSSAPI
|
||||||
from ansible.module_utils.basic import env_fallback, AnsibleFallbackNotFound
|
from ansible.module_utils.basic import env_fallback, AnsibleFallbackNotFound
|
||||||
|
from urllib.parse import quote
|
||||||
|
|
||||||
|
|
||||||
def _env_then_dns_fallback(*args, **kwargs):
|
def _env_then_dns_fallback(*args, **kwargs):
|
||||||
|
|
@ -135,14 +134,7 @@ class IPAClient(object):
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self._fail('post %s' % method, to_native(e))
|
self._fail('post %s' % method, to_native(e))
|
||||||
|
|
||||||
if PY3:
|
charset = resp.headers.get_content_charset('latin-1')
|
||||||
charset = resp.headers.get_content_charset('latin-1')
|
|
||||||
else:
|
|
||||||
response_charset = resp.headers.getparam('charset')
|
|
||||||
if response_charset:
|
|
||||||
charset = response_charset
|
|
||||||
else:
|
|
||||||
charset = 'latin-1'
|
|
||||||
resp = json.loads(to_text(resp.read(), encoding=charset))
|
resp = json.loads(to_text(resp.read(), encoding=charset))
|
||||||
err = resp.get('error')
|
err = resp.get('error')
|
||||||
if err is not None:
|
if err is not None:
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ import os
|
||||||
import hmac
|
import hmac
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from ansible.module_utils.six.moves.urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from hashlib import sha1
|
from hashlib import sha1
|
||||||
|
|
|
||||||
|
|
@ -6,14 +6,14 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
|
||||||
|
import http.client as http_client
|
||||||
import os
|
import os
|
||||||
import socket
|
import socket
|
||||||
import ssl
|
import ssl
|
||||||
import json
|
import json
|
||||||
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
from ansible.module_utils.urls import generic_urlparse
|
from ansible.module_utils.urls import generic_urlparse
|
||||||
from ansible.module_utils.six.moves.urllib.parse import urlparse
|
|
||||||
from ansible.module_utils.six.moves import http_client
|
|
||||||
from ansible.module_utils.common.text.converters import to_text
|
from ansible.module_utils.common.text.converters import to_text
|
||||||
|
|
||||||
# httplib/http.client connection using unix domain socket
|
# httplib/http.client connection using unix domain socket
|
||||||
|
|
|
||||||
|
|
@ -11,10 +11,10 @@
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from ansible.module_utils.six.moves.urllib.parse import urlencode
|
from urllib.parse import urlencode
|
||||||
from ansible.module_utils.urls import open_url
|
from ansible.module_utils.urls import open_url
|
||||||
from ansible.module_utils.basic import json
|
from ansible.module_utils.basic import json
|
||||||
import ansible.module_utils.six.moves.urllib.error as urllib_error
|
import urllib.error as urllib_error
|
||||||
|
|
||||||
|
|
||||||
class Response(object):
|
class Response(object):
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@ import json
|
||||||
import time
|
import time
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from ansible.module_utils.six import iteritems
|
|
||||||
from ansible.module_utils.urls import open_url
|
from ansible.module_utils.urls import open_url
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -167,7 +166,7 @@ def list_pritunl_organizations(
|
||||||
else:
|
else:
|
||||||
if not any(
|
if not any(
|
||||||
filter_val != org[filter_key]
|
filter_val != org[filter_key]
|
||||||
for filter_key, filter_val in iteritems(filters)
|
for filter_key, filter_val in filters.items()
|
||||||
):
|
):
|
||||||
orgs.append(org)
|
orgs.append(org)
|
||||||
|
|
||||||
|
|
@ -198,7 +197,7 @@ def list_pritunl_users(
|
||||||
else:
|
else:
|
||||||
if not any(
|
if not any(
|
||||||
filter_val != user[filter_key]
|
filter_val != user[filter_key]
|
||||||
for filter_key, filter_val in iteritems(filters)
|
for filter_key, filter_val in filters.items()
|
||||||
):
|
):
|
||||||
users.append(user)
|
users.append(user)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,12 +8,12 @@ from __future__ import annotations
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import uuid
|
import uuid
|
||||||
|
from urllib.error import URLError, HTTPError
|
||||||
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
from ansible.module_utils.urls import open_url
|
from ansible.module_utils.urls import open_url
|
||||||
from ansible.module_utils.common.text.converters import to_native
|
from ansible.module_utils.common.text.converters import to_native
|
||||||
from ansible.module_utils.common.text.converters import to_text
|
from ansible.module_utils.common.text.converters import to_text
|
||||||
from ansible.module_utils.six.moves.urllib.error import URLError, HTTPError
|
|
||||||
from ansible.module_utils.six.moves.urllib.parse import urlparse
|
|
||||||
|
|
||||||
|
|
||||||
GET_HEADERS = {'accept': 'application/json'}
|
GET_HEADERS = {'accept': 'application/json'}
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ import abc
|
||||||
import collections
|
import collections
|
||||||
import json
|
import json
|
||||||
import traceback
|
import traceback
|
||||||
|
from collections.abc import Mapping
|
||||||
|
|
||||||
HPE_ONEVIEW_IMP_ERR = None
|
HPE_ONEVIEW_IMP_ERR = None
|
||||||
try:
|
try:
|
||||||
|
|
@ -24,10 +25,8 @@ except ImportError:
|
||||||
HPE_ONEVIEW_IMP_ERR = traceback.format_exc()
|
HPE_ONEVIEW_IMP_ERR = traceback.format_exc()
|
||||||
HAS_HPE_ONEVIEW = False
|
HAS_HPE_ONEVIEW = False
|
||||||
|
|
||||||
from ansible.module_utils import six
|
|
||||||
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
|
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
|
||||||
from ansible.module_utils.common.text.converters import to_native
|
from ansible.module_utils.common.text.converters import to_native
|
||||||
from ansible.module_utils.six.moves.collections_abc import Mapping
|
|
||||||
|
|
||||||
|
|
||||||
def transform_list_to_dict(list_):
|
def transform_list_to_dict(list_):
|
||||||
|
|
@ -128,7 +127,7 @@ class OneViewModuleException(Exception):
|
||||||
self.msg = None
|
self.msg = None
|
||||||
self.oneview_response = None
|
self.oneview_response = None
|
||||||
|
|
||||||
if isinstance(data, six.string_types):
|
if isinstance(data, str):
|
||||||
self.msg = data
|
self.msg = data
|
||||||
else:
|
else:
|
||||||
self.oneview_response = data
|
self.oneview_response = data
|
||||||
|
|
@ -178,8 +177,7 @@ class OneViewModuleResourceNotFound(OneViewModuleException):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(abc.ABCMeta)
|
class OneViewModuleBase(object, metaclass=abc.ABCMeta):
|
||||||
class OneViewModuleBase(object):
|
|
||||||
MSG_CREATED = 'Resource created successfully.'
|
MSG_CREATED = 'Resource created successfully.'
|
||||||
MSG_UPDATED = 'Resource updated successfully.'
|
MSG_UPDATED = 'Resource updated successfully.'
|
||||||
MSG_DELETED = 'Resource deleted successfully.'
|
MSG_DELETED = 'Resource deleted successfully.'
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@ from __future__ import annotations
|
||||||
import time
|
import time
|
||||||
import ssl
|
import ssl
|
||||||
from os import environ
|
from os import environ
|
||||||
from ansible.module_utils.six import string_types
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -263,7 +262,7 @@ class OpenNebulaModule:
|
||||||
self.cast_template(template[key])
|
self.cast_template(template[key])
|
||||||
elif isinstance(value, list):
|
elif isinstance(value, list):
|
||||||
template[key] = ', '.join(value)
|
template[key] = ', '.join(value)
|
||||||
elif not isinstance(value, string_types):
|
elif not isinstance(value, str):
|
||||||
template[key] = str(value)
|
template[key] = str(value)
|
||||||
|
|
||||||
def requires_template_update(self, current, desired):
|
def requires_template_update(self, current, desired):
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,6 @@ except ImportError:
|
||||||
|
|
||||||
|
|
||||||
from ansible.module_utils.common.text.converters import to_bytes
|
from ansible.module_utils.common.text.converters import to_bytes
|
||||||
from ansible.module_utils.six import iteritems
|
|
||||||
|
|
||||||
__version__ = "1.6.0-dev"
|
__version__ = "1.6.0-dev"
|
||||||
|
|
||||||
|
|
@ -820,7 +819,7 @@ def is_attr_assigned_default(default_attribute_values, attr, assigned_value):
|
||||||
# this is to ensure forward compatibility when the API returns new keys that are not known during
|
# this is to ensure forward compatibility when the API returns new keys that are not known during
|
||||||
# the time when the module author provided default values for the attribute
|
# the time when the module author provided default values for the attribute
|
||||||
keys = {}
|
keys = {}
|
||||||
for k, v in iteritems(assigned_value.items()):
|
for k, v in assigned_value.items().items():
|
||||||
if k in default_val_for_attr:
|
if k in default_val_for_attr:
|
||||||
keys[k] = v
|
keys[k] = v
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,6 @@
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from ansible.module_utils.six import raise_from
|
|
||||||
|
|
||||||
from ansible_collections.community.general.plugins.module_utils import deps
|
from ansible_collections.community.general.plugins.module_utils import deps
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -49,7 +47,7 @@ class PackageRequirement:
|
||||||
return req.name, req
|
return req.name, req
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise_from(ValueError("Invalid package specification for '{0}': {1}".format(name, e)), e)
|
raise ValueError("Invalid package specification for '{0}': {1}".format(name, e)) from e
|
||||||
|
|
||||||
def matches_version(self, version):
|
def matches_version(self, version):
|
||||||
"""
|
"""
|
||||||
|
|
@ -70,4 +68,4 @@ class PackageRequirement:
|
||||||
return ver in self.requirement.specifier
|
return ver in self.requirement.specifier
|
||||||
|
|
||||||
except InvalidVersion as e:
|
except InvalidVersion as e:
|
||||||
raise_from(ValueError("Invalid version '{0}': {1}".format(version, e)))
|
raise ValueError("Invalid version '{0}': {1}".format(version, e)) from e
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import http.client as http_client
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import random
|
import random
|
||||||
|
|
@ -13,10 +14,8 @@ from ansible.module_utils.urls import open_url
|
||||||
from ansible.module_utils.common.text.converters import to_native
|
from ansible.module_utils.common.text.converters import to_native
|
||||||
from ansible.module_utils.common.text.converters import to_text
|
from ansible.module_utils.common.text.converters import to_text
|
||||||
from ansible.module_utils.common.text.converters import to_bytes
|
from ansible.module_utils.common.text.converters import to_bytes
|
||||||
from ansible.module_utils.six import text_type
|
from urllib.error import URLError, HTTPError
|
||||||
from ansible.module_utils.six.moves import http_client
|
from urllib.parse import urlparse
|
||||||
from ansible.module_utils.six.moves.urllib.error import URLError, HTTPError
|
|
||||||
from ansible.module_utils.six.moves.urllib.parse import urlparse
|
|
||||||
|
|
||||||
GET_HEADERS = {'accept': 'application/json', 'OData-Version': '4.0'}
|
GET_HEADERS = {'accept': 'application/json', 'OData-Version': '4.0'}
|
||||||
POST_HEADERS = {'content-type': 'application/json', 'accept': 'application/json',
|
POST_HEADERS = {'content-type': 'application/json', 'accept': 'application/json',
|
||||||
|
|
@ -378,7 +377,7 @@ class RedfishUtils(object):
|
||||||
def write_buffer(body, line):
|
def write_buffer(body, line):
|
||||||
# Adds to the multipart body based on the provided data type
|
# Adds to the multipart body based on the provided data type
|
||||||
# At this time there is only support for strings, dictionaries, and bytes (default)
|
# At this time there is only support for strings, dictionaries, and bytes (default)
|
||||||
if isinstance(line, text_type):
|
if isinstance(line, str):
|
||||||
body.append(to_bytes(line, encoding='utf-8'))
|
body.append(to_bytes(line, encoding='utf-8'))
|
||||||
elif isinstance(line, dict):
|
elif isinstance(line, dict):
|
||||||
body.append(to_bytes(json.dumps(line), encoding='utf-8'))
|
body.append(to_bytes(json.dumps(line), encoding='utf-8'))
|
||||||
|
|
|
||||||
|
|
@ -29,11 +29,9 @@ from stringprep import (
|
||||||
)
|
)
|
||||||
from unicodedata import normalize
|
from unicodedata import normalize
|
||||||
|
|
||||||
from ansible.module_utils.six import text_type
|
|
||||||
|
|
||||||
|
|
||||||
def is_unicode_str(string):
|
def is_unicode_str(string):
|
||||||
return True if isinstance(string, text_type) else False
|
return True if isinstance(string, str) else False
|
||||||
|
|
||||||
|
|
||||||
def mapping_profile(string):
|
def mapping_profile(string):
|
||||||
|
|
@ -156,9 +154,8 @@ def saslprep(string):
|
||||||
# RFC4013: "The algorithm assumes all strings are
|
# RFC4013: "The algorithm assumes all strings are
|
||||||
# comprised of characters from the Unicode [Unicode] character set."
|
# comprised of characters from the Unicode [Unicode] character set."
|
||||||
# Validate the string is a Unicode string
|
# Validate the string is a Unicode string
|
||||||
# (text_type is the string type if PY3 and unicode otherwise):
|
|
||||||
if not is_unicode_str(string):
|
if not is_unicode_str(string):
|
||||||
raise TypeError('input must be of type %s, not %s' % (text_type, type(string)))
|
raise TypeError('input must be of type str, not %s' % type(string))
|
||||||
|
|
||||||
# RFC4013: 2.1. Mapping.
|
# RFC4013: 2.1. Mapping.
|
||||||
string = mapping_profile(string)
|
string = mapping_profile(string)
|
||||||
|
|
|
||||||
|
|
@ -10,10 +10,10 @@ import sys
|
||||||
import datetime
|
import datetime
|
||||||
import time
|
import time
|
||||||
import traceback
|
import traceback
|
||||||
|
from urllib.parse import urlencode
|
||||||
|
|
||||||
from ansible.module_utils.basic import env_fallback, missing_required_lib
|
from ansible.module_utils.basic import env_fallback, missing_required_lib
|
||||||
from ansible.module_utils.urls import fetch_url
|
from ansible.module_utils.urls import fetch_url
|
||||||
from ansible.module_utils.six.moves.urllib.parse import urlencode
|
|
||||||
|
|
||||||
from ansible_collections.community.general.plugins.module_utils.datetime import (
|
from ansible_collections.community.general.plugins.module_utils.datetime import (
|
||||||
now,
|
now,
|
||||||
|
|
|
||||||
|
|
@ -10,12 +10,11 @@ import re
|
||||||
import time
|
import time
|
||||||
import tarfile
|
import tarfile
|
||||||
import os
|
import os
|
||||||
|
from urllib.parse import urlparse, urlunparse
|
||||||
|
|
||||||
from ansible.module_utils.urls import fetch_file
|
from ansible.module_utils.urls import fetch_file
|
||||||
from ansible_collections.community.general.plugins.module_utils.redfish_utils import RedfishUtils
|
from ansible_collections.community.general.plugins.module_utils.redfish_utils import RedfishUtils
|
||||||
|
|
||||||
from ansible.module_utils.six.moves.urllib.parse import urlparse, urlunparse
|
|
||||||
|
|
||||||
|
|
||||||
class WdcRedfishUtils(RedfishUtils):
|
class WdcRedfishUtils(RedfishUtils):
|
||||||
"""Extension to RedfishUtils to support WDC enclosures."""
|
"""Extension to RedfishUtils to support WDC enclosures."""
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ description:
|
||||||
extends_documentation_fragment:
|
extends_documentation_fragment:
|
||||||
- community.general.attributes
|
- community.general.attributes
|
||||||
requirements:
|
requirements:
|
||||||
- Python package C(BeautifulSoup) on Python 2, C(beautifulsoup4) on Python 3.
|
- Python package C(beautifulsoup4)
|
||||||
attributes:
|
attributes:
|
||||||
check_mode:
|
check_mode:
|
||||||
support: full
|
support: full
|
||||||
|
|
@ -213,14 +213,9 @@ from ansible_collections.community.general.plugins.module_utils.module_helper im
|
||||||
|
|
||||||
from ansible.module_utils.common.text.converters import to_text
|
from ansible.module_utils.common.text.converters import to_text
|
||||||
from ansible.module_utils.urls import fetch_url
|
from ansible.module_utils.urls import fetch_url
|
||||||
from ansible.module_utils.six import raise_from, PY2
|
|
||||||
|
|
||||||
if PY2:
|
with deps.declare("beautifulsoup4"):
|
||||||
with deps.declare("BeautifulSoup"):
|
from bs4 import BeautifulSoup
|
||||||
from BeautifulSoup import BeautifulSoup
|
|
||||||
else:
|
|
||||||
with deps.declare("beautifulsoup4"):
|
|
||||||
from bs4 import BeautifulSoup
|
|
||||||
|
|
||||||
# balancer member attributes extraction regexp:
|
# balancer member attributes extraction regexp:
|
||||||
EXPRESSION = re.compile(to_text(r"(b=([\w\.\-]+)&w=(https?|ajp|wss?|ftp|[sf]cgi)://([\w\.\-]+):?(\d*)([/\w\.\-]*)&?[\w\-\=]*)"))
|
EXPRESSION = re.compile(to_text(r"(b=([\w\.\-]+)&w=(https?|ajp|wss?|ftp|[sf]cgi)://([\w\.\-]+):?(\d*)([/\w\.\-]*)&?[\w\-\=]*)"))
|
||||||
|
|
@ -229,8 +224,6 @@ APACHE_VERSION_EXPRESSION = re.compile(to_text(r"SERVER VERSION: APACHE/([\d.]+)
|
||||||
|
|
||||||
|
|
||||||
def find_all(where, what):
|
def find_all(where, what):
|
||||||
if PY2:
|
|
||||||
return where.findAll(what)
|
|
||||||
return where.find_all(what)
|
return where.find_all(what)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -279,7 +272,7 @@ class BalancerMember(object):
|
||||||
try:
|
try:
|
||||||
soup = BeautifulSoup(resp)
|
soup = BeautifulSoup(resp)
|
||||||
except TypeError as exc:
|
except TypeError as exc:
|
||||||
raise_from(ModuleHelperException("Cannot parse balancer_member_page HTML! {0}".format(exc)), exc)
|
raise ModuleHelperException("Cannot parse balancer_member_page HTML! {0}".format(exc)) from exc
|
||||||
|
|
||||||
subsoup = find_all(find_all(soup, 'table')[1], 'tr')
|
subsoup = find_all(find_all(soup, 'table')[1], 'tr')
|
||||||
keys = find_all(subsoup[0], 'th')
|
keys = find_all(subsoup[0], 'th')
|
||||||
|
|
@ -359,7 +352,7 @@ class Balancer(object):
|
||||||
try:
|
try:
|
||||||
soup = BeautifulSoup(self.page)
|
soup = BeautifulSoup(self.page)
|
||||||
except TypeError as e:
|
except TypeError as e:
|
||||||
raise_from(ModuleHelperException("Cannot parse balancer page HTML! {0}".format(self.page)), e)
|
raise ModuleHelperException("Cannot parse balancer page HTML! {0}".format(self.page)) from e
|
||||||
|
|
||||||
elements = find_all(soup, 'a')
|
elements = find_all(soup, 'a')
|
||||||
for element in elements[1::1]:
|
for element in elements[1::1]:
|
||||||
|
|
|
||||||
|
|
@ -72,11 +72,8 @@ options:
|
||||||
default: false
|
default: false
|
||||||
notes:
|
notes:
|
||||||
- Can produce C(gzip), C(bzip2), C(lzma), and C(zip) compressed files or archives.
|
- Can produce C(gzip), C(bzip2), C(lzma), and C(zip) compressed files or archives.
|
||||||
- This module uses C(tarfile), C(zipfile), C(gzip), and C(bz2) packages on the target host to create archives. These are
|
- This module uses C(tarfile), C(zipfile), C(gzip), C(bz2), and C(lzma) packages on the target host to create archives. These are
|
||||||
part of the Python standard library for Python 2 and 3.
|
part of the Python standard library.
|
||||||
requirements:
|
|
||||||
- Requires C(lzma) (standard library of Python 3) or L(backports.lzma, https://pypi.org/project/backports.lzma/) (Python
|
|
||||||
2) if using C(xz) format.
|
|
||||||
seealso:
|
seealso:
|
||||||
- module: ansible.builtin.unarchive
|
- module: ansible.builtin.unarchive
|
||||||
author:
|
author:
|
||||||
|
|
@ -188,13 +185,11 @@ import shutil
|
||||||
import tarfile
|
import tarfile
|
||||||
import zipfile
|
import zipfile
|
||||||
from fnmatch import fnmatch
|
from fnmatch import fnmatch
|
||||||
from sys import version_info
|
|
||||||
from traceback import format_exc
|
from traceback import format_exc
|
||||||
from zlib import crc32
|
from zlib import crc32
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
|
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
|
||||||
from ansible.module_utils.common.text.converters import to_bytes, to_native
|
from ansible.module_utils.common.text.converters import to_bytes, to_native
|
||||||
from ansible.module_utils import six
|
|
||||||
|
|
||||||
try: # python 3.2+
|
try: # python 3.2+
|
||||||
from zipfile import BadZipFile # type: ignore[attr-defined]
|
from zipfile import BadZipFile # type: ignore[attr-defined]
|
||||||
|
|
@ -202,22 +197,12 @@ except ImportError: # older python
|
||||||
from zipfile import BadZipfile as BadZipFile
|
from zipfile import BadZipfile as BadZipFile
|
||||||
|
|
||||||
LZMA_IMP_ERR = None
|
LZMA_IMP_ERR = None
|
||||||
if six.PY3:
|
try:
|
||||||
try:
|
import lzma
|
||||||
import lzma
|
HAS_LZMA = True
|
||||||
HAS_LZMA = True
|
except ImportError:
|
||||||
except ImportError:
|
LZMA_IMP_ERR = format_exc()
|
||||||
LZMA_IMP_ERR = format_exc()
|
HAS_LZMA = False
|
||||||
HAS_LZMA = False
|
|
||||||
else:
|
|
||||||
try:
|
|
||||||
from backports import lzma
|
|
||||||
HAS_LZMA = True
|
|
||||||
except ImportError:
|
|
||||||
LZMA_IMP_ERR = format_exc()
|
|
||||||
HAS_LZMA = False
|
|
||||||
|
|
||||||
PY27 = version_info[0:2] >= (2, 7)
|
|
||||||
|
|
||||||
STATE_ABSENT = 'absent'
|
STATE_ABSENT = 'absent'
|
||||||
STATE_ARCHIVED = 'archive'
|
STATE_ARCHIVED = 'archive'
|
||||||
|
|
@ -226,7 +211,7 @@ STATE_INCOMPLETE = 'incomplete'
|
||||||
|
|
||||||
|
|
||||||
def common_path(paths):
|
def common_path(paths):
|
||||||
empty = b'' if paths and isinstance(paths[0], six.binary_type) else ''
|
empty = b'' if paths and isinstance(paths[0], bytes) else ''
|
||||||
|
|
||||||
return os.path.join(
|
return os.path.join(
|
||||||
os.path.dirname(os.path.commonprefix([os.path.join(os.path.dirname(p), empty) for p in paths])), empty
|
os.path.dirname(os.path.commonprefix([os.path.join(os.path.dirname(p), empty) for p in paths])), empty
|
||||||
|
|
@ -271,8 +256,7 @@ def _to_native_ascii(s):
|
||||||
return to_native(s, errors='surrogate_or_strict', encoding='ascii')
|
return to_native(s, errors='surrogate_or_strict', encoding='ascii')
|
||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(abc.ABCMeta)
|
class Archive(object, metaclass=abc.ABCMeta):
|
||||||
class Archive(object):
|
|
||||||
def __init__(self, module):
|
def __init__(self, module):
|
||||||
self.module = module
|
self.module = module
|
||||||
|
|
||||||
|
|
@ -574,16 +558,10 @@ class TarArchive(Archive):
|
||||||
self.module.fail_json(msg="%s is not a valid archive format" % self.format)
|
self.module.fail_json(msg="%s is not a valid archive format" % self.format)
|
||||||
|
|
||||||
def _add(self, path, archive_name):
|
def _add(self, path, archive_name):
|
||||||
def py27_filter(tarinfo):
|
def filter(tarinfo):
|
||||||
return None if matches_exclusion_patterns(tarinfo.name, self.exclusion_patterns) else tarinfo
|
return None if matches_exclusion_patterns(tarinfo.name, self.exclusion_patterns) else tarinfo
|
||||||
|
|
||||||
def py26_filter(path):
|
self.file.add(path, archive_name, recursive=False, filter=filter)
|
||||||
return matches_exclusion_patterns(path, self.exclusion_patterns)
|
|
||||||
|
|
||||||
if PY27:
|
|
||||||
self.file.add(path, archive_name, recursive=False, filter=py27_filter)
|
|
||||||
else:
|
|
||||||
self.file.add(path, archive_name, recursive=False, exclude=py26_filter)
|
|
||||||
|
|
||||||
def _get_checksums(self, path):
|
def _get_checksums(self, path):
|
||||||
if HAS_LZMA:
|
if HAS_LZMA:
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ description:
|
||||||
- Create an annotation event with a given category, title and description. Optionally start, end or durations can be provided.
|
- Create an annotation event with a given category, title and description. Optionally start, end or durations can be provided.
|
||||||
author: "Nick Harring (@NickatEpic)"
|
author: "Nick Harring (@NickatEpic)"
|
||||||
requirements:
|
requirements:
|
||||||
- requests (either >= 2.0.0 for Python 3, or >= 1.0.0 for Python 2)
|
- requests >= 2.0.0
|
||||||
extends_documentation_fragment:
|
extends_documentation_fragment:
|
||||||
- community.general.attributes
|
- community.general.attributes
|
||||||
attributes:
|
attributes:
|
||||||
|
|
@ -159,7 +159,6 @@ except ImportError:
|
||||||
HAS_REQUESTS = False
|
HAS_REQUESTS = False
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
|
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
|
||||||
from ansible.module_utils.six import PY3
|
|
||||||
from ansible.module_utils.common.text.converters import to_native
|
from ansible.module_utils.common.text.converters import to_native
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -168,7 +167,7 @@ def check_requests_dep(module):
|
||||||
if not HAS_REQUESTS:
|
if not HAS_REQUESTS:
|
||||||
module.fail_json(msg=missing_required_lib('requests'), exception=REQUESTS_IMP_ERR)
|
module.fail_json(msg=missing_required_lib('requests'), exception=REQUESTS_IMP_ERR)
|
||||||
else:
|
else:
|
||||||
required_version = '2.0.0' if PY3 else '1.0.0'
|
required_version = '2.0.0'
|
||||||
if LooseVersion(requests.__version__) < LooseVersion(required_version):
|
if LooseVersion(requests.__version__) < LooseVersion(required_version):
|
||||||
module.fail_json(msg="'requests' library version should be >= %s, found: %s." % (required_version, requests.__version__))
|
module.fail_json(msg="'requests' library version should be >= %s, found: %s." % (required_version, requests.__version__))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -438,9 +438,9 @@ record:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
from urllib.parse import urlencode
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule, env_fallback
|
from ansible.module_utils.basic import AnsibleModule, env_fallback
|
||||||
from ansible.module_utils.six.moves.urllib.parse import urlencode
|
|
||||||
from ansible.module_utils.common.text.converters import to_native, to_text
|
from ansible.module_utils.common.text.converters import to_native, to_text
|
||||||
from ansible.module_utils.urls import fetch_url
|
from ansible.module_utils.urls import fetch_url
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -71,9 +71,9 @@ RETURN = r"""
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import ssl
|
import ssl
|
||||||
|
import xmlrpc.client as xmlrpc_client
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.six.moves import xmlrpc_client
|
|
||||||
from ansible.module_utils.common.text.converters import to_text
|
from ansible.module_utils.common.text.converters import to_text
|
||||||
|
|
||||||
from ansible_collections.community.general.plugins.module_utils.datetime import (
|
from ansible_collections.community.general.plugins.module_utils.datetime import (
|
||||||
|
|
|
||||||
|
|
@ -148,10 +148,9 @@ system:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import ssl
|
import ssl
|
||||||
|
import xmlrpc.client as xmlrpc_client
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.six import iteritems
|
|
||||||
from ansible.module_utils.six.moves import xmlrpc_client
|
|
||||||
from ansible.module_utils.common.text.converters import to_text
|
from ansible.module_utils.common.text.converters import to_text
|
||||||
|
|
||||||
from ansible_collections.community.general.plugins.module_utils.datetime import (
|
from ansible_collections.community.general.plugins.module_utils.datetime import (
|
||||||
|
|
@ -281,7 +280,7 @@ def main():
|
||||||
else:
|
else:
|
||||||
system_id = conn.get_system_handle(name, token)
|
system_id = conn.get_system_handle(name, token)
|
||||||
|
|
||||||
for key, value in iteritems(module.params['properties']):
|
for key, value in module.params['properties'].items():
|
||||||
if key not in system:
|
if key not in system:
|
||||||
module.warn("Property '{0}' is not a valid system property.".format(key))
|
module.warn("Property '{0}' is not a valid system property.".format(key))
|
||||||
if system[key] != value:
|
if system[key] != value:
|
||||||
|
|
@ -298,7 +297,7 @@ def main():
|
||||||
result['changed'] = True
|
result['changed'] = True
|
||||||
|
|
||||||
if module.params['properties']:
|
if module.params['properties']:
|
||||||
for key, value in iteritems(module.params['properties']):
|
for key, value in module.params['properties'].items():
|
||||||
try:
|
try:
|
||||||
conn.modify_system(system_id, key, value, token)
|
conn.modify_system(system_id, key, value, token)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
@ -307,8 +306,8 @@ def main():
|
||||||
# Add interface properties
|
# Add interface properties
|
||||||
interface_properties = dict()
|
interface_properties = dict()
|
||||||
if module.params['interfaces']:
|
if module.params['interfaces']:
|
||||||
for device, values in iteritems(module.params['interfaces']):
|
for device, values in module.params['interfaces'].items():
|
||||||
for key, value in iteritems(values):
|
for key, value in values.items():
|
||||||
if key == 'name':
|
if key == 'name':
|
||||||
continue
|
continue
|
||||||
if key not in IFPROPS_MAPPING:
|
if key not in IFPROPS_MAPPING:
|
||||||
|
|
|
||||||
|
|
@ -101,6 +101,7 @@ repo:
|
||||||
import stat
|
import stat
|
||||||
import os
|
import os
|
||||||
import traceback
|
import traceback
|
||||||
|
from urllib.error import HTTPError
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import dnf
|
import dnf
|
||||||
|
|
@ -114,7 +115,6 @@ except ImportError:
|
||||||
HAS_DNF_PACKAGES = False
|
HAS_DNF_PACKAGES = False
|
||||||
|
|
||||||
from ansible.module_utils.common import respawn
|
from ansible.module_utils.common import respawn
|
||||||
from ansible.module_utils.six.moves.urllib.error import HTTPError
|
|
||||||
from ansible.module_utils.basic import missing_required_lib
|
from ansible.module_utils.basic import missing_required_lib
|
||||||
from ansible.module_utils import distro
|
from ansible.module_utils import distro
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
|
|
|
||||||
|
|
@ -103,9 +103,9 @@ import re
|
||||||
import shlex
|
import shlex
|
||||||
import sys
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
|
from shlex import quote as shlex_quote
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.six.moves import shlex_quote
|
|
||||||
|
|
||||||
|
|
||||||
class CronVarError(Exception):
|
class CronVarError(Exception):
|
||||||
|
|
|
||||||
|
|
@ -50,8 +50,7 @@ options:
|
||||||
type: bool
|
type: bool
|
||||||
default: false
|
default: false
|
||||||
requirements:
|
requirements:
|
||||||
- Requires C(lzma) (standard library of Python 3) or L(backports.lzma, https://pypi.org/project/backports.lzma/) (Python
|
- Requires C(lzma) (standard library of Python 3) if using C(xz) format.
|
||||||
2) if using C(xz) format.
|
|
||||||
author:
|
author:
|
||||||
- Stanislav Shamilov (@shamilovstas)
|
- Stanislav Shamilov (@shamilovstas)
|
||||||
"""
|
"""
|
||||||
|
|
@ -94,16 +93,12 @@ import os
|
||||||
import shutil
|
import shutil
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
from ansible.module_utils import six
|
|
||||||
from ansible_collections.community.general.plugins.module_utils.mh.module_helper import ModuleHelper
|
from ansible_collections.community.general.plugins.module_utils.mh.module_helper import ModuleHelper
|
||||||
from ansible.module_utils.common.text.converters import to_native, to_bytes
|
from ansible.module_utils.common.text.converters import to_native, to_bytes
|
||||||
from ansible_collections.community.general.plugins.module_utils import deps
|
from ansible_collections.community.general.plugins.module_utils import deps
|
||||||
|
|
||||||
with deps.declare("lzma"):
|
with deps.declare("lzma"):
|
||||||
if six.PY3:
|
import lzma
|
||||||
import lzma
|
|
||||||
else:
|
|
||||||
from backports import lzma
|
|
||||||
|
|
||||||
|
|
||||||
def lzma_decompress(src):
|
def lzma_decompress(src):
|
||||||
|
|
@ -111,10 +106,7 @@ def lzma_decompress(src):
|
||||||
|
|
||||||
|
|
||||||
def bz2_decompress(src):
|
def bz2_decompress(src):
|
||||||
if six.PY3:
|
return bz2.open(src, "rb")
|
||||||
return bz2.open(src, "rb")
|
|
||||||
else:
|
|
||||||
return bz2.BZ2File(src, "rb")
|
|
||||||
|
|
||||||
|
|
||||||
def gzip_decompress(src):
|
def gzip_decompress(src):
|
||||||
|
|
|
||||||
|
|
@ -361,11 +361,10 @@ import hashlib
|
||||||
import hmac
|
import hmac
|
||||||
import locale
|
import locale
|
||||||
from time import strftime, gmtime
|
from time import strftime, gmtime
|
||||||
|
from urllib.parse import urlencode
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.urls import fetch_url
|
from ansible.module_utils.urls import fetch_url
|
||||||
from ansible.module_utils.six.moves.urllib.parse import urlencode
|
|
||||||
from ansible.module_utils.six import string_types
|
|
||||||
|
|
||||||
|
|
||||||
class DME2(object):
|
class DME2(object):
|
||||||
|
|
@ -415,7 +414,7 @@ class DME2(object):
|
||||||
|
|
||||||
def query(self, resource, method, data=None):
|
def query(self, resource, method, data=None):
|
||||||
url = self.baseurl + resource
|
url = self.baseurl + resource
|
||||||
if data and not isinstance(data, string_types):
|
if data and not isinstance(data, str):
|
||||||
data = urlencode(data)
|
data = urlencode(data)
|
||||||
|
|
||||||
response, info = fetch_url(self.module, url, data=data, method=method, headers=self._headers())
|
response, info = fetch_url(self.module, url, data=data, method=method, headers=self._headers())
|
||||||
|
|
|
||||||
|
|
@ -171,7 +171,8 @@ command:
|
||||||
sample: "/usr/bin/flatpak install --user --nontinteractive flathub org.gnome.Calculator"
|
sample: "/usr/bin/flatpak install --user --nontinteractive flathub org.gnome.Calculator"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from ansible.module_utils.six.moves.urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
|
|
||||||
from ansible_collections.community.general.plugins.module_utils.version import LooseVersion
|
from ansible_collections.community.general.plugins.module_utils.version import LooseVersion
|
||||||
|
|
|
||||||
|
|
@ -64,8 +64,9 @@ EXAMPLES = r"""
|
||||||
message: 'deployed {{ target }}'
|
message: 'deployed {{ target }}'
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from urllib.parse import urlencode
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.six.moves.urllib.parse import urlencode
|
|
||||||
from ansible.module_utils.urls import fetch_url
|
from ansible.module_utils.urls import fetch_url
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -181,7 +181,6 @@ import re
|
||||||
from ansible_collections.community.general.plugins.module_utils.homebrew import HomebrewValidate
|
from ansible_collections.community.general.plugins.module_utils.homebrew import HomebrewValidate
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.six import iteritems, string_types
|
|
||||||
|
|
||||||
|
|
||||||
# exceptions -------------------------------------------------------------- {{{
|
# exceptions -------------------------------------------------------------- {{{
|
||||||
|
|
@ -224,7 +223,7 @@ class Homebrew(object):
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return (
|
return (
|
||||||
isinstance(state, string_types)
|
isinstance(state, str)
|
||||||
and state.lower() in (
|
and state.lower() in (
|
||||||
'installed',
|
'installed',
|
||||||
'upgraded',
|
'upgraded',
|
||||||
|
|
@ -273,7 +272,7 @@ class Homebrew(object):
|
||||||
raise HomebrewException(self.message)
|
raise HomebrewException(self.message)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
if isinstance(path, string_types):
|
if isinstance(path, str):
|
||||||
self._path = path.split(':')
|
self._path = path.split(':')
|
||||||
else:
|
else:
|
||||||
self._path = path
|
self._path = path
|
||||||
|
|
@ -336,7 +335,7 @@ class Homebrew(object):
|
||||||
def _setup_instance_vars(self, **kwargs):
|
def _setup_instance_vars(self, **kwargs):
|
||||||
self.installed_packages = set()
|
self.installed_packages = set()
|
||||||
self.outdated_packages = set()
|
self.outdated_packages = set()
|
||||||
for key, val in iteritems(kwargs):
|
for key, val in kwargs.items():
|
||||||
setattr(self, key, val)
|
setattr(self, key, val)
|
||||||
|
|
||||||
def _prep(self):
|
def _prep(self):
|
||||||
|
|
@ -507,7 +506,7 @@ class Homebrew(object):
|
||||||
'update',
|
'update',
|
||||||
])
|
])
|
||||||
if rc == 0:
|
if rc == 0:
|
||||||
if out and isinstance(out, string_types):
|
if out and isinstance(out, str):
|
||||||
already_updated = any(
|
already_updated = any(
|
||||||
re.search(r'Already up-to-date.', s.strip(), re.IGNORECASE)
|
re.search(r'Already up-to-date.', s.strip(), re.IGNORECASE)
|
||||||
for s in out.split('\n')
|
for s in out.split('\n')
|
||||||
|
|
|
||||||
|
|
@ -158,7 +158,6 @@ from ansible_collections.community.general.plugins.module_utils.homebrew import
|
||||||
|
|
||||||
from ansible.module_utils.common.text.converters import to_bytes
|
from ansible.module_utils.common.text.converters import to_bytes
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.six import iteritems, string_types
|
|
||||||
|
|
||||||
|
|
||||||
# exceptions -------------------------------------------------------------- {{{
|
# exceptions -------------------------------------------------------------- {{{
|
||||||
|
|
@ -201,7 +200,7 @@ class HomebrewCask(object):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
return (
|
return (
|
||||||
isinstance(cask, string_types)
|
isinstance(cask, str)
|
||||||
and not cls.INVALID_CASK_REGEX.search(cask)
|
and not cls.INVALID_CASK_REGEX.search(cask)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -217,7 +216,7 @@ class HomebrewCask(object):
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return (
|
return (
|
||||||
isinstance(state, string_types)
|
isinstance(state, str)
|
||||||
and state.lower() in (
|
and state.lower() in (
|
||||||
'installed',
|
'installed',
|
||||||
'absent',
|
'absent',
|
||||||
|
|
@ -261,7 +260,7 @@ class HomebrewCask(object):
|
||||||
raise HomebrewCaskException(self.message)
|
raise HomebrewCaskException(self.message)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
if isinstance(path, string_types):
|
if isinstance(path, str):
|
||||||
self._path = path.split(':')
|
self._path = path.split(':')
|
||||||
else:
|
else:
|
||||||
self._path = path
|
self._path = path
|
||||||
|
|
@ -348,7 +347,7 @@ class HomebrewCask(object):
|
||||||
self.message = ''
|
self.message = ''
|
||||||
|
|
||||||
def _setup_instance_vars(self, **kwargs):
|
def _setup_instance_vars(self, **kwargs):
|
||||||
for key, val in iteritems(kwargs):
|
for key, val in kwargs.items():
|
||||||
setattr(self, key, val)
|
setattr(self, key, val)
|
||||||
|
|
||||||
def _prep(self):
|
def _prep(self):
|
||||||
|
|
@ -488,7 +487,7 @@ class HomebrewCask(object):
|
||||||
'update',
|
'update',
|
||||||
])
|
])
|
||||||
if rc == 0:
|
if rc == 0:
|
||||||
if out and isinstance(out, string_types):
|
if out and isinstance(out, str):
|
||||||
already_updated = any(
|
already_updated = any(
|
||||||
re.search(r'Already up-to-date.', s.strip(), re.IGNORECASE)
|
re.search(r'Already up-to-date.', s.strip(), re.IGNORECASE)
|
||||||
for s in out.split('\n')
|
for s in out.split('\n')
|
||||||
|
|
|
||||||
|
|
@ -68,9 +68,9 @@ EXAMPLES = r"""
|
||||||
RETURN = """#"""
|
RETURN = """#"""
|
||||||
|
|
||||||
import traceback
|
import traceback
|
||||||
|
from urllib.parse import urlencode
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.six.moves.urllib.parse import urlencode
|
|
||||||
from ansible.module_utils.common.text.converters import to_native
|
from ansible.module_utils.common.text.converters import to_native
|
||||||
from ansible.module_utils.urls import fetch_url
|
from ansible.module_utils.urls import fetch_url
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -266,6 +266,7 @@ output:
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import traceback
|
import traceback
|
||||||
|
from itertools import zip_longest
|
||||||
|
|
||||||
LXML_ETREE_IMP_ERR = None
|
LXML_ETREE_IMP_ERR = None
|
||||||
try:
|
try:
|
||||||
|
|
@ -284,7 +285,6 @@ except ImportError:
|
||||||
HAS_XMLJSON_COBRA = False
|
HAS_XMLJSON_COBRA = False
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
|
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
|
||||||
from ansible.module_utils.six.moves import zip_longest
|
|
||||||
from ansible.module_utils.urls import fetch_url
|
from ansible.module_utils.urls import fetch_url
|
||||||
|
|
||||||
from ansible_collections.community.general.plugins.module_utils.datetime import (
|
from ansible_collections.community.general.plugins.module_utils.datetime import (
|
||||||
|
|
|
||||||
|
|
@ -214,10 +214,8 @@ data:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
|
|
||||||
from ansible.module_utils.urls import fetch_url
|
from ansible.module_utils.urls import fetch_url
|
||||||
|
from urllib.parse import urlencode
|
||||||
from ansible.module_utils.six.moves.urllib.parse import urlencode
|
|
||||||
|
|
||||||
|
|
||||||
USER_AGENT = 'ansible-community.general.ipbase_info/0.1.0'
|
USER_AGENT = 'ansible-community.general.ipbase_info/0.1.0'
|
||||||
|
|
|
||||||
|
|
@ -205,12 +205,11 @@ cmd:
|
||||||
import os
|
import os
|
||||||
import tempfile
|
import tempfile
|
||||||
import re
|
import re
|
||||||
|
from urllib.parse import urlparse
|
||||||
|
from urllib.request import getproxies
|
||||||
|
|
||||||
# import module snippets
|
# import module snippets
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.six.moves.urllib.parse import urlparse
|
|
||||||
from ansible.module_utils.six.moves.urllib.request import getproxies
|
|
||||||
|
|
||||||
|
|
||||||
def _get_keystore_type_keytool_parameters(keystore_type):
|
def _get_keystore_type_keytool_parameters(keystore_type):
|
||||||
|
|
|
||||||
|
|
@ -182,7 +182,6 @@ import os
|
||||||
import re
|
import re
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
from ansible.module_utils.six import PY2
|
|
||||||
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
|
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
|
||||||
from ansible.module_utils.common.text.converters import to_bytes, to_native
|
from ansible.module_utils.common.text.converters import to_bytes, to_native
|
||||||
|
|
||||||
|
|
@ -509,8 +508,6 @@ def create_file(content):
|
||||||
|
|
||||||
|
|
||||||
def hex_decode(s):
|
def hex_decode(s):
|
||||||
if PY2:
|
|
||||||
return s.decode('hex')
|
|
||||||
return s.hex()
|
return s.hex()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -317,9 +317,9 @@ token_uuid:
|
||||||
returned: success
|
returned: success
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from urllib.parse import urlencode
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.urls import fetch_url, basic_auth_header
|
from ansible.module_utils.urls import fetch_url, basic_auth_header
|
||||||
from ansible.module_utils.six.moves.urllib.parse import urlencode
|
|
||||||
from ansible_collections.community.general.plugins.module_utils import deps
|
from ansible_collections.community.general.plugins.module_utils import deps
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
|
|
||||||
|
|
@ -338,12 +338,11 @@ import os
|
||||||
import tempfile
|
import tempfile
|
||||||
import time
|
import time
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
from http import cookiejar
|
||||||
|
from urllib.parse import urlencode
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule, to_bytes
|
from ansible.module_utils.basic import AnsibleModule, to_bytes
|
||||||
from ansible.module_utils.six.moves import http_cookiejar as cookiejar
|
|
||||||
from ansible.module_utils.six.moves.urllib.parse import urlencode
|
|
||||||
from ansible.module_utils.urls import fetch_url, url_argument_spec, basic_auth_header
|
from ansible.module_utils.urls import fetch_url, url_argument_spec, basic_auth_header
|
||||||
from ansible.module_utils.six import text_type, binary_type
|
|
||||||
from ansible.module_utils.common.text.converters import to_native
|
from ansible.module_utils.common.text.converters import to_native
|
||||||
|
|
||||||
from ansible_collections.community.general.plugins.module_utils.jenkins import download_updates_file
|
from ansible_collections.community.general.plugins.module_utils.jenkins import download_updates_file
|
||||||
|
|
@ -835,7 +834,7 @@ class JenkinsPlugin(object):
|
||||||
# Store the plugin into a temp file and then move it
|
# Store the plugin into a temp file and then move it
|
||||||
tmp_f_fd, tmp_f = tempfile.mkstemp()
|
tmp_f_fd, tmp_f = tempfile.mkstemp()
|
||||||
|
|
||||||
if isinstance(data, (text_type, binary_type)):
|
if isinstance(data, (str, bytes)):
|
||||||
os.write(tmp_f_fd, data)
|
os.write(tmp_f_fd, data)
|
||||||
else:
|
else:
|
||||||
os.write(tmp_f_fd, data.read())
|
os.write(tmp_f_fd, data.read())
|
||||||
|
|
|
||||||
|
|
@ -102,10 +102,10 @@ output:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
from http import cookiejar
|
||||||
|
from urllib.parse import urlencode
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.six.moves import http_cookiejar as cookiejar
|
|
||||||
from ansible.module_utils.six.moves.urllib.parse import urlencode
|
|
||||||
from ansible.module_utils.urls import fetch_url
|
from ansible.module_utils.urls import fetch_url
|
||||||
from ansible.module_utils.common.text.converters import to_native
|
from ansible.module_utils.common.text.converters import to_native
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -482,9 +482,9 @@ import os
|
||||||
import random
|
import random
|
||||||
import string
|
import string
|
||||||
import traceback
|
import traceback
|
||||||
|
from urllib.request import pathname2url
|
||||||
|
|
||||||
from ansible_collections.community.general.plugins.module_utils.module_helper import StateModuleHelper, cause_changes
|
from ansible_collections.community.general.plugins.module_utils.module_helper import StateModuleHelper, cause_changes
|
||||||
from ansible.module_utils.six.moves.urllib.request import pathname2url
|
|
||||||
from ansible.module_utils.common.text.converters import to_text, to_bytes, to_native
|
from ansible.module_utils.common.text.converters import to_text, to_bytes, to_native
|
||||||
from ansible.module_utils.urls import fetch_url
|
from ansible.module_utils.urls import fetch_url
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -131,7 +131,7 @@ end_state:
|
||||||
from ansible_collections.community.general.plugins.module_utils.identity.keycloak.keycloak import KeycloakAPI, camel, \
|
from ansible_collections.community.general.plugins.module_utils.identity.keycloak.keycloak import KeycloakAPI, camel, \
|
||||||
keycloak_argument_spec, get_token, KeycloakError
|
keycloak_argument_spec, get_token, KeycloakError
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.six.moves.urllib.parse import urlencode
|
from urllib.parse import urlencode
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -102,7 +102,7 @@ components:
|
||||||
from ansible_collections.community.general.plugins.module_utils.identity.keycloak.keycloak import KeycloakAPI, \
|
from ansible_collections.community.general.plugins.module_utils.identity.keycloak.keycloak import KeycloakAPI, \
|
||||||
keycloak_argument_spec, get_token, KeycloakError
|
keycloak_argument_spec, get_token, KeycloakError
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.six.moves.urllib.parse import quote
|
from urllib.parse import quote
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
|
||||||
|
|
@ -224,7 +224,7 @@ end_state:
|
||||||
from ansible_collections.community.general.plugins.module_utils.identity.keycloak.keycloak import KeycloakAPI, camel, \
|
from ansible_collections.community.general.plugins.module_utils.identity.keycloak.keycloak import KeycloakAPI, camel, \
|
||||||
keycloak_argument_spec, get_token, KeycloakError
|
keycloak_argument_spec, get_token, KeycloakError
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.six.moves.urllib.parse import urlencode
|
from urllib.parse import urlencode
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -721,7 +721,7 @@ end_state:
|
||||||
from ansible_collections.community.general.plugins.module_utils.identity.keycloak.keycloak import KeycloakAPI, camel, \
|
from ansible_collections.community.general.plugins.module_utils.identity.keycloak.keycloak import KeycloakAPI, camel, \
|
||||||
keycloak_argument_spec, get_token, KeycloakError
|
keycloak_argument_spec, get_token, KeycloakError
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.six.moves.urllib.parse import urlencode
|
from urllib.parse import urlencode
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -408,8 +408,8 @@ data:
|
||||||
from ansible_collections.community.general.plugins.module_utils.identity.keycloak.keycloak import KeycloakAPI, camel, \
|
from ansible_collections.community.general.plugins.module_utils.identity.keycloak.keycloak import KeycloakAPI, camel, \
|
||||||
keycloak_argument_spec, get_token, KeycloakError
|
keycloak_argument_spec, get_token, KeycloakError
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.six.moves.urllib.parse import urlencode
|
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
|
from urllib.parse import urlencode
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -108,7 +108,6 @@ import traceback
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
|
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
|
||||||
from ansible.module_utils.common.text.converters import to_bytes, to_native, to_text
|
from ansible.module_utils.common.text.converters import to_bytes, to_native, to_text
|
||||||
from ansible.module_utils.six import binary_type, string_types, text_type
|
|
||||||
from ansible_collections.community.general.plugins.module_utils.ldap import LdapGeneric, gen_specs, ldap_required_together
|
from ansible_collections.community.general.plugins.module_utils.ldap import LdapGeneric, gen_specs, ldap_required_together
|
||||||
|
|
||||||
LDAP_IMP_ERR = None
|
LDAP_IMP_ERR = None
|
||||||
|
|
@ -147,8 +146,8 @@ def main():
|
||||||
|
|
||||||
|
|
||||||
def _normalize_string(val, convert_to_base64):
|
def _normalize_string(val, convert_to_base64):
|
||||||
if isinstance(val, (string_types, binary_type)):
|
if isinstance(val, (str, bytes)):
|
||||||
if isinstance(val, text_type):
|
if isinstance(val, str):
|
||||||
val = to_bytes(val, encoding='utf-8')
|
val = to_bytes(val, encoding='utf-8')
|
||||||
if convert_to_base64:
|
if convert_to_base64:
|
||||||
val = to_text(base64.b64encode(val))
|
val = to_text(base64.b64encode(val))
|
||||||
|
|
|
||||||
|
|
@ -418,10 +418,10 @@ import copy
|
||||||
import datetime
|
import datetime
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
|
from urllib.parse import urlencode
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible_collections.community.general.plugins.module_utils.lxd import LXDClient, LXDClientException
|
from ansible_collections.community.general.plugins.module_utils.lxd import LXDClient, LXDClientException
|
||||||
from ansible.module_utils.six.moves.urllib.parse import urlencode
|
|
||||||
|
|
||||||
# LXD_ANSIBLE_STATES is a map of states that contain values of methods used
|
# LXD_ANSIBLE_STATES is a map of states that contain values of methods used
|
||||||
# when a particular state is evoked.
|
# when a particular state is evoked.
|
||||||
|
|
|
||||||
|
|
@ -221,9 +221,10 @@ actions:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
from urllib.parse import urlencode
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible_collections.community.general.plugins.module_utils.lxd import LXDClient, LXDClientException
|
from ansible_collections.community.general.plugins.module_utils.lxd import LXDClient, LXDClientException
|
||||||
from ansible.module_utils.six.moves.urllib.parse import urlencode
|
|
||||||
|
|
||||||
# ANSIBLE_LXD_DEFAULT_URL is a default value of the lxd endpoint
|
# ANSIBLE_LXD_DEFAULT_URL is a default value of the lxd endpoint
|
||||||
ANSIBLE_LXD_DEFAULT_URL = 'unix:/var/lib/lxd/unix.socket'
|
ANSIBLE_LXD_DEFAULT_URL = 'unix:/var/lib/lxd/unix.socket'
|
||||||
|
|
|
||||||
|
|
@ -227,7 +227,6 @@ from email.mime.text import MIMEText
|
||||||
from email.header import Header
|
from email.header import Header
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.six import PY3
|
|
||||||
from ansible.module_utils.common.text.converters import to_native
|
from ansible.module_utils.common.text.converters import to_native
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -286,10 +285,7 @@ def main():
|
||||||
try:
|
try:
|
||||||
if secure != 'never':
|
if secure != 'never':
|
||||||
try:
|
try:
|
||||||
if PY3:
|
smtp = smtplib.SMTP_SSL(host=host, port=port, local_hostname=local_hostname, timeout=timeout)
|
||||||
smtp = smtplib.SMTP_SSL(host=host, port=port, local_hostname=local_hostname, timeout=timeout)
|
|
||||||
else:
|
|
||||||
smtp = smtplib.SMTP_SSL(local_hostname=local_hostname, timeout=timeout)
|
|
||||||
code, smtpmessage = smtp.connect(host, port)
|
code, smtpmessage = smtp.connect(host, port)
|
||||||
secure_state = True
|
secure_state = True
|
||||||
except ssl.SSLError as e:
|
except ssl.SSLError as e:
|
||||||
|
|
@ -300,10 +296,7 @@ def main():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if not secure_state:
|
if not secure_state:
|
||||||
if PY3:
|
smtp = smtplib.SMTP(host=host, port=port, local_hostname=local_hostname, timeout=timeout)
|
||||||
smtp = smtplib.SMTP(host=host, port=port, local_hostname=local_hostname, timeout=timeout)
|
|
||||||
else:
|
|
||||||
smtp = smtplib.SMTP(local_hostname=local_hostname, timeout=timeout)
|
|
||||||
code, smtpmessage = smtp.connect(host, port)
|
code, smtpmessage = smtp.connect(host, port)
|
||||||
|
|
||||||
except smtplib.SMTPException as e:
|
except smtplib.SMTPException as e:
|
||||||
|
|
|
||||||
|
|
@ -142,8 +142,7 @@ targets:
|
||||||
version_added: 7.2.0
|
version_added: 7.2.0
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from ansible.module_utils.six import iteritems
|
from shlex import quote as shlex_quote
|
||||||
from ansible.module_utils.six.moves import shlex_quote
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -200,7 +199,7 @@ def main():
|
||||||
# Fall back to system make
|
# Fall back to system make
|
||||||
make_path = module.get_bin_path('make', required=True)
|
make_path = module.get_bin_path('make', required=True)
|
||||||
if module.params['params'] is not None:
|
if module.params['params'] is not None:
|
||||||
make_parameters = [k + (('=' + str(v)) if v is not None else '') for k, v in iteritems(module.params['params'])]
|
make_parameters = [k + (('=' + str(v)) if v is not None else '') for k, v in module.params['params'].items()]
|
||||||
else:
|
else:
|
||||||
make_parameters = []
|
make_parameters = []
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -244,6 +244,7 @@ import re
|
||||||
|
|
||||||
from ansible.module_utils.ansible_release import __version__ as ansible_version
|
from ansible.module_utils.ansible_release import __version__ as ansible_version
|
||||||
from re import match
|
from re import match
|
||||||
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
LXML_ETREE_IMP_ERR = None
|
LXML_ETREE_IMP_ERR = None
|
||||||
try:
|
try:
|
||||||
|
|
@ -271,7 +272,6 @@ except ImportError:
|
||||||
|
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
|
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
|
||||||
from ansible.module_utils.six.moves.urllib.parse import urlparse
|
|
||||||
from ansible.module_utils.urls import fetch_url
|
from ansible.module_utils.urls import fetch_url
|
||||||
from ansible.module_utils.common.text.converters import to_bytes, to_native, to_text
|
from ansible.module_utils.common.text.converters import to_bytes, to_native, to_text
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,6 @@ import re
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.six import python_2_unicode_compatible
|
|
||||||
|
|
||||||
|
|
||||||
STATE_COMMAND_MAP = {
|
STATE_COMMAND_MAP = {
|
||||||
|
|
@ -70,7 +69,6 @@ MONIT_SERVICES = ['Process', 'File', 'Fifo', 'Filesystem', 'Directory', 'Remote
|
||||||
'Network']
|
'Network']
|
||||||
|
|
||||||
|
|
||||||
@python_2_unicode_compatible
|
|
||||||
class StatusValue(namedtuple("Status", "value, is_pending")):
|
class StatusValue(namedtuple("Status", "value, is_pending")):
|
||||||
MISSING = 'missing'
|
MISSING = 'missing'
|
||||||
OK = 'ok'
|
OK = 'ok'
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,7 @@ EXAMPLES = r"""
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.urls import fetch_url
|
from ansible.module_utils.urls import fetch_url
|
||||||
from ansible.module_utils.six.moves.urllib.parse import quote
|
from urllib.parse import quote
|
||||||
import json
|
import json
|
||||||
|
|
||||||
# ===========================================
|
# ===========================================
|
||||||
|
|
|
||||||
|
|
@ -69,8 +69,8 @@ EXAMPLES = r"""
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
"""
|
"""
|
||||||
import json
|
import json
|
||||||
|
from urllib.parse import urlencode
|
||||||
|
|
||||||
from ansible.module_utils.six.moves.urllib.parse import urlencode
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.urls import fetch_url, url_argument_spec
|
from ansible.module_utils.urls import fetch_url, url_argument_spec
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -165,10 +165,10 @@ operationStatusId:
|
||||||
sample: 2
|
sample: 2
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from urllib.parse import urljoin
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible_collections.community.general.plugins.module_utils.ocapi_utils import OcapiUtils
|
from ansible_collections.community.general.plugins.module_utils.ocapi_utils import OcapiUtils
|
||||||
from ansible.module_utils.common.text.converters import to_native
|
from ansible.module_utils.common.text.converters import to_native
|
||||||
from ansible.module_utils.six.moves.urllib.parse import urljoin
|
|
||||||
|
|
||||||
# More will be added as module features are expanded
|
# More will be added as module features are expanded
|
||||||
CATEGORY_COMMANDS_ALL = {
|
CATEGORY_COMMANDS_ALL = {
|
||||||
|
|
|
||||||
|
|
@ -137,10 +137,11 @@ status:
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from urllib.parse import urljoin
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible_collections.community.general.plugins.module_utils.ocapi_utils import OcapiUtils
|
from ansible_collections.community.general.plugins.module_utils.ocapi_utils import OcapiUtils
|
||||||
from ansible.module_utils.common.text.converters import to_native
|
from ansible.module_utils.common.text.converters import to_native
|
||||||
from ansible.module_utils.six.moves.urllib.parse import urljoin
|
|
||||||
|
|
||||||
# More will be added as module features are expanded
|
# More will be added as module features are expanded
|
||||||
CATEGORY_COMMANDS_ALL = {
|
CATEGORY_COMMANDS_ALL = {
|
||||||
|
|
|
||||||
|
|
@ -200,7 +200,6 @@ servers:
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
from ansible.module_utils.six.moves import xrange
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible_collections.community.general.plugins.module_utils.oneandone import (
|
from ansible_collections.community.general.plugins.module_utils.oneandone import (
|
||||||
get_datacenter,
|
get_datacenter,
|
||||||
|
|
@ -576,7 +575,7 @@ def _auto_increment_hostname(count, hostname):
|
||||||
|
|
||||||
return [
|
return [
|
||||||
hostname % i
|
hostname % i
|
||||||
for i in xrange(1, count + 1)
|
for i in range(1, count + 1)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -588,7 +587,7 @@ def _auto_increment_description(count, description):
|
||||||
if '%' in description:
|
if '%' in description:
|
||||||
return [
|
return [
|
||||||
description % i
|
description % i
|
||||||
for i in xrange(1, count + 1)
|
for i in range(1, count + 1)
|
||||||
]
|
]
|
||||||
else:
|
else:
|
||||||
return [description] * count
|
return [description] * count
|
||||||
|
|
|
||||||
|
|
@ -138,7 +138,6 @@ from datetime import datetime
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.six import binary_type, text_type
|
|
||||||
|
|
||||||
|
|
||||||
# exceptions --------------------------------------------------------------- {{{
|
# exceptions --------------------------------------------------------------- {{{
|
||||||
|
|
@ -200,7 +199,7 @@ class OSXDefaults(object):
|
||||||
if data_type == "string":
|
if data_type == "string":
|
||||||
return str(value)
|
return str(value)
|
||||||
elif data_type in ["bool", "boolean"]:
|
elif data_type in ["bool", "boolean"]:
|
||||||
if isinstance(value, (binary_type, text_type)):
|
if isinstance(value, (bytes, str)):
|
||||||
value = value.lower()
|
value = value.lower()
|
||||||
if value in [True, 1, "true", "1", "yes"]:
|
if value in [True, 1, "true", "1", "yes"]:
|
||||||
return True
|
return True
|
||||||
|
|
|
||||||
|
|
@ -112,6 +112,7 @@ RETURN = r"""
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import time
|
import time
|
||||||
|
from urllib.parse import quote_plus
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import ovh
|
import ovh
|
||||||
|
|
@ -122,7 +123,6 @@ except ImportError:
|
||||||
HAS_OVH = False
|
HAS_OVH = False
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.six.moves.urllib.parse import quote_plus
|
|
||||||
|
|
||||||
|
|
||||||
def getOvhClient(ansibleModule):
|
def getOvhClient(ansibleModule):
|
||||||
|
|
|
||||||
|
|
@ -218,8 +218,8 @@ import json
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.urls import fetch_url
|
from ansible.module_utils.urls import fetch_url
|
||||||
from ansible.module_utils.six.moves.urllib.parse import urlparse, urlencode, urlunparse
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
from urllib.parse import urlparse, urlencode, urlunparse
|
||||||
|
|
||||||
|
|
||||||
def check(module, name, state, service_id, integration_key, api_key, incident_key=None, http_call=fetch_url):
|
def check(module, name, state, service_id, integration_key, api_key, incident_key=None, http_call=fetch_url):
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,6 @@ import abc
|
||||||
import re
|
import re
|
||||||
from os.path import basename
|
from os.path import basename
|
||||||
|
|
||||||
from ansible.module_utils import six
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible_collections.community.general.plugins.module_utils import deps
|
from ansible_collections.community.general.plugins.module_utils import deps
|
||||||
from ansible.module_utils.common.text.converters import to_native
|
from ansible.module_utils.common.text.converters import to_native
|
||||||
|
|
@ -80,8 +79,7 @@ class PSAdapterError(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(abc.ABCMeta)
|
class PSAdapter(object, metaclass=abc.ABCMeta):
|
||||||
class PSAdapter(object):
|
|
||||||
NAME_ATTRS = ('name', 'cmdline')
|
NAME_ATTRS = ('name', 'cmdline')
|
||||||
PATTERN_ATTRS = ('name', 'exe', 'cmdline')
|
PATTERN_ATTRS = ('name', 'exe', 'cmdline')
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -64,8 +64,8 @@ EXAMPLES = r"""
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
from shlex import quote as shlex_quote
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.six.moves import shlex_quote
|
|
||||||
|
|
||||||
|
|
||||||
def query_package(module, name):
|
def query_package(module, name):
|
||||||
|
|
|
||||||
|
|
@ -87,8 +87,8 @@ EXAMPLES = r"""
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from urllib.parse import urlencode
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.six.moves.urllib.parse import urlencode
|
|
||||||
from ansible.module_utils.urls import fetch_url
|
from ansible.module_utils.urls import fetch_url
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -270,6 +270,7 @@ subscribed_pool_ids:
|
||||||
|
|
||||||
from os.path import isfile
|
from os.path import isfile
|
||||||
from os import getuid, unlink
|
from os import getuid, unlink
|
||||||
|
import configparser
|
||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
@ -277,7 +278,6 @@ import json
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.common.text.converters import to_native
|
from ansible.module_utils.common.text.converters import to_native
|
||||||
from ansible.module_utils.six.moves import configparser
|
|
||||||
from ansible.module_utils import distro
|
from ansible.module_utils import distro
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -83,10 +83,11 @@ EXAMPLES = r"""
|
||||||
revision: "{{ lookup('pipe', 'git rev-parse HEAD') }}"
|
revision: "{{ lookup('pipe', 'git rev-parse HEAD') }}"
|
||||||
user: "{{ lookup('env', 'USER') }}"
|
user: "{{ lookup('env', 'USER') }}"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import traceback
|
import traceback
|
||||||
|
from urllib.parse import urlencode
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.six.moves.urllib.parse import urlencode
|
|
||||||
from ansible.module_utils.common.text.converters import to_native
|
from ansible.module_utils.common.text.converters import to_native
|
||||||
from ansible.module_utils.urls import fetch_url
|
from ansible.module_utils.urls import fetch_url
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -128,8 +128,8 @@ executions:
|
||||||
]
|
]
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from urllib.parse import quote
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.six.moves.urllib.parse import quote
|
|
||||||
from ansible_collections.community.general.plugins.module_utils.rundeck import (
|
from ansible_collections.community.general.plugins.module_utils.rundeck import (
|
||||||
api_argument_spec,
|
api_argument_spec,
|
||||||
api_request
|
api_request
|
||||||
|
|
|
||||||
|
|
@ -180,9 +180,9 @@ execution_info:
|
||||||
# Modules import
|
# Modules import
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
from urllib.parse import quote
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.six.moves.urllib.parse import quote
|
|
||||||
from ansible_collections.community.general.plugins.module_utils.rundeck import (
|
from ansible_collections.community.general.plugins.module_utils.rundeck import (
|
||||||
api_argument_spec,
|
api_argument_spec,
|
||||||
api_request
|
api_request
|
||||||
|
|
|
||||||
|
|
@ -125,6 +125,7 @@ EXAMPLES = r"""
|
||||||
#
|
#
|
||||||
import os
|
import os
|
||||||
import traceback
|
import traceback
|
||||||
|
from urllib.parse import urlencode
|
||||||
|
|
||||||
from ansible_collections.community.general.plugins.module_utils.version import LooseVersion
|
from ansible_collections.community.general.plugins.module_utils.version import LooseVersion
|
||||||
|
|
||||||
|
|
@ -137,7 +138,6 @@ except ImportError:
|
||||||
HAS_SENDGRID = False
|
HAS_SENDGRID = False
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
|
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
|
||||||
from ansible.module_utils.six.moves.urllib.parse import urlencode
|
|
||||||
from ansible.module_utils.common.text.converters import to_bytes
|
from ansible.module_utils.common.text.converters import to_bytes
|
||||||
from ansible.module_utils.urls import fetch_url
|
from ansible.module_utils.urls import fetch_url
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -286,7 +286,6 @@ except ImportError:
|
||||||
HAS_SL = False
|
HAS_SL = False
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.six import string_types
|
|
||||||
|
|
||||||
|
|
||||||
# TODO: get this info from API
|
# TODO: get this info from API
|
||||||
|
|
@ -374,7 +373,7 @@ def cancel_instance(module):
|
||||||
canceled = True
|
canceled = True
|
||||||
if module.params.get('instance_id') is None and (module.params.get('tags') or module.params.get('hostname') or module.params.get('domain')):
|
if module.params.get('instance_id') is None and (module.params.get('tags') or module.params.get('hostname') or module.params.get('domain')):
|
||||||
tags = module.params.get('tags')
|
tags = module.params.get('tags')
|
||||||
if isinstance(tags, string_types):
|
if isinstance(tags, str):
|
||||||
tags = [module.params.get('tags')]
|
tags = [module.params.get('tags')]
|
||||||
instances = vsManager.list_instances(tags=tags, hostname=module.params.get('hostname'), domain=module.params.get('domain'))
|
instances = vsManager.list_instances(tags=tags, hostname=module.params.get('hostname'), domain=module.params.get('domain'))
|
||||||
for instance in instances:
|
for instance in instances:
|
||||||
|
|
|
||||||
|
|
@ -266,8 +266,8 @@ EXAMPLES = r"""
|
||||||
|
|
||||||
import re
|
import re
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.six.moves.urllib.parse import urlencode
|
|
||||||
from ansible.module_utils.urls import fetch_url
|
from ansible.module_utils.urls import fetch_url
|
||||||
|
from urllib.parse import urlencode
|
||||||
|
|
||||||
OLD_SLACK_INCOMING_WEBHOOK = 'https://%s/services/hooks/incoming-webhook?token=%s'
|
OLD_SLACK_INCOMING_WEBHOOK = 'https://%s/services/hooks/incoming-webhook?token=%s'
|
||||||
SLACK_INCOMING_WEBHOOK = 'https://hooks.%s/services/%s'
|
SLACK_INCOMING_WEBHOOK = 'https://hooks.%s/services/%s'
|
||||||
|
|
|
||||||
|
|
@ -145,7 +145,7 @@ changed_attrs:
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.common.text.converters import to_native
|
from ansible.module_utils.common.text.converters import to_native
|
||||||
from ansible.module_utils.urls import fetch_url
|
from ansible.module_utils.urls import fetch_url
|
||||||
from ansible.module_utils.six.moves.urllib.parse import quote
|
from urllib.parse import quote
|
||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
import xml.etree.ElementTree as ET
|
import xml.etree.ElementTree as ET
|
||||||
|
|
|
||||||
|
|
@ -225,7 +225,6 @@ from copy import deepcopy
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
|
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
|
||||||
from ansible.module_utils.common.text.converters import to_native
|
from ansible.module_utils.common.text.converters import to_native
|
||||||
from ansible.module_utils.six import string_types
|
|
||||||
from ansible_collections.community.general.plugins.module_utils._stormssh import ConfigParser, HAS_PARAMIKO, PARAMIKO_IMPORT_ERROR
|
from ansible_collections.community.general.plugins.module_utils._stormssh import ConfigParser, HAS_PARAMIKO, PARAMIKO_IMPORT_ERROR
|
||||||
from ansible_collections.community.general.plugins.module_utils.ssh import determine_config_file
|
from ansible_collections.community.general.plugins.module_utils.ssh import determine_config_file
|
||||||
|
|
||||||
|
|
@ -301,7 +300,7 @@ class SSHConfig(object):
|
||||||
if key.lower() != key:
|
if key.lower() != key:
|
||||||
self.module.fail_json(msg="The other_options key {key!r} must be lower case".format(key=key))
|
self.module.fail_json(msg="The other_options key {key!r} must be lower case".format(key=key))
|
||||||
if key not in args:
|
if key not in args:
|
||||||
if not isinstance(value, string_types):
|
if not isinstance(value, str):
|
||||||
self.module.fail_json(msg="The other_options value provided for key {key!r} must be a string, got {type}".format(key=key,
|
self.module.fail_json(msg="The other_options value provided for key {key!r} must be a string, got {type}".format(key=key,
|
||||||
type=type(value)))
|
type=type(value)))
|
||||||
args[key] = value
|
args[key] = value
|
||||||
|
|
|
||||||
|
|
@ -121,7 +121,7 @@ EXAMPLES = r"""
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule, env_fallback
|
from ansible.module_utils.basic import AnsibleModule, env_fallback
|
||||||
from ansible.module_utils.six.moves.urllib.parse import urlencode
|
from urllib.parse import urlencode
|
||||||
from ansible.module_utils.urls import fetch_url
|
from ansible.module_utils.urls import fetch_url
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -84,10 +84,10 @@ telegram_error:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
from urllib.parse import quote
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
# noinspection PyUnresolvedReferences
|
# noinspection PyUnresolvedReferences
|
||||||
from ansible.module_utils.six.moves.urllib.parse import quote
|
|
||||||
from ansible.module_utils.urls import fetch_url
|
from ansible.module_utils.urls import fetch_url
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -281,8 +281,7 @@ command:
|
||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
import tempfile
|
import tempfile
|
||||||
from ansible.module_utils.six.moves import shlex_quote
|
from shlex import quote as shlex_quote
|
||||||
from ansible.module_utils.six import integer_types
|
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
|
|
||||||
|
|
@ -599,11 +598,11 @@ def main():
|
||||||
ret_out.append('{0}={{{1}}}'.format(k, process_complex_args(v)))
|
ret_out.append('{0}={{{1}}}'.format(k, process_complex_args(v)))
|
||||||
elif isinstance(v, list):
|
elif isinstance(v, list):
|
||||||
ret_out.append("{0}={1}".format(k, process_complex_args(v)))
|
ret_out.append("{0}={1}".format(k, process_complex_args(v)))
|
||||||
elif isinstance(v, (integer_types, float, str, bool)):
|
elif isinstance(v, (int, float, str, bool)):
|
||||||
ret_out.append('{0}={1}'.format(k, format_args(v)))
|
ret_out.append('{0}={1}'.format(k, format_args(v)))
|
||||||
else:
|
else:
|
||||||
# only to handle anything unforeseen
|
# only to handle anything unforeseen
|
||||||
module.fail_json(msg="Supported types are, dictionaries, lists, strings, integer_types, boolean and float.")
|
module.fail_json(msg="Supported types are, dictionaries, lists, strings, integers, boolean and float.")
|
||||||
if isinstance(vars, list):
|
if isinstance(vars, list):
|
||||||
l_out = []
|
l_out = []
|
||||||
for item in vars:
|
for item in vars:
|
||||||
|
|
@ -611,11 +610,11 @@ def main():
|
||||||
l_out.append("{{{0}}}".format(process_complex_args(item)))
|
l_out.append("{{{0}}}".format(process_complex_args(item)))
|
||||||
elif isinstance(item, list):
|
elif isinstance(item, list):
|
||||||
l_out.append("{0}".format(process_complex_args(item)))
|
l_out.append("{0}".format(process_complex_args(item)))
|
||||||
elif isinstance(item, (str, integer_types, float, bool)):
|
elif isinstance(item, (str, int, float, bool)):
|
||||||
l_out.append(format_args(item))
|
l_out.append(format_args(item))
|
||||||
else:
|
else:
|
||||||
# only to handle anything unforeseen
|
# only to handle anything unforeseen
|
||||||
module.fail_json(msg="Supported types are, dictionaries, lists, strings, integer_types, boolean and float.")
|
module.fail_json(msg="Supported types are, dictionaries, lists, strings, integers, boolean and float.")
|
||||||
|
|
||||||
ret_out.append("[{0}]".format(",".join(l_out)))
|
ret_out.append("[{0}]".format(",".join(l_out)))
|
||||||
return ",".join(ret_out)
|
return ",".join(ret_out)
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,6 @@ import string
|
||||||
import filecmp
|
import filecmp
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule, get_distribution
|
from ansible.module_utils.basic import AnsibleModule, get_distribution
|
||||||
from ansible.module_utils.six import iteritems
|
|
||||||
|
|
||||||
|
|
||||||
class Timezone(object):
|
class Timezone(object):
|
||||||
|
|
@ -189,7 +188,7 @@ class Timezone(object):
|
||||||
`--diff` option of ansible-playbook.
|
`--diff` option of ansible-playbook.
|
||||||
"""
|
"""
|
||||||
diff = {phase1: {}, phase2: {}}
|
diff = {phase1: {}, phase2: {}}
|
||||||
for key, value in iteritems(self.value):
|
for key, value in self.value.items():
|
||||||
diff[phase1][key] = value[phase1]
|
diff[phase1][key] = value[phase1]
|
||||||
diff[phase2][key] = value[phase2]
|
diff[phase2][key] = value[phase2]
|
||||||
return diff
|
return diff
|
||||||
|
|
@ -205,12 +204,12 @@ class Timezone(object):
|
||||||
"""
|
"""
|
||||||
if phase == 'planned':
|
if phase == 'planned':
|
||||||
return
|
return
|
||||||
for key, value in iteritems(self.value):
|
for key, value in self.value.items():
|
||||||
value[phase] = self.get(key, phase)
|
value[phase] = self.get(key, phase)
|
||||||
|
|
||||||
def change(self):
|
def change(self):
|
||||||
"""Make the changes effect based on `self.value`."""
|
"""Make the changes effect based on `self.value`."""
|
||||||
for key, value in iteritems(self.value):
|
for key, value in self.value.items():
|
||||||
if value['before'] != value['planned']:
|
if value['before'] != value['planned']:
|
||||||
self.set(key, value['planned'])
|
self.set(key, value['planned'])
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -107,8 +107,8 @@ EXAMPLES = r"""
|
||||||
# =======================================
|
# =======================================
|
||||||
# twilio module support methods
|
# twilio module support methods
|
||||||
#
|
#
|
||||||
|
from urllib.parse import urlencode
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.six.moves.urllib.parse import urlencode
|
|
||||||
from ansible.module_utils.urls import fetch_url
|
from ansible.module_utils.urls import fetch_url
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -58,9 +58,9 @@ EXAMPLES = r"""
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
from urllib.parse import urlencode
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.six.moves.urllib.parse import urlencode
|
|
||||||
from ansible.module_utils.urls import fetch_url, ConnectionError
|
from ansible.module_utils.urls import fetch_url, ConnectionError
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -57,9 +57,9 @@ EXAMPLES = r"""
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
from urllib.parse import urlencode
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.six.moves.urllib.parse import urlencode
|
|
||||||
from ansible.module_utils.urls import fetch_url
|
from ansible.module_utils.urls import fetch_url
|
||||||
from ansible.module_utils.common.text.converters import to_text
|
from ansible.module_utils.common.text.converters import to_text
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -542,7 +542,6 @@ except ImportError:
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.common.network import is_mac
|
from ansible.module_utils.common.network import is_mac
|
||||||
from ansible.module_utils import six
|
|
||||||
from ansible_collections.community.general.plugins.module_utils.xenserver import (
|
from ansible_collections.community.general.plugins.module_utils.xenserver import (
|
||||||
xenserver_common_argument_spec, XenServerObject, get_object_ref,
|
xenserver_common_argument_spec, XenServerObject, get_object_ref,
|
||||||
gather_vm_params, gather_vm_facts, set_vm_power_state,
|
gather_vm_params, gather_vm_facts, set_vm_power_state,
|
||||||
|
|
@ -714,7 +713,7 @@ class XenServerVM(XenServerObject):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
for change in config_changes:
|
for change in config_changes:
|
||||||
if isinstance(change, six.string_types):
|
if isinstance(change, str):
|
||||||
if change == "name":
|
if change == "name":
|
||||||
self.xapi_session.xenapi.VM.set_name_label(self.vm_ref, self.module.params['name'])
|
self.xapi_session.xenapi.VM.set_name_label(self.vm_ref, self.module.params['name'])
|
||||||
elif change == "name_desc":
|
elif change == "name_desc":
|
||||||
|
|
|
||||||
|
|
@ -361,6 +361,7 @@ import os
|
||||||
import re
|
import re
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
|
from collections.abc import MutableMapping
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
|
||||||
from ansible_collections.community.general.plugins.module_utils.version import LooseVersion
|
from ansible_collections.community.general.plugins.module_utils.version import LooseVersion
|
||||||
|
|
@ -374,8 +375,6 @@ except ImportError:
|
||||||
HAS_LXML = False
|
HAS_LXML = False
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule, json_dict_bytes_to_unicode, missing_required_lib
|
from ansible.module_utils.basic import AnsibleModule, json_dict_bytes_to_unicode, missing_required_lib
|
||||||
from ansible.module_utils.six import iteritems, string_types
|
|
||||||
from ansible.module_utils.six.moves.collections_abc import MutableMapping
|
|
||||||
from ansible.module_utils.common.text.converters import to_bytes, to_native
|
from ansible.module_utils.common.text.converters import to_bytes, to_native
|
||||||
|
|
||||||
_IDENT = r"[a-zA-Z-][a-zA-Z0-9_\-\.]*"
|
_IDENT = r"[a-zA-Z-][a-zA-Z0-9_\-\.]*"
|
||||||
|
|
@ -746,13 +745,13 @@ def child_to_element(module, child, in_type):
|
||||||
except etree.XMLSyntaxError as e:
|
except etree.XMLSyntaxError as e:
|
||||||
module.fail_json(msg="Error while parsing child element: %s" % e)
|
module.fail_json(msg="Error while parsing child element: %s" % e)
|
||||||
elif in_type == 'yaml':
|
elif in_type == 'yaml':
|
||||||
if isinstance(child, string_types):
|
if isinstance(child, str):
|
||||||
return etree.Element(child)
|
return etree.Element(child)
|
||||||
elif isinstance(child, MutableMapping):
|
elif isinstance(child, MutableMapping):
|
||||||
if len(child) > 1:
|
if len(child) > 1:
|
||||||
module.fail_json(msg="Can only create children from hashes with one key")
|
module.fail_json(msg="Can only create children from hashes with one key")
|
||||||
|
|
||||||
(key, value) = next(iteritems(child))
|
(key, value) = list(child.items())[0]
|
||||||
if isinstance(value, MutableMapping):
|
if isinstance(value, MutableMapping):
|
||||||
children = value.pop('_', None)
|
children = value.pop('_', None)
|
||||||
child_value = value.pop('+value', None)
|
child_value = value.pop('+value', None)
|
||||||
|
|
|
||||||
|
|
@ -116,7 +116,6 @@ parsable:
|
||||||
|
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
|
||||||
from ansible.module_utils.six import iteritems
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -152,7 +151,7 @@ class ZPoolFacts(object):
|
||||||
|
|
||||||
self._pools[pool].update({prop: value})
|
self._pools[pool].update({prop: value})
|
||||||
|
|
||||||
for k, v in iteritems(self._pools):
|
for k, v in self._pools.items():
|
||||||
v.update({'name': k})
|
v.update({'name': k})
|
||||||
self.facts.append(v)
|
self.facts.append(v)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -126,6 +126,7 @@ EXAMPLES = r"""
|
||||||
runrefresh: true
|
runrefresh: true
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import configparser
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
XML_IMP_ERR = None
|
XML_IMP_ERR = None
|
||||||
|
|
@ -140,9 +141,7 @@ from ansible.module_utils.basic import AnsibleModule, missing_required_lib
|
||||||
|
|
||||||
from ansible.module_utils.urls import fetch_url
|
from ansible.module_utils.urls import fetch_url
|
||||||
from ansible.module_utils.common.text.converters import to_text
|
from ansible.module_utils.common.text.converters import to_text
|
||||||
from ansible.module_utils.six import PY3
|
from io import StringIO, open
|
||||||
from ansible.module_utils.six.moves import configparser, StringIO
|
|
||||||
from io import open
|
|
||||||
|
|
||||||
from ansible_collections.community.general.plugins.module_utils.version import LooseVersion
|
from ansible_collections.community.general.plugins.module_utils.version import LooseVersion
|
||||||
|
|
||||||
|
|
@ -408,10 +407,7 @@ def main():
|
||||||
|
|
||||||
repofile = configparser.ConfigParser()
|
repofile = configparser.ConfigParser()
|
||||||
try:
|
try:
|
||||||
if PY3:
|
repofile.read_file(StringIO(repofile_text))
|
||||||
repofile.read_file(StringIO(repofile_text))
|
|
||||||
else:
|
|
||||||
repofile.readfp(StringIO(repofile_text))
|
|
||||||
except configparser.Error:
|
except configparser.Error:
|
||||||
module.fail_json(msg='Invalid format, .repo file could not be parsed')
|
module.fail_json(msg='Invalid format, .repo file could not be parsed')
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,64 +1,14 @@
|
||||||
plugins/module_utils/csv.py pylint:ansible-bad-import-from
|
|
||||||
plugins/module_utils/gitlab.py pylint:ansible-bad-import-from
|
|
||||||
plugins/module_utils/homebrew.py pylint:ansible-bad-import-from
|
|
||||||
plugins/module_utils/ipa.py pylint:ansible-bad-import-from
|
|
||||||
plugins/module_utils/net_tools/pritunl/api.py pylint:ansible-bad-import-from
|
|
||||||
plugins/module_utils/opennebula.py pylint:ansible-bad-import-from
|
|
||||||
plugins/module_utils/oracle/oci_utils.py pylint:ansible-bad-import-from
|
|
||||||
plugins/module_utils/pkg_req.py pylint:ansible-bad-import-from
|
|
||||||
plugins/module_utils/redfish_utils.py pylint:ansible-bad-import-from
|
|
||||||
plugins/module_utils/saslprep.py pylint:ansible-bad-import-from
|
|
||||||
plugins/module_utils/univention_umc.py pylint:use-yield-from # suggested construct does not work with Python 2
|
plugins/module_utils/univention_umc.py pylint:use-yield-from # suggested construct does not work with Python 2
|
||||||
plugins/modules/apache2_mod_proxy.py pylint:ansible-bad-import-from
|
|
||||||
plugins/modules/circonus_annotation.py pylint:ansible-bad-import-from
|
|
||||||
plugins/modules/cobbler_system.py pylint:ansible-bad-import-from
|
|
||||||
plugins/modules/consul_session.py validate-modules:parameter-state-invalid-choice
|
plugins/modules/consul_session.py validate-modules:parameter-state-invalid-choice
|
||||||
plugins/modules/dnsmadeeasy.py pylint:ansible-bad-import-from
|
|
||||||
plugins/modules/homebrew.py pylint:ansible-bad-import-from
|
|
||||||
plugins/modules/homebrew_cask.py pylint:ansible-bad-import-from
|
|
||||||
plugins/modules/homectl.py import-3.11 # Uses deprecated stdlib library 'crypt'
|
plugins/modules/homectl.py import-3.11 # Uses deprecated stdlib library 'crypt'
|
||||||
plugins/modules/homectl.py import-3.12 # Uses deprecated stdlib library 'crypt'
|
plugins/modules/homectl.py import-3.12 # Uses deprecated stdlib library 'crypt'
|
||||||
plugins/modules/iptables_state.py validate-modules:undocumented-parameter # params _back and _timeout used by action plugin
|
plugins/modules/iptables_state.py validate-modules:undocumented-parameter # params _back and _timeout used by action plugin
|
||||||
plugins/modules/java_keystore.py pylint:ansible-bad-import-from
|
|
||||||
plugins/modules/jenkins_plugin.py pylint:ansible-bad-import-from
|
|
||||||
plugins/modules/ldap_search.py pylint:ansible-bad-import-from
|
|
||||||
plugins/modules/lxc_container.py validate-modules:use-run-command-not-popen
|
plugins/modules/lxc_container.py validate-modules:use-run-command-not-popen
|
||||||
plugins/modules/mail.py pylint:ansible-bad-import-from
|
|
||||||
plugins/modules/make.py pylint:ansible-bad-import-from
|
|
||||||
plugins/modules/monit.py pylint:ansible-bad-import-from
|
|
||||||
plugins/modules/osx_defaults.py pylint:ansible-bad-import-from
|
|
||||||
plugins/modules/osx_defaults.py validate-modules:parameter-state-invalid-choice
|
plugins/modules/osx_defaults.py validate-modules:parameter-state-invalid-choice
|
||||||
plugins/modules/parted.py validate-modules:parameter-state-invalid-choice
|
plugins/modules/parted.py validate-modules:parameter-state-invalid-choice
|
||||||
plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice
|
plugins/modules/rhevm.py validate-modules:parameter-state-invalid-choice
|
||||||
plugins/modules/sl_vm.py pylint:ansible-bad-import-from
|
|
||||||
plugins/modules/ssh_config.py pylint:ansible-bad-import-from
|
|
||||||
plugins/modules/terraform.py pylint:ansible-bad-import-from
|
|
||||||
plugins/modules/timezone.py pylint:ansible-bad-import-from
|
|
||||||
plugins/modules/udm_user.py import-3.11 # Uses deprecated stdlib library 'crypt'
|
plugins/modules/udm_user.py import-3.11 # Uses deprecated stdlib library 'crypt'
|
||||||
plugins/modules/udm_user.py import-3.12 # Uses deprecated stdlib library 'crypt'
|
plugins/modules/udm_user.py import-3.12 # Uses deprecated stdlib library 'crypt'
|
||||||
plugins/modules/xfconf.py validate-modules:return-syntax-error
|
plugins/modules/xfconf.py validate-modules:return-syntax-error
|
||||||
plugins/modules/xml.py pylint:ansible-bad-import-from
|
|
||||||
plugins/modules/zpool_facts.py pylint:ansible-bad-import-from
|
|
||||||
plugins/modules/zypper_repository.py pylint:ansible-bad-import-from
|
|
||||||
tests/unit/plugins/module_utils/identity/keycloak/test_keycloak_connect.py pylint:ansible-bad-import-from
|
|
||||||
tests/unit/plugins/module_utils/net_tools/pritunl/test_api.py pylint:ansible-bad-import-from
|
|
||||||
tests/unit/plugins/modules/conftest.py pylint:ansible-bad-import-from
|
|
||||||
tests/unit/plugins/modules/uthelper.py pylint:use-yield-from # suggested construct does not work with Python 2
|
tests/unit/plugins/modules/uthelper.py pylint:use-yield-from # suggested construct does not work with Python 2
|
||||||
tests/unit/plugins/modules/test_gio_mime.yaml no-smart-quotes
|
tests/unit/plugins/modules/test_gio_mime.yaml no-smart-quotes
|
||||||
tests/unit/plugins/modules/test_keycloak_authentication.py pylint:ansible-bad-import-from
|
|
||||||
tests/unit/plugins/modules/test_keycloak_authentication_required_actions.py pylint:ansible-bad-import-from
|
|
||||||
tests/unit/plugins/modules/test_keycloak_client.py pylint:ansible-bad-import-from
|
|
||||||
tests/unit/plugins/modules/test_keycloak_client_rolemapping.py pylint:ansible-bad-import-from
|
|
||||||
tests/unit/plugins/modules/test_keycloak_clientscope.py pylint:ansible-bad-import-from
|
|
||||||
tests/unit/plugins/modules/test_keycloak_component.py pylint:ansible-bad-import-from
|
|
||||||
tests/unit/plugins/modules/test_keycloak_identity_provider.py pylint:ansible-bad-import-from
|
|
||||||
tests/unit/plugins/modules/test_keycloak_realm.py pylint:ansible-bad-import-from
|
|
||||||
tests/unit/plugins/modules/test_keycloak_realm_info.py pylint:ansible-bad-import-from
|
|
||||||
tests/unit/plugins/modules/test_keycloak_realm_keys.py pylint:ansible-bad-import-from
|
|
||||||
tests/unit/plugins/modules/test_keycloak_realm_keys_metadata_info.py pylint:ansible-bad-import-from
|
|
||||||
tests/unit/plugins/modules/test_keycloak_role.py pylint:ansible-bad-import-from
|
|
||||||
tests/unit/plugins/modules/test_keycloak_user.py pylint:ansible-bad-import-from
|
|
||||||
tests/unit/plugins/modules/test_keycloak_user_federation.py pylint:ansible-bad-import-from
|
|
||||||
tests/unit/plugins/modules/test_keycloak_userprofile.py pylint:ansible-bad-import-from
|
|
||||||
tests/unit/plugins/modules/test_pritunl_org.py pylint:ansible-bad-import-from
|
|
||||||
tests/unit/plugins/modules/test_pritunl_user.py pylint:ansible-bad-import-from
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@ from ansible_collections.community.internal_test_tools.tests.unit.compat import
|
||||||
from ansible_collections.community.internal_test_tools.tests.unit.compat.mock import patch
|
from ansible_collections.community.internal_test_tools.tests.unit.compat.mock import patch
|
||||||
|
|
||||||
from ansible.errors import AnsibleError
|
from ansible.errors import AnsibleError
|
||||||
from ansible.module_utils import six
|
|
||||||
from ansible.plugins.loader import lookup_loader
|
from ansible.plugins.loader import lookup_loader
|
||||||
from ansible_collections.community.general.plugins.lookup.bitwarden import Bitwarden, BitwardenException
|
from ansible_collections.community.general.plugins.lookup.bitwarden import Bitwarden, BitwardenException
|
||||||
from ansible.parsing.ajson import AnsibleJSONEncoder
|
from ansible.parsing.ajson import AnsibleJSONEncoder
|
||||||
|
|
@ -240,7 +239,7 @@ class TestLookupModule(unittest.TestCase):
|
||||||
# Entry 0, "a_test" of the test input should have no duplicates.
|
# Entry 0, "a_test" of the test input should have no duplicates.
|
||||||
record = MOCK_RECORDS[0]
|
record = MOCK_RECORDS[0]
|
||||||
record_name = record['name']
|
record_name = record['name']
|
||||||
for k, v in six.iteritems(record['login']):
|
for k, v in record['login'].items():
|
||||||
self.assertEqual([v],
|
self.assertEqual([v],
|
||||||
self.lookup.run([record_name], field=k)[0])
|
self.lookup.run([record_name], field=k)[0])
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,6 @@ from ansible_collections.community.internal_test_tools.tests.unit.compat import
|
||||||
from ansible_collections.community.internal_test_tools.tests.unit.compat.mock import patch
|
from ansible_collections.community.internal_test_tools.tests.unit.compat.mock import patch
|
||||||
|
|
||||||
from ansible.errors import AnsibleError
|
from ansible.errors import AnsibleError
|
||||||
from ansible.module_utils import six
|
|
||||||
from ansible.plugins.loader import lookup_loader
|
from ansible.plugins.loader import lookup_loader
|
||||||
from ansible_collections.community.general.plugins.lookup.lastpass import LPass, LPassException
|
from ansible_collections.community.general.plugins.lookup.lastpass import LPass, LPassException
|
||||||
|
|
||||||
|
|
@ -142,7 +141,7 @@ class TestLPass(unittest.TestCase):
|
||||||
lp = MockLPass()
|
lp = MockLPass()
|
||||||
for entry in MOCK_ENTRIES:
|
for entry in MOCK_ENTRIES:
|
||||||
entry_id = entry.get('id')
|
entry_id = entry.get('id')
|
||||||
for k, v in six.iteritems(entry):
|
for k, v in entry.items():
|
||||||
self.assertEqual(v.strip(), lp.get_field(entry_id, k))
|
self.assertEqual(v.strip(), lp.get_field(entry_id, k))
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -155,7 +154,7 @@ class TestLastpassPlugin(unittest.TestCase):
|
||||||
def test_lastpass_plugin_normal(self):
|
def test_lastpass_plugin_normal(self):
|
||||||
for entry in MOCK_ENTRIES:
|
for entry in MOCK_ENTRIES:
|
||||||
entry_id = entry.get('id')
|
entry_id = entry.get('id')
|
||||||
for k, v in six.iteritems(entry):
|
for k, v in entry.items():
|
||||||
self.assertEqual(v.strip(),
|
self.assertEqual(v.strip(),
|
||||||
self.lookup.run([entry_id], field=k)[0])
|
self.lookup.run([entry_id], field=k)[0])
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,14 +5,14 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
from io import StringIO
|
||||||
from itertools import count
|
from itertools import count
|
||||||
|
from urllib.error import HTTPError
|
||||||
|
|
||||||
from ansible_collections.community.general.plugins.module_utils.identity.keycloak.keycloak import (
|
from ansible_collections.community.general.plugins.module_utils.identity.keycloak.keycloak import (
|
||||||
get_token,
|
get_token,
|
||||||
KeycloakError,
|
KeycloakError,
|
||||||
)
|
)
|
||||||
from ansible.module_utils.six import StringIO
|
|
||||||
from ansible.module_utils.six.moves.urllib.error import HTTPError
|
|
||||||
|
|
||||||
module_params_creds = {
|
module_params_creds = {
|
||||||
'auth_keycloak_url': 'http://keycloak.url/auth',
|
'auth_keycloak_url': 'http://keycloak.url/auth',
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ import json
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from ansible.module_utils.common.dict_transformations import dict_merge
|
from ansible.module_utils.common.dict_transformations import dict_merge
|
||||||
from ansible.module_utils.six import iteritems
|
|
||||||
from ansible_collections.community.general.plugins.module_utils.net_tools.pritunl import (
|
from ansible_collections.community.general.plugins.module_utils.net_tools.pritunl import (
|
||||||
api,
|
api,
|
||||||
)
|
)
|
||||||
|
|
@ -527,7 +526,7 @@ class TestPritunlApi:
|
||||||
)
|
)
|
||||||
|
|
||||||
# Ensure provided settings match with the ones returned by Pritunl
|
# Ensure provided settings match with the ones returned by Pritunl
|
||||||
for k, v in iteritems(pritunl_organization_data):
|
for k, v in pritunl_organization_data.items():
|
||||||
assert create_response[k] == v
|
assert create_response[k] == v
|
||||||
|
|
||||||
@pytest.mark.parametrize("org_id", [("58070daee63f3b2e6e472c36")])
|
@pytest.mark.parametrize("org_id", [("58070daee63f3b2e6e472c36")])
|
||||||
|
|
@ -553,7 +552,7 @@ class TestPritunlApi:
|
||||||
)
|
)
|
||||||
|
|
||||||
# Ensure provided settings match with the ones returned by Pritunl
|
# Ensure provided settings match with the ones returned by Pritunl
|
||||||
for k, v in iteritems(pritunl_user_data):
|
for k, v in pritunl_user_data.items():
|
||||||
assert create_response[k] == v
|
assert create_response[k] == v
|
||||||
|
|
||||||
# Update the newly created user to ensure only certain settings are changed
|
# Update the newly created user to ensure only certain settings are changed
|
||||||
|
|
@ -576,7 +575,8 @@ class TestPritunlApi:
|
||||||
)
|
)
|
||||||
|
|
||||||
# Ensure only certain settings changed and the rest remained untouched.
|
# Ensure only certain settings changed and the rest remained untouched.
|
||||||
for k, v in iteritems(update_response):
|
# TODO: there is something wrong with this check!
|
||||||
|
for k, v in update_response.items():
|
||||||
if k in update_response:
|
if k in update_response:
|
||||||
assert update_response[k] == v
|
assert update_response[k] == v
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,6 @@ import json
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from .FakeAnsibleModule import FakeAnsibleModule
|
from .FakeAnsibleModule import FakeAnsibleModule
|
||||||
from ansible.module_utils import six
|
|
||||||
from ansible_collections.community.internal_test_tools.tests.unit.compat.mock import MagicMock
|
from ansible_collections.community.internal_test_tools.tests.unit.compat.mock import MagicMock
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -98,7 +97,7 @@ def fixture_data_from_file(request):
|
||||||
fixture_path = os.path.join(os.path.dirname(__file__), 'fixtures')
|
fixture_path = os.path.join(os.path.dirname(__file__), 'fixtures')
|
||||||
fixture_data = {}
|
fixture_data = {}
|
||||||
|
|
||||||
if isinstance(request.param, six.string_types):
|
if isinstance(request.param, str):
|
||||||
request.param = [request.param]
|
request.param = [request.param]
|
||||||
|
|
||||||
for fixture_name in request.param:
|
for fixture_name in request.param:
|
||||||
|
|
|
||||||
|
|
@ -6,18 +6,16 @@ from __future__ import annotations
|
||||||
|
|
||||||
import contextlib as _contextlib
|
import contextlib as _contextlib
|
||||||
import json
|
import json
|
||||||
|
from collections.abc import MutableMapping
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from ansible.module_utils.six import string_types
|
|
||||||
from ansible.module_utils.six.moves.collections_abc import MutableMapping
|
|
||||||
|
|
||||||
from ansible_collections.community.general.plugins.module_utils import deps
|
from ansible_collections.community.general.plugins.module_utils import deps
|
||||||
from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import set_module_args as _set_module_args
|
from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import set_module_args as _set_module_args
|
||||||
|
|
||||||
|
|
||||||
def _fix_ansible_args(args):
|
def _fix_ansible_args(args):
|
||||||
if isinstance(args, string_types):
|
if isinstance(args, str):
|
||||||
# This should be deprecated!
|
# This should be deprecated!
|
||||||
return json.loads(args)
|
return json.loads(args)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,9 @@ from __future__ import annotations
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
import json
|
import json
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
from collections.abc import Mapping
|
||||||
|
|
||||||
from ansible_collections.community.general.plugins.modules.jenkins_plugin import JenkinsPlugin
|
from ansible_collections.community.general.plugins.modules.jenkins_plugin import JenkinsPlugin
|
||||||
from ansible.module_utils.six.moves.collections_abc import Mapping
|
|
||||||
from ansible_collections.community.internal_test_tools.tests.unit.compat.mock import (
|
from ansible_collections.community.internal_test_tools.tests.unit.compat.mock import (
|
||||||
MagicMock,
|
MagicMock,
|
||||||
patch,
|
patch,
|
||||||
|
|
|
||||||
|
|
@ -13,10 +13,9 @@ from ansible_collections.community.internal_test_tools.tests.unit.plugins.module
|
||||||
|
|
||||||
from ansible_collections.community.general.plugins.modules import keycloak_authentication
|
from ansible_collections.community.general.plugins.modules import keycloak_authentication
|
||||||
|
|
||||||
|
from io import StringIO
|
||||||
from itertools import count
|
from itertools import count
|
||||||
|
|
||||||
from ansible.module_utils.six import StringIO
|
|
||||||
|
|
||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
def patch_keycloak_api(get_authentication_flow_by_alias=None, copy_auth_flow=None, create_empty_auth_flow=None,
|
def patch_keycloak_api(get_authentication_flow_by_alias=None, copy_auth_flow=None, create_empty_auth_flow=None,
|
||||||
|
|
|
||||||
|
|
@ -13,10 +13,9 @@ from ansible_collections.community.internal_test_tools.tests.unit.plugins.module
|
||||||
|
|
||||||
from ansible_collections.community.general.plugins.modules import keycloak_authentication_required_actions
|
from ansible_collections.community.general.plugins.modules import keycloak_authentication_required_actions
|
||||||
|
|
||||||
|
from io import StringIO
|
||||||
from itertools import count
|
from itertools import count
|
||||||
|
|
||||||
from ansible.module_utils.six import StringIO
|
|
||||||
|
|
||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
def patch_keycloak_api(
|
def patch_keycloak_api(
|
||||||
|
|
|
||||||
|
|
@ -14,10 +14,9 @@ from ansible_collections.community.internal_test_tools.tests.unit.plugins.module
|
||||||
|
|
||||||
from ansible_collections.community.general.plugins.modules import keycloak_client
|
from ansible_collections.community.general.plugins.modules import keycloak_client
|
||||||
|
|
||||||
|
from io import StringIO
|
||||||
from itertools import count
|
from itertools import count
|
||||||
|
|
||||||
from ansible.module_utils.six import StringIO
|
|
||||||
|
|
||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
def patch_keycloak_api(get_client_by_clientid=None, get_client_by_id=None, update_client=None, create_client=None,
|
def patch_keycloak_api(get_client_by_clientid=None, get_client_by_id=None, update_client=None, create_client=None,
|
||||||
|
|
|
||||||
|
|
@ -13,10 +13,9 @@ from ansible_collections.community.internal_test_tools.tests.unit.plugins.module
|
||||||
|
|
||||||
from ansible_collections.community.general.plugins.modules import keycloak_client_rolemapping
|
from ansible_collections.community.general.plugins.modules import keycloak_client_rolemapping
|
||||||
|
|
||||||
|
from io import StringIO
|
||||||
from itertools import count
|
from itertools import count
|
||||||
|
|
||||||
from ansible.module_utils.six import StringIO
|
|
||||||
|
|
||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
def patch_keycloak_api(get_group_by_name=None, get_client_id=None, get_client_role_id_by_name=None,
|
def patch_keycloak_api(get_group_by_name=None, get_client_id=None, get_client_role_id_by_name=None,
|
||||||
|
|
|
||||||
|
|
@ -14,10 +14,9 @@ from ansible_collections.community.internal_test_tools.tests.unit.plugins.module
|
||||||
|
|
||||||
from ansible_collections.community.general.plugins.modules import keycloak_clientscope
|
from ansible_collections.community.general.plugins.modules import keycloak_clientscope
|
||||||
|
|
||||||
|
from io import StringIO
|
||||||
from itertools import count
|
from itertools import count
|
||||||
|
|
||||||
from ansible.module_utils.six import StringIO
|
|
||||||
|
|
||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
def patch_keycloak_api(get_clientscope_by_name=None, get_clientscope_by_clientscopeid=None, create_clientscope=None,
|
def patch_keycloak_api(get_clientscope_by_name=None, get_clientscope_by_clientscopeid=None, create_clientscope=None,
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue