Skip to content

Commit

Permalink
disable network scan feature in the CSE
Browse files Browse the repository at this point in the history
Change-Id: I687376d5973b9631b5879ece223ef70c2e21a010
JIRA-Ref: SAASDEV-2711
  • Loading branch information
kain88-de committed Dec 5, 2024
1 parent 899a1b0 commit 6b6f5ab
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 14 deletions.
2 changes: 2 additions & 0 deletions cmk/gui/cre/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
NotificationParameterMail,
)
from cmk.gui.wato import registration as wato_registration
from cmk.gui.watolib import network_scan
from cmk.gui.watolib.activate_changes import (
activation_features_registry,
ActivationFeatures,
Expand Down Expand Up @@ -109,6 +110,7 @@ def register_painters() -> None:

def register(edition: Edition) -> None:
autocomplete.register(endpoint_registry)
network_scan.register(host_attribute_registry, automation_command_registry, cron_job_registry)
common_registration(
mega_menu_registry,
job_registry,
Expand Down
31 changes: 28 additions & 3 deletions cmk/gui/watolib/network_scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import time
import traceback
from collections.abc import Sequence
from datetime import timedelta
from typing import Literal, NamedTuple, TypeGuard

from cmk.ccc import store
Expand All @@ -22,17 +23,24 @@
from cmk.utils.user import UserId

from cmk.gui import userdb
from cmk.gui.cron import CronJob, CronJobRegistry
from cmk.gui.http import request
from cmk.gui.i18n import _
from cmk.gui.log import logger
from cmk.gui.session import UserContext
from cmk.gui.site_config import get_site_config, is_wato_slave_site, site_is_local

from ..config import active_config
from . import bakery
from .automation_commands import AutomationCommand
from . import bakery, builtin_attributes
from .automation_commands import AutomationCommand, AutomationCommandRegistry
from .automations import do_remote_automation
from .host_attributes import ExcludeIPRange, HostAttributes, IPRange, NetworkScanResult
from .host_attributes import (
ExcludeIPRange,
HostAttributeRegistry,
HostAttributes,
IPRange,
NetworkScanResult,
)
from .hosts_and_folders import Folder, folder_tree, Host, update_metadata

NetworkScanFoundHosts = list[tuple[HostName, HostAddress]]
Expand Down Expand Up @@ -191,6 +199,23 @@ def execute(self, api_request: NetworkScanRequest) -> list[tuple[HostName, HostA
return _do_network_scan(folder)


def register(
host_attribute_registry: HostAttributeRegistry,
automation_command_registry: AutomationCommandRegistry,
cron_job_registry: CronJobRegistry,
) -> None:
host_attribute_registry.register(builtin_attributes.HostAttributeNetworkScan)
host_attribute_registry.register(builtin_attributes.HostAttributeNetworkScanResult)
automation_command_registry.register(AutomationNetworkScan)
cron_job_registry.register(
CronJob(
name="execute_network_scan_job",
callable=execute_network_scan_job,
interval=timedelta(minutes=1),
)
)


# This is executed in the site the host is assigned to.
def _do_network_scan(folder: Folder) -> list[tuple[HostName, HostAddress]]:
ip_addresses = _ip_addresses_to_scan(folder)
Expand Down
11 changes: 0 additions & 11 deletions cmk/gui/watolib/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@
MatchItemGeneratorHosts,
rebuild_folder_lookup_cache,
)
from .network_scan import AutomationNetworkScan, execute_network_scan_job
from .notifications import (
find_timeperiod_usage_in_notification_rules,
find_usages_of_contact_group_in_notification_rules,
Expand Down Expand Up @@ -153,7 +152,6 @@ def register(
automation_command_registry.register(AutomationRemoveTLSRegistration)
automation_command_registry.register(AutomationCheckAnalyzeConfig)
automation_command_registry.register(AutomationDiscoveredHostLabelSync)
automation_command_registry.register(AutomationNetworkScan)
automation_command_registry.register(AutomationCheckmkAutomationStart)
automation_command_registry.register(AutomationCheckmkAutomationGetStatus)
sample_config_generator_registry.register(ConfigGeneratorBasicWATOConfig)
Expand Down Expand Up @@ -226,8 +224,6 @@ def _register_host_attribute(host_attribute_registry: HostAttributeRegistry) ->
builtin_attributes.HostAttributeAdditionalIPv6Addresses,
builtin_attributes.HostAttributeSNMPCommunity,
builtin_attributes.HostAttributeParents,
builtin_attributes.HostAttributeNetworkScan,
builtin_attributes.HostAttributeNetworkScanResult,
builtin_attributes.HostAttributeManagementAddress,
builtin_attributes.HostAttributeManagementProtocol,
builtin_attributes.HostAttributeManagementSNMPCommunity,
Expand Down Expand Up @@ -267,13 +263,6 @@ def _register_cronjobs(cron_job_registry: CronJobRegistry) -> None:
run_in_thread=True,
)
)
cron_job_registry.register(
CronJob(
name="execute_network_scan_job",
callable=execute_network_scan_job,
interval=timedelta(minutes=1),
)
)
cron_job_registry.register(
CronJob(
name="rebuild_folder_lookup_cache",
Expand Down

0 comments on commit 6b6f5ab

Please sign in to comment.