update exec_script_group
This commit is contained in:
parent
39c0895538
commit
dc8d71a574
@ -76,8 +76,6 @@ def main():
|
|||||||
if not group_id in groups:
|
if not group_id in groups:
|
||||||
print_red('Groupe inconnu')
|
print_red('Groupe inconnu')
|
||||||
group_id = None
|
group_id = None
|
||||||
elif not group_id in groups:
|
|
||||||
print_red('Le groupe "{}" est inconnu'.format(group_id))
|
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
liste_serveurs = groups[group_id][1]
|
liste_serveurs = groups[group_id][1]
|
||||||
for id_serv in liste_serveurs :
|
for id_serv in liste_serveurs :
|
||||||
|
@ -6,6 +6,8 @@ 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
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
from zephir.backend.lib_backend import CxPool
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -72,26 +74,29 @@ def main():
|
|||||||
print('Liste des groupes :')
|
print('Liste des groupes :')
|
||||||
for grp_id, group_infos in groups.items():
|
for grp_id, group_infos in groups.items():
|
||||||
print(' - ' + str(grp_id) + ' : ' + group_infos[0])
|
print(' - ' + str(grp_id) + ' : ' + group_infos[0])
|
||||||
|
print( ' - N : Créer un nouveau groupe')
|
||||||
while group_id is None:
|
while group_id is None:
|
||||||
tmp_group_id = flushed_input("Numéro du groupe : ")
|
tmp_group_id = flushed_input("Numéro du groupe : ")
|
||||||
try:
|
if tmp_group_id == 'N':
|
||||||
group_id = int(tmp_group_id)
|
group_id = 'N'
|
||||||
except Exception as err:
|
liste_serveurs = make_group()
|
||||||
print(err)
|
else:
|
||||||
continue
|
try:
|
||||||
if not group_id in groups:
|
group_id = int(tmp_group_id)
|
||||||
print_red('Groupe inconnu')
|
except Exception as err:
|
||||||
group_id = None
|
print(err)
|
||||||
elif not group_id in groups:
|
continue
|
||||||
print_red('Le groupe "{}" est inconnu'.format(group_id))
|
if not group_id in groups:
|
||||||
sys.exit(1)
|
print_red('Groupe inconnu')
|
||||||
|
group_id = None
|
||||||
|
sys.exit(1)
|
||||||
|
liste_serveurs = groups[group_id][1]
|
||||||
if script is None:
|
if script is None:
|
||||||
script = flushed_input("Script à executer : ")
|
script = flushed_input("Script à executer : ")
|
||||||
if params is None:
|
if params is None:
|
||||||
params = flushed_input("Paramètres : ")
|
params = flushed_input("Paramètres : ")
|
||||||
|
|
||||||
liste_serveurs = groups[group_id][1]
|
|
||||||
|
|
||||||
ret = proxy.uucp.exec_script(liste_serveurs, script, params)
|
ret = proxy.uucp.exec_script(liste_serveurs, script, params)
|
||||||
|
|
||||||
@ -101,6 +106,60 @@ def main():
|
|||||||
|
|
||||||
print('Script {} {} exécuté sur les serveurs {}'.format(script, params, liste_serveurs))
|
print('Script {} {} exécuté sur les serveurs {}'.format(script, params, liste_serveurs))
|
||||||
|
|
||||||
|
def make_group():
|
||||||
|
cx_pool = CxPool()
|
||||||
|
cu = cx_pool.create()
|
||||||
|
cu.execute("""select libelle,id from modules""")
|
||||||
|
infos = {}
|
||||||
|
variante_infos = {}
|
||||||
|
filename = 'exportation'
|
||||||
|
server_infos = []
|
||||||
|
for module_name in cu.fetchall():
|
||||||
|
module, version = module_name[0].rsplit('-', 1)
|
||||||
|
infos.setdefault(version, {})[module] = module_name[1]
|
||||||
|
|
||||||
|
versions = infos.keys()
|
||||||
|
versions.sort()
|
||||||
|
print('Choix de la version :')
|
||||||
|
for idx, version in enumerate(versions):
|
||||||
|
print('{}: {}'.format(idx, version))
|
||||||
|
idx = input('> ')
|
||||||
|
version = versions[int(idx)]
|
||||||
|
filename += '-' + version
|
||||||
|
print
|
||||||
|
print('Choix du module :')
|
||||||
|
modules = infos[version].keys()
|
||||||
|
modules.sort()
|
||||||
|
for idx, module in enumerate(modules):
|
||||||
|
print('{}: {}'.format(idx, module))
|
||||||
|
idx = input('> ')
|
||||||
|
module = modules[int(idx)]
|
||||||
|
filename += '-' + module
|
||||||
|
print
|
||||||
|
cu.execute("select libelle,id from variantes where module = " + str(infos[version][module]))
|
||||||
|
for variante_obj in cu.fetchall():
|
||||||
|
variante_infos[variante_obj[0]] = variante_obj[1]
|
||||||
|
print('Choix de la variante :')
|
||||||
|
variantes = variante_infos.keys()
|
||||||
|
variantes.sort()
|
||||||
|
for idx, variante in enumerate(variantes):
|
||||||
|
print('{}: {}'.format(idx, variante))
|
||||||
|
idx_all = idx + 1
|
||||||
|
print('{}: toutes les variantes'.format(idx_all))
|
||||||
|
idx = input('> ')
|
||||||
|
if idx == idx_all:
|
||||||
|
variantes = variante_infos.values()
|
||||||
|
else:
|
||||||
|
filename += '-' + variantes[idx]
|
||||||
|
variantes = [variante_infos[variantes[idx]]]
|
||||||
|
print
|
||||||
|
for variante in variantes:
|
||||||
|
cu.execute('select id,ip_publique,rne,libelle from serveurs where variante=' + str(variante))
|
||||||
|
print("Liste des serveurs : ")
|
||||||
|
for server in cu.fetchall():
|
||||||
|
print('{} - {} - {} - {}'.format(server[0], server[1], server[2], server[3]))
|
||||||
|
server_infos.append(server[0])
|
||||||
|
return server_infos
|
||||||
|
|
||||||
|
|
||||||
def get_pwd(addr, port):
|
def get_pwd(addr, port):
|
||||||
|
Loading…
Reference in New Issue
Block a user