ajout remonté zephir et multivalues
This commit is contained in:
parent
4c409112d8
commit
d79fd7be7a
@ -10,32 +10,35 @@ from collections import OrderedDict
|
|||||||
|
|
||||||
def display_help():
|
def display_help():
|
||||||
print("Modification de la valeur d'une variable d'un serveur")
|
print("Modification de la valeur d'une variable d'un serveur")
|
||||||
print("{} [--r realm --d domain]".format(sys.argv[0]))
|
print("{} [--r realm --d domain --save]".format(sys.argv[0]))
|
||||||
|
|
||||||
|
|
||||||
def argparser():
|
def argparser():
|
||||||
# récupère l'ID du groupe
|
# récupère l'ID du groupe
|
||||||
arglen = len(sys.argv)
|
arglen = len(sys.argv)
|
||||||
|
save = False
|
||||||
|
if "--save" in sys.argv:
|
||||||
|
save = True
|
||||||
if arglen == 1:
|
if arglen == 1:
|
||||||
return None, None
|
return None, None, save
|
||||||
if sys.argv[1] in ['-h', '--help']:
|
if sys.argv[1] in ['-h', '--help']:
|
||||||
display_help()
|
display_help()
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
if sys.argv[1] in ['-r', '--realm']:
|
if sys.argv[1] in ['-r', '--realm']:
|
||||||
realm = sys.argv[2]
|
realm = sys.argv[2]
|
||||||
return realm, None
|
return realm, None, save
|
||||||
|
|
||||||
if sys.argv[3] in ['-d', '--domain']:
|
if sys.argv[3] in ['-d', '--domain']:
|
||||||
domain = sys.argv[4]
|
domain = sys.argv[4]
|
||||||
return realm, domain
|
return realm, domain, save
|
||||||
|
|
||||||
return None, None
|
return None, None, save
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
# import des fonctions communes de Zéphir client
|
# import des fonctions communes de Zéphir client
|
||||||
realm, domain = argparser()
|
realm, domain, save = argparser()
|
||||||
|
|
||||||
if realm is None :
|
if realm is None :
|
||||||
realm = raw_input("Realm AD : ")
|
realm = raw_input("Realm AD : ")
|
||||||
@ -64,6 +67,10 @@ def main():
|
|||||||
output = os.popen(cmd)
|
output = os.popen(cmd)
|
||||||
res = output.read().strip()
|
res = output.read().strip()
|
||||||
output.close()
|
output.close()
|
||||||
|
if save:
|
||||||
|
cmd="""/usr/share/zephir/scripts/zephir_client save_files"""
|
||||||
|
output = os.popen(cmd)
|
||||||
|
output.close()
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import sys, getpass, socket, cjson
|
import sys, getpass, socket, cjson, os
|
||||||
from pyeole.ihm import print_line
|
from pyeole.ihm import print_line
|
||||||
from pyeole.ansiprint import print_orange, print_red
|
from pyeole.ansiprint import print_orange, print_red
|
||||||
from creole.client import CreoleClient
|
from creole.client import CreoleClient
|
||||||
@ -10,33 +10,36 @@ from collections import OrderedDict
|
|||||||
|
|
||||||
def display_help():
|
def display_help():
|
||||||
print("Modification de la valeur d'une variable d'un serveur")
|
print("Modification de la valeur d'une variable d'un serveur")
|
||||||
print("{} [--var nom_variable --value valeur]".format(sys.argv[0]))
|
print("{} [--var nom_variable --value valeur --save]".format(sys.argv[0]))
|
||||||
|
|
||||||
|
|
||||||
def argparser():
|
def argparser():
|
||||||
# récupère l'ID du groupe
|
# récupère l'ID du groupe
|
||||||
arglen = len(sys.argv)
|
arglen = len(sys.argv)
|
||||||
|
save = False
|
||||||
|
if "--save" in sys.argv:
|
||||||
|
save = True
|
||||||
if arglen == 1:
|
if arglen == 1:
|
||||||
return None, None
|
return None, None, save
|
||||||
|
|
||||||
if sys.argv[1] in ['-h', '--help']:
|
if sys.argv[1] in ['-h', '--help']:
|
||||||
display_help()
|
display_help()
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
||||||
if sys.argv[1] in ['-v', '--var']:
|
if sys.argv[1] in ['-v', '--var']:
|
||||||
varc = sys.argv[2]
|
varc = sys.argv[2]
|
||||||
return varc, None
|
if sys.argv[3] in ['-l', '--value']:
|
||||||
|
valvar = sys.argv[4]
|
||||||
|
return varc, valvar, save
|
||||||
|
else:
|
||||||
|
return varc, None, save
|
||||||
|
|
||||||
if sys.argv[3] in ['-l', '--value']:
|
return None, None, save
|
||||||
valvar = sys.argv[4]
|
|
||||||
return varc, valvar
|
|
||||||
|
|
||||||
return None, None
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
# import des fonctions communes de Zéphir client
|
# import des fonctions communes de Zéphir client
|
||||||
varc, valvar = argparser()
|
varc, valvar, save = argparser()
|
||||||
|
|
||||||
|
|
||||||
if varc is None :
|
if varc is None :
|
||||||
@ -49,11 +52,17 @@ def main():
|
|||||||
store = cjson.decode(fh.read(), all_unicode=True)
|
store = cjson.decode(fh.read(), all_unicode=True)
|
||||||
fh.close
|
fh.close
|
||||||
if varc in store:
|
if varc in store:
|
||||||
|
if "|" in valvar:
|
||||||
|
valvar = valvar.split("|")
|
||||||
store[varc]['val'] = valvar
|
store[varc]['val'] = valvar
|
||||||
|
|
||||||
fh = open("/etc/eole/config.eol", 'w')
|
fh = open("/etc/eole/config.eol", 'w')
|
||||||
fh.write(cjson.encode(store))
|
fh.write(cjson.encode(store))
|
||||||
fh.close()
|
fh.close()
|
||||||
|
if save:
|
||||||
|
cmd="""/usr/share/zephir/scripts/zephir_client save_files"""
|
||||||
|
output = os.popen(cmd)
|
||||||
|
output.close()
|
||||||
else:
|
else:
|
||||||
print_orange('Erreur : variable {} inconnue'.format(varc))
|
print_orange('Erreur : variable {} inconnue'.format(varc))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user