Fix Grafana lookup auth header for py2/3 compatibility (#50816)
This commit is contained in:
parent
a3c0277259
commit
13a8dbfd5c
1 changed files with 2 additions and 3 deletions
|
@ -64,7 +64,7 @@ import json
|
||||||
import os
|
import os
|
||||||
from ansible.errors import AnsibleError, AnsibleParserError
|
from ansible.errors import AnsibleError, AnsibleParserError
|
||||||
from ansible.plugins.lookup import LookupBase
|
from ansible.plugins.lookup import LookupBase
|
||||||
from ansible.module_utils.urls import open_url
|
from ansible.module_utils.urls import basic_auth_header, open_url
|
||||||
from ansible.module_utils._text import to_bytes, to_native
|
from ansible.module_utils._text import to_bytes, to_native
|
||||||
from ansible.module_utils.six.moves.urllib.error import HTTPError
|
from ansible.module_utils.six.moves.urllib.error import HTTPError
|
||||||
from ansible.utils.display import Display
|
from ansible.utils.display import Display
|
||||||
|
@ -124,8 +124,7 @@ class GrafanaAPI:
|
||||||
if self.grafana_api_key:
|
if self.grafana_api_key:
|
||||||
headers['Authorization'] = "Bearer %s==" % self.grafana_api_key
|
headers['Authorization'] = "Bearer %s==" % self.grafana_api_key
|
||||||
else:
|
else:
|
||||||
auth = base64.b64encode(to_bytes('%s:%s' % (self.grafana_user, self.grafana_password)).replace('\n', ''))
|
headers['Authorization'] = basic_auth_header(self.grafana_user, self.grafana_password)
|
||||||
headers['Authorization'] = 'Basic %s' % auth
|
|
||||||
self.grafana_switch_organisation(headers)
|
self.grafana_switch_organisation(headers)
|
||||||
|
|
||||||
return headers
|
return headers
|
||||||
|
|
Loading…
Reference in a new issue