neutron_client: stop using global conf

Change-Id: Idd2814b8d971bea7df1aec0522c333f91f79c8ec
This commit is contained in:
Mehdi Abaakouk 2016-10-10 22:06:22 +02:00
parent 692c3e474e
commit f28d1398bf
6 changed files with 18 additions and 11 deletions

View File

@ -13,6 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_config import cfg
from ceilometer.agent import plugin_base
from ceilometer import neutron_client
@ -22,7 +24,7 @@ class _BaseServicesDiscovery(plugin_base.DiscoveryBase):
def __init__(self):
super(_BaseServicesDiscovery, self).__init__()
self.neutron_cli = neutron_client.Client()
self.neutron_cli = neutron_client.Client(cfg.CONF)
class LBPoolsDiscovery(_BaseServicesDiscovery):

View File

@ -227,7 +227,7 @@ class _LBStatsPollster(base.BaseServicesPollster):
def __init__(self):
super(_LBStatsPollster, self).__init__()
self.client = neutron_client.Client()
self.client = neutron_client.Client(cfg.CONF)
self.lb_version = cfg.CONF.service_types.neutron_lbaas_version
@staticmethod

View File

@ -14,6 +14,7 @@
import re
from oslo_config import cfg
from six.moves.urllib import parse as urlparse
from ceilometer.network.statistics import driver
@ -65,7 +66,7 @@ class OpencontrailDriver(driver.Driver):
data = {
'o_client': client.Client(endpoint),
'n_client': neutron_client.Client()
'n_client': neutron_client.Client(cfg.CONF)
}
cache['network.statistics.opencontrail'] = data

View File

@ -59,16 +59,16 @@ def logged(func):
class Client(object):
"""A client which gets information via python-neutronclient."""
def __init__(self):
conf = cfg.CONF.service_credentials
def __init__(self, conf):
creds = conf.service_credentials
params = {
'session': keystone_client.get_session(),
'endpoint_type': conf.interface,
'region_name': conf.region_name,
'service_type': cfg.CONF.service_types.neutron,
'endpoint_type': creds.interface,
'region_name': creds.region_name,
'service_type': conf.service_types.neutron,
}
self.client = clientv20.Client(**params)
self.lb_version = cfg.CONF.service_types.neutron_lbaas_version
self.lb_version = conf.service_types.neutron_lbaas_version
@logged
def port_get_all(self):

View File

@ -14,6 +14,7 @@
import mock
from oslo_config import fixture as fixture_config
from oslotest import base
from ceilometer import neutron_client
@ -23,7 +24,8 @@ class TestNeutronClient(base.BaseTestCase):
def setUp(self):
super(TestNeutronClient, self).setUp()
self.nc = neutron_client.Client()
self.CONF = self.useFixture(fixture_config.Config()).conf
self.nc = neutron_client.Client(self.CONF)
self.nc.lb_version = 'v1'
@staticmethod

View File

@ -13,6 +13,7 @@
import mock
from neutronclient.v2_0 import client
from oslo_config import fixture as fixture_config
from oslotest import base
from ceilometer import neutron_client
@ -22,7 +23,8 @@ class TestNeutronClientLBaaSV2(base.BaseTestCase):
def setUp(self):
super(TestNeutronClientLBaaSV2, self).setUp()
self.nc = neutron_client.Client()
self.CONF = self.useFixture(fixture_config.Config()).conf
self.nc = neutron_client.Client(self.CONF)
@staticmethod
def fake_list_lbaas_pools():