예제 #1
0
	def __init__(self, profile_name = None, config = None):
		self._dbus_exporter = None

		storage_provider = storage.PickleProvider()
		storage_factory = storage.Factory(storage_provider)

		monitors_repository = monitors.Repository()
		hardware_inventory = hardware.Inventory()
		device_matcher = hardware.DeviceMatcher()
		device_matcher_udev = hardware.DeviceMatcherUdev()
		plugin_instance_factory = plugins.instance.Factory()
		self.variables = profiles.variables.Variables()

		self.config = GlobalConfig() if config is None else config
		if self.config.get_bool(consts.CFG_DYNAMIC_TUNING):
			log.info("dynamic tuning is enabled (can be overriden in plugins)")
		else:
			log.info("dynamic tuning is globally disabled")

		plugins_repository = plugins.Repository(monitors_repository, storage_factory, hardware_inventory,\
			device_matcher, device_matcher_udev, plugin_instance_factory, self.config, self.variables)
		def_instance_priority = int(self.config.get(consts.CFG_DEFAULT_INSTANCE_PRIORITY, consts.CFG_DEF_DEFAULT_INSTANCE_PRIORITY))
		unit_manager = units.Manager(plugins_repository, monitors_repository, def_instance_priority)

		profile_factory = profiles.Factory()
		profile_merger = profiles.Merger()
		profile_locator = profiles.Locator(consts.LOAD_DIRECTORIES)
		profile_loader = profiles.Loader(profile_locator, profile_factory, profile_merger, self.config, self.variables)

		self._daemon = daemon.Daemon(unit_manager, profile_loader, profile_name, self.config, self)
		self._controller = controller.Controller(self._daemon, self.config)

		self._init_signals()

		self._pid_file = None
예제 #2
0
파일: application.py 프로젝트: CZerta/tuned
	def __init__(self, profile_name = None, config = None):
		# os.uname()[2] is for the python-2.7 compatibility, it's the release string
		# like e.g. '5.15.13-100.fc34.x86_64'
		log.info("TuneD: %s, kernel: %s" % (tuned.version.TUNED_VERSION_STR, os.uname()[2]))
		self._dbus_exporter = None

		storage_provider = storage.PickleProvider()
		storage_factory = storage.Factory(storage_provider)

		self.config = GlobalConfig() if config is None else config
		if self.config.get_bool(consts.CFG_DYNAMIC_TUNING):
			log.info("dynamic tuning is enabled (can be overridden in plugins)")
		else:
			log.info("dynamic tuning is globally disabled")

		monitors_repository = monitors.Repository()
		udev_buffer_size = self.config.get_size("udev_buffer_size", consts.CFG_DEF_UDEV_BUFFER_SIZE)
		hardware_inventory = hardware.Inventory(buffer_size=udev_buffer_size)
		device_matcher = hardware.DeviceMatcher()
		device_matcher_udev = hardware.DeviceMatcherUdev()
		plugin_instance_factory = plugins.instance.Factory()
		self.variables = profiles.variables.Variables()

		plugins_repository = plugins.Repository(monitors_repository, storage_factory, hardware_inventory,\
			device_matcher, device_matcher_udev, plugin_instance_factory, self.config, self.variables)
		def_instance_priority = int(self.config.get(consts.CFG_DEFAULT_INSTANCE_PRIORITY, consts.CFG_DEF_DEFAULT_INSTANCE_PRIORITY))
		unit_manager = units.Manager(
				plugins_repository, monitors_repository,
				def_instance_priority, hardware_inventory, self.config)

		profile_factory = profiles.Factory()
		profile_merger = profiles.Merger()
		profile_locator = profiles.Locator(consts.LOAD_DIRECTORIES)
		profile_loader = profiles.Loader(profile_locator, profile_factory, profile_merger, self.config, self.variables)

		self._daemon = daemon.Daemon(unit_manager, profile_loader, profile_name, self.config, self)
		self._controller = controller.Controller(self._daemon, self.config)

		self._init_signals()

		self._pid_file = None
예제 #3
0
    def __init__(self):
        '''
        Constructor
        '''

        self._plugins = set()
        self.plugins_doc = {}

        storage_provider = storage.PickleProvider()
        storage_factory = storage.Factory(storage_provider)
        monitors_repository = monitors.Repository()
        hardware_inventory = hardware.Inventory()
        device_matcher = hardware.DeviceMatcher()
        device_matcher_udev = hardware.DeviceMatcherUdev()
        plugin_instance_factory = plugins.instance.Factory()

        self.repo = repository.Repository(monitors_repository, storage_factory,
                                          hardware_inventory, device_matcher,
                                          device_matcher_udev,
                                          plugin_instance_factory, None, None)
        self._set_loader_parameters(),
        self.create_all(self._import_plugin_names())
예제 #4
0
파일: test_base.py 프로젝트: tapakund/tuned
import tuned.plugins.decorators as decorators
from tuned.plugins.base import Plugin
import tuned.hardware as hardware
import tuned.monitors as monitors
import tuned.profiles as profiles
import tuned.plugins as plugins
import tuned.consts as consts
from tuned import storage
import tuned.plugins.base

temp_storage_file = tempfile.TemporaryFile(mode='r')
consts.DEFAULT_STORAGE_FILE = temp_storage_file.name
monitors_repository = monitors.Repository()
hardware_inventory = hardware.Inventory(set_receive_buffer_size=False)
device_matcher = hardware.DeviceMatcher()
device_matcher_udev = hardware.DeviceMatcherUdev()
plugin_instance_factory = plugins.instance.Factory()
storage_provider = storage.PickleProvider()
storage_factory = storage.Factory(storage_provider)


class PluginBaseTestCase(unittest2.TestCase):
    def setUp(self):
        self._plugin = DummyPlugin(monitors_repository,storage_factory,\
         hardware_inventory,device_matcher,device_matcher_udev,\
         plugin_instance_factory,None,None)

        self._commands_plugin = CommandsPlugin(monitors_repository,\
         storage_factory,hardware_inventory,device_matcher,\
         device_matcher_udev,plugin_instance_factory,None,\
         profiles.variables.Variables())