Module: check_mk
Branch: master
Commit: 931573fe707348e8c9048abe45903a4c84648428
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=931573fe707348…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Mar 14 08:21:22 2019 +0100
Changed initial WATO tag config to be in new format
Change-Id: I3bd1b0daccd06f24389c57ffdadb8e3abe073628
---
cmk/gui/watolib/__init__.py | 58 +++++++++++++++++++++--------
tests/unit/cmk/gui/watolib/test_tags.py | 66 +++++++++++++++++++++++++++++++++
2 files changed, 109 insertions(+), 15 deletions(-)
diff --git a/cmk/gui/watolib/__init__.py b/cmk/gui/watolib/__init__.py
index 5dc3e93..bc35b05 100644
--- a/cmk/gui/watolib/__init__.py
+++ b/cmk/gui/watolib/__init__.py
@@ -512,22 +512,50 @@ def _create_sample_config():
def _initialize_tag_config():
- tag_config = cmk.gui.tags.TagConfig().parse_config((
- [
- ('criticality', u'Criticality', [
- ('prod', u'Productive system', []),
- ('critical', u'Business critical', []),
- ('test', u'Test system', []),
- ('offline', u'Do not monitor this host', []),
- ]),
- ('networking', u'Networking Segment', [
- ('lan', u'Local network (low latency)', []),
- ('wan', u'WAN (high latency)', []),
- ('dmz', u'DMZ (low latency, secure access)', []),
- ]),
+ tag_config = cmk.gui.tags.TagConfig()
+ tag_config.parse_config({
+ 'aux_tags': [],
+ 'tag_groups': [
+ {
+ 'id': 'criticality',
+ 'tags': [{
+ 'aux_tags': [],
+ 'id': 'prod',
+ 'title': u'Productive system'
+ }, {
+ 'aux_tags': [],
+ 'id': 'critical',
+ 'title': u'Business critical'
+ }, {
+ 'aux_tags': [],
+ 'id': 'test',
+ 'title': u'Test system'
+ }, {
+ 'aux_tags': [],
+ 'id': 'offline',
+ 'title': u'Do not monitor this host'
+ }],
+ 'title': u'Criticality'
+ },
+ {
+ 'id': 'networking',
+ 'tags': [{
+ 'aux_tags': [],
+ 'id': 'lan',
+ 'title': u'Local network (low latency)'
+ }, {
+ 'aux_tags': [],
+ 'id': 'wan',
+ 'title': u'WAN (high latency)'
+ }, {
+ 'aux_tags': [],
+ 'id': 'dmz',
+ 'title': u'DMZ (low latency, secure access)'
+ }],
+ 'title': u'Networking Segment'
+ },
],
- [],
- ))
+ })
TagConfigFile().save(tag_config.get_dict_format())
# Make sure the host tag attributes are immediately declared!
config.tags = tag_config
diff --git a/tests/unit/cmk/gui/watolib/test_tags.py
b/tests/unit/cmk/gui/watolib/test_tags.py
index cd86fb2..165564b 100644
--- a/tests/unit/cmk/gui/watolib/test_tags.py
+++ b/tests/unit/cmk/gui/watolib/test_tags.py
@@ -47,6 +47,72 @@ wato_aux_tags += [("bla", u"bläää")]
tags_mk.unlink() # pylint: disable=no-member
+def test_convert_pre_16_tags():
+ dict_config = cmk.gui.tags.transform_pre_16_tags(
+ [
+ ('criticality', u'Criticality', [
+ ('prod', u'Productive system', []),
+ ('critical', u'Business critical', []),
+ ('test', u'Test system', []),
+ ('offline', u'Do not monitor this host', []),
+ ]),
+ ('networking', u'Networking Segment', [
+ ('lan', u'Local network (low latency)', []),
+ ('wan', u'WAN (high latency)', []),
+ ('dmz', u'DMZ (low latency, secure access)', []),
+ ]),
+ ],
+ [("bla", u"blüb")],
+ )
+
+ assert dict_config == {
+ 'aux_tags': [{
+ 'id': 'bla',
+ 'title': u'bl\xfcb'
+ }],
+ 'tag_groups': [
+ {
+ 'id': 'criticality',
+ 'tags': [{
+ 'aux_tags': [],
+ 'id': 'prod',
+ 'title': u'Productive system'
+ }, {
+ 'aux_tags': [],
+ 'id': 'critical',
+ 'title': u'Business critical'
+ }, {
+ 'aux_tags': [],
+ 'id': 'test',
+ 'title': u'Test system'
+ }, {
+ 'aux_tags': [],
+ 'id': 'offline',
+ 'title': u'Do not monitor this host'
+ }],
+ 'title': u'Criticality'
+ },
+ {
+ 'id': 'networking',
+ 'tags': [{
+ 'aux_tags': [],
+ 'id': 'lan',
+ 'title': u'Local network (low latency)'
+ }, {
+ 'aux_tags': [],
+ 'id': 'wan',
+ 'title': u'WAN (high latency)'
+ }, {
+ 'aux_tags': [],
+ 'id': 'dmz',
+ 'title': u'DMZ (low latency, secure access)'
+ }],
+ 'title': u'Networking Segment'
+ },
+ ],
+ }
+
+
def test_tag_config():
cfg = tags.TagConfig()
assert cfg.tag_groups == []