Douglas Schilling Landgraf has uploaded a new change for review.
Change subject: vdsClient: manage vdsm.conf
......................................................................
vdsClient: manage vdsm.conf
A user reported that would like to have option in vdsClient to
show the current settings. Additionaly to this option, created a flag
to update vdsm config file.
Change-Id: I58d20ae4724549f85ae7f4fcea998679b177d1ae
Signed-off-by: Douglas Schilling Landgraf <dougsland(a)redhat.com>
---
M client/vdsClient.py
1 file changed, 67 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/75/21875/1
diff --git a/client/vdsClient.py b/client/vdsClient.py
index d549500..c2eb209 100644
--- a/client/vdsClient.py
+++ b/client/vdsClient.py
@@ -26,7 +26,9 @@
import socket
import pprint as pp
+from datetime import datetime
from vdsm import vdscli
+from shutil import copy2
try:
import vdsClientGluster as ge
_glusterEnabled = True
@@ -59,6 +61,9 @@
SHARED_VOL = 6
INTERNAL_VOL = 7
LEAF_VOL = 8
+
+# VDSM CONF
+VDSM_CONF = "/etc/vdsm/vdsm.conf"
def validateArgTypes(args, conv, requiredArgsNumber=0):
@@ -999,6 +1004,57 @@
volUUID, descr)
if status['status']['code']:
return status['status']['code'],
status['status']['message']
+ return 0, ''
+
+ def setConfig(self, args):
+
+ configName = args[0]
+ configNewValue = args[1]
+
+ dt = datetime.now()
+ bkpFile = "/etc/vdsm/." + dt.strftime("%Y-%m-%d_%H%M%S") +
"-vdsm.conf"
+
+ copy2(VDSM_CONF, bkpFile)
+
+ with open(VDSM_CONF, 'r') as fd:
+ vdsmConf = fd.readlines()
+
+ newVdsmConf = ""
+ for line in vdsmConf:
+ if configName in line:
+ key, value = line.split("=")
+ newVdsmConf = '{0}{1}= {2}{3}'.format(
+ newVdsmConf, key, configNewValue, "\n")
+ else:
+ newVdsmConf = '{0}{1}'.format(newVdsmConf, line)
+
+ with open(VDSM_CONF, 'w+') as fd:
+ fd.write(newVdsmConf)
+
+ print "Please note: \n" \
+ "\tCopied previous vdsm.conf to " + bkpFile + "\n" \
+ "\tTo VDSM load this new change, restart VDSM daemon\n" \
+ "\tIf the system is a oVirt Node (or derivative) run persist " \
+ "/etc/vdsm/vdsm.conf to keep the new config in case of reboot"
+
+ return 0, ''
+
+ def showConfig(self, args):
+ with open("/etc/vdsm/vdsm.conf", 'r') as fd:
+ vdsmConf = fd.readlines()
+
+ for line in vdsmConf:
+ if "=" in line:
+ key, value = line.split("=")
+
+ if "#" in key:
+ key = key.strip("#") + "<current
commented>"
+
+ if len(value.strip()) == 0:
+ value = "<no assigned value>"
+
+ print "key: {0}\nkey value: {1}\n".format(
+ key.strip(), value.strip())
return 0, ''
def setVolumeLegality(self, args):
@@ -2219,6 +2275,17 @@
'<Description>',
'Sets a new description to the volume'
)),
+
+ 'setConfig': (serv.setConfig,
+ ('<configName> <newValue>',
+ 'Set new value for a vdsm config'
+ )),
+
+ 'showConfig': (serv.showConfig,
+ ('',
+ 'Get vdsm configuration options available in vdsm.conf'
+ )),
+
'setVolumeLegality': (serv.setVolumeLegality,
('<sdUUID> <spUUID> <imgUUID>
<volUUID> '
'<Legality>',
--
To view, visit
http://gerrit.ovirt.org/21875
To unsubscribe, visit
http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I58d20ae4724549f85ae7f4fcea998679b177d1ae
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Douglas Schilling Landgraf <dougsland(a)redhat.com>