I need some guidance on developing a custom acknowledge button in cmk gui to create a ticket in BMC/Remedy and acknowledge a host or service problem with the ticket number.
The feature should be migrated from a cmk 1.6 instance to a 2.3.0p42.cee.
It is working in cmk 1.6 and looks like this in the gui (Acknowledge with Ticket):
I put this into folder local/lib/python3/cmk/gui/plugins/views/commands/bmc_remedy_ack.py
#!/usr/bin/env python3
# -*- encoding: utf-8; py-indent-offset: 4 -*-
import suds, ssl
from suds.client import Client
import cmk.gui.views.command as commands
import time
import livestatus
from cmk.gui.log import logger
import cmk.gui.config as config
import cmk.gui.utils as utils
import cmk.gui.bi as bi
import cmk.gui.sites as sites
from cmk.gui.i18n import _, _l, _u, ungettext
from cmk.gui.htmllib.html import html
from cmk.gui.exceptions import MKUserError
from cmk.gui.valuespec import Age
from cmk.gui.utils.speaklater import LazyString
from typing import Any, Literal, Protocol
from cmk.gui.permissions import (
Permission,
PermissionSection,
PermissionRegistry,
PermissionSectionRegistry,
)
from cmk.gui.views.command import (
command_group_registry,
CommandGroup,
command_registry,
Command,
CommandActionResult,
PermissionSectionAction,
)
PermissionActionAcknowledgeWithTicket = Permission(
section=PermissionSectionAction,
name="acknowledge_inc",
title=_l("Acknowledge with Ticket"),
description=_l("Acknowledge with Ticket host and service problems and remove acknowledgements"),
defaults=["user", "admin"],
)
@command_registry.register
class CommandAcknowledgeWithTicket(commands.Command):
@property
def ident(self):
return "acknowledge_inc"
@property
def title(self):
return _("Acknowledge with Ticket")
@property
def confirm_title(self) -> str:
return _("Acknowledge problems?")
@property
def confirm_button(self) -> LazyString:
return _l("Yes, acknowledge")
@property
def cancel_button(self) -> LazyString:
return _l("No, discard")
@property
def deny_button(self) -> LazyString | None:
return _l("No, adjust settings")
@property
def deny_js_function(self) -> str | None:
return '() => cmk.page_menu.toggle_popup("popup_command_acknowledge")'
@property
def icon_name(self):
return "ack"
@property
def is_shortcut(self) -> bool:
return True
@property
def is_suggested(self) -> bool:
return True
@property
def permission(self) -> Permission:
return PermissionActionAcknowledgeWithTicket
@property
def group(self) -> type[CommandGroup]:
return CommandGroupAcknowledge
@property
def tables(self):
return ["host", "service", "aggr"]
def render(self, what):
submit_id = "_acknowledge"
html.open_div(class_="group buttons")
html.button(
submit_id,
_("Acknowledge INC"),
cssclass="hot disabled",
)
html.close_div()
# html.hr()
# html.button("_acknowledge_inc", _("Acknowledge INC"))
def _action(self, cmdtag: Literal["HOST", "SVC"], spec, row, row_index, num_rows) -> CommandActionResult:
if "aggr_tree" in row: # BI mode
.
.
.
.
The code will be executed, but there appears no additional ack command in gui.
In web.log there is no error. I have no idea what is missing here and how to get this working with cmk version 2.3 and also in 2.4 in the future.
Is something additional needed to get it working?
Should the file be in another location/folder?
Any hint is welcome ![]()
