Exemple #1
0
def _plugin_package_names(main_module_name: str) -> Iterator[str]:
    yield f"cmk.gui.plugins.{main_module_name}"

    if not cmk_version.is_raw_edition():
        yield f"cmk.gui.cee.plugins.{main_module_name}"

    if cmk_version.is_managed_edition():
        yield f"cmk.gui.cme.plugins.{main_module_name}"

    if cmk_version.is_plus_edition():
        yield f"cmk.gui.cpe.plugins.{main_module_name}"
Exemple #2
0
def test_is_plus_edition(monkeypatch, omd_version_str: str,
                         expected: bool) -> None:
    monkeypatch.setattr(cmk_version, "omd_version", lambda: omd_version_str)
    assert cmk_version.is_plus_edition() is expected
Exemple #3
0
import enum
from typing import Any, Mapping, Type, Union

from cmk.utils import version

from . import cache
from ._base import Fetcher, FileCache, Parser, Summarizer, verify_ipaddress
from .agent import AgentFileCache
from .ipmi import IPMIFetcher
from .piggyback import PiggybackFetcher
from .program import ProgramFetcher
from .snmp import SNMPFetcher, SNMPFileCache
from .tcp import TCPFetcher

if version.is_plus_edition():
    # pylint: disable=no-name-in-module,import-error
    from cmk.core_helpers.cpe.push_agent_fetcher import PushAgentFetcher  # type: ignore[import]
else:

    class PushAgentFetcher:  # type: ignore[no-redef]
        def from_json(self, _serialized):
            raise NotImplementedError(
                f"Push agent fetcher not available ({version.edition().short})"
            )


__all__ = [
    "PushAgentFetcher",
    "Fetcher",
    "FileCache",
 def is_show_more(self) -> bool:
     # non plus edition currently only has one option
     return not is_plus_edition()
Exemple #5
0
from cmk.utils.plugin_loader import load_plugins_with_exceptions

import cmk.gui.utils as utils
from cmk.gui.log import logger

# The following imports trigger loading of builtin main modules
# isort: off
import cmk.gui.plugins.main_modules  # noqa: F401 # pylint: disable=no-name-in-module,unused-import

if not cmk_version.is_raw_edition():
    import cmk.gui.cee.plugins.main_modules  # noqa: F401 # pylint: disable=no-name-in-module,unused-import

if cmk_version.is_managed_edition():
    import cmk.gui.cme.plugins.main_modules  # noqa: F401 # pylint: disable=no-name-in-module,unused-import

if cmk_version.is_plus_edition():
    import cmk.gui.cpe.plugins.main_modules  # noqa: F401 # pylint: disable=no-name-in-module,unused-import
# isort: on


def _imports() -> Iterator[str]:
    """Returns a list of names of all currently imported python modules"""
    for val in globals().values():
        if isinstance(val, ModuleType):
            yield val.__name__


def load_plugins() -> None:
    """Loads and initializes main modules and plugins into the application
    Only builtin main modules are already imported."""
    local_main_modules = _import_local_main_modules()