Inventory View Painters

With 1.6 there where huge changes inside the web page generation and also coming with this many extension programmed before are not working anymore.

Now I have one problem what I cannot solve completely by myself.
Own HW/SW inventory plugin also uses own painters to color some fields inside the HW/SW inventory table.

With 1.5 these painters where defined inside the same file as the display hints for the inventory table.
Now with 1.6 there is no chance to define these painters outside from ~/lib/python/cmk/gui/plugins/views/inventory.py

If someone wonders what such painters do.
image
Automatic coloring if the date is in the future or past.

@decorate_inv_paint
def inv_paint_date_status(date_string):

    warn_days = -90
    crit_days = -30

    #  check if date_sting not None, if so return no CSS Class and None
    if date_string is None:
        return '', ''

    try:
        days = int((time.time() - time.mktime(time.strptime(date_string, '%Y-%m-%d'))) / 86400)
    except ValueError:
        return '', date_string

    if days > crit_days:
        css_class = 'date_crit'
    elif days > warn_days:
        css_class = 'date_warn'
    else:
        css_class = 'date_default'

    return css_class, '%s' % date_string

If someone knows how to use painters now with 1.6 in combination with HW/SW inventory tables it would be nice to know :slight_smile:

Hi Andreas,

there are some changes in the class structure within check_mk. What you can try to do is, to move the code you need to your own file in local/share/check_mk/web/plugin/views to overwrite the class methode.
You need also to import the base classes.

Regards,
Christian

Own painters inside local/share/check_mk/web/plugin/views are ignored and not found at time of usage.
Also if all imports are correct.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.