Do not instantiate network plugin when not used by driver

We have two types of share drivers. First type supports creation of
share servers and second does not.
Then, we have approach of "network plugin" for handling of networking
and it is useful only with first type of share drivers.

So, we should restrict instantiation of network plugins with second type of
share drivers.
It will allow us to remove unused dependencies for running some share drivers.

Change-Id: Ib7d6a9ff1b6ce0d5d2bca350040363ea1461c419
Closes-Bug: #1417087
This commit is contained in:
Valeriy Ponomaryov 2015-02-03 17:02:11 +02:00
parent 0fef140020
commit d1722c4d2f
2 changed files with 12 additions and 6 deletions

View File

@ -185,6 +185,9 @@ class ShareDriver(object):
network_config_group = None
self._verify_share_server_handling(driver_handles_share_servers)
if self.driver_handles_share_servers:
self.network_api = network.API(
config_group_name=network_config_group)
if hasattr(self, 'init_execute_mixin'):
# Instance with 'ExecuteMixin'
@ -192,7 +195,6 @@ class ShareDriver(object):
if hasattr(self, 'init_ganesha_mixin'):
# Instance with 'GaneshaMixin'
self.init_ganesha_mixin(*args, **kwargs) # pylint: disable=E1101
self.network_api = network.API(config_group_name=network_config_group)
@property
def driver_handles_share_servers(self):

View File

@ -77,12 +77,16 @@ class ShareDriverTestCase(test.TestCase):
self.assertTrue(hasattr(share_driver, 'configuration'))
config.append_config_values.assert_called_once_with(driver.share_opts)
if network_config_group:
network.API.assert_called_once_with(
config_group_name=config.network_config_group)
if driver_handles_share_servers:
if network_config_group:
network.API.assert_called_once_with(
config_group_name=config.network_config_group)
else:
network.API.assert_called_once_with(
config_group_name=config.config_group)
else:
network.API.assert_called_once_with(
config_group_name=config.config_group)
self.assertFalse(hasattr(share_driver, 'network_api'))
self.assertFalse(network.API.called)
return share_driver
def test_instantiate_share_driver(self):