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:
Joshua Kraitberg
2025-03-31 08:46:58 -04:00
parent a91ea4c06f
commit 90199d5886

View File

@@ -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
#
import argparse
import http.client as http_client
import os
from six.moves import urllib
import sys
@@ -510,11 +511,14 @@ def process_main(argv=sys.argv[1:]): # pylint: disable=dangerous-default-value
args = parser.parse_args(argv)
if args.debug:
# Enable Debug
# Enable debug for legacy HTTP requests
handler = urllib.request.HTTPHandler(debuglevel=1)
opener = urllib.request.build_opener(handler)
urllib.request.install_opener(opener)
# Enable debug for requests library
http_client.HTTPConnection.debuglevel = 1
if args.os_auth_url is None:
args.os_auth_url = os.environ.get('OS_AUTH_URL', None)