mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Fixed import of urlencode and pathname2url from urllib for python3 (#24424)
This commit is contained in:
parent
98a8b967d2
commit
b65ebf3519
26 changed files with 66 additions and 69 deletions
|
@ -74,7 +74,6 @@ import re
|
||||||
import sys
|
import sys
|
||||||
from time import time
|
from time import time
|
||||||
import traceback
|
import traceback
|
||||||
import urllib
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import json
|
import json
|
||||||
|
@ -82,6 +81,7 @@ except ImportError:
|
||||||
import simplejson as json
|
import simplejson as json
|
||||||
|
|
||||||
from six import iteritems
|
from six import iteritems
|
||||||
|
from six.moves.urllib.parse import urlencode
|
||||||
|
|
||||||
from ansible.module_utils.urls import open_url
|
from ansible.module_utils.urls import open_url
|
||||||
|
|
||||||
|
@ -194,7 +194,7 @@ class CollinsInventory(object):
|
||||||
query_parameters['page'] = cur_page
|
query_parameters['page'] = cur_page
|
||||||
query_url = "%s?%s" % (
|
query_url = "%s?%s" % (
|
||||||
(CollinsDefaults.ASSETS_API_ENDPOINT % self.collins_host),
|
(CollinsDefaults.ASSETS_API_ENDPOINT % self.collins_host),
|
||||||
urllib.urlencode(query_parameters, doseq=True)
|
urlencode(query_parameters, doseq=True)
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
response = open_url(query_url,
|
response = open_url(query_url,
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
#
|
#
|
||||||
# { "groups": ["utility", "databases"], "a": false, "b": true }
|
# { "groups": ["utility", "databases"], "a": false, "b": true }
|
||||||
|
|
||||||
import urllib
|
|
||||||
try:
|
try:
|
||||||
import json
|
import json
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
@ -35,6 +34,7 @@ import sys
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
|
|
||||||
from six import iteritems
|
from six import iteritems
|
||||||
|
from six.moves.urllib.parse import urlencode
|
||||||
|
|
||||||
from ansible.module_utils.urls import open_url
|
from ansible.module_utils.urls import open_url
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ class ProxmoxAPI(object):
|
||||||
def auth(self):
|
def auth(self):
|
||||||
request_path = '{}api2/json/access/ticket'.format(self.options.url)
|
request_path = '{}api2/json/access/ticket'.format(self.options.url)
|
||||||
|
|
||||||
request_params = urllib.urlencode({
|
request_params = urlencode({
|
||||||
'username': self.options.username,
|
'username': self.options.username,
|
||||||
'password': self.options.password,
|
'password': self.options.password,
|
||||||
})
|
})
|
||||||
|
|
|
@ -225,9 +225,9 @@ from datetime import datetime, timedelta
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
from time import sleep
|
from time import sleep
|
||||||
from urllib 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
|
||||||
|
|
||||||
API_URL = 'https://api.cloudscale.ch/v1/'
|
API_URL = 'https://api.cloudscale.ch/v1/'
|
||||||
|
|
|
@ -96,13 +96,13 @@ EXAMPLES = '''
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import atexit
|
import atexit
|
||||||
import urllib
|
|
||||||
import mmap
|
import mmap
|
||||||
import errno
|
import errno
|
||||||
import socket
|
import socket
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.pycompat24 import get_exception
|
from ansible.module_utils.pycompat24 import get_exception
|
||||||
|
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
|
||||||
|
|
||||||
def vmware_path(datastore, datacenter, path):
|
def vmware_path(datastore, datacenter, path):
|
||||||
|
@ -116,7 +116,7 @@ def vmware_path(datastore, datacenter, path):
|
||||||
params = dict( dsName = datastore )
|
params = dict( dsName = datastore )
|
||||||
if datacenter:
|
if datacenter:
|
||||||
params["dcPath"] = datacenter
|
params["dcPath"] = datacenter
|
||||||
params = urllib.urlencode(params)
|
params = urlencode(params)
|
||||||
return "%s?%s" % (path, params)
|
return "%s?%s" % (path, params)
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
|
@ -77,7 +77,7 @@ EXAMPLES = '''
|
||||||
revision: '4.2'
|
revision: '4.2'
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import urllib
|
from ansible.module_utils.six.moves.urllib.parse import urlencode
|
||||||
|
|
||||||
# ===========================================
|
# ===========================================
|
||||||
# Module execution.
|
# Module execution.
|
||||||
|
@ -122,7 +122,7 @@ def main():
|
||||||
module.exit_json(changed=True)
|
module.exit_json(changed=True)
|
||||||
|
|
||||||
# Send the data to airbrake
|
# Send the data to airbrake
|
||||||
data = urllib.urlencode(params)
|
data = urlencode(params)
|
||||||
response, info = fetch_url(module, url, data=data)
|
response, info = fetch_url(module, url, data=data)
|
||||||
if info['status'] == 200:
|
if info['status'] == 200:
|
||||||
module.exit_json(changed=True)
|
module.exit_json(changed=True)
|
||||||
|
|
|
@ -82,11 +82,10 @@ EXAMPLES = '''
|
||||||
|
|
||||||
RETURN = '''# '''
|
RETURN = '''# '''
|
||||||
|
|
||||||
import urllib
|
|
||||||
|
|
||||||
# import module snippets
|
# import module snippets
|
||||||
from ansible.module_utils.basic import *
|
from ansible.module_utils.basic import *
|
||||||
from ansible.module_utils.pycompat24 import get_exception
|
from ansible.module_utils.pycompat24 import get_exception
|
||||||
|
from ansible.module_utils.six.moves.urllib.parse import urlencode
|
||||||
from ansible.module_utils.urls import *
|
from ansible.module_utils.urls import *
|
||||||
|
|
||||||
# ===========================================
|
# ===========================================
|
||||||
|
@ -131,7 +130,7 @@ def main():
|
||||||
module.exit_json(changed=True)
|
module.exit_json(changed=True)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
data = urllib.urlencode(params)
|
data = urlencode(params)
|
||||||
response, info = fetch_url(module, url, data=data)
|
response, info = fetch_url(module, url, data=data)
|
||||||
except Exception:
|
except Exception:
|
||||||
e = get_exception()
|
e = get_exception()
|
||||||
|
@ -144,4 +143,3 @@ def main():
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
||||||
|
|
|
@ -530,7 +530,8 @@ import platform
|
||||||
import socket
|
import socket
|
||||||
import sys
|
import sys
|
||||||
import types
|
import types
|
||||||
import urllib
|
|
||||||
|
from ansible.module_utils.six.moves.urllib.parse import urlencode
|
||||||
|
|
||||||
HAS_LIB_JSON = True
|
HAS_LIB_JSON = True
|
||||||
try:
|
try:
|
||||||
|
@ -575,8 +576,8 @@ class LogicMonitor(object):
|
||||||
and return the response"""
|
and return the response"""
|
||||||
self.module.debug("Running LogicMonitor.rpc")
|
self.module.debug("Running LogicMonitor.rpc")
|
||||||
|
|
||||||
param_str = urllib.urlencode(params)
|
param_str = urlencode(params)
|
||||||
creds = urllib.urlencode(
|
creds = urlencode(
|
||||||
{"c": self.company,
|
{"c": self.company,
|
||||||
"u": self.user,
|
"u": self.user,
|
||||||
"p": self.password})
|
"p": self.password})
|
||||||
|
@ -614,8 +615,8 @@ class LogicMonitor(object):
|
||||||
server \"do\" function"""
|
server \"do\" function"""
|
||||||
self.module.debug("Running LogicMonitor.do...")
|
self.module.debug("Running LogicMonitor.do...")
|
||||||
|
|
||||||
param_str = urllib.urlencode(params)
|
param_str = urlencode(params)
|
||||||
creds = (urllib.urlencode(
|
creds = (urlencode(
|
||||||
{"c": self.company,
|
{"c": self.company,
|
||||||
"u": self.user,
|
"u": self.user,
|
||||||
"p": self.password}))
|
"p": self.password}))
|
||||||
|
|
|
@ -135,7 +135,8 @@ RETURN = '''
|
||||||
|
|
||||||
import socket
|
import socket
|
||||||
import types
|
import types
|
||||||
import urllib
|
|
||||||
|
from ansible.module_utils.six.moves.urllib.parse import urlencode
|
||||||
|
|
||||||
HAS_LIB_JSON = True
|
HAS_LIB_JSON = True
|
||||||
try:
|
try:
|
||||||
|
@ -179,8 +180,8 @@ class LogicMonitor(object):
|
||||||
and return the response"""
|
and return the response"""
|
||||||
self.module.debug("Running LogicMonitor.rpc")
|
self.module.debug("Running LogicMonitor.rpc")
|
||||||
|
|
||||||
param_str = urllib.urlencode(params)
|
param_str = urlencode(params)
|
||||||
creds = urllib.urlencode(
|
creds = urlencode(
|
||||||
{"c": self.company,
|
{"c": self.company,
|
||||||
"u": self.user,
|
"u": self.user,
|
||||||
"p": self.password})
|
"p": self.password})
|
||||||
|
|
|
@ -88,7 +88,7 @@ EXAMPLES = '''
|
||||||
revision: '1.0'
|
revision: '1.0'
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import urllib
|
from ansible.module_utils.six.moves.urllib.parse import urlencode
|
||||||
|
|
||||||
# ===========================================
|
# ===========================================
|
||||||
# Module execution.
|
# Module execution.
|
||||||
|
@ -135,7 +135,7 @@ def main():
|
||||||
|
|
||||||
# Send the data to NewRelic
|
# Send the data to NewRelic
|
||||||
url = "https://rpm.newrelic.com/deployments.xml"
|
url = "https://rpm.newrelic.com/deployments.xml"
|
||||||
data = urllib.urlencode(params)
|
data = urlencode(params)
|
||||||
headers = {
|
headers = {
|
||||||
'x-api-key': module.params["token"],
|
'x-api-key': module.params["token"],
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,10 +82,9 @@ EXAMPLES = '''
|
||||||
comment: Test Deploy
|
comment: Test Deploy
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import urllib
|
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.pycompat24 import get_exception
|
from ansible.module_utils.pycompat24 import get_exception
|
||||||
|
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
|
||||||
|
|
||||||
|
|
||||||
|
@ -129,7 +128,7 @@ def main():
|
||||||
url = module.params.get('url')
|
url = module.params.get('url')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
data = urllib.urlencode(params)
|
data = urlencode(params)
|
||||||
response, info = fetch_url(module, url, data=data)
|
response, info = fetch_url(module, url, data=data)
|
||||||
except Exception:
|
except Exception:
|
||||||
e = get_exception()
|
e = get_exception()
|
||||||
|
|
|
@ -79,9 +79,10 @@ except ImportError:
|
||||||
# Let snippet from module_utils/basic.py return a proper error in this case
|
# Let snippet from module_utils/basic.py return a proper error in this case
|
||||||
pass
|
pass
|
||||||
|
|
||||||
import urllib
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
from ansible.module_utils.six.moves.urllib.parse import urlencode
|
||||||
|
|
||||||
API_BASE = "http://api.uptimerobot.com/"
|
API_BASE = "http://api.uptimerobot.com/"
|
||||||
|
|
||||||
API_ACTIONS = dict(
|
API_ACTIONS = dict(
|
||||||
|
@ -97,7 +98,7 @@ SUPPORTS_CHECK_MODE = False
|
||||||
|
|
||||||
def checkID(module, params):
|
def checkID(module, params):
|
||||||
|
|
||||||
data = urllib.urlencode(params)
|
data = urlencode(params)
|
||||||
full_uri = API_BASE + API_ACTIONS['status'] + data
|
full_uri = API_BASE + API_ACTIONS['status'] + data
|
||||||
req, info = fetch_url(module, full_uri)
|
req, info = fetch_url(module, full_uri)
|
||||||
result = req.read()
|
result = req.read()
|
||||||
|
@ -109,7 +110,7 @@ def checkID(module, params):
|
||||||
def startMonitor(module, params):
|
def startMonitor(module, params):
|
||||||
|
|
||||||
params['monitorStatus'] = 1
|
params['monitorStatus'] = 1
|
||||||
data = urllib.urlencode(params)
|
data = urlencode(params)
|
||||||
full_uri = API_BASE + API_ACTIONS['editMonitor'] + data
|
full_uri = API_BASE + API_ACTIONS['editMonitor'] + data
|
||||||
req, info = fetch_url(module, full_uri)
|
req, info = fetch_url(module, full_uri)
|
||||||
result = req.read()
|
result = req.read()
|
||||||
|
@ -121,7 +122,7 @@ def startMonitor(module, params):
|
||||||
def pauseMonitor(module, params):
|
def pauseMonitor(module, params):
|
||||||
|
|
||||||
params['monitorStatus'] = 0
|
params['monitorStatus'] = 0
|
||||||
data = urllib.urlencode(params)
|
data = urlencode(params)
|
||||||
full_uri = API_BASE + API_ACTIONS['editMonitor'] + data
|
full_uri = API_BASE + API_ACTIONS['editMonitor'] + data
|
||||||
req, info = fetch_url(module, full_uri)
|
req, info = fetch_url(module, full_uri)
|
||||||
result = req.read()
|
result = req.read()
|
||||||
|
|
|
@ -289,10 +289,9 @@ except ImportError:
|
||||||
# Let snippet from module_utils/basic.py return a proper error in this case
|
# Let snippet from module_utils/basic.py return a proper error in this case
|
||||||
pass
|
pass
|
||||||
|
|
||||||
import urllib
|
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.pycompat24 import get_exception
|
from ansible.module_utils.pycompat24 import get_exception
|
||||||
|
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
|
||||||
|
|
||||||
|
|
||||||
|
@ -449,7 +448,7 @@ class CloudflareAPI(object):
|
||||||
name = self.zone
|
name = self.zone
|
||||||
param = ''
|
param = ''
|
||||||
if name:
|
if name:
|
||||||
param = '?' + urllib.urlencode({'name' : name})
|
param = '?' + urlencode({'name' : name})
|
||||||
zones,status = self._cf_api_call('/zones' + param)
|
zones,status = self._cf_api_call('/zones' + param)
|
||||||
return zones
|
return zones
|
||||||
|
|
||||||
|
@ -475,7 +474,7 @@ class CloudflareAPI(object):
|
||||||
if value:
|
if value:
|
||||||
query['content'] = value
|
query['content'] = value
|
||||||
if query:
|
if query:
|
||||||
api_call += '?' + urllib.urlencode(query)
|
api_call += '?' + urlencode(query)
|
||||||
|
|
||||||
records,status = self._cf_api_call(api_call)
|
records,status = self._cf_api_call(api_call)
|
||||||
return records
|
return records
|
||||||
|
|
|
@ -154,7 +154,7 @@ EXAMPLES = '''
|
||||||
# DNSMadeEasy module specific support methods.
|
# DNSMadeEasy module specific support methods.
|
||||||
#
|
#
|
||||||
|
|
||||||
import urllib
|
from ansible.module_utils.six.moves.urllib.parse import urlencode
|
||||||
|
|
||||||
IMPORT_ERROR = None
|
IMPORT_ERROR = None
|
||||||
try:
|
try:
|
||||||
|
@ -204,7 +204,7 @@ class DME2:
|
||||||
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, basestring):
|
if data and not isinstance(data, basestring):
|
||||||
data = urllib.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())
|
||||||
if info['status'] not in (200, 201, 204):
|
if info['status'] not in (200, 201, 204):
|
||||||
|
|
|
@ -117,7 +117,9 @@ EXAMPLES = '''
|
||||||
|
|
||||||
import base64
|
import base64
|
||||||
import socket
|
import socket
|
||||||
import urllib
|
|
||||||
|
from ansible.module_utils.six.moves.urllib.parse import urlencode
|
||||||
|
|
||||||
|
|
||||||
class netscaler(object):
|
class netscaler(object):
|
||||||
|
|
||||||
|
@ -129,7 +131,7 @@ class netscaler(object):
|
||||||
def http_request(self, api_endpoint, data_json={}):
|
def http_request(self, api_endpoint, data_json={}):
|
||||||
request_url = self._nsc_protocol + '://' + self._nsc_host + self._nitro_base_url + api_endpoint
|
request_url = self._nsc_protocol + '://' + self._nsc_host + self._nitro_base_url + api_endpoint
|
||||||
|
|
||||||
data_json = urllib.urlencode(data_json)
|
data_json = urlencode(data_json)
|
||||||
if not len(data_json):
|
if not len(data_json):
|
||||||
data_json = None
|
data_json = None
|
||||||
|
|
||||||
|
|
|
@ -110,7 +110,7 @@ EXAMPLES = '''
|
||||||
tags: tag1,tag2,tag3
|
tags: tag1,tag2,tag3
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import urllib
|
from ansible.module_utils.six.moves.urllib.parse import urlencode
|
||||||
|
|
||||||
# ===========================================
|
# ===========================================
|
||||||
# Module execution.
|
# Module execution.
|
||||||
|
@ -185,7 +185,7 @@ def main():
|
||||||
module.exit_json(changed=False)
|
module.exit_json(changed=False)
|
||||||
|
|
||||||
# Send the data to Flowdock
|
# Send the data to Flowdock
|
||||||
data = urllib.urlencode(params)
|
data = urlencode(params)
|
||||||
response, info = fetch_url(module, url, data=data)
|
response, info = fetch_url(module, url, data=data)
|
||||||
if info['status'] != 200:
|
if info['status'] != 200:
|
||||||
module.fail_json(msg="unable to send msg: %s" % info['msg'])
|
module.fail_json(msg="unable to send msg: %s" % info['msg'])
|
||||||
|
|
|
@ -69,7 +69,7 @@ EXAMPLES = '''
|
||||||
message=deployed {{ target }}
|
message=deployed {{ target }}
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import urllib
|
from ansible.module_utils.six.moves.urllib.parse import urlencode
|
||||||
|
|
||||||
BASE_URL = 'https://grove.io/api/notice/%s/'
|
BASE_URL = 'https://grove.io/api/notice/%s/'
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ def do_notify_grove(module, channel_token, service, message, url=None, icon_url=
|
||||||
if icon_url is not None:
|
if icon_url is not None:
|
||||||
my_data['icon_url'] = icon_url
|
my_data['icon_url'] = icon_url
|
||||||
|
|
||||||
data = urllib.urlencode(my_data)
|
data = urlencode(my_data)
|
||||||
response, info = fetch_url(module, my_url, data=data)
|
response, info = fetch_url(module, my_url, data=data)
|
||||||
if info['status'] != 200:
|
if info['status'] != 200:
|
||||||
module.fail_json(msg="failed to send notification: %s" % info['msg'])
|
module.fail_json(msg="failed to send notification: %s" % info['msg'])
|
||||||
|
|
|
@ -103,15 +103,17 @@ EXAMPLES = '''
|
||||||
# HipChat module specific support methods.
|
# HipChat module specific support methods.
|
||||||
#
|
#
|
||||||
|
|
||||||
import urllib
|
|
||||||
try:
|
try:
|
||||||
import json
|
import json
|
||||||
except ImportError:
|
except ImportError:
|
||||||
import simplejson as json
|
import simplejson as json
|
||||||
|
|
||||||
|
|
||||||
# import module snippets
|
# import module snippets
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.pycompat24 import get_exception
|
from ansible.module_utils.pycompat24 import get_exception
|
||||||
|
from ansible.module_utils.six.moves.urllib.parse import urlencode
|
||||||
|
from ansible.module_utils.six.moves.urllib.request import pathname2url
|
||||||
from ansible.module_utils.urls import fetch_url
|
from ansible.module_utils.urls import fetch_url
|
||||||
|
|
||||||
DEFAULT_URI = "https://api.hipchat.com/v1"
|
DEFAULT_URI = "https://api.hipchat.com/v1"
|
||||||
|
@ -135,7 +137,7 @@ def send_msg_v1(module, token, room, msg_from, msg, msg_format='text',
|
||||||
params['notify'] = int(notify)
|
params['notify'] = int(notify)
|
||||||
|
|
||||||
url = api + MSG_URI_V1 + "?auth_token=%s" % (token)
|
url = api + MSG_URI_V1 + "?auth_token=%s" % (token)
|
||||||
data = urllib.urlencode(params)
|
data = urlencode(params)
|
||||||
|
|
||||||
if module.check_mode:
|
if module.check_mode:
|
||||||
# In check mode, exit before actually sending the message
|
# In check mode, exit before actually sending the message
|
||||||
|
@ -162,7 +164,7 @@ def send_msg_v2(module, token, room, msg_from, msg, msg_format='text',
|
||||||
|
|
||||||
POST_URL = api + NOTIFY_URI_V2
|
POST_URL = api + NOTIFY_URI_V2
|
||||||
|
|
||||||
url = POST_URL.replace('{id_or_name}', urllib.pathname2url(room))
|
url = POST_URL.replace('{id_or_name}', pathname2url(room))
|
||||||
data = json.dumps(body)
|
data = json.dumps(body)
|
||||||
|
|
||||||
if module.check_mode:
|
if module.check_mode:
|
||||||
|
|
|
@ -76,7 +76,7 @@ EXAMPLES = """
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import urllib
|
from ansible.module_utils.six.moves.urllib.parse import urlencode
|
||||||
|
|
||||||
NEXMO_API = 'https://rest.nexmo.com/sms/json'
|
NEXMO_API = 'https://rest.nexmo.com/sms/json'
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ def send_msg(module):
|
||||||
}
|
}
|
||||||
for number in module.params.get('dest'):
|
for number in module.params.get('dest'):
|
||||||
msg['to'] = number
|
msg['to'] = number
|
||||||
url = "%s?%s" % (NEXMO_API, urllib.urlencode(msg))
|
url = "%s?%s" % (NEXMO_API, urlencode(msg))
|
||||||
|
|
||||||
headers = dict(Accept='application/json')
|
headers = dict(Accept='application/json')
|
||||||
response, info = fetch_url(module, url, headers=headers)
|
response, info = fetch_url(module, url, headers=headers)
|
||||||
|
|
|
@ -65,7 +65,7 @@ EXAMPLES = '''
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import urllib
|
from ansible.module_utils.six.moves.urllib.parse import urlencode
|
||||||
|
|
||||||
|
|
||||||
class Pushover(object):
|
class Pushover(object):
|
||||||
|
@ -87,7 +87,7 @@ class Pushover(object):
|
||||||
token=self.token,
|
token=self.token,
|
||||||
priority=priority,
|
priority=priority,
|
||||||
message=msg)
|
message=msg)
|
||||||
data = urllib.urlencode(options)
|
data = urlencode(options)
|
||||||
|
|
||||||
headers = { "Content-type": "application/x-www-form-urlencoded"}
|
headers = { "Content-type": "application/x-www-form-urlencoded"}
|
||||||
r, info = fetch_url(self.module, url, method='POST', data=data, headers=headers)
|
r, info = fetch_url(self.module, url, method='POST', data=data, headers=headers)
|
||||||
|
|
|
@ -140,7 +140,7 @@ EXAMPLES = '''
|
||||||
# =======================================
|
# =======================================
|
||||||
# sendgrid module support methods
|
# sendgrid module support methods
|
||||||
#
|
#
|
||||||
import urllib
|
from ansible.module_utils.six.moves.urllib.parse import urlencode
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import sendgrid
|
import sendgrid
|
||||||
|
@ -157,7 +157,7 @@ def post_sendgrid_api(module, username, password, from_address, to_addresses,
|
||||||
AGENT = "Ansible"
|
AGENT = "Ansible"
|
||||||
data = {'api_user': username, 'api_key':password,
|
data = {'api_user': username, 'api_key':password,
|
||||||
'from':from_address, 'subject': subject, 'text': body}
|
'from':from_address, 'subject': subject, 'text': body}
|
||||||
encoded_data = urllib.urlencode(data)
|
encoded_data = urlencode(data)
|
||||||
to_addresses_api = ''
|
to_addresses_api = ''
|
||||||
for recipient in to_addresses:
|
for recipient in to_addresses:
|
||||||
if isinstance(recipient, unicode):
|
if isinstance(recipient, unicode):
|
||||||
|
|
|
@ -109,7 +109,7 @@ EXAMPLES = '''
|
||||||
# =======================================
|
# =======================================
|
||||||
# twilio module support methods
|
# twilio module support methods
|
||||||
#
|
#
|
||||||
import urllib
|
from ansible.module_utils.six.moves.urllib.parse import urlencode
|
||||||
|
|
||||||
|
|
||||||
def post_twilio_api(module, account_sid, auth_token, msg, from_number,
|
def post_twilio_api(module, account_sid, auth_token, msg, from_number,
|
||||||
|
@ -121,7 +121,7 @@ def post_twilio_api(module, account_sid, auth_token, msg, from_number,
|
||||||
data = {'From':from_number, 'To':to_number, 'Body':msg}
|
data = {'From':from_number, 'To':to_number, 'Body':msg}
|
||||||
if media_url:
|
if media_url:
|
||||||
data['MediaUrl'] = media_url
|
data['MediaUrl'] = media_url
|
||||||
encoded_data = urllib.urlencode(data)
|
encoded_data = urlencode(data)
|
||||||
|
|
||||||
headers = {'User-Agent': AGENT,
|
headers = {'User-Agent': AGENT,
|
||||||
'Content-type': 'application/x-www-form-urlencoded',
|
'Content-type': 'application/x-www-form-urlencoded',
|
||||||
|
|
|
@ -56,8 +56,6 @@ EXAMPLES = '''
|
||||||
msg: install completed
|
msg: install completed
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import urllib
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import json
|
import json
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
@ -69,11 +67,12 @@ except ImportError:
|
||||||
# import module snippets
|
# import module snippets
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.pycompat24 import get_exception
|
from ansible.module_utils.pycompat24 import get_exception
|
||||||
|
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
|
||||||
|
|
||||||
|
|
||||||
def do_request(module, url, params, headers=None):
|
def do_request(module, url, params, headers=None):
|
||||||
data = urllib.urlencode(params)
|
data = urlencode(params)
|
||||||
if headers is None:
|
if headers is None:
|
||||||
headers = dict()
|
headers = dict()
|
||||||
headers = dict(headers, **{
|
headers = dict(headers, **{
|
||||||
|
|
|
@ -112,8 +112,8 @@ import os
|
||||||
import re
|
import re
|
||||||
import tempfile
|
import tempfile
|
||||||
import json
|
import json
|
||||||
import urllib
|
|
||||||
|
|
||||||
|
from ansible.module_utils.six.moves.urllib.parse import urlencode
|
||||||
|
|
||||||
|
|
||||||
class StackiHost:
|
class StackiHost:
|
||||||
|
@ -152,7 +152,7 @@ class StackiHost:
|
||||||
|
|
||||||
# Get Final CSRF and Session ID
|
# Get Final CSRF and Session ID
|
||||||
login_req = self.do_request(self.module, login_endpoint, headers=header,
|
login_req = self.do_request(self.module, login_endpoint, headers=header,
|
||||||
payload=urllib.urlencode(auth_creds), method="POST")
|
payload=urlencode(auth_creds), method='POST')
|
||||||
|
|
||||||
cookie_f = login_req.headers.get('Set-Cookie').split(';')
|
cookie_f = login_req.headers.get('Set-Cookie').split(';')
|
||||||
csrftoken = None
|
csrftoken = None
|
||||||
|
|
|
@ -296,6 +296,7 @@ state:
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.pycompat24 import get_exception
|
from ansible.module_utils.pycompat24 import get_exception
|
||||||
|
from ansible.module_utils.six.moves.urllib.parse import urlencode
|
||||||
from ansible.module_utils.urls import fetch_url, url_argument_spec
|
from ansible.module_utils.urls import fetch_url, url_argument_spec
|
||||||
from ansible.module_utils._text import to_native
|
from ansible.module_utils._text import to_native
|
||||||
import base64
|
import base64
|
||||||
|
@ -304,7 +305,6 @@ import json
|
||||||
import os
|
import os
|
||||||
import tempfile
|
import tempfile
|
||||||
import time
|
import time
|
||||||
import urllib
|
|
||||||
|
|
||||||
|
|
||||||
class JenkinsPlugin(object):
|
class JenkinsPlugin(object):
|
||||||
|
@ -435,7 +435,7 @@ class JenkinsPlugin(object):
|
||||||
'script': install_script
|
'script': install_script
|
||||||
}
|
}
|
||||||
script_data.update(self.crumb)
|
script_data.update(self.crumb)
|
||||||
data = urllib.urlencode(script_data)
|
data = urlencode(script_data)
|
||||||
|
|
||||||
# Send the installation request
|
# Send the installation request
|
||||||
r = self._get_url_data(
|
r = self._get_url_data(
|
||||||
|
@ -723,7 +723,7 @@ class JenkinsPlugin(object):
|
||||||
def _pm_query(self, action, msg):
|
def _pm_query(self, action, msg):
|
||||||
url = "%s/pluginManager/plugin/%s/%s" % (
|
url = "%s/pluginManager/plugin/%s/%s" % (
|
||||||
self.params['url'], self.params['name'], action)
|
self.params['url'], self.params['name'], action)
|
||||||
data = urllib.urlencode(self.crumb)
|
data = urlencode(self.crumb)
|
||||||
|
|
||||||
# Send the request
|
# Send the request
|
||||||
self._get_url_data(
|
self._get_url_data(
|
||||||
|
|
|
@ -119,13 +119,8 @@ output:
|
||||||
import json
|
import json
|
||||||
|
|
||||||
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
|
||||||
try:
|
|
||||||
# python2
|
|
||||||
from urllib import urlencode
|
|
||||||
except ImportError:
|
|
||||||
# python3
|
|
||||||
from urllib.parse import urlencode
|
|
||||||
|
|
||||||
|
|
||||||
def is_csrf_protection_enabled(module):
|
def is_csrf_protection_enabled(module):
|
||||||
|
|
|
@ -20,7 +20,6 @@ from __future__ import (absolute_import, division, print_function)
|
||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import urllib
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import prettytable
|
import prettytable
|
||||||
|
@ -29,6 +28,7 @@ except ImportError:
|
||||||
HAS_PRETTYTABLE = False
|
HAS_PRETTYTABLE = False
|
||||||
|
|
||||||
from ansible.plugins.callback import CallbackBase
|
from ansible.plugins.callback import CallbackBase
|
||||||
|
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
|
||||||
|
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ class CallbackModule(CallbackBase):
|
||||||
|
|
||||||
url = ('%s?auth_token=%s' % (self.msg_uri, self.token))
|
url = ('%s?auth_token=%s' % (self.msg_uri, self.token))
|
||||||
try:
|
try:
|
||||||
response = open_url(url, data=urllib.urlencode(params))
|
response = open_url(url, data=urlencode(params))
|
||||||
return response.read()
|
return response.read()
|
||||||
except:
|
except:
|
||||||
self._display.warning('Could not submit message to hipchat')
|
self._display.warning('Could not submit message to hipchat')
|
||||||
|
|
Loading…
Reference in a new issue