Skip to content

Commit

Permalink
setup: addition of azure quick setup menu link
Browse files Browse the repository at this point in the history
Change-Id: I38a1730a0c6a804d56414e170becc12efe45fe2c
  • Loading branch information
anthonyh209 committed Oct 8, 2024
1 parent 32f9ca3 commit dc25d16
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 10 deletions.
69 changes: 60 additions & 9 deletions cmk/gui/quick_setup/_modes.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,13 @@
from cmk.gui.utils.html import HTML
from cmk.gui.utils.transaction_manager import transactions
from cmk.gui.utils.urls import make_confirm_delete_link
from cmk.gui.valuespec import Dictionary, DictionaryEntry, FixedValue, RuleComment, TextInput
from cmk.gui.valuespec import (
Dictionary,
DictionaryEntry,
FixedValue,
RuleComment,
TextInput,
)
from cmk.gui.wato._main_module_topics import MainModuleTopicQuickSetup
from cmk.gui.wato.pages.hosts import ModeEditHost
from cmk.gui.wato.pages.password_store import ModeEditPassword
Expand All @@ -54,11 +60,7 @@
valid_special_agent_bundle,
)
from cmk.gui.watolib.hosts_and_folders import folder_from_request, make_action_link
from cmk.gui.watolib.main_menu import (
ABCMainModule,
MainModuleRegistry,
MainModuleTopic,
)
from cmk.gui.watolib.main_menu import ABCMainModule, MainModuleRegistry, MainModuleTopic
from cmk.gui.watolib.mode import mode_url, ModeRegistry, redirect, WatoMode
from cmk.gui.watolib.rulespecs import rulespec_registry

Expand All @@ -68,6 +70,7 @@ def register(main_module_registry: MainModuleRegistry, mode_registry: ModeRegist
mode_registry.register(ModeEditConfigurationBundles)
mode_registry.register(ModeQuickSetupSpecialAgent)
main_module_registry.register(MainModuleQuickSetupAWS)
main_module_registry.register(MainModuleQuickSetupAzure)


class ModeQuickSetupSpecialAgent(WatoMode):
Expand Down Expand Up @@ -198,7 +201,8 @@ def page_menu(self, breadcrumb: Breadcrumb) -> PageMenu:
icon_name="new",
item=make_simple_link(
mode_url(
ModeQuickSetupSpecialAgent.name(), varname=self._name
ModeQuickSetupSpecialAgent.name(),
varname=self._name,
)
),
is_shortcut=True,
Expand Down Expand Up @@ -392,6 +396,47 @@ def megamenu_search_terms(cls) -> Sequence[str]:
return ["aws"]


class MainModuleQuickSetupAzure(ABCMainModule):
@property
def mode_or_url(self) -> str:
return mode_url(
ModeEditConfigurationBundles.name(),
varname=RuleGroup.SpecialAgents("azure"),
)

@property
def topic(self) -> MainModuleTopic:
return MainModuleTopicQuickSetup

@property
def title(self) -> str:
return _("Microsoft Azure")

@property
def icon(self) -> Icon:
return "quick_setup_azure"

@property
def permission(self) -> None | str:
return None

@property
def description(self) -> str:
return _("Configure Microsoft Azure monitoring in Checkmk")

@property
def sort_index(self) -> int:
return 11

@property
def is_show_more(self) -> bool:
return False

@classmethod
def megamenu_search_terms(cls) -> Sequence[str]:
return ["azure"]


class EditDCDConnection(Protocol):
def __init__(self) -> None: ...

Expand Down Expand Up @@ -503,7 +548,10 @@ def _configuration_vs(bundle_id: str) -> Dictionary:
elements: Sequence[DictionaryEntry] = [
("_name", TextInput(title=_("Name"), size=80)),
("_comment", RuleComment()),
("_bundle_id", FixedValue(title=_("Configuration bundle ID"), value=bundle_id)),
(
"_bundle_id",
FixedValue(title=_("Configuration bundle ID"), value=bundle_id),
),
]
return Dictionary(
title=_("Configuration bundle properties"),
Expand Down Expand Up @@ -535,7 +583,10 @@ def _sub_page_host(self) -> None:

def _sub_page_dcd_connection(self) -> None:
if any(edit_dcd_connection for edit_dcd_connection in self._edit_dcd_connections):
html.h1(_("Dynamic host management"), class_=["edit_configuration_bundle_header"])
html.h1(
_("Dynamic host management"),
class_=["edit_configuration_bundle_header"],
)
for index, edit_dcd_connection in enumerate(self._edit_dcd_connections):
if edit_dcd_connection:
edit_dcd_connection.page(f"edit_dcd_{index}")
Expand Down
5 changes: 4 additions & 1 deletion tests/unit/cmk/gui/wato/test_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,10 @@ def expected_items() -> dict[str, list[str]]:
],
"hosts": hosts_items,
"maintenance": maintenance_items,
"quick_setups": ["wato.py?mode=edit_configuration_bundles&varname=special_agents%3Aaws"],
"quick_setups": [
"wato.py?mode=edit_configuration_bundles&varname=special_agents%3Aaws",
"wato.py?mode=edit_configuration_bundles&varname=special_agents%3Aazure",
],
"services": [
"wato.py?group=monconf&mode=rulesets",
"wato.py?group=checkparams&mode=rulesets",
Expand Down

0 comments on commit dc25d16

Please sign in to comment.