def driver_manager_context(self, drivers): cfg.CONF.register_opts(sfc_config.SFC_DRIVER_OPTS, 'sfc') backup_driver_names = cfg.CONF.sfc.drivers driver_names = [driver_name for driver_name in six.iterkeys(drivers)] cfg.CONF.set_override('drivers', driver_names, 'sfc') iter_entry_points = pkg_resources.iter_entry_points find_entry_points = stevedore.ExtensionManager._find_entry_points pkg_resources.iter_entry_points = mock.Mock() stevedore.ExtensionManager._find_entry_points = mock.Mock() driver_entry_points = [] for driver_name in driver_names: driver_class = mock.Mock() ep = mock.Mock() ep.name = driver_name ep.resolve.return_value = driver_class driver_class.return_value = drivers[driver_name] drivers[driver_name].native_bulk_support = True driver_entry_points.append(ep) pkg_resources.iter_entry_points.return_value = driver_entry_points stevedore.ExtensionManager._find_entry_points.return_value = ( driver_entry_points) yield sfc_driver.SfcDriverManager() cfg.CONF.set_override('drivers', backup_driver_names, 'sfc') pkg_resources.iter_entry_points = iter_entry_points stevedore.ExtensionManager._find_entry_points = find_entry_points
def __init__(self): self.driver_manager = sfc_driver.SfcDriverManager() super(SfcPlugin, self).__init__() self.driver_manager.initialize()