Fix deprecated warnings
This commit is contained in:
parent
3664c74cb8
commit
98fb47b061
5 changed files with 20 additions and 16 deletions
|
@ -103,11 +103,12 @@ slug:
|
|||
sample: foo
|
||||
'''
|
||||
|
||||
import base64
|
||||
import json
|
||||
import os
|
||||
import base64
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.urls import fetch_url
|
||||
from ansible.module_utils._text import to_bytes
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
|
@ -162,7 +163,7 @@ def grafana_create_dashboard(module, data):
|
|||
if 'grafana_api_key' in data and data['grafana_api_key']:
|
||||
headers['Authorization'] = "Bearer %s" % data['grafana_api_key']
|
||||
else:
|
||||
auth = base64.encodestring('%s:%s' % (data['grafana_user'], data['grafana_password'])).replace('\n', '')
|
||||
auth = base64.b64encode(to_bytes('%s:%s' % (data['grafana_user'], data['grafana_password'])).replace('\n', ''))
|
||||
headers['Authorization'] = 'Basic %s' % auth
|
||||
grafana_switch_organisation(module, data['grafana_url'], data['org_id'], headers)
|
||||
|
||||
|
@ -220,7 +221,7 @@ def grafana_delete_dashboard(module, data):
|
|||
if 'grafana_api_key' in data and data['grafana_api_key']:
|
||||
headers['Authorization'] = "Bearer %s" % data['grafana_api_key']
|
||||
else:
|
||||
auth = base64.encodestring('%s:%s' % (data['grafana_user'], data['grafana_password'])).replace('\n', '')
|
||||
auth = base64.b64encode(to_bytes('%s:%s' % (data['grafana_user'], data['grafana_password'])).replace('\n', ''))
|
||||
headers['Authorization'] = 'Basic %s' % auth
|
||||
grafana_switch_organisation(module, data['grafana_url'], data['org_id'], headers)
|
||||
|
||||
|
@ -253,7 +254,7 @@ def grafana_export_dashboard(module, data):
|
|||
if 'grafana_api_key' in data and data['grafana_api_key']:
|
||||
headers['Authorization'] = "Bearer %s" % data['grafana_api_key']
|
||||
else:
|
||||
auth = base64.encodestring('%s:%s' % (data['grafana_user'], data['grafana_password'])).replace('\n', '')
|
||||
auth = base64.b64encode(to_bytes('%s:%s' % (data['grafana_user'], data['grafana_password'])).replace('\n', ''))
|
||||
headers['Authorization'] = 'Basic %s' % auth
|
||||
grafana_switch_organisation(module, data['grafana_url'], data['org_id'], headers)
|
||||
|
||||
|
|
|
@ -249,11 +249,12 @@ after:
|
|||
"withCredentials": false }
|
||||
'''
|
||||
|
||||
import base64
|
||||
import json
|
||||
import os
|
||||
import base64
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.urls import fetch_url
|
||||
from ansible.module_utils._text import to_bytes
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
|
@ -362,7 +363,7 @@ def grafana_create_datasource(module, data):
|
|||
if 'grafana_api_key' in data and data['grafana_api_key'] is not None:
|
||||
headers['Authorization'] = "Bearer %s" % data['grafana_api_key']
|
||||
else:
|
||||
auth = base64.encodestring('%s:%s' % (data['grafana_user'], data['grafana_password'])).replace('\n', '')
|
||||
auth = base64.b64encode(to_bytes('%s:%s' % (data['grafana_user'], data['grafana_password'])).replace('\n', ''))
|
||||
headers['Authorization'] = 'Basic %s' % auth
|
||||
grafana_switch_organisation(module, data['grafana_url'], data['org_id'], headers)
|
||||
|
||||
|
@ -422,7 +423,7 @@ def grafana_delete_datasource(module, data):
|
|||
if 'grafana_api_key' in data and data['grafana_api_key']:
|
||||
headers['Authorization'] = "Bearer %s" % data['grafana_api_key']
|
||||
else:
|
||||
auth = base64.encodestring('%s:%s' % (data['grafana_user'], data['grafana_password'])).replace('\n', '')
|
||||
auth = base64.b64encode(to_bytes('%s:%s' % (data['grafana_user'], data['grafana_password'])).replace('\n', ''))
|
||||
headers['Authorization'] = 'Basic %s' % auth
|
||||
grafana_switch_organisation(module, data['grafana_url'], data['org_id'], headers)
|
||||
|
||||
|
|
|
@ -134,19 +134,20 @@ EXAMPLES = '''
|
|||
service: '{{ pd_window.result.maintenance_window.id }}'
|
||||
'''
|
||||
|
||||
import base64
|
||||
import datetime
|
||||
import json
|
||||
import base64
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.urls import fetch_url
|
||||
from ansible.module_utils._text import to_bytes
|
||||
|
||||
|
||||
def auth_header(user, passwd, token):
|
||||
if token:
|
||||
return "Token token=%s" % token
|
||||
|
||||
auth = base64.encodestring('%s:%s' % (user, passwd)).replace('\n', '')
|
||||
auth = base64.b64encode(to_bytes('%s:%s' % (user, passwd)).replace('\n', ''))
|
||||
return "Basic %s" % auth
|
||||
|
||||
|
||||
|
|
|
@ -88,14 +88,14 @@ EXAMPLES = '''
|
|||
action: disable
|
||||
'''
|
||||
|
||||
import base64
|
||||
import json
|
||||
import socket
|
||||
import traceback
|
||||
import base64
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.six.moves.urllib.parse import urlencode
|
||||
from ansible.module_utils._text import to_native
|
||||
from ansible.module_utils._text import to_native, to_bytes
|
||||
from ansible.module_utils.urls import fetch_url
|
||||
|
||||
|
||||
|
@ -115,7 +115,7 @@ class netscaler(object):
|
|||
if not len(data_json):
|
||||
data_json = None
|
||||
|
||||
auth = base64.encodestring('%s:%s' % (self._nsc_user, self._nsc_pass)).replace('\n', '').strip()
|
||||
auth = base64.b64encode(to_bytes('%s:%s' % (self._nsc_user, self._nsc_pass)).replace('\n', '').strip())
|
||||
headers = {
|
||||
'Authorization': 'Basic %s' % auth,
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
|
|
|
@ -80,15 +80,16 @@ EXAMPLES = '''
|
|||
delegate_to: localhost
|
||||
'''
|
||||
|
||||
import base64
|
||||
import json
|
||||
import base64
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.urls import fetch_url
|
||||
from ansible.module_utils._text import to_bytes
|
||||
|
||||
|
||||
def request(module, url, user, oauthkey, data='', method='GET'):
|
||||
auth = base64.encodestring('%s:%s' % (user, oauthkey)).replace('\n', '')
|
||||
auth = base64.b64encode(to_bytes('%s:%s' % (user, oauthkey)).replace('\n', ''))
|
||||
headers = {
|
||||
'Authorization': 'Basic %s' % auth,
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue