Create header with authtoken for requests without args

This patch adds authentication tokens to headers for requests that do
not include arguments like DELETE and GET.

Closes-bug: #1680575

Change-Id: Ifc1c1e701f45eed28afc101a32e2232b3f3c3546
This commit is contained in:
Brent Eagles 2017-04-06 10:32:46 -02:30
parent 2c2efb123f
commit 9928b3a6db
2 changed files with 12 additions and 6 deletions

View File

@ -127,13 +127,14 @@ class OctaviaRequest(object):
def request(self, method, url, args=None, headers=None):
if args:
if not headers:
token = self.auth_session.get_token()
headers = {
'Content-type': 'application/json',
'X-Auth-Token': token
}
args = jsonutils.dumps(args)
if not headers or not headers.get('X-Auth-Token'):
headers = headers or {
'Content-type': 'application/json',
}
headers['X-Auth-Token'] = self.auth_session.get_token()
LOG.debug("url = %s", '%s%s' % (self.base_url, str(url)))
LOG.debug("args = %s", args)
r = requests.request(method,

View File

@ -0,0 +1,5 @@
---
fixes:
- |
Authentication tokens are now added to GET and DELETE Octavia requests if
missing.