[node-patches] Change in ovirt-node[master]: fix snmp to work
hadong0720 at gmail.com
hadong0720 at gmail.com
Sat Aug 30 11:36:06 UTC 2014
hadong has uploaded a new change for review.
Change subject: fix snmp to work
......................................................................
fix snmp to work
Need clean /var/lib/net-snmp/snmpd.conf before configure snmp and
set iptables for snmp
Change-Id: Idc32bd53cffd2ef93a60a06f8937a9a9ff4539a5
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1096164
Signed-off-by: hadong <hadong at redhat.com>
---
M src/ovirt/node/setup/snmp/snmp_model.py
1 file changed, 15 insertions(+), 10 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/67/32167/1
diff --git a/src/ovirt/node/setup/snmp/snmp_model.py b/src/ovirt/node/setup/snmp/snmp_model.py
index b5bb30e..ebb0620 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, system, fs
+from ovirt.node.utils import process, system, fs, firewall
import os.path
@@ -37,11 +37,6 @@
conf = snmp_conf
cmd = "cat %s|grep createUser| grep -v '^#' | awk '{print $4}'" % conf
oldpwd = process.pipe(cmd, shell=True).strip()
- process.call("sed -c -ie '/^createUser root/d' %s" % snmp_conf, shell=True)
- f = open(snmp_conf, "a")
- # create user account
- f.write("createUser root SHA %s AES\n" % password)
- f.close()
# change existing password
if len(oldpwd) > 0:
@@ -53,22 +48,32 @@
# Only reached when no excepion occurs
process.call(["rm", "-rf", "/tmp/snmpd.conf"])
system.service("snmpd", "stop")
- fs.Config().persist(snmp_conf)
if not any([x for x in open('/etc/snmp/snmpd.conf').readlines()
if 'rwuser root' in x]):
with open('/etc/snmp/snmpd.conf', 'a') as f:
f.write("rwuser root")
- fs.Config().persist("/etc/snmp/snmpd.conf")
+ fs.Config().persist("/etc/snmp/snmpd.conf")
+ process.check_call("cat /dev/null >%s" % snmp_conf,
+ shell=True)
+ f = open(snmp_conf, "a")
+ # create user account
+ f.write("createUser root SHA %s AES\n" % password)
+ f.close()
system.service("snmpd", "start")
+ fs.Config().persist(snmp_conf)
+ if firewall.is_firewalld():
+ firewall.setup_firewalld("161", "udp")
+ else:
+ firewall.setup_iptables("161", "udp")
def disable_snmpd():
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,
+ process.check_call("cat /dev/null >%s" % snmp_conf,
shell=True)
fs.Config().unpersist(snmp_conf)
@@ -79,7 +84,7 @@
>>> from ovirt.node.utils import fs
>>> n = SNMP(fs.FakeFs.File("dst"))
>>> n.update(True) # doctest: +ELLIPSIS
- <ovirt.node.setup.snmp.snmp_model.SNMP object at ...>
+ <snmp_model.SNMP object at ...>
>>> n.retrieve()
{'enabled': True}
"""
--
To view, visit http://gerrit.ovirt.org/32167
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Idc32bd53cffd2ef93a60a06f8937a9a9ff4539a5
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