Fixed missing HTTP debug logging on VIM requests
When the sw-manager CLI ported some HTTP calls from urllib to requests the debug logging capability was lost. This change remedies this. TEST PLAN PASS: sw-manager ... commands work with no impact PASS: sw-manager --debug ... work with no impact * Requests to VIM should be seen: send: b'POST /api/orchestration/sw-upgrade/strategy ... * Other debug logging still present: send: b'POST /v3/auth/tokens ... Closes-Bug: https://bugs.launchpad.net/starlingx/+bug/2105490 Change-Id: I27d8509f618005a46d44ff0ace3ccd2bddfb475e Signed-off-by: Joshua Kraitberg <joshua.kraitberg@windriver.com>
This commit is contained in:
@@ -1,9 +1,10 @@
|
|||||||
#
|
#
|
||||||
# Copyright (c) 2016-2024 Wind River Systems, Inc.
|
# Copyright (c) 2016-2025 Wind River Systems, Inc.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
#
|
#
|
||||||
import argparse
|
import argparse
|
||||||
|
import http.client as http_client
|
||||||
import os
|
import os
|
||||||
from six.moves import urllib
|
from six.moves import urllib
|
||||||
import sys
|
import sys
|
||||||
@@ -510,11 +511,14 @@ def process_main(argv=sys.argv[1:]): # pylint: disable=dangerous-default-value
|
|||||||
args = parser.parse_args(argv)
|
args = parser.parse_args(argv)
|
||||||
|
|
||||||
if args.debug:
|
if args.debug:
|
||||||
# Enable Debug
|
# Enable debug for legacy HTTP requests
|
||||||
handler = urllib.request.HTTPHandler(debuglevel=1)
|
handler = urllib.request.HTTPHandler(debuglevel=1)
|
||||||
opener = urllib.request.build_opener(handler)
|
opener = urllib.request.build_opener(handler)
|
||||||
urllib.request.install_opener(opener)
|
urllib.request.install_opener(opener)
|
||||||
|
|
||||||
|
# Enable debug for requests library
|
||||||
|
http_client.HTTPConnection.debuglevel = 1
|
||||||
|
|
||||||
if args.os_auth_url is None:
|
if args.os_auth_url is None:
|
||||||
args.os_auth_url = os.environ.get('OS_AUTH_URL', None)
|
args.os_auth_url = os.environ.get('OS_AUTH_URL', None)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user