in lemur/sources/cli.py [0:0]
def sync(source_strings, ttl):
sources = validate_sources(source_strings)
for source in sources:
status = FAILURE_METRIC_STATUS
start_time = time.time()
click.echo("[+] Staring to sync source: {label} and expire endpoints ttl={ttl}h\n".format(
label=source.label, ttl=ttl))
user = user_service.get_by_username("lemur")
try:
data = source_service.sync(source, user, ttl_hours=ttl)
click.echo(
"[+] Certificates: New: {new} Updated: {updated}".format(
new=data["certificates"][0], updated=data["certificates"][1]
)
)
click.echo(
"[+] Endpoints: New: {new} Updated: {updated} Expired: {expired}".format(
new=data["endpoints"][0], updated=data["endpoints"][1], expired=data["endpoints"][2]
)
)
click.echo(
"[+] Finished syncing source: {label}. Run Time: {time}".format(
label=source.label, time=(time.time() - start_time)
)
)
status = SUCCESS_METRIC_STATUS
except Exception as e:
current_app.logger.exception(e)
click.echo(f"[X] Failed syncing source {source.label}!\n")
capture_exception()
metrics.send(
"source_sync_fail",
"counter",
1,
metric_tags={"source": source.label, "status": status},
)
metrics.send(
"source_sync",
"counter",
1,
metric_tags={"source": source.label, "status": status},
)