[node-patches] Change in ovirt-node[master]: make src/ovirt/node/ package use the new Config.persist

asegurap at redhat.com asegurap at redhat.com
Mon Jun 23 10:58:34 UTC 2014


Antoni Segura Puimedon has uploaded a new change for review.

Change subject: make src/ovirt/node/ package use the new Config.persist
......................................................................

make src/ovirt/node/ package use the new Config.persist

ovirt_store_config is part of the old and deprecated ovirtnode
package. This patch removes the direct usage of it by substituting
its usages with the recently added Config.persist that has symlink
support.

Change-Id: I4b153524496e278e97cb7e0a6f88392d5aad26ba
Signed-off-by: Antoni S. Puimedon <asegurap at redhat.com>
---
M src/ovirt/node/config/defaults.py
M src/ovirt/node/setup/rhn/rhn_model.py
2 files changed, 27 insertions(+), 28 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/55/29055/1

diff --git a/src/ovirt/node/config/defaults.py b/src/ovirt/node/config/defaults.py
index 11a9e10..ddaa81d 100644
--- a/src/ovirt/node/config/defaults.py
+++ b/src/ovirt/node/config/defaults.py
@@ -23,7 +23,7 @@
 from ovirt.node.exceptions import InvalidData
 from ovirt.node.utils import storage, process, fs, AugeasWrapper, console, \
     system, firewall
-from ovirt.node.utils.fs import ShellVarFile, File
+from ovirt.node.utils.fs import Config, ShellVarFile, File
 from ovirt.node.utils.network import NIC, Bridges, Bonds
 from ovirt.node.utils.system import Bootloader
 import glob
@@ -985,10 +985,9 @@
             def commit(self):
                 # pylint: disable-msg=E0611
                 from ovirt_config_setup import collectd  # @UnresolvedImport
-                from ovirtnode.ovirtfunctions import ovirt_store_config
                 # pylint: enable-msg=E0611
                 if collectd.write_collectd_config(server, port):
-                    ovirt_store_config("/etc/collectd.conf")
+                    Config().persist("/etc/collectd.conf")
                     self.logger.debug("Collectd was configured successfully")
                 else:
                     raise exceptions.TransactionError("Failed to configure " +
@@ -1117,7 +1116,6 @@
 
             def commit(self):
                 import ovirtnode.kdump as okdump
-                from ovirtnode.ovirtfunctions import ovirt_store_config
 
                 okdump.write_kdump_config(ssh, "ssh")
 
@@ -1130,10 +1128,12 @@
                 try:
                     utils.process.check_call(cmd)
 
-                    ovirt_store_config(["/root/.ssh/kdump_id_rsa.pub",
-                                        "/root/.ssh/kdump_id_rsa",
-                                        "/root/.ssh/known_hosts",
-                                        "/root/.ssh/config"])
+                    conf = Config()
+                    for confpath in ("/root/.ssh/kdump_id_rsa.pub",
+                                     "/root/.ssh/kdump_id_rsa",
+                                     "/root/.ssh/known_hosts",
+                                     "/root/.ssh/config"):
+                        conf.persist(confpath)
                 except utils.process.CalledProcessError as e:
                     self.logger.warning("Failed to activate KDump with " +
                                         "SSH: %s" % e)
@@ -1162,8 +1162,7 @@
                 super(RestartKdumpService, self).__init__()
 
             def commit(self):
-                from ovirtnode.ovirtfunctions import unmount_config, \
-                    ovirt_store_config
+                from ovirtnode.ovirtfunctions import unmount_config
 
                 try:
                     system.service("kdump", "restart")
@@ -1177,7 +1176,7 @@
                                        "location unreachable. Previous " +
                                        "configuration was restored.")
 
-                ovirt_store_config("/etc/kdump.conf")
+                Config().persist("/etc/kdump.conf")
                 self.backups.remove()
 
         tx = utils.Transaction("Configuring kdump")
@@ -1357,21 +1356,19 @@
             title = "Setting logrotate maximum logfile size"
 
             def commit(self):
-                from ovirtnode.ovirtfunctions import ovirt_store_config
                 aug = utils.AugeasWrapper()
                 aug.set("/files/etc/logrotate.d/ovirt-node/rule/minsize",
                         max_size)
-                ovirt_store_config("/etc/logrotate.d/ovirt-node")
+                Config().persist("/etc/logrotate.d/ovirt-node")
 
         class SetLogrotateInterval(utils.Transaction.Element):
             title = "Setting logrotate interval"
 
             def commit(self):
-                from ovirtnode.ovirtfunctions import ovirt_store_config
                 aug = utils.AugeasWrapper()
                 aug.set("/files/etc/logrotate.d/ovirt-node/rule/schedule",
                         interval)
-                ovirt_store_config("/etc/logrotate.d/ovirt-node")
+                Config().persist("/etc/logrotate.d/ovirt-node")
 
         tx = utils.Transaction("Configuring logrotate")
 
@@ -1406,11 +1403,11 @@
             title = "Setting keyboard layout"
 
             def commit(self):
-                from ovirtnode.ovirtfunctions import ovirt_store_config
                 kbd = utils.system.Keyboard()
                 kbd.set_layout(layout)
-                ovirt_store_config("/etc/vconsole.conf")
-                ovirt_store_config("/etc/sysconfig/keyboard")
+                conf = Config()
+                conf.persist("/etc/vconsole.conf")
+                conf.persist("/etc/sysconfig/keyboard")
 
         tx = utils.Transaction("Configuring keyboard layout")
         tx.append(CreateKeyboardConfig())
diff --git a/src/ovirt/node/setup/rhn/rhn_model.py b/src/ovirt/node/setup/rhn/rhn_model.py
index e0635cd..6361b4e 100644
--- a/src/ovirt/node/setup/rhn/rhn_model.py
+++ b/src/ovirt/node/setup/rhn/rhn_model.py
@@ -21,8 +21,8 @@
 from ovirt.node import utils
 from ovirt.node.config.defaults import NodeConfigFileSection
 from ovirt.node.utils import process
-from ovirtnode.ovirtfunctions import remove_config, ovirt_store_config, \
-    unmount_config
+from ovirt.node.utils.fs import Config
+from ovirtnode.ovirtfunctions import remove_config, unmount_config
 from urlparse import urlparse
 import sys
 import os.path
@@ -137,7 +137,7 @@
                             if os.stat(location).st_size > 0:
                                 args.append('--sslCACert')
                                 args.append(location)
-                                ovirt_store_config(location)
+                                Config().persist(location)
                             else:
                                 raise RuntimeError("Error Downloading \
                                                    CA cert!")
@@ -184,8 +184,9 @@
                 self.logger.debug(logged_args)
                 try:
                     subprocess.check_call(args)
-                    ovirt_store_config("/etc/sysconfig/rhn/up2date")
-                    ovirt_store_config("/etc/sysconfig/rhn/systemid")
+                    conf = Config()
+                    conf.persist("/etc/sysconfig/rhn/up2date")
+                    conf.persist("/etc/sysconfig/rhn/systemid")
                     self.logger.info("System %s sucessfully registered to %s" %
                                      (profilename, serverurl))
                     # sync profile if reregistering, fixes problem with
@@ -258,7 +259,7 @@
                         RHN().retrieveCert(cacert, location)
                     if os.path.isfile(location):
                         if os.stat(location).st_size > 0:
-                            ovirt_store_config(location)
+                            Config().persist(location)
                         else:
                             raise RuntimeError("Error Downloading CA cert!")
 
@@ -276,7 +277,7 @@
                     smconf.append('/etc/rhsm/ca/candlepin-local.pem')
                 try:
                     subprocess.check_call(smconf)
-                    ovirt_store_config("/etc/rhsm/rhsm.conf")
+                    Config().persist("/etc/rhsm/rhsm.conf")
                 except:
                     raise RuntimeError("Error updating subscription manager \
                                        configuration")
@@ -348,9 +349,10 @@
                     else:
                         raise RuntimeError("Registration Failed")
                 else:
-                    ovirt_store_config(rhsm_configs)
-                    ovirt_store_config("/etc/pki/consumer/key.pem")
-                    ovirt_store_config("/etc/pki/consumer/cert.pem")
+                    conf = Config()
+                    conf.persist(rhsm_configs)
+                    conf.persist("/etc/pki/consumer/key.pem")
+                    conf.persist("/etc/pki/consumer/cert.pem")
                     self.logger.info("System %s sucessfully registered \
                                       to %s" % (profilename, serverurl))
 


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4b153524496e278e97cb7e0a6f88392d5aad26ba
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: Antoni Segura Puimedon <asegurap at redhat.com>



More information about the node-patches mailing list