Module: check_mk
Branch: master
Commit: 0a1e4b1e0a58a9f41ab8fb6c2aff531170162fae
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=0a1e4b1e0a58a9…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Feb 2 20:20:09 2018 +0100
Moved valuespec helper function dict_choices() to the related valuespecs
Change-Id: I7fd0ea56c0e70f65698356fc2ef45e31e0b1c2ee
---
web/htdocs/lib.py | 10 ----------
web/htdocs/valuespec.py | 10 ++++++++++
web/plugins/visuals/inventory.py | 2 +-
web/plugins/wato/check_parameters.py | 10 +++++-----
web/plugins/wato/inventory.py | 2 +-
5 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/web/htdocs/lib.py b/web/htdocs/lib.py
index 897c962..c1861de 100644
--- a/web/htdocs/lib.py
+++ b/web/htdocs/lib.py
@@ -749,13 +749,3 @@ def file_size_human_readable(file_size):
as_string = as_string[:-3]
result = as_string + result
return result
-
-# For usage in Dropdown choices an the like
-#
-# TODO: Move this functionality into the related value specs. We could simply
-# make them work with choices passed as dict types and then use this logic
-# to convert the dict to choices.
-def dict_choices(types):
- return [ (str(type_id), "%d - %s" % (type_id, type_name))
- for (type_id, type_name)
- in sorted(types.items()) ]
diff --git a/web/htdocs/valuespec.py b/web/htdocs/valuespec.py
index b5dd0f1..c2ba6e5 100644
--- a/web/htdocs/valuespec.py
+++ b/web/htdocs/valuespec.py
@@ -1555,6 +1555,8 @@ class DropdownChoice(ValueSpec):
result = []
if type(self._choices) == list:
result = self._choices
+ elif type(self._choices) == dict:
+ result = ListChoice.dict_choices(self._choices)
else:
result = self._choices()
@@ -1980,6 +1982,12 @@ class RadioChoice(DropdownChoice):
# A list of checkboxes representing a list of values
class ListChoice(ValueSpec):
+ @staticmethod
+ def dict_choices(types):
+ return [ ("%s" % type_id, "%d - %s" % (type_id, type_name))
+ for (type_id, type_name) in sorted(types.items()) ]
+
+
def __init__(self, **kwargs):
ValueSpec.__init__(self, **kwargs)
self._choices = kwargs.get("choices")
@@ -1999,6 +2007,8 @@ class ListChoice(ValueSpec):
if self._choices != None:
if type(self._choices) == list:
self._elements = self._choices
+ elif type(self._choices) == dict:
+ self._elements = ListChoice.dict_choices(self._choices)
else:
self._elements = self._choices()
return
diff --git a/web/plugins/visuals/inventory.py b/web/plugins/visuals/inventory.py
index 7ed958c..45ae28d 100644
--- a/web/plugins/visuals/inventory.py
+++ b/web/plugins/visuals/inventory.py
@@ -266,7 +266,7 @@ class FilterInvtableInterfaceType(Filter):
def valuespec(self):
return DualListChoice(
- choices = dict_choices(defines.interface_port_types()),
+ choices = defines.interface_port_types(),
rows = 4,
enlarge_active = True,
custom_order = True)
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index c28d0f4..ab333ed 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -965,7 +965,7 @@ register_rule(group + '/' + subgroup_inventory,
"<tt>ifAdminStatus</tt> of <tt>down</tt> - a port administratively switched off. If you check this option "
"then an alternate version of the check is being used that fetches the <tt>ifAdminState</tt> in addition. "
"This will add about 5% of additional SNMP traffic."),
- choices = dict_choices(defines.interface_oper_states()),
+ choices = defines.interface_oper_states(),
toggle_all = True,
default_value = ['1'],
)),
@@ -973,7 +973,7 @@ register_rule(group + '/' + subgroup_inventory,
DualListChoice(title = _("Network interface port types to discover"),
help = _("When doing discovery on switches or other devices with network interfaces "
"then only ports of the specified types will be created services for."),
- choices = dict_choices(defines.interface_port_types()),
+ choices = defines.interface_port_types(),
custom_order = True,
rows = 40,
toggle_all = True,
@@ -7882,7 +7882,7 @@ register_check_parameters(
Optional(
ListChoice(
title = _("Allowed states:"),
- choices = dict_choices(defines.interface_oper_states())),
+ choices = defines.interface_oper_states()),
title = _("Operational state"),
help = _("If you activate the monitoring of the operational state (<tt>ifOperStatus</tt>) "
"the check will get warning or critical if the current state "
@@ -7898,7 +7898,7 @@ register_check_parameters(
Tuple(
orientation = "horizontal",
elements = [
- DropdownChoice(choices = dict_choices(defines.interface_oper_states())),
+ DropdownChoice(choices = defines.interface_oper_states()),
MonitoringState()
]),
title = _('Map operational states'),
@@ -11780,7 +11780,7 @@ vs_elements_if_groups_matches = [
("iftype", Transform(
DropdownChoice(
title = _("Select interface port type"),
- choices = dict_choices(defines.interface_port_types()),
+ choices = defines.interface_port_types(),
help = _("Only interfaces with the given port type are put into this group. "
"For example 53 (propVirtual)."),
), forth = lambda x: str(x),
diff --git a/web/plugins/wato/inventory.py b/web/plugins/wato/inventory.py
index b9644f9..d171245 100644
--- a/web/plugins/wato/inventory.py
+++ b/web/plugins/wato/inventory.py
@@ -153,7 +153,7 @@ register_rule(group,
( "usage_port_types",
DualListChoice(
title = _("Port types to include in usage statistics"),
- choices = dict_choices(defines.interface_port_types()),
+ choices = defines.interface_port_types(),
autoheight = False,
rows = 40,
enlarge_active = False,
Module: check_mk
Branch: master
Commit: a4fa67ababc49a7dd2ff06786c00de559c265906
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=a4fa67ababc49a…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Feb 2 14:54:44 2018 +0100
5719 FIX The Start URL is now configured optionally for new users
There is either a global defaukt start URL for fresh logged in users set
in Check_MK. It is either <tt>dashboard.py</tt> by default or customized
using the global settings. There is also a user attribute to customize
this setting for each user individually.
The idea of this setting was to set the start URL attribute only in case
one wanted to override the global setting. But the attribute was set to
<tt>dashboard.py</tt> during creation of each new user, since the attribute
was not an optional one. If one then tried to change the global setting
it had no effect on the users, because they had all the start URL set to
<tt>dashboard.py</tt> individually.
This option has been made optionally now. It defaults to
<i>Use the default start URL</i> for new users.
Change-Id: I3d6ff8069d430aa331d6a0dd767d4d72c0e0ef1b
---
.werks/5719 | 23 +++++++++++++++++++++++
web/plugins/userdb/user_attributes.py | 30 +++++++++++++++++++++++-------
web/plugins/wato/check_mk_configuration.py | 4 ++--
3 files changed, 48 insertions(+), 9 deletions(-)
diff --git a/.werks/5719 b/.werks/5719
new file mode 100644
index 0000000..c50b7ef
--- /dev/null
+++ b/.werks/5719
@@ -0,0 +1,23 @@
+Title: The Start URL is now configured optionally for new users
+Level: 1
+Component: wato
+Compatible: compat
+Edition: cre
+Version: 1.5.0i3
+Date: 1517579382
+Class: fix
+
+There is either a global defaukt start URL for fresh logged in users set
+in Check_MK. It is either <tt>dashboard.py</tt> by default or customized
+using the global settings. There is also a user attribute to customize
+this setting for each user individually.
+
+The idea of this setting was to set the start URL attribute only in case
+one wanted to override the global setting. But the attribute was set to
+<tt>dashboard.py</tt> during creation of each new user, since the attribute
+was not an optional one. If one then tried to change the global setting
+it had no effect on the users, because they had all the start URL set to
+<tt>dashboard.py</tt> individually.
+
+This option has been made optionally now. It defaults to
+<i>Use the default start URL</i> for new users.
diff --git a/web/plugins/userdb/user_attributes.py b/web/plugins/userdb/user_attributes.py
index da46cd9..039a7cc 100644
--- a/web/plugins/userdb/user_attributes.py
+++ b/web/plugins/userdb/user_attributes.py
@@ -82,11 +82,27 @@ declare_user_attribute(
declare_user_attribute(
"start_url",
- TextAscii(title = _("Start-URL to display in main frame"),
- help = _("When you point your browser to the Multisite GUI, usually the dashboard "
- "is shown in the main (right) frame. You can replace this with any other "
- "URL you like here."),
- size = 80,
- default_value = "dashboard.py",
- attrencode = True),
+ Transform(
+ Alternative(
+ title = _("Start URL to display in main frame"),
+ style = "dropdown",
+ orientation = "horizontal",
+ elements = [
+ FixedValue(None,
+ title = _("Use the default start URL"),
+ totext = "",
+ ),
+ TextAscii(
+ title = _("Use this custom start URL"),
+ help = _("When you point your browser to the Check_MK GUI, usually the dashboard "
+ "is shown in the main (right) frame. You can replace this with any other "
+ "URL you like here."),
+ size = 80,
+ default_value = "dashboard.py",
+ attrencode = True
+ ),
+ ],
+ ),
+ forth = lambda v: None if v == "" else v,
+ ),
domain = "multisite")
diff --git a/web/plugins/wato/check_mk_configuration.py b/web/plugins/wato/check_mk_configuration.py
index 2c849e2..468e61b 100644
--- a/web/plugins/wato/check_mk_configuration.py
+++ b/web/plugins/wato/check_mk_configuration.py
@@ -278,8 +278,8 @@ register_configvar(group,
register_configvar(group,
"start_url",
- TextAscii(title = _("Start-URL to display in main frame"),
- help = _("When you point your browser to the Multisite GUI, usually the dashboard "
+ TextAscii(title = _("Start URL to display in main frame"),
+ help = _("When you point your browser to the Check_MK GUI, usually the dashboard "
"is shown in the main (right) frame. You can replace this with any other "
"URL you like here."),
size = 80,
Module: check_mk
Branch: master
Commit: 094de0b28bbbc53966e5ba1579de263f4bcd29b0
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=094de0b28bbbc5…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Feb 1 21:28:43 2018 +0100
5718 FIX omd: Improved error handling when deleting site users
When deleting a Check_MK site, the whole site user including it's
home directory and group is removed. Previous versions were suppressing
errors occuring during deletion of the site user which could leave
the site user untouched including the site group which can only
be deleted when the user has been deleted.
The <tt>omd rm</tt> command will now fail with an error in case the
user can not be deleted and print out the reason for this issue. After
resolving it, you can then try to execute <tt>omd rm</tt> again.
Change-Id: I2fba84fbc625fc44cde679b785ebc85c4f8da702
---
.werks/5718 | 18 ++++++++++++++++++
omd/packages/omd/omd | 23 +++++++++++++++++++++--
2 files changed, 39 insertions(+), 2 deletions(-)
diff --git a/.werks/5718 b/.werks/5718
new file mode 100644
index 0000000..9cd5c93
--- /dev/null
+++ b/.werks/5718
@@ -0,0 +1,18 @@
+Title: omd: Improved error handling when deleting site users
+Level: 1
+Component: omd
+Compatible: compat
+Edition: cre
+Version: 1.5.0i3
+Date: 1517516618
+Class: fix
+
+When deleting a Check_MK site, the whole site user including it's
+home directory and group is removed. Previous versions were suppressing
+errors occuring during deletion of the site user which could leave
+the site user untouched including the site group which can only
+be deleted when the user has been deleted.
+
+The <tt>omd rm</tt> command will now fail with an error in case the
+user can not be deleted and print out the reason for this issue. After
+resolving it, you can then try to execute <tt>omd rm</tt> again.
diff --git a/omd/packages/omd/omd b/omd/packages/omd/omd
index d419094..60ae1fa 100644
--- a/omd/packages/omd/omd
+++ b/omd/packages/omd/omd
@@ -398,7 +398,16 @@ def find_processes_of_user(username):
return []
def groupdel(groupname):
- os.system("groupdel " + groupname)
+ try:
+ p = subprocess.Popen(["groupdel", groupname],
+ stdin=open(os.devnull, "r"), stdout=open(os.devnull, "w"),
+ stderr=subprocess.PIPE, close_fds=True)
+ except OSError, e:
+ bail_out("\n" + tty_error + ": Failed to delete user '%s': %s" % (groupname, e))
+
+ stderr = p.communicate()[1]
+ if p.returncode != 0:
+ bail_out("\n" + tty_error + ": Failed to delete user '%s': %s" % (groupname, stderr))
def groupadd(groupname, gid = None):
cmd = "groupadd "
@@ -434,7 +443,17 @@ def add_user_to_group(user, group):
return os.system(cmd + " >/dev/null") == 0
def userdel(name):
- os.system("userdel -r %s >/dev/null 2>&1" % name)
+ try:
+ p = subprocess.Popen(["userdel", "-r", name],
+ stdin=open(os.devnull, "r"), stdout=open(os.devnull, "w"),
+ stderr=subprocess.PIPE, close_fds=True)
+ except OSError, e:
+ bail_out("\n" + tty_error + ": Failed to delete user '%s': %s" % (name, e))
+
+ stderr = p.communicate()[1]
+ if p.returncode != 0:
+ bail_out("\n" + tty_error + ": Failed to delete user '%s': %s" % (name, stderr))
+
# On some OSes (e.g. debian) the group is automatically removed if
# it bears the same name as the user. So first check for the group.
if group_exists(name):