ajout de l'option --force et prise en compte des regen services
This commit is contained in:
parent
d2e1b92eb7
commit
57db5abf91
1 changed files with 28 additions and 8 deletions
36
main.py
Executable file → Normal file
36
main.py
Executable file → Normal file
|
@ -10,6 +10,8 @@ import requests
|
|||
import base64
|
||||
import json
|
||||
|
||||
import sys
|
||||
|
||||
config = ConfigParser()
|
||||
config.read('config.ini')
|
||||
|
||||
|
@ -29,6 +31,18 @@ ENV = Environment(loader=FileSystemLoader('.'))
|
|||
|
||||
# Création du template final avec les valeurs contenues dans le dictionnaire "valeurs" - Ces valeurs sont positionnées dans un objet "temp", qui sera utilisé par le moteur, et que l'on retrouve dans le template.
|
||||
|
||||
for arg in sys.argv:
|
||||
if arg=="--force":
|
||||
sw = Switch()
|
||||
for switch in all_switchs:
|
||||
sw.switch = switch
|
||||
sw.gen_conf_and_write()
|
||||
try:
|
||||
sw.apply_conf()
|
||||
except:
|
||||
print("Erreur dans l'application de la conf pour " + switch["short_name"])
|
||||
|
||||
|
||||
|
||||
class Switch:
|
||||
def __init__(self):
|
||||
|
@ -170,11 +184,17 @@ class Switch:
|
|||
|
||||
|
||||
|
||||
sw = Switch()
|
||||
for switch in all_switchs:
|
||||
sw.switch = switch
|
||||
sw.gen_conf_and_write()
|
||||
try:
|
||||
sw.apply_conf()
|
||||
except:
|
||||
print("Erreur dans l'application de la conf pour " + switch["short_name"])
|
||||
for service in api_client.list("services/regen/"):
|
||||
if service['hostname'] == client_hostname and \
|
||||
service['service_name'] == 'switchs' and \
|
||||
service['need_regen']:
|
||||
error = False
|
||||
sw=Switch()
|
||||
for switch in all_switchs:
|
||||
sw.switch = switch
|
||||
sw.gen_conf_and_write()
|
||||
try:
|
||||
sw.apply_conf()
|
||||
except:
|
||||
error = True
|
||||
api_client.patch(service['api_url'], data={'need_regen': error})
|
||||
|
|
Loading…
Reference in a new issue