[node-patches] Change in ovirt-node[master]: Get serial console working on Fedora and add TUI configuration

rbarry at redhat.com rbarry at redhat.com
Mon Aug 12 16:52:44 UTC 2013


Ryan Barry has uploaded a new change for review.

Change subject: Get serial console working on Fedora and add TUI configuration
......................................................................

Get serial console working on Fedora and add TUI configuration

Previously, the serial console options for the installer did not
work as ovirt-firstboot explicitly used TTY1. Change it to use
/dev/console instead, and present TUI options for users to set
the console path.

Change-Id: Id99623830b56b77815196c8b0d153c86d3704f00
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=966302
Signed-off-by: Ryan Barry <rbarry at redhat.com>
---
M scripts/ovirt-init-functions.sh.in
M services/ovirt-firstboot.service
M src/ovirt/node/setup/core/status_page.py
3 files changed, 94 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/82/17982/1

diff --git a/scripts/ovirt-init-functions.sh.in b/scripts/ovirt-init-functions.sh.in
index 4e555d8..f5ace9d 100644
--- a/scripts/ovirt-init-functions.sh.in
+++ b/scripts/ovirt-init-functions.sh.in
@@ -689,6 +689,9 @@
             crashkernel=*)
             bootparams="$bootparams $i"
             ;;
+            console=*)
+            bootparams="$bootparams $i"
+            ;;
             kdump_nfs=*)
             kdump_nfs=${i#kdump_nfs=}
             ;;
diff --git a/services/ovirt-firstboot.service b/services/ovirt-firstboot.service
index 51d6787..f0f31be 100644
--- a/services/ovirt-firstboot.service
+++ b/services/ovirt-firstboot.service
@@ -15,7 +15,7 @@
 StandardInput=tty-force
 StandardOutput=inherit
 StandardError=inherit
-TTYPath=/dev/tty1
+TTYPath=/dev/console
 
 [Install]
 WantedBy=multi-user.target
diff --git a/src/ovirt/node/setup/core/status_page.py b/src/ovirt/node/setup/core/status_page.py
index 2fdef7a..2e0919b 100644
--- a/src/ovirt/node/setup/core/status_page.py
+++ b/src/ovirt/node/setup/core/status_page.py
@@ -18,7 +18,7 @@
 # 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.
-from ovirt.node import ui, plugins, utils
+from ovirt.node import exceptions, ui, plugins, utils
 from ovirt.node.config import defaults
 from ovirt.node.utils import security, virt, system
 from ovirt.node.utils.network import IPAddress
@@ -37,7 +37,8 @@
     There are no validators, as there is no input.
     """
 
-    _model = None
+    _model = {}
+    _extra_model = {}
 
     def name(self):
         return "Status"
@@ -55,13 +56,16 @@
 
         num_domains = virt.number_of_domains()
 
-        return {
+        model = {
             "status": virt.hardware_status(),
             "networking": net_status,
             "networking.bridge": "%s %s" % (net_br, net_addrs_str),
             "logs": self._logging_summary(),
             "libvirt.num_guests": num_domains,
         }
+
+        model.update(self._extra_model)
+        return model
 
     def validators(self):
         return {}
@@ -107,6 +111,7 @@
                           [ui.Button("action.hostkey", "View Host Key"),
                            ui.Button("action.cpu_details",
                                      "View CPU Details"),
+                           ui.Button("action.console", "Set Console Path"),
                            ]),
 
                    ui.Row("row[2]", action_widgets),
@@ -119,7 +124,11 @@
         return page
 
     def on_change(self, changes):
-        pass
+        if "console.path" in changes:
+            if "console.path" is not "" and not os.path.exists(
+                            "/dev/%s" % changes["console.path"].split(',')[0]):
+                raise exceptions.InvalidData("Console path must be a valid"
+                                             "device or empty")
 
     def on_merge(self, changes):
         # Handle button presses
@@ -178,6 +187,18 @@
             self.logger.info("Showing CPU details")
             return CPUFeaturesDialog("dialog.cpu_details", "CPU Details")
 
+        elif "action.console" in changes:
+            self.logger.info("Showing Console details")
+            self._consoledialog = ConsoleDialog(self, "dialog.console",
+                                                "Console Details")
+            return self._consoledialog
+
+        elif "dialog.console.save" in changes:
+            self.logger.info("Saving Console Details")
+            if "console.path" in changes:
+                self._consoledialog._console(changes["console.path"])
+            self._consoledialog.close()
+
         elif "_save" in changes:
             self.widgets["dialog.hostkey"].close()
 
@@ -229,6 +250,71 @@
         super(CPUFeaturesDialog, self).__init__(path, title, msg)
 
 
+class ConsoleDialog(ui.Dialog):
+    def __init__(self, plugin, path, title):
+        self.plugin = plugin
+        super(ConsoleDialog, self).__init__(path, title, [])
+        self.plugin._extra_model.update({"console.path": self._console()})
+        self.plugin.model()
+        self.children= [ui.Entry("console.path", "Console path:")]
+
+    def __find_grub_cfg(self):
+        from ovirtnode import ovirtfunctions
+        import os
+
+        cfg_path = ""
+
+        if ovirtfunctions.findfs("Boot"):
+            cfg_path = "/boot/grub/grub.conf"
+        elif os.path.ismount("/dev/.initramfs/live"):
+            if not ovirtfunctions.grub2_available():
+                cfg_path = "/dev/.initramfs/live/grub/grub.conf"
+            else:
+                cfg_path = "/dev/.initramfs/live/grub2/grub.cfg"
+        elif os.path.ismount("/run/initramfs/.live"):
+            cfg_path = "/liveos/grub/grub.conf"
+
+        cfg_path = "/boot/grub/grub.conf"
+
+        return cfg_path
+
+    def _console(self, console_path=None):
+        import re
+        import fileinput
+        grub_path = self.__find_grub_cfg()
+        f = open(grub_path, "r")
+        lines = f.readlines()
+        f.close()
+        if not console_path:
+            kernel = [line for line in lines if re.match(r'.*?vmlinuz',
+                                                         line)][0]
+            try:
+                return re.match(r'.*?console=(.*?)\s.*', kernel).groups()[0]
+            except:
+                self.logger.debug("SET EXC %s" % kernel)
+                return ""
+        else:
+            utils.process.check_call("mount -o rw,remount %s" %
+                                     self.__find_mount(grub_path), shell=True)
+            f = open(grub_path, "w")
+
+            for line in lines:
+                if re.match(r'.*?console=.*', line):
+                    line = re.sub(r'console=.*?\s', '', line)
+                if re.match(r'^.*?vmlinuz', line):
+                    if not console_path == "":
+                        line = line.strip() + " console=%s\n" % console_path
+                f.write(line)
+
+            utils.process.check_call("mount -o ro,remount %s" %
+                                     self.find_mount(grub_path), shell=True)
+
+    def __find_mount(self, path):
+        while not os.path.ismount(path):
+            path = os.path.dirname(path)
+        return path
+
+
 class LockDialog(ui.Dialog):
     """The dialog beeing displayed when the srceen is locked
     """


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id99623830b56b77815196c8b0d153c86d3704f00
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