implement --limit
This commit is contained in:
parent
33a3f20f89
commit
4b059c1e68
1 changed files with 42 additions and 33 deletions
75
main.py
75
main.py
|
@ -277,38 +277,47 @@ if "--limit" in sys.argv:
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
found_switchs = { x['short_name'] for x in all_switchs }
|
||||||
|
all_switchs = list(
|
||||||
|
filter(
|
||||||
|
lambda x: x['short_name'] in limit_switchs,
|
||||||
|
all_switchs
|
||||||
|
)
|
||||||
|
)
|
||||||
|
if not limit_switchs.issubset(found_switchs):
|
||||||
|
print("WARNING: some switchs in the list have not been found in the re2o API and will not be processed")
|
||||||
|
for sw_name in limit_switchs - found_switchs:
|
||||||
|
print("{name} has not been found".format(name=sw_name))
|
||||||
|
|
||||||
#if "--force" in sys.argv:
|
if "--force" in sys.argv:
|
||||||
# sw = Switch()
|
sw = Switch()
|
||||||
# for switch in all_switchs:
|
for switch in all_switchs:
|
||||||
# sw.switch = switch
|
sw.switch = switch
|
||||||
# sw.gen_conf_and_write()
|
sw.gen_conf_and_write()
|
||||||
# try:
|
try:
|
||||||
# sw.apply_conf()
|
sw.apply_conf()
|
||||||
# except:
|
except:
|
||||||
# print("Erreur dans l'application de la conf pour " + switch["short_name"])
|
print("Erreur dans l'application de la conf pour " + switch["short_name"])
|
||||||
#
|
|
||||||
#if "--upgrade" in sys.argv:
|
|
||||||
# sw = Switch()
|
if "--upgrade" in sys.argv:
|
||||||
# for switch in all_switchs:
|
sw = Switch()
|
||||||
# sw.switch = switch
|
for switch in all_switchs:
|
||||||
# sw.upgrade()
|
sw.switch = switch
|
||||||
#
|
sw.upgrade()
|
||||||
#
|
|
||||||
#for service in api_client.list("services/regen/"):
|
for service in api_client.list("services/regen/"):
|
||||||
# if service['hostname'] == client_hostname and \
|
if service['hostname'] == client_hostname and \
|
||||||
# service['service_name'] == 'switchs' and \
|
service['service_name'] == 'switchs' and \
|
||||||
# service['need_regen']:
|
service['need_regen']:
|
||||||
# error = False
|
error = False
|
||||||
# sw=Switch()
|
sw=Switch()
|
||||||
# for switch in all_switchs:
|
for switch in all_switchs:
|
||||||
# sw.switch = switch
|
sw.switch = switch
|
||||||
# sw.gen_conf_and_write()
|
sw.gen_conf_and_write()
|
||||||
# try:
|
try:
|
||||||
# sw.apply_conf()
|
sw.apply_conf()
|
||||||
# except:
|
except:
|
||||||
# error = True
|
error = True
|
||||||
# api_client.patch(service['api_url'], data={'need_regen': error})
|
api_client.patch(service['api_url'], data={'need_regen': error})
|
||||||
|
|
||||||
for switch in all_switchs:
|
|
||||||
print(switch['short_name'])
|
|
||||||
|
|
Loading…
Reference in a new issue