in lemur/sources/cli.py [0:0]
def sync(source_strings):
sources = validate_sources(source_strings)
for source in sources:
status = FAILURE_METRIC_STATUS
start_time = time.time()
print("[+] Staring to sync source: {label}!\n".format(label=source.label))
user = user_service.get_by_username("lemur")
try:
data = source_service.sync(source, user)
print(
"[+] Certificates: New: {new} Updated: {updated}".format(
new=data["certificates"][0], updated=data["certificates"][1]
)
)
print(
"[+] Endpoints: New: {new} Updated: {updated} Removed: {removed}".format(
new=data["endpoints"][0],
updated=data["endpoints"][1],
removed=data["endpoints"][2],
)
)
print(
"[+] 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)
print("[X] Failed syncing source {label}!\n".format(label=source.label))
sentry.captureException()
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},
)