Merge "Use the keystone session loader in the placement reporting"

This commit is contained in:
Jenkins
2017-02-23 02:21:05 +00:00
committed by Gerrit Code Review
2 changed files with 10 additions and 8 deletions
+2 -2
View File
@@ -21,7 +21,6 @@ import time
from keystoneauth1 import exceptions as ks_exc
from keystoneauth1 import loading as keystone
from keystoneauth1 import session
from oslo_log import log as logging
from nova.compute import utils as compute_utils
@@ -195,7 +194,8 @@ class SchedulerReportClient(object):
self._provider_aggregate_map = {}
auth_plugin = keystone.load_auth_from_conf_options(
CONF, 'placement')
self._client = session.Session(auth=auth_plugin)
self._client = keystone.load_session_from_conf_options(
CONF, 'placement', auth=auth_plugin)
# NOTE(danms): Keep track of how naggy we've been
self._warn_count = 0
self.ks_filter = {'service_type': 'placement',
@@ -132,23 +132,25 @@ class SafeConnectedTestCase(test.NoDBTestCase):
class TestConstructor(test.NoDBTestCase):
@mock.patch('keystoneauth1.session.Session')
@mock.patch('keystoneauth1.loading.load_session_from_conf_options')
@mock.patch('keystoneauth1.loading.load_auth_from_conf_options')
def test_constructor(self, load_auth_mock, ks_sess_mock):
def test_constructor(self, load_auth_mock, load_sess_mock):
client = report.SchedulerReportClient()
load_auth_mock.assert_called_once_with(CONF, 'placement')
ks_sess_mock.assert_called_once_with(auth=load_auth_mock.return_value)
load_sess_mock.assert_called_once_with(CONF, 'placement',
auth=load_auth_mock.return_value)
self.assertIsNone(client.ks_filter['interface'])
@mock.patch('keystoneauth1.session.Session')
@mock.patch('keystoneauth1.loading.load_session_from_conf_options')
@mock.patch('keystoneauth1.loading.load_auth_from_conf_options')
def test_constructor_admin_interface(self, load_auth_mock, ks_sess_mock):
def test_constructor_admin_interface(self, load_auth_mock, load_sess_mock):
self.flags(os_interface='admin', group='placement')
client = report.SchedulerReportClient()
load_auth_mock.assert_called_once_with(CONF, 'placement')
ks_sess_mock.assert_called_once_with(auth=load_auth_mock.return_value)
load_sess_mock.assert_called_once_with(CONF, 'placement',
auth=load_auth_mock.return_value)
self.assertEqual('admin', client.ks_filter['interface'])