Files
powervc-driver/neutron-powervc/bin/neutron-powervc-agent
Le Tian Ren 05a8443e12 New config strategy to adapt to oslo-messaging
* Extract and remove --config-file amqp_openstack.conf(or
  amqp-openstack-neutron and --config-file amqp-powervc.conf from sys.argv to
  create 2 AMQP cfg.ConfigOpts objects without conflicting with other options
  parsing as before, particularly those OpenStack AMQP configurations in
  [DEFAULT] section of nova.conf, cinder.conf.

* adapt all affected code to the new config strategy

Implements: blueprint
https://blueprints.launchpad.net/powervc-driver/+spec/new-configuration-strategy-needed-to-adapt-to-oslo-messaging

Closes-Bug: 1356225
Change-Id: I61a4fd0c28148e31a8cb85acea3793f40028dfb4
2014-09-16 17:53:07 +08:00

49 lines
1.7 KiB
Python
Executable File

#!/usr/bin/env python
# Copyright 2013 IBM Corp.
import os
import sys
# NOTE(mikal): All of this is because if dnspython is present in your
# environment then eventlet monkeypatches socket.getaddrinfo() with an
# implementation which doesn't work for IPv6. What we're checking here is
# that the magic environment variable was set when the import happened.
if ('eventlet' in sys.modules and
os.environ.get('EVENTLET_NO_GREENDNS', '').lower() != 'yes'):
raise ImportError('eventlet imported before neutron agent '
'(env var set to %s)'
% os.environ.get('EVENTLET_NO_GREENDNS'))
os.environ['EVENTLET_NO_GREENDNS'] = 'yes'
import eventlet
eventlet.patcher.monkey_patch(os=False, thread=False)
# If ../powervc/__init__.py exists, add ../ to Python search path, so that
# it will override what happens to be installed in /usr/(local/)lib/python.
POSSIBLE_TOPDIR = os.path.normpath(os.path.join(
os.path.abspath(sys.argv[0]),
os.pardir,
os.pardir))
if os.path.exists(os.path.join(POSSIBLE_TOPDIR, 'powervc', '__init__.py')):
sys.path.insert(0, POSSIBLE_TOPDIR)
# TODO RYKAL
# This should go in the base __init__ folder I think
from neutron.openstack.common import gettextutils
gettextutils.install('neutron')
# NOTE: Import powervc driver common config at the very beginning to parse
# AMQP.
from powervc.common import config
from neutron.common import config as logging_config
config.parse_power_config(sys.argv, 'powervc-neutron')
logging_config.setup_logging()
from powervc.neutron.agent.neutron_powervc_agent import main
main()