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: I81c3f2d2588d3963c66bad42e469e78f1393104b Signed-off-by: Douglas Schilling Landgraf <dougsl...@redhat.com> --- M client/vdsClient.py 1 file changed, 63 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/76/21876/1 diff --git a/client/vdsClient.py b/client/vdsClient.py index d549500..733c7ff 100644 --- a/client/vdsClient.py +++ b/client/vdsClient.py @@ -26,7 +26,10 @@ import socket import pprint as pp +from ConfigParser import ConfigParser +from datetime import datetime from vdsm import vdscli +from shutil import copy2 try: import vdsClientGluster as ge _glusterEnabled = True @@ -59,6 +62,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 +1005,52 @@ volUUID, descr) if status['status']['code']: return status['status']['code'], status['status']['message'] + return 0, '' + + def setConfig(self, args): + + sectionName = args[0] + configName = args[1] + configNewValue = args[2] + + dt = datetime.now() + bkpFile = "/etc/vdsm/." + dt.strftime("%Y-%m-%d_%H%M%S") + "-vdsm.conf" + + copy2(VDSM_CONF, bkpFile) + + config = ConfigParser() + config.read(VDSM_CONF) + + sectionFound = False + for sec in config.sections(): + if sectionName in sec: + sectionFound = True + + if not sectionFound: + config.add_section(sectionName) + + config.set(sectionName, configName, configNewValue) + + with open(VDSM_CONF, 'w+') as fd: + config.write(fd) + + 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): + config = ConfigParser() + config.read(VDSM_CONF) + + for section_name in config.sections(): + print '\n[%s]' % section_name + for name, value in config.items(section_name): + print '%s = %s' % (name, value) + return 0, '' def setVolumeLegality(self, args): @@ -2219,6 +2271,17 @@ '<Description>', 'Sets a new description to the volume' )), + + 'setConfig': (serv.setConfig, + ('<section> <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/21876 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I81c3f2d2588d3963c66bad42e469e78f1393104b Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Douglas Schilling Landgraf <dougsl...@redhat.com> _______________________________________________ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches