[node-patches] Change in ovirt-node[master]: Add a confirmation page

rbarry at redhat.com rbarry at redhat.com
Fri Apr 25 16:02:00 UTC 2014


Ryan Barry has uploaded a new change for review.

Change subject: Add a confirmation page
......................................................................

Add a confirmation page

Confirm storage selections before the install proceeds, and
try to warn users if the disk is part of a storage domain
(by looking for an LVM tag)

Change-Id: If0c099fbfbfda9bc609a024964905ee59e04280f
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1062515
Signed-off-by: Ryan Barry <rbarry at redhat.com>
---
M src/Makefile.am
A src/ovirt/node/installer/core/confirmation_page.py
2 files changed, 142 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/74/27074/1

diff --git a/src/Makefile.am b/src/Makefile.am
index 959ac23..c8d1579 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -137,6 +137,7 @@
 pyovirt_node_installer_core_PYTHON = \
   ovirt/node/installer/core/__init__.py \
   ovirt/node/installer/core/boot_device_page.py \
+  ovirt/node/installer/core/confirmation_page.py \
   ovirt/node/installer/core/installation_device_page.py \
   ovirt/node/installer/core/keyboard_page.py \
   ovirt/node/installer/core/password_page.py \
diff --git a/src/ovirt/node/installer/core/confirmation_page.py b/src/ovirt/node/installer/core/confirmation_page.py
new file mode 100644
index 0000000..e3453cd
--- /dev/null
+++ b/src/ovirt/node/installer/core/confirmation_page.py
@@ -0,0 +1,141 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+#
+# storage_vol_page.py - Copyright (C) 2014 Red Hat, Inc.
+# Written by Ryan Barry <rbarry at redhat.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA  02110-1301, USA.  A copy of the GNU General Public License is
+# also available at http://www.gnu.org/copyleft/gpl.html.
+
+"""
+Confirmation page of the installer
+"""
+from ovirt.node import plugins, ui
+from ovirt.node.installer.core.boot_device_page import StorageDiscovery
+from ovirt.node.utils import process
+
+
+class Plugin(plugins.NodePlugin):
+    _model = {}
+
+    def __init__(self, app):
+        super(Plugin, self).__init__(app)
+        self.storage_discovery = StorageDiscovery(app.args.dry)
+        self.storage_discovery.start()
+        self._header = "{!s:8.8} {!s:48.48} {!s:9.9}"
+        self._tagged_pvs = [x.split()[0] for x in
+                            process.check_output(["lvm", "vgs",
+                                                  "--noheadings",
+                                                  "-o", "pv_name_tags"]).split(
+                                "\n") if "storage_domain" in x]
+
+    def name(self):
+        return "Confirm disk selections"
+
+    def rank(self):
+        return 45
+
+    def model(self):
+        # Force rebuilding in case they go back and change a value
+        self._build_model()
+
+        return self._model
+
+    def validators(self):
+        return {}
+
+    def ui_content(self):
+        align = lambda l: l.ljust(16)
+        if not self._model:
+            self._build_model()
+
+        ws = [ui.Header("header[0]", _("Confirm disk selections")),
+              ui.Header("boot.header", _("Boot device")),
+              DiskDetails("boot.device", self,
+                          self._model["boot.device.current"])]
+
+        if self._model["boot.device.current"] in self._tagged_pvs:
+            ws.extend([ui.Notice("boot.notice", _("Boot device may be part "
+                                                  "of a storage domain!"))])
+
+        ws.extend([ui.Header("install.header", "Install devices")])
+
+        for i in range(len(self._model["installation.devices"])):
+            ws.extend([DiskDetails("installation.device[%s]" % i, self,
+                                   self._model["installation.devices"][i])])
+            if self._model["installation.devices"][i] in self._tagged_pvs:
+                ws.extend([ui.Notice("installation.notice[%s]" % i,
+                                     _("This device may be part of a storage "
+                                       "domain!"))])
+
+        ws.extend([ui.Header("storage.volumes", _("Volume sizes (MB)"))])
+
+        for x in self._model.keys():
+            if x.startswith("storage."):
+                ws.extend([ui.KeywordLabel(x, _(align(
+                    x.replace("_", " ").replace("storage.", "").title() + ":"))
+                    )])
+
+        page = ui.Page("confirmation", ws)
+        page.buttons = [ui.QuitButton("button.quit", _("Quit")),
+                        ui.Button("button.back", _("Back")),
+                        ui.SaveButton("button.next", _("Confirm"))]
+
+        self.widgets.add(page)
+        return page
+
+    def on_change(self, changes):
+        pass
+
+    def on_merge(self, effective_changes):
+        changes = self.pending_changes(False)
+        if changes.contains_any(["button.back"]):
+            self.application.ui.navigate.to_previous_plugin()
+        elif changes.contains_any(["button.next"]):
+            self.application.ui.navigate.to_next_plugin()
+
+    def _build_model(self):
+        _model = {}
+
+        [_model.update(plugin.model()) for plugin in
+         self.application.plugins().values() if not
+         plugin.name() == "Confirm selections"]
+
+        _model["installation.devices"].sort()
+
+        self._model = _model
+
+
+class DiskDetails(ui.Label):
+    """Display basic disk information"""
+
+    def __init__(self, path, plugin, dev):
+        super(DiskDetails, self).__init__(path, "")
+        self._plugin = plugin
+        self.get_details(dev)
+
+    def get_details(self, dev):
+        all_devices = self._plugin.storage_discovery.all_devices()
+        device = all_devices[dev]
+
+        txt = self._plugin._header.format(device.bus, device.name,
+                                          "%sGB" % device.size)
+
+        self.text(txt)
+
+    def value(self, value=None):
+        if value:
+            self.get_details(value)
+        return value


-- 
To view, visit http://gerrit.ovirt.org/27074
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If0c099fbfbfda9bc609a024964905ee59e04280f
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: Ryan Barry <rbarry at redhat.com>



More information about the node-patches mailing list