Fix for rabbitmq address format
A package update sometime after the notificationclient 2.3.0 release has changed the behaviour of oslo_messaging. In rpc_helper.py get_transport(), the oslo_messaging.get_rpc_transport() now errors out when passed an ipv4 address wrapped in "[]". This was not previously the case. Updated the parsing for the broker_host variable so that it is only wrapped in brackets when it is ipv6. Testing: Pass: Verify operation on ipv4 systems Pass: Verify operation on ipv6 systems Closes-bug: 2093125 Signed-off-by: Cole Walker <cole.walker@windriver.com> Change-Id: I7211d0d4c2769547233ecc1dae0416327a19c32c
This commit is contained in:
parent
ec7cf92b65
commit
a5bb2dc260
@ -1,9 +1,10 @@
|
||||
#
|
||||
# Copyright (c) 2021 Wind River Systems, Inc.
|
||||
# Copyright (c) 2021-2025 Wind River Systems, Inc.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
import ipaddress
|
||||
import time
|
||||
import oslo_messaging
|
||||
import logging
|
||||
@ -13,6 +14,7 @@ from notificationclientsdk.common.helpers import log_helper
|
||||
from notificationclientsdk.client.locationservice import LocationServiceClient
|
||||
from notificationclientsdk.client.notificationservice \
|
||||
import NotificationServiceClient
|
||||
from notificationclientsdk.exception import client_exception
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
log_helper.config_logger(LOG)
|
||||
@ -246,7 +248,16 @@ class BrokerConnectionManager:
|
||||
# special case: if monitor all node, then use the same broker as
|
||||
# locationservice
|
||||
return self.location_watcher
|
||||
broker_host = "[{0}]".format(broker_pod_ip)
|
||||
try:
|
||||
check_pod_ip = ipaddress.ip_address(broker_pod_ip)
|
||||
if check_pod_ip.version == 4:
|
||||
broker_host = "{0}".format(broker_pod_ip)
|
||||
else: #IPv6
|
||||
broker_host = "[{0}]".format(broker_pod_ip)
|
||||
except ValueError as err:
|
||||
LOG.error("%s: broker_pod_ip %s is not a valid address" % (err, broker_pod_ip))
|
||||
raise client_exception.InvalidEndpoint(broker_name)
|
||||
|
||||
broker_transport_endpoint = "rabbit://{0}:{1}@{2}:{3}".format(
|
||||
self.shared_broker_context['NOTIFICATION_BROKER_USER'],
|
||||
self.shared_broker_context['NOTIFICATION_BROKER_PASS'],
|
||||
|
@ -1,9 +1,10 @@
|
||||
#
|
||||
# Copyright (c) 2021-2024 Wind River Systems, Inc.
|
||||
# Copyright (c) 2021-2025 Wind River Systems, Inc.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
import ipaddress
|
||||
import json
|
||||
import logging
|
||||
from datetime import datetime
|
||||
@ -99,7 +100,16 @@ class PtpService(object):
|
||||
|
||||
def _query(self, broker_name, broker_pod_ip, resource_address=None,
|
||||
optional=None):
|
||||
broker_host = "[{0}]".format(broker_pod_ip)
|
||||
try:
|
||||
check_pod_ip = ipaddress.ip_address(broker_pod_ip)
|
||||
if check_pod_ip.version == 4:
|
||||
broker_host = "{0}".format(broker_pod_ip)
|
||||
else: #IPv6
|
||||
broker_host = "[{0}]".format(broker_pod_ip)
|
||||
except ValueError as err:
|
||||
LOG.error("%s: broker_pod_ip %s is not a valid address" % (err, broker_pod_ip))
|
||||
raise client_exception.InvalidEndpoint(broker_name)
|
||||
|
||||
broker_transport_endpoint = "rabbit://{0}:{1}@{2}:{3}".format(
|
||||
self.daemon_control.daemon_context['NOTIFICATION_BROKER_USER'],
|
||||
self.daemon_control.daemon_context['NOTIFICATION_BROKER_PASS'],
|
||||
|
Loading…
x
Reference in New Issue
Block a user