From 9928b3a6db41608cf5a486b85f601961c7ecb3de Mon Sep 17 00:00:00 2001 From: Brent Eagles Date: Thu, 6 Apr 2017 10:32:46 -0230 Subject: [PATCH] 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 --- neutron_lbaas/drivers/octavia/driver.py | 13 +++++++------ ...ken-to-octavia-del-and-get-e001340f621816dd.yaml | 5 +++++ 2 files changed, 12 insertions(+), 6 deletions(-) create mode 100644 releasenotes/notes/add-authtoken-to-octavia-del-and-get-e001340f621816dd.yaml diff --git a/neutron_lbaas/drivers/octavia/driver.py b/neutron_lbaas/drivers/octavia/driver.py index d9b4dc04b..6b7da1612 100644 --- a/neutron_lbaas/drivers/octavia/driver.py +++ b/neutron_lbaas/drivers/octavia/driver.py @@ -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, diff --git a/releasenotes/notes/add-authtoken-to-octavia-del-and-get-e001340f621816dd.yaml b/releasenotes/notes/add-authtoken-to-octavia-del-and-get-e001340f621816dd.yaml new file mode 100644 index 000000000..2747964d0 --- /dev/null +++ b/releasenotes/notes/add-authtoken-to-octavia-del-and-get-e001340f621816dd.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - | + Authentication tokens are now added to GET and DELETE Octavia requests if + missing.