Skip to content
This repository was archived by the owner on Aug 12, 2020. It is now read-only.

Commit 98807f6

Browse files
committed
change rabbit mq config to url
Signed-off-by: Peng Xiao <[email protected]>
1 parent 72753a3 commit 98807f6

File tree

4 files changed

+9
-42
lines changed

4 files changed

+9
-42
lines changed

etc/yabgp/yabgp.ini.sample

+3-15
Original file line numberDiff line numberDiff line change
@@ -126,20 +126,8 @@
126126

127127
[rabbit_mq]
128128

129-
# The RabbitMQ broker address where a single node is used. (string value)
130-
# rabbit_host = localhost
131-
132-
# The RabbitMQ broker port where a single node is used. (integer value)
133-
# rabbit_port = 5672
134-
135-
# Connect over SSL for RabbitMQ. (boolean value)
136-
# rabbit_use_ssl = false
137-
138-
# The RabbitMQ userid. (string value)
139-
# rabbit_userid = guest
140-
141-
# The RabbitMQ password. (string value)
142-
# rabbit_password = guest
129+
# The RabbitMQ connection url
130+
# rabbit_url = amqp://guest:guest@localhost:5672/%2F
143131

144132
[database]
145133

@@ -175,4 +163,4 @@
175163
# write concern timeout (integer) Used in conjunction with w. Specify a value in milliseconds to
176164
# control how long to wait for write propagation to complete. If replication does not complete
177165
# in the given timeframe, a timeout exception is raised.
178-
# write_concern_timeout = 5000
166+
# write_concern_timeout = 5000

yabgp/agent/__init__.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,7 @@ def prepare_twisted_service():
143143
# check running mode
144144
if not CONF.standalone:
145145
# rabbitmq factory
146-
rabbit_mq_factory = PikaFactory(
147-
host=CONF.rabbit_mq.rabbit_host,
148-
port=CONF.rabbit_mq.rabbit_port,
149-
userid=CONF.rabbit_mq.rabbit_userid,
150-
password=CONF.rabbit_mq.rabbit_password
151-
)
146+
rabbit_mq_factory = PikaFactory(url=CONF.rabbit_mq.rabbit_url)
152147
rabbit_mq_factory.peer_list = CONF.bgp.running_config.keys()
153148
rabbit_mq_factory.connect()
154149
# mongodb connection

yabgp/channel/config.py

+3-16
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,9 @@
2222
CONF = cfg.CONF
2323

2424
rabbit_mq = [
25-
cfg.StrOpt('rabbit_host',
26-
default='localhost',
27-
help='The RabbitMQ broker address where a single node is used'),
28-
cfg.IntOpt('rabbit_port',
29-
default=5672,
30-
help='The RabbitMQ broker port where a single node is used'),
31-
cfg.BoolOpt('rabbit_use_ssl',
32-
default=False,
33-
help='Connect over SSL for RabbitMQ.'),
34-
cfg.StrOpt('rabbit_userid',
35-
default='guest',
36-
help='The RabbitMQ userid.'),
37-
cfg.StrOpt('rabbit_password',
38-
default='guest',
39-
help='The RabbitMQ password.',
40-
secret=True),
25+
cfg.StrOpt('rabbit_url',
26+
default='amqp://guest:guest@localhost:5672/%2F',
27+
help='The RabbitMQ connection url')
4128
]
4229

4330
channle_filter = [

yabgp/channel/factory.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,8 @@
3030

3131
class PikaFactory(protocol.ReconnectingClientFactory):
3232

33-
def __init__(self, host='localhost', port=5672, userid='guest', password='guest'):
34-
self.parameters = pika.ConnectionParameters(
35-
host=host, port=port,
36-
credentials=pika.PlainCredentials(userid, password)
37-
)
33+
def __init__(self, url):
34+
self.parameters = pika.URLParameters(url)
3835
self.client = None
3936
self.queued_messages = []
4037
self.peer_list = []

0 commit comments

Comments
 (0)