示例#1
0
def workspace_manager_fixture(tmpdir_factory):
    """Sets the default workspace direcotry to the temporary one. """

    temp_workspace_dir = tmpdir_factory.mktemp('pmtest')
    workspace_manager = workspaces.WorkspaceManager(str(temp_workspace_dir))
    from infrared.core.services import CoreServices
    CoreServices.register_service("workspace_manager", workspace_manager)
    yield workspace_manager
示例#2
0
    def _configure(cls, workspace_dir, plugins_conf):
        """Register services to manager. """

        # create workspace manager
        if ServiceName.WORKSPACE_MANAGER not in CoreServices._SERVICES:
            cls.register_service(ServiceName.WORKSPACE_MANAGER,
                                 workspaces.WorkspaceManager(workspace_dir))
        # create plugins manager
        if ServiceName.PLUGINS_MANAGER not in CoreServices._SERVICES:
            cls.register_service(ServiceName.PLUGINS_MANAGER,
                                 plugins.InfraredPluginManager(plugins_conf))
示例#3
0
    def setup(cls, core_settings=None):
        """
        Creates configuration from file or from defaults.

        :param core_settings: the instance of the CoreSettings class with the
        desired settings. If None is provided then the default settings
        will be used.
        """

        if core_settings is None:
            core_settings = CoreSettings()

        # create workspace manager
        if ServiceName.WORKSPACE_MANAGER not in cls._SERVICES:
            cls.register_service(
                ServiceName.WORKSPACE_MANAGER,
                workspaces.WorkspaceManager(
                    core_settings.workspaces_base_folder))

        # create plugins manager
        if ServiceName.PLUGINS_MANAGER not in cls._SERVICES:
            # A temporary WH to skip all plugins installation on first InfraRed
            # command if the command is 'infrared plugin add'.
            # Should be removed together with auto plugins installation
            # mechanism.
            skip_plugins_install = {'plugin', 'add'}.issubset(sys.argv)
            cls.register_service(
                ServiceName.PLUGINS_MANAGER,
                plugins.InfraredPluginManager(
                    plugins_conf=core_settings.plugins_conf_file,
                    install_plugins=(core_settings.install_plugin_at_start
                                     and not skip_plugins_install),
                    plugins_dir=core_settings.plugins_base_folder))

        # create ansible config manager
        if ServiceName.ANSIBLE_CONFIG_MANAGER not in cls._SERVICES:
            cls.register_service(
                ServiceName.ANSIBLE_CONFIG_MANAGER,
                ansible_config.AnsibleConfigManager(
                    core_settings.infrared_home))

        # create execution logger manager
        if ServiceName.EXECUTION_LOGGER_MANAGER not in cls._SERVICES:
            # get ansible manager
            ansible_manager = CoreServices.ansible_config_manager()
            # build log file path
            log_file = \
                os.path.join(core_settings.infrared_home, 'ir-commands.log')
            cls.register_service(
                ServiceName.EXECUTION_LOGGER_MANAGER,
                execution_logger.ExecutionLoggerManager(
                    ansible_manager.ansible_config_path, log_file=log_file))
示例#4
0
    def setup(cls, core_settings=None):
        """
        Creates configuration from file or from defaults.

        :param core_settings: the instance of the CoreSettings class with the
        desired settings. If None is provided then the default settings
        will be used.
        """

        if core_settings is None:
            core_settings = CoreSettings()

        # create workspace manager
        if ServiceName.WORKSPACE_MANAGER not in cls._SERVICES:
            cls.register_service(ServiceName.WORKSPACE_MANAGER,
                                 workspaces.WorkspaceManager(
                                     core_settings.workspaces_base_folder))

        # create dependency manager for plugins
        if ServiceName.DEPENDENCY_MANAGER not in cls._SERVICES:
            cls.register_service(ServiceName.DEPENDENCY_MANAGER,
                                 dependency.PluginDependencyManager(
                                     core_settings.library_base_folder))

        # create plugins manager
        if ServiceName.PLUGINS_MANAGER not in cls._SERVICES:
            # A temporary WH to skip all plugins installation on first InfraRed
            # command if the command is 'infrared plugin add'.
            # Should be removed together with auto plugins installation
            # mechanism.
            skip_plugins_install = {'plugin', 'add'}.issubset(sys.argv)
            cls.register_service(
                ServiceName.PLUGINS_MANAGER, plugins.InfraredPluginManager(
                    plugins_conf=core_settings.plugins_conf_file,
                    dependencies_manager=CoreServices.dependency_manager(),
                    install_plugins=(core_settings.install_plugin_at_start and
                                     not skip_plugins_install),
                    plugins_dir=core_settings.plugins_base_folder))