Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Sebastian Luna-Valero <[email protected]>
  • Loading branch information
enolfc and sebastian-luna-valero authored Dec 11, 2024
1 parent 6f11ba2 commit 9cd327f
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions fedcloud_vm_monitoring/sla_monitor_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


def check_site_slas(site, site_slas, goc, acct, appdb):
click.echo(f"[-] Checking site {site}")
click.secho(f"[-] Checking site {site}", fg="blue", bold=True)
sla_vos = set()
appdb_vos = set(appdb.get_vo_for_site(site))
if site not in site_slas:
Expand All @@ -21,37 +21,38 @@ def check_site_slas(site, site_slas, goc, acct, appdb):
accounted_vos = sla["vos"].intersection(acct.site_vos(site))
if accounted_vos:
click.echo(
f"[OK] SITE {site} has accounting info for SLA {sla_name} ({accounted_vos})"
f"[OK] {site} has accounting info for SLA {sla_name} ({accounted_vos})"
)
else:
click.echo(
f"[ERR] SITE {site} has no accounting info for SLA {sla_name}"
f"[ERR] {site} has no accounting info for SLA {sla_name}"
)
info_vos = sla["vos"].intersection(appdb_vos)
if info_vos:
click.echo(
f"[OK] SITE {site} has configured {info_vos} for SLA {sla_name}"
f"[OK] {site} has configured {info_vos} for SLA {sla_name}"
)
else:
click.echo(f"[ERR] SITE {site} has no configured VO for SLA {sla_name}")
click.echo("[-] Checking aditional VOs")
click.echo(f"[ERR] {site} has no configured VO for SLA {sla_name}")
click.secho(f"[-] Checking aditional VOs at {site}", fg="yellow", bold=True)
# Now check which VOs are being reported without a SLA
if not sla_vos:
sla_vos = goc.sla_vos
non_sla_vos = acct.site_vos(site) - sla_vos.union(set(["ops"]))
if non_sla_vos:
click.echo(
f"[W] Site {site} has accounting for VOs {non_sla_vos} but non covered by SLA"
f"[W] {site} has accounting for VOs {non_sla_vos} but not covered by SLA"
)
if "ops" not in acct.site_vos(site):
click.echo(f"[W] SITE {site} has accounting for ops")
click.echo(f"[W] {site} has accounting for ops")
non_sla_appdb_vos = appdb_vos - sla_vos.union(set(["ops"]))
if non_sla_vos:
click.echo(
f"[W] Site {site} has VOs {non_sla_appdb_vos} configured but non covered by SLA"
f"[W] {site} has VOs {non_sla_appdb_vos} configured but not covered by SLA"
)
if "ops" not in appdb_vos:
click.echo(f"[W] SITE {site} has no configuration for ops")
click.echo(f"[W] {site} has no configuration for ops")
click.echo()


@click.command()
Expand All @@ -76,7 +77,6 @@ def main(
appdb = AppDB()
slas = goc.get_sites_slas(user_cert, vo_map)

print(slas)
if site:
check_site_slas(site, slas, goc, acct, appdb)
else:
Expand Down

0 comments on commit 9cd327f

Please sign in to comment.