Use FLAGS instead of constants
This commit is contained in:
parent
deac609ceb
commit
f0f9904954
@ -196,6 +196,8 @@ DEFINE_integer('rabbit_port', 5672, 'rabbit port')
|
||||
DEFINE_string('rabbit_userid', 'guest', 'rabbit userid')
|
||||
DEFINE_string('rabbit_password', 'guest', 'rabbit password')
|
||||
DEFINE_string('rabbit_virtual_host', '/', 'rabbit virtual host')
|
||||
DEFINE_integer('rabbit_retry_interval', 10, 'rabbit connection retry interval')
|
||||
DEFINE_integer('rabbit_max_retries', 12, 'rabbit connection attempts')
|
||||
DEFINE_string('control_exchange', 'nova', 'the main exchange to connect to')
|
||||
DEFINE_string('cc_host', '127.0.0.1', 'ip of api server')
|
||||
DEFINE_integer('cc_port', 8773, 'cloud controller port')
|
||||
|
11
nova/rpc.py
11
nova/rpc.py
@ -41,9 +41,6 @@ from nova import context
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
|
||||
AMQP_RETRY_INT = 10
|
||||
AMQP_MAX_RETRIES = 12
|
||||
|
||||
LOG = logging.getLogger('amqplib')
|
||||
LOG.setLevel(logging.DEBUG)
|
||||
|
||||
@ -86,9 +83,9 @@ class Consumer(messaging.Consumer):
|
||||
Contains methods for connecting the fetch method to async loops
|
||||
"""
|
||||
def __init__(self, *args, **kwargs):
|
||||
for i in xrange(AMQP_MAX_RETRIES):
|
||||
for i in xrange(FLAGS.rabbit_max_retries):
|
||||
if i > 0:
|
||||
time.sleep(AMQP_RETRY_INT)
|
||||
time.sleep(FLAGS.rabbit_retry_interval)
|
||||
try:
|
||||
super(Consumer, self).__init__(*args, **kwargs)
|
||||
self.failed_connection = False
|
||||
@ -98,11 +95,11 @@ class Consumer(messaging.Consumer):
|
||||
" Trying again in %d seconds." % (
|
||||
FLAGS.rabbit_host,
|
||||
FLAGS.rabbit_port,
|
||||
AMQP_RETRY_INT))
|
||||
FLAGS.rabbit_retry_interval))
|
||||
self.failed_connection = True
|
||||
if self.failed_connection:
|
||||
logging.exception("Unable to connect to AMQP server" \
|
||||
" after %d tries. Shutting down." % AMQP_MAX_RETRIES)
|
||||
" after %d tries. Shutting down." % FLAGS.rabbit_max_retries)
|
||||
sys.exit(1)
|
||||
|
||||
def fetch(self, no_ack=None, auto_ack=None, enable_callbacks=False):
|
||||
|
Loading…
Reference in New Issue
Block a user