[node-patches] Change in ovirt-node[master]: kdump: Improve page
fabiand at fedoraproject.org
fabiand at fedoraproject.org
Tue Dec 11 20:09:33 UTC 2012
Fabian Deutsch has uploaded a new change for review.
Change subject: kdump: Improve page
......................................................................
kdump: Improve page
Change-Id: I8bc642f0327a783f6a1b1a568cea9e174f7d78f2
Signed-off-by: Fabian Deutsch <fabiand at fedoraproject.org>
---
M scripts/tui/src/ovirt/node/plugins/__init__.py
M scripts/tui/src/ovirt/node/plugins/example.py
M scripts/tui/src/ovirt/node/plugins/kdump.py
M scripts/tui/src/ovirt/node/plugins/ping.py
M scripts/tui/src/ovirt/node/tui.py
M scripts/tui/src/ovirt/node/widgets.py
6 files changed, 37 insertions(+), 39 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/79/9879/1
diff --git a/scripts/tui/src/ovirt/node/plugins/__init__.py b/scripts/tui/src/ovirt/node/plugins/__init__.py
index 6e0cdd4..4441b04 100644
--- a/scripts/tui/src/ovirt/node/plugins/__init__.py
+++ b/scripts/tui/src/ovirt/node/plugins/__init__.py
@@ -172,7 +172,7 @@
is_valid = False
return is_valid
- def on_merge(self, changes):
+ def on_merge(self, effective_changes):
"""Handles the changes and throws an Exception if something goes wrong
Needs to be implemented by any subclass
diff --git a/scripts/tui/src/ovirt/node/plugins/example.py b/scripts/tui/src/ovirt/node/plugins/example.py
index 4aabc8a..349d366 100644
--- a/scripts/tui/src/ovirt/node/plugins/example.py
+++ b/scripts/tui/src/ovirt/node/plugins/example.py
@@ -85,9 +85,9 @@
return True
- def on_merge(self, changes):
+ def on_merge(self, effective_changes):
"""Applies the changes to the plugins model, will do all required logic
"""
- LOGGER.debug("saving %s" % changes)
+ LOGGER.debug("saving %s" % effective_changes)
# Look for conflicts etc
- self._model.update(changes)
+ self._model.update(effective_changes)
diff --git a/scripts/tui/src/ovirt/node/plugins/kdump.py b/scripts/tui/src/ovirt/node/plugins/kdump.py
index aabe5a5..a4e1c12 100644
--- a/scripts/tui/src/ovirt/node/plugins/kdump.py
+++ b/scripts/tui/src/ovirt/node/plugins/kdump.py
@@ -45,8 +45,8 @@
"""
return {
"kdump.type": ovirt.node.valid.Options(dict(self._types).keys()),
- "kdump.ssh_location": ovirt.node.valid.Text(),
- "kdump.nfs_location": ovirt.node.valid.Text(),
+ "kdump.ssh_location": ovirt.node.valid.NoSpaces(),
+ "kdump.nfs_location": ovirt.node.valid.NoSpaces(),
}
def ui_content(self):
@@ -62,11 +62,6 @@
# Save it "locally" as a dict, for better accessability
self._widgets = dict(widgets)
return widgets
-
- def ui_config(self):
- return {
- "save_button": False
- }
def on_change(self, changes):
"""Applies the changes to the plugins model, will do all required logic
@@ -84,23 +79,13 @@
self._model.update(changes)
- def on_merge(self, changes):
+ def on_merge(self, effective_changes):
"""Applies the changes to the plugins model, will do all required logic
Normally on_merge is called by pushing the SaveButton instance, in this
case it is called by on_change
"""
- if "ping.address" in self._model:
- addr = self._model["ping.address"]
- count = self._model["ping.count"]
- LOGGER.debug("Pinging %s" % addr)
-
- cmd = "ping"
- if ovirt.node.valid.IPv6Address().validate(addr):
- cmd = "ping6"
-
- cmd = "%s -c %s %s" % (cmd, count, addr)
- out = ""
- for line in ovirt.node.utils.pipe_async(cmd):
- out += line
- self._widgets["ping.result"].text("Result:\n\n%s" % out)
+ if effective_changes:
+ LOGGER.debug("Generating kdump.conf according to model and changes")
+ else:
+ LOGGER.debug("Generating no new kdump.conf as there are no changes")
diff --git a/scripts/tui/src/ovirt/node/plugins/ping.py b/scripts/tui/src/ovirt/node/plugins/ping.py
index d4fd6cf..6aff0dd 100644
--- a/scripts/tui/src/ovirt/node/plugins/ping.py
+++ b/scripts/tui/src/ovirt/node/plugins/ping.py
@@ -76,7 +76,7 @@
if "ping.do_ping" in changes:
self.on_merge(changes)
- def on_merge(self, changes):
+ def on_merge(self, effective_changes):
"""Applies the changes to the plugins model, will do all required logic
Normally on_merge is called by pushing the SaveButton instance, in this
case it is called by on_change
diff --git a/scripts/tui/src/ovirt/node/tui.py b/scripts/tui/src/ovirt/node/tui.py
index 8cfc11c..67b5391 100644
--- a/scripts/tui/src/ovirt/node/tui.py
+++ b/scripts/tui/src/ovirt/node/tui.py
@@ -33,8 +33,9 @@
('main.menu', 'black', ''),
('main.menu.frame', 'light gray', ''),
('plugin.widget.entry', 'dark gray', ''),
- ('plugin.widget.entry.frame', 'light gray', ''),
('plugin.widget.entry.disabled', 'dark gray', 'light gray'),
+ ('plugin.widget.entry.frame', 'light gray', ''),
+ ('plugin.widget.entry.frame.invalid', 'dark red', ''),
('plugin.widget.notice', 'light red', ''),
('plugin.widget.header', 'light blue', 'light gray'),
('plugin.widget.divider', 'dark gray', ''),
@@ -106,6 +107,7 @@
plugin.validate(path, new_value)
plugin._on_ui_change({path: new_value})
widget.notice = ""
+ widget.valid(True)
plugin.__save_button.enable(True)
except ovirt.node.plugins.Concern as e:
@@ -114,7 +116,11 @@
except ovirt.node.plugins.InvalidData as e:
LOGGER.error("Invalid data when updating: %s" % e)
widget.notice = e.message
+ widget.valid(False)
plugin.__save_button.enable(False)
+
+ # FIXME page validation must happen within tui, not plugin
+ # as UI data should be handled in tui
self.__loop.draw_screen()
urwid.connect_signal(widget, 'change', on_widget_value_change)
@@ -173,12 +179,13 @@
widget = self.__build_widget_for_item(plugin, path, item)
widgets.append(("flow", widget))
+ # Always create the SaveButton, but only display it if requested
+ # FIXME introduce a widget for the plugin page
+ save = ovirt.node.widgets.Button("Save")
+ urwid.connect_signal(save, 'click', lambda x: plugin._on_ui_save())
+ plugin.__save_button = save
if config["save_button"]:
- save = ovirt.node.widgets.Button("Save")
- save.enable(False)
- urwid.connect_signal(save, 'click', lambda x: plugin._on_ui_save())
widgets.append(urwid.Filler(save))
- plugin.__save_button = save
widgets.append(urwid.Filler(urwid.Text("")))
diff --git a/scripts/tui/src/ovirt/node/widgets.py b/scripts/tui/src/ovirt/node/widgets.py
index 2a01c82..3254f19 100644
--- a/scripts/tui/src/ovirt/node/widgets.py
+++ b/scripts/tui/src/ovirt/node/widgets.py
@@ -159,12 +159,16 @@
def enable(self, is_enabled):
self.selectable = lambda: is_enabled
- if is_enabled:
- self._edit_attrmap.set_attr_map({None: ""})
- else:
- self._edit_attrmap.set_attr_map({
- None: "plugin.widget.entry.disabled"
- })
+ attr_map = {None: "plugin.widget.entry"}
+ if not is_enabled:
+ attr_map = {None: "plugin.widget.entry.disabled"}
+ self._edit_attrmap.set_attr_map(attr_map)
+
+ def valid(self, is_valid):
+ attr_map = {None: "plugin.widget.entry.frame"}
+ if not is_valid:
+ attr_map = {None: "plugin.widget.entry.frame.invalid"}
+ self._linebox_attrmap.set_attr_map(attr_map)
def __init__(self, label, value=None, mask=None):
self._label = urwid.Text("\n" + label + ":")
@@ -251,7 +255,9 @@
widget.set_state(True)
self._buttons.append(widget)
self._columns = urwid.Columns(self._buttons)
- super(Options, self).__init__(self._columns)
+ self._pile = urwid.Pile([urwid.Divider(), self._columns,
+ urwid.Divider()])
+ super(Options, self).__init__(self._pile)
def _on_state_change(self, widget, new_state):
if new_state:
--
To view, visit http://gerrit.ovirt.org/9879
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I8bc642f0327a783f6a1b1a568cea9e174f7d78f2
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: Fabian Deutsch <fabiand at fedoraproject.org>
More information about the node-patches
mailing list