diff --git a/inv_cisco_support.mkp b/inv_cisco_support.mkp index a96518aba99b6e0f98df55f25f215e457596d702..9601232b11de5d64a013a4c50a567d4fd0d458e4 100644 Binary files a/inv_cisco_support.mkp and b/inv_cisco_support.mkp differ diff --git a/inventory/snmp_cisco_bug b/inventory/snmp_cisco_bug index 624679f2e8a9604836522cde95dfd450c23f2375..fff058f59b78d2b9710aedf0086e842d370d1db6 100644 --- a/inventory/snmp_cisco_bug +++ b/inventory/snmp_cisco_bug @@ -69,6 +69,21 @@ def inv_cisco_bug(info, params): return version, pid + def get_bug_status(bug_status): + _bug_status = { + 'F': 'Fixed', + 'O': 'Open', + 'T': 'Terminated' + } + return _bug_status.get(bug_status, bug_status) + + def get_bug_behavior_changed(behavior_changed): + _behavior_changed = { + 'Y': 'yes', + 'N': 'no', + } + return _behavior_changed.get(behavior_changed, behavior_changed) + set_loglevel() # disable_bug = False @@ -159,6 +174,8 @@ def inv_cisco_bug(info, params): bug_ids.append(bug.get('bug_id')) #bug['known_fixed_releases'] = bug['known_fixed_releases'].split(' ') #bug['known_affected_releases'] = bug['known_affected_releases'].split(' ') + bug['status'] = get_bug_status(bug['status']) + bug['behavior_changed'] = get_bug_behavior_changed(bug['behavior_changed']) logging.info('remove columns: %s' % optionalcolumns) if optionalcolumns is not None: for column in optionalcolumns: diff --git a/inventory/snmp_cisco_suggestion b/inventory/snmp_cisco_suggestion index 3d570d679408fc1c1470d44c452d5316043e6d7b..b0e8b537601dcf23bd47601d7961774c51657661 100644 --- a/inventory/snmp_cisco_suggestion +++ b/inventory/snmp_cisco_suggestion @@ -124,6 +124,9 @@ def create_suggested_record(pidfile, optionalcolumns): def inv_cisco_suggestion(info, params): + # disabled till display hints will work with tables in tables :-( + # ToDo: recreate rendering of tables in tables + return set_loglevel() # list of PIDs to drop diff --git a/lib/nagios/plugins/cisco_api_status b/lib/nagios/plugins/cisco_api_status index bec335c7e8bbf82f80cd2b7844e58c752a790884..b5323bbac4001f87ef9865cc4439ad9d6a4425c2 100755 --- a/lib/nagios/plugins/cisco_api_status +++ b/lib/nagios/plugins/cisco_api_status @@ -1,13 +1,11 @@ #!/usr/bin/python # encoding: utf-8 + +# Monitor Cisco API plugins for CheckMK +# Author: thl-cmk[al]outlook[dot]com # -# License: GNU General Public License v2 -# -# Author: thl-cmk[at]outlook[dot]com -# URL : https://thl-cmk.hopto.org -# -# 2020-03-15: changed getopt to argparse # +# 15.03.2020: changed getopt to argparse import os import argparse @@ -461,4 +459,5 @@ def main(): sys.stdout.write(output + '\n' + long_output) sys.exit(status) -main() \ No newline at end of file +main() + diff --git a/packages/inv_cisco_support b/packages/inv_cisco_support index 64bf31ca0a5b24fd091b618b4225647a463f8190..94b1cae590e0891b0824de9d7c071ef0bc828c06 100644 --- a/packages/inv_cisco_support +++ b/packages/inv_cisco_support @@ -28,6 +28,7 @@ 'name': 'inv_cisco_support', 'num_files': 24, 'title': u'Inventory for Cisco Bug, EoX, contract status, PSIRT advisories and suggested software', - 'version': '20190830.v0.0.11', - 'version.min_required': '1.4.0p1', - 'version.packaged': '1.4.0p38'} \ No newline at end of file + 'version': '20200810.v0.0.12', + 'version.min_required': '1.6.0', + 'version.packaged': '1.6.0p12', + 'version.usable_until': None} \ No newline at end of file diff --git a/web/plugins/views/inv_cisco_support.py b/web/plugins/views/inv_cisco_support.py index b41a89004c7ba348903bea5b7027c7deb10160f5..5f64ef90018be2c725648b68d08a2d782ce5b978 100644 --- a/web/plugins/views/inv_cisco_support.py +++ b/web/plugins/views/inv_cisco_support.py @@ -14,9 +14,79 @@ # (https://bst.cloudapps.cisco.com/bugsearch/bug/CSCuh91645) # -import random +# import random # needed for quickinfo tables +import time + +from cmk.gui.plugins.views.inventory import ( + declare_invtable_view, + decorate_inv_paint, +) +from cmk.gui.plugins.visuals.inventory import ( + FilterInvtableText, +) +from cmk.gui.i18n import _ +# +# ToDo: move painters to local tree +# painters are at the moment hard coded in lib/python/cmk/gui/plugins/views/inventory.py +# +# from cmk.gui.plugins.views.inventory import ( +# declare_invtable_view, +# decorate_inv_paint, +# ) +# +# import time +# +# from cmk.utils.regex import regex +# import cmk.utils.defines as defines +# import cmk.utils.render +# +# import cmk.gui.pages +# import cmk.gui.config as config +# import cmk.gui.sites as sites +# import cmk.gui.inventory as inventory +# from cmk.gui.i18n import _ +# from cmk.gui.globals import html, current_app +# from cmk.gui.htmllib import HTML +# from cmk.gui.valuespec import Dictionary, Checkbox, Hostname +# from cmk.gui.exceptions import MKUserError +# +# from cmk.gui.plugins.visuals import ( +# filter_registry, +# VisualInfo, +# visual_info_registry, +# ) +# from cmk.gui.plugins.visuals.inventory import ( +# FilterInvText, +# FilterInvBool, +# FilterInvFloat, +# FilterInvtableText, +# FilterInvtableIDRange, +# ) +# +# from cmk.gui.plugins.views import ( +# data_source_registry, +# DataSource, +# RowTable, +# painter_registry, +# Painter, +# register_painter, +# register_sorter, +# display_options, +# painter_option_registry, +# PainterOption, +# PainterOptions, +# inventory_displayhints, +# multisite_builtin_views, +# view_is_enabled, +# paint_age, +# declare_1to1_sorter, +# cmp_simple_number, +# render_labels, +# ) + +@decorate_inv_paint def inv_paint_date_status(date_string): warn_days = -90 @@ -41,39 +111,32 @@ def inv_paint_date_status(date_string): return css_class, '%s' % date_string +@decorate_inv_paint def inv_paint_last_checked_status(date_string): - warn_days = 32 crit_days = 40 - - # check if date_sting not None, if so return no CSS Class and None if date_string is None: return '', '' - - # check if _date_string in the right format, if not return CSS Class and date_string try: days = int((time.time() - time.mktime(time.strptime(date_string, '%Y-%m-%d'))) / 86400) except ValueError: return '', date_string - - # last_checked is ok if days <= warn_days: css_class = '' - # no refresh for far to long elif days >= crit_days: css_class = 'date_crit' - # no refresh for to long else: css_class = 'date_warn' - # css_class = '' return css_class, ' %s' % date_string +@decorate_inv_paint def inv_paint_psirt_advisoryId(advisoryId): psirt_url = '<a class="href_blue" target="_blank" href="https://tools.cisco.com/security/center/content/CiscoSecurityAdvisory/%s">%s</a>' % (advisoryId, advisoryId) return '', psirt_url +@decorate_inv_paint def inv_paint_eox_eolid(eolid): if eolid is not None: search_eolid_url = '<a class="href_blue" target="_blank" href="https://search.cisco.com/search?query=%s">%s</a>' % (eolid, eolid) @@ -82,259 +145,258 @@ def inv_paint_eox_eolid(eolid): return '', search_eolid_url -def render_inv_dicttable_suggestion_noqf(hostname, tree_id, invpath, node): - # In delta mode node is a pair of (old_items, new_items) - if type(node) == tuple: - html.write(_("Removed entries") + ":") - html.write("<span class=invold>") - render_inv_dicttable_suggestion_noqf(hostname, tree_id, invpath, node[0]) - html.write("</span>") - - html.write(_("New entries") + ":") - html.write("<span class=invnew>") - render_inv_dicttable_suggestion_noqf(hostname, tree_id, invpath, node[1]) - html.write("</span>") - return - - hint = inv_display_hint(invpath) - keyorder = hint.get("keyorder", []) # well known keys - - # Add titles for those keys - titles = [] - for key in keyorder: - invpath_sub = invpath + "0." + key - icon, title = inv_titleinfo(invpath_sub, None) - sub_hint = inv_display_hint(invpath_sub) - short_title = sub_hint.get("short", title) - titles.append((short_title, key)) - - # Determine *all* keys, in order to find unknown ones - keys = set([]) - for entry in node: - keys.update(entry.keys()) - - # Order not well-known keys alphabetically - extratitles = [] - for key in keys: - if key not in keyorder: - icon, title = inv_titleinfo(invpath + "0." + key, None) - extratitles.append((title, key)) - extratitles.sort() - titles += extratitles - - # Link to Multisite view with exactly this table - if "view" in hint: - url = html.makeuri_contextless([ - ("view_name", hint["view"] ), - ("host", hostname)], - filename="view.py") - html.write('<div class=invtablelink><a href="%s">%s</a></div>' % - (url, _("Open this table for filtering / sorting"))) - - # We cannot use table here, since html.plug() does not work recursively - html.write('<table class=data>') - html.write('<tr>') - for title, key in titles: - html.write('<th>%s</th>' % title) - html.write('</tr>') - - for nr, entry in enumerate(node): - html.write('<tr class=even0>') - for title, key in titles: - value = entry.get(key) - invpath_sub = invpath + "%d.%s" % (nr, key) - if type(value) == dict: - invpath_sub += "." - elif type(value) == list or (type(value) == tuple and type(value[0]) == list): - invpath_sub += ":" - - hint = inv_display_hint(invpath_sub) - if "paint_function" in hint: - td_class, text = hint["paint_function"](value) - classtext = ' class="%s"' % td_class - else: - classtext = "" - - html.write('<td%s>' % classtext) -# render_inv_subtree(hostname, tree_id, invpath_sub, value) - # render suggestions as not foldable - if key == 'suggestion' and type(value) == list: - render_inv_subtree_container(hostname, tree_id, invpath_sub, value) - else: - render_inv_subtree(hostname, tree_id, invpath_sub, value) - html.write('</td>') - html.write('</tr>') - html.write('</table>') - - -def render_inv_dicttable_suggestion(hostname, tree_id, invpath, node): - # In delta mode node is a pair of (old_items, new_items) - if type(node) == tuple: - html.write(_("Removed entries") + ":") - html.write("<span class=invold>") - render_inv_dicttable_suggestion(hostname, tree_id, invpath, node[0]) - html.write("</span>") - - html.write(_("New entries") + ":") - html.write("<span class=invnew>") - render_inv_dicttable_suggestion(hostname, tree_id, invpath, node[1]) - html.write("</span>") - return - - hint = inv_display_hint(invpath) - keyorder = hint.get("keyorder", []) # well known keys - - # Add titles for those keys - titles = [] - for key in keyorder: - invpath_sub = invpath + "0." + key - icon, title = inv_titleinfo(invpath_sub, None) - sub_hint = inv_display_hint(invpath_sub) - short_title = sub_hint.get("short", title) - titles.append((short_title, key)) - - # Determine *all* keys, in order to find unknown ones - keys = set([]) - for entry in node: - keys.update(entry.keys()) - - # Order not well-known keys alphabetically - extratitles = [] - for key in keys: - if key not in keyorder: - icon, title = inv_titleinfo(invpath + "0." + key, None) - extratitles.append((title, key)) - extratitles.sort() - titles += extratitles - - # Link to Multisite view with exactly this table - if "view" in hint: - url = html.makeuri_contextless([ - ("view_name", hint["view"] ), - ("host", hostname)], - filename="view.py") - html.write('<div class=invtablelink><a href="%s">%s</a></div>' % - (url, _("Open this table for filtering / sorting"))) - - # - # Th.L.: insert jscript for quickfilter - # - qfurl = html.makeuri([],filename="TableFilter/tablefilter.js", delvars=["host","selection","site","view_name"]) - html.write('<script language="javascript" type="text/javascript" src="%s"></script>' % qfurl) - - # Th.L.: create random table id - qf_table_id = "qf_id_" + "".join(random.SystemRandom().choice('ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789') for _ in range(10)) - - # We cannot use table here, since html.plug() does not work recursively - # html.write('<table class=data>') - html.write('<table id=%s class=data>' % qf_table_id) - # html.write('<tr>') - html.write('<thead><tr>') # Th.L.: added thead for quickfilter (sort) - for title, key in titles: - html.write('<th>%s</th>' % title) - #html.write('</tr>') - html.write('</tr></thead><tbody>') # Th.L.: added thead and tbody for quickfilter (sort) - - for nr, entry in enumerate(node): - html.write('<tr class=even0>') - for title, key in titles: - value = entry.get(key) - invpath_sub = invpath + "%d.%s" % (nr, key) - if type(value) == dict: - invpath_sub += "." - elif type(value) == list or (type(value) == tuple and type(value[0]) == list): - invpath_sub += ":" - - hint = inv_display_hint(invpath_sub) - if "paint_function" in hint: - td_class, text = hint["paint_function"](value) - classtext = ' class="%s"' % td_class - else: - classtext = "" - - html.write('<td%s>' % classtext) -# render_inv_subtree(hostname, tree_id, invpath_sub, value) - # render suggestions as not foldable - if key == 'suggestion' and type(value) == list: - render_inv_subtree_container(hostname, tree_id, invpath_sub, value) - else: - render_inv_subtree(hostname, tree_id, invpath_sub, value) - html.write('</td>') - html.write('</tr>') - #html.write('</table>') - html.write('</tbody></table>') # Th.L.: added tbody for quickfilter (sort) - - # - # Th.L.: add jscript for quickfilter - # - html.write('<script data-config>\n') - html.write(' var filtersConfig = {\n') - html.write(' base_path: "TableFilter/",\n') - html.write(' alternate_rows: true,\n') - html.write(' rows_counter: true,\n') - html.write(' btn_reset: true,\n') - html.write(' bnt_reset_text: "Clear all",\n') - html.write(' loader: true,\n') - html.write(' status_bar: true,\n') - html.write(' status_bar_text : "status:",\n') - html.write(' loader : true,\n') - html.write(' mark_active_columns: true,\n') - html.write(' highlight_keywords: true,\n') - html.write(' auto_filter: true,\n') - html.write(' auto_filter_delay: 100,\n') - html.write(' paging: true,\n') - html.write(' mark_active_columns: true,\n') - html.write(' results_per_page: [" Results per page",[10,25,50,100,250,500,1000]],\n') - html.write(' no_results_message: true,\n') - html.write(' extensions:[{ name: "sort"},\n') - html.write(' { name: "colsVisibility",\n') - html.write(' tick_to_hide: false,\n') - html.write(' at_start: [11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65],\n') - html.write(' text: "Displayed columns: ",\n') - html.write(' enable_tick_all: true,\n') - html.write(' btn_html: "<button>Columns manager ▼</button>",\n') - html.write(' btn_close_html: "<button>Close</button>",\n') - html.write(' enable_hover: false,\n') - html.write(' },\n') -# html.write(' {name: "filtersVisibility"} - html.write(' ]\n') - html.write(' };\n') - html.write('\n') - html.write(' var tf = new TableFilter("%s", filtersConfig);\n' % qf_table_id) - html.write(' tf.init();\n') - html.write('\n') - html.write('</script>\n') - - -def inv_paint_bug_status(bug_status): - _bug_status = { - 'F': 'Fixed', - 'O': 'Open', - 'T': 'Terminated' - } - return '', _bug_status.get(bug_status, bug_status) - - -def inv_paint_bug_behavior_changed(behavior_changed): - _behavior_changed = { - 'Y': 'yes', - 'N': 'no', - } - return '', _behavior_changed.get(behavior_changed, behavior_changed) - - +@decorate_inv_paint def inv_paint_bug_bugid(bugid): if bugid is not None: search_bugid_url = '<a class="href_blue" target="_blank" href="https://bst.cloudapps.cisco.com/bugsearch/bug/%s">%s</a>' % (bugid, bugid) else: - search_eolid_url = '' + search_bugid_url = '' return '', search_bugid_url +# def render_inv_dicttable_suggestion_noqf(hostname, tree_id, invpath, node): +# # In delta mode node is a pair of (old_items, new_items) +# if type(node) == tuple: +# html.write(_("Removed entries") + ":") +# html.write("<span class=invold>") +# render_inv_dicttable_suggestion_noqf(hostname, tree_id, invpath, node[0]) +# html.write("</span>") +# +# html.write(_("New entries") + ":") +# html.write("<span class=invnew>") +# render_inv_dicttable_suggestion_noqf(hostname, tree_id, invpath, node[1]) +# html.write("</span>") +# return +# +# hint = inv_display_hint(invpath) +# keyorder = hint.get("keyorder", []) # well known keys +# +# # Add titles for those keys +# titles = [] +# for key in keyorder: +# invpath_sub = invpath + "0." + key +# icon, title = inv_titleinfo(invpath_sub, None) +# sub_hint = inv_display_hint(invpath_sub) +# short_title = sub_hint.get("short", title) +# titles.append((short_title, key)) +# +# # Determine *all* keys, in order to find unknown ones +# keys = set([]) +# for entry in node: +# keys.update(entry.keys()) +# +# # Order not well-known keys alphabetically +# extratitles = [] +# for key in keys: +# if key not in keyorder: +# icon, title = inv_titleinfo(invpath + "0." + key, None) +# extratitles.append((title, key)) +# extratitles.sort() +# titles += extratitles +# +# # Link to Multisite view with exactly this table +# if "view" in hint: +# url = html.makeuri_contextless([ +# ("view_name", hint["view"] ), +# ("host", hostname)], +# filename="view.py") +# html.write('<div class=invtablelink><a href="%s">%s</a></div>' % +# (url, _("Open this table for filtering / sorting"))) +# +# # We cannot use table here, since html.plug() does not work recursively +# html.write('<table class=data>') +# html.write('<tr>') +# for title, key in titles: +# html.write('<th>%s</th>' % title) +# html.write('</tr>') +# +# for nr, entry in enumerate(node): +# html.write('<tr class=even0>') +# for title, key in titles: +# value = entry.get(key) +# invpath_sub = invpath + "%d.%s" % (nr, key) +# if type(value) == dict: +# invpath_sub += "." +# elif type(value) == list or (type(value) == tuple and type(value[0]) == list): +# invpath_sub += ":" +# +# hint = inv_display_hint(invpath_sub) +# if "paint_function" in hint: +# td_class, text = hint["paint_function"](value) +# classtext = ' class="%s"' % td_class +# else: +# classtext = "" +# +# html.write('<td%s>' % classtext) +# # render_inv_subtree(hostname, tree_id, invpath_sub, value) +# # render suggestions as not foldable +# if key == 'suggestion' and type(value) == list: +# render_inv_subtree_container(hostname, tree_id, invpath_sub, value) +# else: +# render_inv_subtree(hostname, tree_id, invpath_sub, value) +# html.write('</td>') +# html.write('</tr>') +# html.write('</table>') +# +# +# def render_inv_dicttable_suggestion(hostname, tree_id, invpath, node): +# # In delta mode node is a pair of (old_items, new_items) +# if type(node) == tuple: +# html.write(_("Removed entries") + ":") +# html.write("<span class=invold>") +# render_inv_dicttable_suggestion(hostname, tree_id, invpath, node[0]) +# html.write("</span>") +# +# html.write(_("New entries") + ":") +# html.write("<span class=invnew>") +# render_inv_dicttable_suggestion(hostname, tree_id, invpath, node[1]) +# html.write("</span>") +# return +# +# hint = inv_display_hint(invpath) +# keyorder = hint.get("keyorder", []) # well known keys +# +# # Add titles for those keys +# titles = [] +# for key in keyorder: +# invpath_sub = invpath + "0." + key +# icon, title = inv_titleinfo(invpath_sub, None) +# sub_hint = inv_display_hint(invpath_sub) +# short_title = sub_hint.get("short", title) +# titles.append((short_title, key)) +# +# # Determine *all* keys, in order to find unknown ones +# keys = set([]) +# for entry in node: +# keys.update(entry.keys()) +# +# # Order not well-known keys alphabetically +# extratitles = [] +# for key in keys: +# if key not in keyorder: +# icon, title = inv_titleinfo(invpath + "0." + key, None) +# extratitles.append((title, key)) +# extratitles.sort() +# titles += extratitles +# +# # Link to Multisite view with exactly this table +# if "view" in hint: +# url = html.makeuri_contextless([ +# ("view_name", hint["view"] ), +# ("host", hostname)], +# filename="view.py") +# html.write('<div class=invtablelink><a href="%s">%s</a></div>' % +# (url, _("Open this table for filtering / sorting"))) +# +# # +# # Th.L.: insert jscript for quickfilter +# # +# qfurl = html.makeuri([],filename="TableFilter/tablefilter.js", delvars=["host","selection","site","view_name"]) +# html.write('<script language="javascript" type="text/javascript" src="%s"></script>' % qfurl) +# +# # Th.L.: create random table id +# qf_table_id = "qf_id_" + "".join(random.SystemRandom().choice('ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789') for _ in range(10)) +# +# # We cannot use table here, since html.plug() does not work recursively +# # html.write('<table class=data>') +# html.write('<table id=%s class=data>' % qf_table_id) +# # html.write('<tr>') +# html.write('<thead><tr>') # Th.L.: added thead for quickfilter (sort) +# for title, key in titles: +# html.write('<th>%s</th>' % title) +# #html.write('</tr>') +# html.write('</tr></thead><tbody>') # Th.L.: added thead and tbody for quickfilter (sort) +# +# for nr, entry in enumerate(node): +# html.write('<tr class=even0>') +# for title, key in titles: +# value = entry.get(key) +# invpath_sub = invpath + "%d.%s" % (nr, key) +# if type(value) == dict: +# invpath_sub += "." +# elif type(value) == list or (type(value) == tuple and type(value[0]) == list): +# invpath_sub += ":" +# +# hint = inv_display_hint(invpath_sub) +# if "paint_function" in hint: +# td_class, text = hint["paint_function"](value) +# classtext = ' class="%s"' % td_class +# else: +# classtext = "" +# +# html.write('<td%s>' % classtext) +# # render_inv_subtree(hostname, tree_id, invpath_sub, value) +# # render suggestions as not foldable +# if key == 'suggestion' and type(value) == list: +# render_inv_subtree_container(hostname, tree_id, invpath_sub, value) +# else: +# render_inv_subtree(hostname, tree_id, invpath_sub, value) +# html.write('</td>') +# html.write('</tr>') +# #html.write('</table>') +# html.write('</tbody></table>') # Th.L.: added tbody for quickfilter (sort) +# +# # +# # Th.L.: add jscript for quickfilter +# # +# html.write('<script data-config>\n') +# html.write(' var filtersConfig = {\n') +# html.write(' base_path: "TableFilter/",\n') +# html.write(' alternate_rows: true,\n') +# html.write(' rows_counter: true,\n') +# html.write(' btn_reset: true,\n') +# html.write(' bnt_reset_text: "Clear all",\n') +# html.write(' loader: true,\n') +# html.write(' status_bar: true,\n') +# html.write(' status_bar_text : "status:",\n') +# html.write(' loader : true,\n') +# html.write(' mark_active_columns: true,\n') +# html.write(' highlight_keywords: true,\n') +# html.write(' auto_filter: true,\n') +# html.write(' auto_filter_delay: 100,\n') +# html.write(' paging: true,\n') +# html.write(' mark_active_columns: true,\n') +# html.write(' results_per_page: [" Results per page",[10,25,50,100,250,500,1000]],\n') +# html.write(' no_results_message: true,\n') +# html.write(' extensions:[{ name: "sort"},\n') +# html.write(' { name: "colsVisibility",\n') +# html.write(' tick_to_hide: false,\n') +# html.write(' at_start: [11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65],\n') +# html.write(' text: "Displayed columns: ",\n') +# html.write(' enable_tick_all: true,\n') +# html.write(' btn_html: "<button>Columns manager ▼</button>",\n') +# html.write(' btn_close_html: "<button>Close</button>",\n') +# html.write(' enable_hover: false,\n') +# html.write(' },\n') +# # html.write(' {name: "filtersVisibility"} +# html.write(' ]\n') +# html.write(' };\n') +# html.write('\n') +# html.write(' var tf = new TableFilter("%s", filtersConfig);\n' % qf_table_id) +# html.write(' tf.init();\n') +# html.write('\n') +# html.write('</script>\n') + + +# def inv_paint_bug_status(bug_status): +# _bug_status = { +# 'F': 'Fixed', +# 'O': 'Open', +# 'T': 'Terminated' +# } +# return '', _bug_status.get(bug_status, bug_status) +# +# +# def inv_paint_bug_behavior_changed(behavior_changed): +# _behavior_changed = { +# 'Y': 'yes', +# 'N': 'no', +# } +# return '', _behavior_changed.get(behavior_changed, behavior_changed) + +# EoX display hints inventory_displayhints.update({ - # EoX display hints '.hardware.support.cisco_eox:': {'title': _('Cisco EoX status'), - 'render': render_inv_dicttable, 'keyorder': ['pid', 'serial_number', 'ProductIDDescription', 'Last_checked', 'EOXExternalAnnouncementDate', 'EndOfSaleDate', 'LastDateOfSupport', 'EndOfSvcAttachDate', 'UpdatedTimeStamp', @@ -345,26 +407,26 @@ inventory_displayhints.update({ '.hardware.support.cisco_eox:*.pid': {'title': _('PID (EoX)'), }, '.hardware.support.cisco_eox:*.serial_number': {'title': _('Serial number'), }, '.hardware.support.cisco_eox:*.ProductIDDescription': {'title': _('Description'), }, - '.hardware.support.cisco_eox:*.EOXExternalAnnouncementDate': {'title': _('EOL Announcement'), 'paint': 'date_status', 'filter': visuals.FilterInvtableText, }, - '.hardware.support.cisco_eox:*.EndOfSaleDate': {'title': _('End of sale'), 'paint': 'date_status', 'filter': visuals.FilterInvtableText, }, - '.hardware.support.cisco_eox:*.EndOfSvcAttachDate': {'title': _('End of service attachment'), 'paint': 'date_status', 'filter': visuals.FilterInvtableText, }, - '.hardware.support.cisco_eox:*.LastDateOfSupport': {'title': _('End of support'), 'paint': 'date_status', 'filter': visuals.FilterInvtableText, }, - '.hardware.support.cisco_eox:*.ProductBulletinNumber': {'title': _('EOL bulletin ID'), 'paint': 'eox_eolid', 'filter': visuals.FilterInvtableText, }, + '.hardware.support.cisco_eox:*.EOXExternalAnnouncementDate': {'title': _('EOL Announcement'), 'filter': FilterInvtableText, 'paint': 'date_status',}, + '.hardware.support.cisco_eox:*.EndOfSaleDate': {'title': _('End of sale'), 'filter': FilterInvtableText, 'paint': 'date_status',}, + '.hardware.support.cisco_eox:*.EndOfSvcAttachDate': {'title': _('End of service attachment'), 'filter': FilterInvtableText, 'paint': 'date_status',}, + '.hardware.support.cisco_eox:*.LastDateOfSupport': {'title': _('End of support'), 'filter': FilterInvtableText, 'paint': 'date_status',}, + '.hardware.support.cisco_eox:*.ProductBulletinNumber': {'title': _('EOL bulletin ID'), 'filter': FilterInvtableText, 'paint': 'eox_eolid', }, '.hardware.support.cisco_eox:*.LinkToProductBulletinURL': {'title': _('EOL bulletin URL'), }, '.hardware.support.cisco_eox:*.UpdatedTimeStamp': {'title': _('EOL bulletin last update'), }, - '.hardware.support.cisco_eox:*.EndOfSecurityVulSupportDate': {'title': _('End of service vulnerability support'), 'paint': 'date_status', 'filter': visuals.FilterInvtableText, }, - '.hardware.support.cisco_eox:*.EndOfSWMaintenanceReleases': {'title': _('End of software maintenace releases'), 'paint': 'date_status', 'filter': visuals.FilterInvtableText, }, - '.hardware.support.cisco_eox:*.EndOfRoutineFailureAnalysisDate': {'title': _('End of routine failure analysis'), 'paint': 'date_status', 'filter': visuals.FilterInvtableText, }, + '.hardware.support.cisco_eox:*.EndOfSecurityVulSupportDate': {'title': _('End of service vulnerability support'), 'filter': FilterInvtableText, 'paint': 'date_status',}, + '.hardware.support.cisco_eox:*.EndOfSWMaintenanceReleases': {'title': _('End of software maintenace releases'), 'filter': FilterInvtableText, 'paint': 'date_status',}, + '.hardware.support.cisco_eox:*.EndOfRoutineFailureAnalysisDate': {'title': _('End of routine failure analysis'), 'filter': FilterInvtableText, 'paint': 'date_status',}, '.hardware.support.cisco_eox:*.MigrationProductId': {'title': _('Migration PID'), }, '.hardware.support.cisco_eox:*.MigrationInformation': {'title': _('Migration information'), }, '.hardware.support.cisco_eox:*.MigrationProductInfoURL': {'title': _('Migration PID URL'), }, '.hardware.support.cisco_eox:*.MigrationProductName': {'title': _('Migration product name'), }, - '.hardware.support.cisco_eox:*.Last_checked': {'title': _('Last checked'), 'paint': 'last_checked_status', 'filter': visuals.FilterInvtableText, }, - + '.hardware.support.cisco_eox:*.Last_checked': {'title': _('Last checked'), 'filter': FilterInvtableText, 'paint': 'last_checked_status',}, +}) - # SN2Info (contract) display hints +# SN2Info (contract) display hints +inventory_displayhints.update({ '.hardware.support.cisco_contract:': {'title': _('Cisco contract status'), - 'render': render_inv_dicttable, 'keyorder': ['pid', 'serial_number', 'ProductIDDescription', 'Last_checked', 'is_covered', 'service_contract_number', 'covered_product_line_end_date', @@ -374,7 +436,7 @@ inventory_displayhints.update({ '.hardware.support.cisco_contract:*.pid': {'title': _('PID (contract)'), }, '.hardware.support.cisco_contract:*.serial_number': {'title': _('Serial number'), }, '.hardware.support.cisco_contract:*.ProductIDDescription': {'title': _('Description'), }, - '.hardware.support.cisco_contract:*.Last_checked': {'title': _('Last checked'), 'paint': 'last_checked_status', 'filter': visuals.FilterInvtableText,}, + '.hardware.support.cisco_contract:*.Last_checked': {'title': _('Last checked'), 'filter': FilterInvtableText, 'paint': 'last_checked_status',}, '.hardware.support.cisco_contract:*.is_covered': {'title': _('is covered'), }, '.hardware.support.cisco_contract:*.contract_site_customer_name': {'title': _('Customer name'), }, '.hardware.support.cisco_contract:*.contract_site_address1': {'title': _('Address'), }, @@ -383,52 +445,52 @@ inventory_displayhints.update({ '.hardware.support.cisco_contract:*.contract_site_country': {'title': _('Country'), }, '.hardware.support.cisco_contract:*.service_line_descr': {'title': _('Service description'), }, '.hardware.support.cisco_contract:*.service_contract_number': {'title': _('Contract number'), }, - '.hardware.support.cisco_contract:*.covered_product_line_end_date': {'title': _('Contract end date'), 'paint': 'date_status', 'filter': visuals.FilterInvtableText,}, + '.hardware.support.cisco_contract:*.covered_product_line_end_date': {'title': _('Contract end date'), 'filter': FilterInvtableText, 'paint': 'date_status',}, '.hardware.support.cisco_contract:*.parent_sr_no': {'title': _('Parent S/N'), }, '.hardware.support.cisco_contract:*.warranty_type': {'title': _('Warranty type'), }, '.hardware.support.cisco_contract:*.warranty_type_description': {'title': _('Warranty Description'), }, '.hardware.support.cisco_contract:*.warranty_end_date': {'title': _('Warranty end date'), }, +}) - - # BUG display hints +# BUG display hints +inventory_displayhints.update({ '.software.support.cisco_bug.Total_records': {'title': _('Records total'), }, '.software.support.cisco_bug.duplicate_records': {'title': _('Records duplicate'), }, '.software.support.cisco_bug.missing_records': {'title': _('Records missing'), }, '.software.support.cisco_bug.PID': {'title': _('PID'), }, '.software.support.cisco_bug.os_version': {'title': _('OS version'), }, '.software.support.cisco_bug.bugs:': {'title': _('Cisco BUG IDs'), - 'render': render_inv_dicttable, 'keyorder': ['bug_id', 'last_modified_date', 'headline', 'severity', 'status', 'support_case_count', 'behavior_changed', ], 'view': 'invciscobugs_of_host', }, - '.software.support.cisco_bug.bugs:*.status': {'title': _('Status'), 'paint': 'bug_status', 'filter': visuals.FilterInvtableText, }, + '.software.support.cisco_bug.bugs:*.status': {'title': _('Status'), 'filter': FilterInvtableText, }, '.software.support.cisco_bug.bugs:*.product': {'title': _('Product'), }, '.software.support.cisco_bug.bugs:*.description': {'title': _('Description'), }, '.software.support.cisco_bug.bugs:*.headline': {'title': _('Headline'), }, '.software.support.cisco_bug.bugs:*.support_case_count': {'title': _('Support case count'), }, '.software.support.cisco_bug.bugs:*.last_modified_date': {'title': _('Last modified date'), }, - '.software.support.cisco_bug.bugs:*.behavior_changed': {'title': _('Behavior changed'), 'paint': 'bug_behavior_changed', 'filter': visuals.FilterInvtableText, }, - '.software.support.cisco_bug.bugs:*.bug_id': {'title': _('Bug ID'), 'paint': 'bug_bugid', }, + '.software.support.cisco_bug.bugs:*.behavior_changed': {'title': _('Behavior changed'), 'filter': FilterInvtableText, }, + '.software.support.cisco_bug.bugs:*.bug_id': {'title': _('Bug ID'), 'paint': 'bug_bugid', }, # '.software.support.cisco_bug.bugs:*.base_pid': {'title': _('Base PID'), }, - '.software.support.cisco_bug.bugs:*.known_fixed_releases': {'title': _('Known fixed releases'), 'filter': visuals.FilterInvtableText, }, + '.software.support.cisco_bug.bugs:*.known_fixed_releases': {'title': _('Known fixed releases'), 'filter': FilterInvtableText, }, '.software.support.cisco_bug.bugs:*.id': {'title': _('ID'), }, '.software.support.cisco_bug.bugs:*.known_affected_releases': {'title': _('known affected releases'), }, '.software.support.cisco_bug.bugs:*.severity': {'title': _('Severity'), }, +}) - - # PSIRT display hints +# PSIRT display hints +inventory_displayhints.update({ '.software.support.cisco_psirt.dont_show_older_than': {'title': _('Don\'t show advisories not updated since'), }, '.software.support.cisco_psirt.dont_show_not_updated_since': {'title': _('Don\'t show advisories not updated for X days'), }, '.software.support.cisco_psirt.removed_advisories': {'title': _('Advisories removed'), }, '.software.support.cisco_psirt.advisories:': {'title': _('Cisco PSIRT advisories'), - 'render': render_inv_dicttable, 'keyorder': ['advisoryId', 'sir', 'cvssBaseScore', 'advisoryTitle', ], 'view': 'invciscopsirt_of_host', }, - '.software.support.cisco_psirt.advisories:*.advisoryId': {'title': _('Advisory ID'), 'paint': 'psirt_advisoryId', 'filter': visuals.FilterInvtableText, }, + '.software.support.cisco_psirt.advisories:*.advisoryId': {'title': _('Advisory ID'), 'filter': FilterInvtableText, 'paint': 'psirt_advisoryId',}, # '.software.support.cisco_psirt.advisories:*.advisoryTitle': {'title': _('Advisory Title'), }, - '.software.support.cisco_psirt.advisories:*.bugIDs': {'title': _('Bug IDs'), }, # 'paint': 'psirt_bugid', 'filter': visuals.FilterInvtableText, + '.software.support.cisco_psirt.advisories:*.bugIDs': {'title': _('Bug IDs'), 'filter': FilterInvtableText, }, # 'paint': 'psirt_bugid', '.software.support.cisco_psirt.advisories:*.cvssBaseScore': {'title': _('CVSS base Score'), }, '.software.support.cisco_psirt.advisories:*.firstFixed': {'title': _('First fixed in'), }, '.software.support.cisco_psirt.advisories:*.firstPublished': {'title': _('First Published'), }, @@ -444,26 +506,30 @@ inventory_displayhints.update({ '.software.support.cisco_psirt.advisories:*.cvrfUrl': {'title': _('CVRF URL'), }, '.software.support.cisco_psirt.advisories:*.ovalUrl': {'title': _('OVAL URL'), }, '.software.support.cisco_psirt.os_version': {'title': _('OS version'), }, - '.software.support.cisco_psirt.Last_checked': {'title': _('Last checked'), 'paint': 'last_checked_status', 'filter': visuals.FilterInvtableText,}, + '.software.support.cisco_psirt.Last_checked': {'title': _('Last checked'), 'filter': FilterInvtableText, 'paint': 'last_checked_status',}, # '.software.support.cisco_psirt.not_updated_for_x_days': {'title': _('don\'t show advisories not updated for X days'), }, '.software.support.cisco_psirt.dont_show_older_then': {'title': _('don\'t show advisories not updated after'), }, +}) - # SUGGESTION display hints +# SUGGESTION display hints +inventory_displayhints.update({ '.software.support.cisco_suggestion:': {'title': _('Cisco suggested software'), - 'render': render_inv_dicttable_suggestion, + # 'render': render_inv_dicttable_suggestion, 'keyorder': ['pid', 'ProductIDDescription', 'Last_checked', ], # 'view' : 'invciscosuggestion_of_host', }, '.software.support.cisco_suggestion:*.pid': {'title': _('PID (suggestion)'), }, '.software.support.cisco_suggestion:*.ProductIDDescription': {'title': _('Description'), }, - '.software.support.cisco_suggestion:*.Last_checked': {'title': _('Last checked'), 'paint': 'last_checked_status', 'filter': visuals.FilterInvtableText,}, + '.software.support.cisco_suggestion:*.Last_checked': {'title': _('Last checked'), 'filter': FilterInvtableText, 'paint': 'last_checked_status',}, # '.software.support.cisco_suggestion:*.suggestion': {'title': _('Suggestion(s)'), }, - '.software.support.cisco_suggestion:*.suggestion:': {'render': render_inv_dicttable_suggestion_noqf, 'keyorder': ['productName', 'softwareType']}, + # '.software.support.cisco_suggestion:*.suggestion:': {'render': render_inv_dicttable_suggestion_noqf, 'keyorder': ['productName', 'softwareType']}, + '.software.support.cisco_suggestion:*.suggestion:': {'keyorder': ['productName', 'softwareType']}, '.software.support.cisco_suggestion:*.suggestion:*.productName': {'title': _('Product name'), }, '.software.support.cisco_suggestion:*.suggestion:*.softwareType': {'title': _('Software type'), }, '.software.support.cisco_suggestion:*.suggestion:*.suggestion': {'title': _('Suggestion(s)'), }, - '.software.support.cisco_suggestion:*.suggestion:*.suggestion:': {'render': render_inv_dicttable_suggestion_noqf, 'keyorder': ['id', 'releaseFormat2', 'releaseDate']}, + # '.software.support.cisco_suggestion:*.suggestion:*.suggestion:': {'render': render_inv_dicttable_suggestion_noqf, 'keyorder': ['id', 'releaseFormat2', 'releaseDate']}, + '.software.support.cisco_suggestion:*.suggestion:*.suggestion:': {'keyorder': ['id', 'releaseFormat2', 'releaseDate']}, '.software.support.cisco_suggestion:*.suggestion:*.suggestion:*.id': {'title': _('ID'), }, '.software.support.cisco_suggestion:*.suggestion:*.suggestion:*.releaseDate': {'title': _('Release date'), }, '.software.support.cisco_suggestion:*.suggestion:*.suggestion:*.releaseFormat2': {'title': _('Version'), }, @@ -476,9 +542,9 @@ inventory_displayhints.update({ '.software.support.cisco_suggestion:*.suggestion:*.suggestion:*.trainDispName': {'title': _('train display name'), } }) - declare_invtable_view('invciscoeox', '.hardware.support.cisco_eox:', _('Cisco EoX status'), _('Cisco EoX status')) declare_invtable_view('invciscocontract', '.hardware.support.cisco_contract:', _('Cisco contract status'), _('Cisco contract status')) declare_invtable_view('invciscopsirt', '.software.support.cisco_psirt.advisories:', _('Cisco PSIRT advisories'), _('Cisco PSIRT advisories')) declare_invtable_view('invciscobugs', '.software.support.cisco_bug.bugs:', _('Cisco BUG IDs'), _('Cisco Bug IDs')) #declare_invtable_view('invciscosuggestion', '.software.support.cisco_suggestion:', _('Cisco suggested software'), _('Cisco suggested software')) +