[node-patches] Change in ovirt-node[master]: Make netconsole able to be disabled

rbarry at redhat.com rbarry at redhat.com
Thu Apr 10 16:34:13 UTC 2014


Ryan Barry has uploaded a new change for review.

Change subject: Make netconsole able to be disabled
......................................................................

Make netconsole able to be disabled

Previously, we weren't able to unset netconsole parameters, since
augeas cannot reliably comment files, and setting values to None
put netconsole in a bad state. Resolve this.

Change-Id: I54f3c2123408462d20f7df3366933160d9a4fc28
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1051434
Signed-off-by: Ryan Barry <rbarry at redhat.com>
---
M src/ovirt/node/config/defaults.py
M src/ovirtnode/log.py
2 files changed, 27 insertions(+), 14 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/88/26688/1

diff --git a/src/ovirt/node/config/defaults.py b/src/ovirt/node/config/defaults.py
index 42d1a0f..92d88ef 100644
--- a/src/ovirt/node/config/defaults.py
+++ b/src/ovirt/node/config/defaults.py
@@ -1266,16 +1266,38 @@
         server, port = (cfg["server"], cfg["port"])
 
         class CreateNetconsoleConfig(utils.Transaction.Element):
-            title = "Setting netconsole server and port"
+            if server and port:
+                title = "Setting netconsole server and port"
+            else:
+                title = "Disabling netconsole"
 
             def commit(self):
-                import ovirtnode.log as olog
-                olog.ovirt_netconsole(server, port)
+                Netconsole().configure_netconsole(server, port)
 
         tx = utils.Transaction("Configuring netconsole")
         tx.append(CreateNetconsoleConfig())
         return tx
 
+    def configure_netconsole(self, server, port):
+        from ovirtnode.ovirtfunctions import ovirt_store_config
+        aug = utils.AugeasWrapper()
+        if server and port:
+            aug.set("/files/etc/sysconfig/netconsole/SYSLOGADDR", server)
+            aug.set("/files/etc/sysconfig/netconsole/SYSLOGPORT", port)
+            try:
+                system.service("netconsole", "restart")
+            except:
+                raise RuntimeError("Failed to restart netconsole "
+                                   "service. Is the host resolvable?")
+        else:
+            self.logger.info("Disabling netconsole")
+            utils.process.check_call("sed -i -e '/SYSLOGADDR/d' "
+                                      "-e '/SYSLOGPORT/d' "
+                                      "/etc/sysconfig/netconsole",
+                                      shell=True)
+        if ovirt_store_config("/etc/sysconfig/netconsole"):
+            self.logger.info("Netconsole Configuration Updated")
+
 
 class Logrotate(NodeConfigFileSection):
     """Configure logrotate
diff --git a/src/ovirtnode/log.py b/src/ovirtnode/log.py
index 22c1124..8656fa0 100755
--- a/src/ovirtnode/log.py
+++ b/src/ovirtnode/log.py
@@ -23,6 +23,7 @@
 import logging
 import ovirtnode.ovirtfunctions as _functions
 from ovirt.node.utils import system
+from ovirt.node.config.defaults import Netconsole
 
 logger = logging.getLogger(__name__)
 
@@ -105,17 +106,7 @@
 
 
 def ovirt_netconsole(server, port):
-    _functions.augtool("set", \
-                       "/files/etc/sysconfig/netconsole/SYSLOGADDR", server)
-    _functions.augtool("set", \
-                       "/files/etc/sysconfig/netconsole/SYSLOGPORT", port)
-    try:
-        system.service("netconsole", "restart")
-    except:
-        raise RuntimeError("Failed to restart netconsole service. "
-                           "Is the host resolvable?")
-    if _functions.ovirt_store_config("/etc/sysconfig/netconsole"):
-        logger.info("Netconsole Configuration Updated")
+    Netconsole().configure_netconsole(server, port)
     return True
 
 


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

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