[node-patches] Change in ovirt-node[master]: Use system.service() for service cim/snmp action

hadong0720 at gmail.com hadong0720 at gmail.com
Wed Jun 19 04:10:30 UTC 2013


hadong has uploaded a new change for review.

Change subject: Use system.service() for service cim/snmp action
......................................................................

Use system.service() for service cim/snmp action

Previously using process.call() for service cim/snmp
stop/start/restart.
Now using system.service() instead of process.call()

Change-Id: I15291be934c68d5c3f3b56d3bdb044244c415a58
Signed-off-by: hadong <hadong0720 at gmail.com>
---
M src/ovirt/node/setup/cim/cim_model.py
M src/ovirt/node/setup/snmp/snmp_model.py
2 files changed, 6 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/71/15871/1

diff --git a/src/ovirt/node/setup/cim/cim_model.py b/src/ovirt/node/setup/cim/cim_model.py
index 79a1cef..28073e0 100644
--- a/src/ovirt/node/setup/cim/cim_model.py
+++ b/src/ovirt/node/setup/cim/cim_model.py
@@ -21,7 +21,7 @@
 from ovirt.node import utils
 from ovirt.node.config.defaults import NodeConfigFileSection
 from ovirt.node.exceptions import TransactionError
-from ovirt.node.utils import process
+from ovirt.node.utils import process, system
 import pwd
 # pylint: disable-msg=E0611
 import grp  # @UnresolvedImport
@@ -63,8 +63,7 @@
             def commit(self):
                 action = "restart" if enabled else "stop"
                 try:
-                    process.check_call("service ovirt-cim %s 2>/dev/null" %
-                                       action)
+                    system.service("ovirt-cim", action)
                     self.logger.debug("Configured CIM successfully")
                 except RuntimeError:
                     raise TransactionError("CIM configuration failed")
diff --git a/src/ovirt/node/setup/snmp/snmp_model.py b/src/ovirt/node/setup/snmp/snmp_model.py
index 97ae425..32aab1e 100644
--- a/src/ovirt/node/setup/snmp/snmp_model.py
+++ b/src/ovirt/node/setup/snmp/snmp_model.py
@@ -20,7 +20,7 @@
 # also available at http://www.gnu.org/copyleft/gpl.html.
 from ovirt.node import utils
 from ovirt.node.config.defaults import NodeConfigFileSection
-from ovirt.node.utils import process
+from ovirt.node.utils import process, system
 import os.path
 
 
@@ -30,7 +30,7 @@
 def enable_snmpd(password):
     from ovirtnode.ovirtfunctions import ovirt_store_config
 
-    process.call("service snmpd stop")
+    system.service("snmpd", "stop")
 
     # get old password #
     if os.path.exists("/tmp/snmpd.conf"):
@@ -45,7 +45,7 @@
     # create user account
     f.write("createUser root SHA %s AES\n" % password)
     f.close()
-    process.check_call("service snmpd start")
+    system.service("snmpd", "start")
     # change existing password
     if len(oldpwd) > 0:
         pwd_change_cmd = (("snmpusm -v 3 -u root -n \"\" -l authNoPriv -a " +
@@ -60,7 +60,7 @@
 def disable_snmpd():
     from ovirtnode.ovirtfunctions import remove_config
 
-    process.check_call("service snmpd stop")
+    system.service("snmpd", "stop")
     # copy to /tmp for enable/disable toggles w/o reboot
     process.check_call("cp /etc/snmp/snmpd.conf /tmp")
     process.check_call("sed -c -ie '/^createUser root/d' %s" % snmp_conf)


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I15291be934c68d5c3f3b56d3bdb044244c415a58
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: hadong <hadong0720 at gmail.com>



More information about the node-patches mailing list