From bcc67e41868df9af9c20674b59d39b515885b869 Mon Sep 17 00:00:00 2001 From: Terry Yao Date: Tue, 30 Sep 2014 15:39:11 +0800 Subject: [PATCH] fix neutron-powervc debug utility issue Fix the issue that neutron-powervc debug utility needs a conf file and also remove other powervc python program needs to add config files during startup, set the default configure file for ampq files if those are not presented in CLI. Closes-Bug: #1375618 Change-Id: Idfc1a43a5e583678106b8d1cbed2738c1863254c --- common-powervc/powervc/common/config.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/common-powervc/powervc/common/config.py b/common-powervc/powervc/common/config.py index 5a73e1a..ab29609 100644 --- a/common-powervc/powervc/common/config.py +++ b/common-powervc/powervc/common/config.py @@ -17,8 +17,11 @@ if 'powervc' in sys.argv[0]: # those OpenStack AMQP configurations in [DEFAULT] section of nova.conf, # cinder.conf. argv = sys.argv[1:] - argv1 = None - argv2 = None + if 'neutron' in sys.argv[0]: + argv1 = ['--config-file', '/etc/powervc/amqp-openstack-neutron.conf'] + else: + argv1 = ['--config-file', '/etc/powervc/amqp-openstack.conf'] + argv2 = ['--config-file', '/etc/powervc/amqp-powervc.conf'] argv1_index = -1 argv2_index = -1 for i in range(len(argv)): @@ -30,16 +33,18 @@ if 'powervc' in sys.argv[0]: elif os.path.basename(argv[i+1]) == 'amqp-powervc.conf': argv2 = argv[i:i+2] argv2_index = i+1 - if argv1 is None or argv2 is None: - sys.exit("Invalid configuration: amqp-powervc.conf and" - + " amqp-openstack.conf(or openstack-neutron.conf)" - + " are required.") - else: - if argv1_index > argv2_index: - argv1_index, argv2_index = argv2_index, argv1_index + if argv1_index > argv2_index: + argv1_index, argv2_index = argv2_index, argv1_index + if argv1_index > -1 and argv2_index > -1: sys.argv = (sys.argv[:argv1_index] + sys.argv[argv1_index+2:argv2_index] + sys.argv[argv2_index+2:]) + elif argv1_index > -1 and argv2_index == -1: + sys.argv = (sys.argv[:argv1_index] + + sys.argv[argv1_index+2:]) + elif argv2_index > -1 and argv1_index == -1: + sys.argv = (sys.argv[:argv2_index] + + sys.argv[argv2_index+2:]) AMQP_OPENSTACK_CONF = cfg.ConfigOpts() AMQP_POWERVC_CONF = cfg.ConfigOpts()