Merge "NSXv: Mask passwords when logging debug messages"
This commit is contained in:
commit
aa0c947244
@ -12,6 +12,7 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import re
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
@ -122,16 +123,27 @@ class Vcns(object):
|
|||||||
insecure=insecure)
|
insecure=insecure)
|
||||||
self._nsx_version = None
|
self._nsx_version = None
|
||||||
|
|
||||||
|
def _log_request(self, method, uri, body, format):
|
||||||
|
if format == 'json':
|
||||||
|
pattern = r'\"password\": [^,}]*'
|
||||||
|
body = re.sub(pattern,
|
||||||
|
'"password": "********"', body)
|
||||||
|
else:
|
||||||
|
pattern = r'<password>.*?</password>'
|
||||||
|
body = re.sub(pattern,
|
||||||
|
'<password>********</password>', body)
|
||||||
|
LOG.debug("VcnsApiHelper('%(method)s', '%(uri)s', '%(body)s')", {
|
||||||
|
'method': method,
|
||||||
|
'uri': uri,
|
||||||
|
'body': body})
|
||||||
|
|
||||||
@retry_upon_exception(exceptions.ServiceConflict)
|
@retry_upon_exception(exceptions.ServiceConflict)
|
||||||
def _client_request(self, client, method, uri,
|
def _client_request(self, client, method, uri,
|
||||||
params, headers, encodeParams):
|
params, headers, encodeParams):
|
||||||
return client(method, uri, params, headers, encodeParams)
|
return client(method, uri, params, headers, encodeParams)
|
||||||
|
|
||||||
def do_request(self, method, uri, params=None, format='json', **kwargs):
|
def do_request(self, method, uri, params=None, format='json', **kwargs):
|
||||||
LOG.debug("VcnsApiHelper('%(method)s', '%(uri)s', '%(body)s')", {
|
self._log_request(method, uri, jsonutils.dumps(params), format)
|
||||||
'method': method,
|
|
||||||
'uri': uri,
|
|
||||||
'body': jsonutils.dumps(params)})
|
|
||||||
headers = kwargs.get('headers')
|
headers = kwargs.get('headers')
|
||||||
encodeParams = kwargs.get('encode', True)
|
encodeParams = kwargs.get('encode', True)
|
||||||
if format == 'json':
|
if format == 'json':
|
||||||
|
Loading…
x
Reference in New Issue
Block a user