Add disable_drivers config option
This commit adds the new option 'disabled_drivers' config option to support disabling of specific drivers if not needed. Usage: disabled_drivers = plexxi, murano Partially-Implements blueprint enable-drivers-by-default Change-Id: I008d095d70cd0718f614332bc92b57178e1d3aaa
This commit is contained in:
parent
ada4038ea1
commit
4734d2ab27
@ -55,6 +55,10 @@ core_opts = [
|
|||||||
deprecated_for_removal=True,
|
deprecated_for_removal=True,
|
||||||
deprecated_reason='automatically loads all configured drivers',
|
deprecated_reason='automatically loads all configured drivers',
|
||||||
help=_('List of driver class paths to import.')),
|
help=_('List of driver class paths to import.')),
|
||||||
|
cfg.ListOpt('disabled_drivers',
|
||||||
|
default=[],
|
||||||
|
help=_('List of driver names to be disabled. For example, '
|
||||||
|
'disabled_drivers=nova, plexxi')),
|
||||||
cfg.IntOpt('datasource_sync_period', default=60,
|
cfg.IntOpt('datasource_sync_period', default=60,
|
||||||
help='The number of seconds to wait between synchronizing '
|
help='The number of seconds to wait between synchronizing '
|
||||||
'datasource config from the database'),
|
'datasource config from the database'),
|
||||||
|
@ -514,7 +514,8 @@ class DseNode(object):
|
|||||||
invoke_on_load=False)
|
invoke_on_load=False)
|
||||||
|
|
||||||
for driver in mgr:
|
for driver in mgr:
|
||||||
result[driver.name] = driver
|
if driver.name not in cfg.CONF.disabled_drivers:
|
||||||
|
result[driver.name] = driver
|
||||||
|
|
||||||
cls.loaded_drivers = result
|
cls.loaded_drivers = result
|
||||||
|
|
||||||
|
@ -235,7 +235,8 @@ class DatasourceNotFound(NotFound):
|
|||||||
|
|
||||||
|
|
||||||
class DriverNotFound(NotFound):
|
class DriverNotFound(NotFound):
|
||||||
msg_fmt = _("Driver not found %(id)s")
|
msg_fmt = _("Driver not found %(id)s. Either not supported or disabled by "
|
||||||
|
"deployer in Congress config")
|
||||||
|
|
||||||
|
|
||||||
class DatasourceCreationError(BadConfig):
|
class DatasourceCreationError(BadConfig):
|
||||||
|
@ -17,6 +17,8 @@ from __future__ import print_function
|
|||||||
from __future__ import division
|
from __future__ import division
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
|
||||||
|
from oslo_config import cfg
|
||||||
|
|
||||||
from congress.api import webservice
|
from congress.api import webservice
|
||||||
from congress.tests.api import base as api_base
|
from congress.tests.api import base as api_base
|
||||||
from congress.tests import base
|
from congress.tests import base
|
||||||
@ -28,20 +30,8 @@ class TestDriverModel(base.SqlTestCase):
|
|||||||
super(TestDriverModel, self).setUp()
|
super(TestDriverModel, self).setUp()
|
||||||
services = api_base.setup_config()
|
services = api_base.setup_config()
|
||||||
self.node = services['node']
|
self.node = services['node']
|
||||||
self.ds_manager = services['ds_manager']
|
|
||||||
|
|
||||||
self.ds_manager.add_datasource(self._get_datasource_request())
|
|
||||||
self.driver_model = services['api']['api-system']
|
self.driver_model = services['api']['api-system']
|
||||||
|
|
||||||
def _get_datasource_request(self):
|
|
||||||
req = {'driver': 'fake_datasource',
|
|
||||||
'name': 'fake_datasource'}
|
|
||||||
req['config'] = {'auth_url': 'foo',
|
|
||||||
'username': 'foo',
|
|
||||||
'password': 'password',
|
|
||||||
'tenant_name': 'foo'}
|
|
||||||
return req
|
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
super(TestDriverModel, self).tearDown()
|
super(TestDriverModel, self).tearDown()
|
||||||
|
|
||||||
@ -53,6 +43,15 @@ class TestDriverModel(base.SqlTestCase):
|
|||||||
actual_ret = sorted(ret, key=lambda d: d['id'])
|
actual_ret = sorted(ret, key=lambda d: d['id'])
|
||||||
self.assertEqual(expected_ret, actual_ret)
|
self.assertEqual(expected_ret, actual_ret)
|
||||||
|
|
||||||
|
def test_drivers_list_with_disabled_drivers(self):
|
||||||
|
cfg.CONF.set_override('disabled_drivers', 'plexxi')
|
||||||
|
services = api_base.setup_config(node_id='test-node-1')
|
||||||
|
driver_api = services['api']['api-system']
|
||||||
|
drivers = [d['id'] for d in helper.supported_drivers()]
|
||||||
|
drivers.remove('plexxi')
|
||||||
|
ret = [d['id'] for d in driver_api.get_items({}, {})['results']]
|
||||||
|
self.assertEqual(sorted(drivers), sorted(ret))
|
||||||
|
|
||||||
def test_driver_details(self):
|
def test_driver_details(self):
|
||||||
context = {
|
context = {
|
||||||
"driver_id": "fake_datasource"
|
"driver_id": "fake_datasource"
|
||||||
|
@ -186,10 +186,7 @@ class TestDataSource(base.SqlTestCase):
|
|||||||
self.assertRaises(congressException.DatasourceNotFound,
|
self.assertRaises(congressException.DatasourceNotFound,
|
||||||
self.ds_manager.delete_datasource, req)
|
self.ds_manager.delete_datasource, req)
|
||||||
|
|
||||||
# TODO(dse2): Doesn't seem like we need this (or it will be moved to API).
|
def test_get_driver_schema(self):
|
||||||
# def test_get_driver_schema(self):
|
schema = self.dseNode.get_driver_schema('fake_datasource')
|
||||||
# schema = self.datasource_mgr.get_driver_schema(
|
self.assertEqual(schema,
|
||||||
# 'fake_datasource')
|
fake_datasource.FakeDataSource.get_schema())
|
||||||
# self.assertEqual(
|
|
||||||
# schema,
|
|
||||||
# fake_datasource.FakeDataSource.get_schema())
|
|
||||||
|
@ -60,27 +60,6 @@ function configure_congress {
|
|||||||
iniset $CONGRESS_CONF DEFAULT datasource_sync_period 30
|
iniset $CONGRESS_CONF DEFAULT datasource_sync_period 30
|
||||||
iniset $CONGRESS_CONF DEFAULT replicated_policy_engine "$CONGRESS_REPLICATED"
|
iniset $CONGRESS_CONF DEFAULT replicated_policy_engine "$CONGRESS_REPLICATED"
|
||||||
iniset $CONGRESS_CONF DEFAULT transport_url rabbit://$RABBIT_USERID:$RABBIT_PASSWORD@$RABBIT_HOST:5672
|
iniset $CONGRESS_CONF DEFAULT transport_url rabbit://$RABBIT_USERID:$RABBIT_PASSWORD@$RABBIT_HOST:5672
|
||||||
|
|
||||||
CONGRESS_DRIVERS="congress.datasources.neutronv2_driver.NeutronV2Driver,"
|
|
||||||
CONGRESS_DRIVERS+="congress.datasources.neutronv2_qos_driver.NeutronV2QosDriver,"
|
|
||||||
CONGRESS_DRIVERS+="congress.datasources.glancev2_driver.GlanceV2Driver,"
|
|
||||||
CONGRESS_DRIVERS+="congress.datasources.nova_driver.NovaDriver,"
|
|
||||||
CONGRESS_DRIVERS+="congress.datasources.keystonev3_driver.KeystoneV3Driver,"
|
|
||||||
CONGRESS_DRIVERS+="congress.datasources.cinder_driver.CinderDriver,"
|
|
||||||
CONGRESS_DRIVERS+="congress.datasources.swift_driver.SwiftDriver,"
|
|
||||||
CONGRESS_DRIVERS+="congress.datasources.plexxi_driver.PlexxiDriver,"
|
|
||||||
CONGRESS_DRIVERS+="congress.datasources.vCenter_driver.VCenterDriver,"
|
|
||||||
CONGRESS_DRIVERS+="congress.datasources.murano_driver.MuranoDriver,"
|
|
||||||
CONGRESS_DRIVERS+="congress.datasources.ironic_driver.IronicDriver,"
|
|
||||||
CONGRESS_DRIVERS+="congress.datasources.heatv1_driver.HeatV1Driver,"
|
|
||||||
CONGRESS_DRIVERS+="congress.datasources.doctor_driver.DoctorDriver,"
|
|
||||||
CONGRESS_DRIVERS+="congress.datasources.aodh_driver.AodhDriver,"
|
|
||||||
CONGRESS_DRIVERS+="congress.datasources.cfgvalidator_driver.ValidatorDriver,"
|
|
||||||
CONGRESS_DRIVERS+="congress.datasources.mistral_driver.MistralDriver,"
|
|
||||||
CONGRESS_DRIVERS+="congress.tests.fake_datasource.FakeDataSource"
|
|
||||||
|
|
||||||
iniset $CONGRESS_CONF DEFAULT drivers $CONGRESS_DRIVERS
|
|
||||||
|
|
||||||
iniset $CONGRESS_CONF database connection `database_connection_url $CONGRESS_DB_NAME`
|
iniset $CONGRESS_CONF database connection `database_connection_url $CONGRESS_DB_NAME`
|
||||||
|
|
||||||
_congress_setup_keystone $CONGRESS_CONF keystone_authtoken
|
_congress_setup_keystone $CONGRESS_CONF keystone_authtoken
|
||||||
|
Loading…
Reference in New Issue
Block a user