Browse Source

Merge "Add debug loging for Api requests and responses"

changes/51/574251/46
Zuul 11 months ago
parent
commit
50803cafd2
1 changed files with 11 additions and 0 deletions
  1. 11
    0
      networking_opencontrail/drivers/drv_opencontrail.py

+ 11
- 0
networking_opencontrail/drivers/drv_opencontrail.py View File

@@ -111,6 +111,10 @@ class OpenContrailDrivers(driver_base.OpenContrailDriversBase):
111 111
             self._use_api_certs = True
112 112
 
113 113
     def _request_api_server(self, url, data=None, headers=None):
114
+        LOG.debug("Api-Server request:\n"
115
+                  "URL: %(url)s\nHeaders: %(heads)s\nPayload: %(payload)s\n",
116
+                  {'url': url, 'heads': headers, 'payload': data})
117
+
114 118
         # Attempt to post to Api-Server
115 119
         if self._apiinsecure:
116 120
             response = requests.post(url, data=data,
@@ -150,6 +154,13 @@ class OpenContrailDrivers(driver_base.OpenContrailDriversBase):
150 154
                 response = self._request_api_server(url, data, auth_headers)
151 155
             else:
152 156
                 raise RuntimeError('Authentication Failure')
157
+
158
+        if response.status_code != requests.codes.ok:
159
+            LOG.error("Api-Server response:\n"
160
+                      "Status: %(status)s\nPayload: %(payload)s\n",
161
+                      {'status': response.status_code,
162
+                       'payload': response.content})
163
+
153 164
         return response
154 165
 
155 166
     def _request_api_server_authn(self, url, data=None, headers=None):

Loading…
Cancel
Save