Replace password to "***" in the debug message

Use regex pattern to replace password to "***" for both env vars and
request body output

Also includes a minor refactor to move the code up in the file as
suggested by termie and henry regarding the review comments in
https://review.openstack.org/#/c/26487/
(Original Change-Id: I890415c755dd383749f2d4382f53d0b3a6badc6c)

Fix bug 1166697

Change-Id: I671ea25cca78b4dea1fbf2e63c89b82912279f2d
Merge "Replace password to "***" in the debug message" into stable/grizzly