Skip to content

Commit

Permalink
Use parse_url() from utils.py for parsing URL, when --proxy is used.
Browse files Browse the repository at this point in the history
  • Loading branch information
jirihnidek committed Oct 16, 2023
1 parent d06f3d1 commit a99bb83
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions src/subscription_manager/managercli.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
import rhsm.config
import rhsm.connection as connection
from rhsm.connection import ProxyException, UnauthorizedException, ConnectionException, RemoteServerException, ConnectionOSErrorException
from rhsm.utils import cmd_name, remove_scheme, ServerUrlParseError
from rhsm.utils import cmd_name, ServerUrlParseError

from subscription_manager import identity
from subscription_manager.branding import get_branding
Expand Down Expand Up @@ -462,17 +462,13 @@ def main(self, args=None):
baseurl_server_prefix)
config_changed = True

# support foo.example.com:3128 format
if hasattr(self.options, "proxy_url") and self.options.proxy_url:
parts = remove_scheme(self.options.proxy_url).split(':')
self.proxy_hostname = parts[0]
# no ':'
if len(parts) > 1:
self.proxy_port = int(parts[1])
else:
# if no port specified, use the one from the config, or fallback to the default
self.proxy_port = conf['server'].get_int('proxy_port') or rhsm.config.DEFAULT_PROXY_PORT
config_changed = True
default_proxy_port = conf["server"].get_int("proxy_port") or rhsm.config.DEFAULT_PROXY_PORT
proxy_user, proxy_pass, proxy_hostname, proxy_port, proxy_prefix = rhsm.utils.parse_url(
self.options.proxy_url, default_port=default_proxy_port
)
self.proxy_hostname = proxy_hostname
self.proxy_port = int(proxy_port)

if hasattr(self.options, "proxy_user") and self.options.proxy_user:
self.proxy_user = self.options.proxy_user
Expand Down

0 comments on commit a99bb83

Please sign in to comment.