Skip to content
Permalink
Browse files

fix: foreman_heal non current schedule clean up

when a cloud didn't have a schedule we were not removing pre-existing
roles.

closes: #306
Change-Id: Ife2f62125b23a590add4623094b6a6f7dc44ad37
  • Loading branch information
grafuls committed Jan 21, 2020
1 parent ee93443 commit 596e04d9a14dfd7aa5f44d521308040f2687db91
Showing with 10 additions and 4 deletions.
  1. +10 −4 quads/tools/foreman_heal.py
@@ -24,13 +24,13 @@ def main():
loop=loop,
)

ignore = []
ignore = ["cloud01"]
foreman_rbac_exclude = conf.get("foreman_rbac_exclude")
if foreman_rbac_exclude:
ignore = foreman_rbac_exclude.split("|")
ignore.extend(foreman_rbac_exclude.split("|"))
clouds = Cloud.objects()
for cloud in clouds:
if cloud.name != "cloud01" and cloud.name not in ignore:
if cloud.name not in ignore:
logger.info(f"Processing {cloud.name}")
user_id = loop.run_until_complete(foreman.get_user_id(cloud.name))
roles = loop.run_until_complete(foreman.get_user_roles(user_id))
@@ -62,7 +62,13 @@ def main():
)
logger.info(f"* Added role {schedule.host.name}")
else:
logger.info(" No active schedule.")
if roles:
logger.info(" No active schedule, removing pre-existing roles.")
for role, data in roles.items():
loop.run_until_complete(foreman.remove_role(cloud.name, role))
logger.info(f"* Removed role {role}")
else:
logger.info(" No active schedule nor roles assigned.")


if __name__ == "__main__":

0 comments on commit 596e04d

Please sign in to comment.
You can’t perform that action at this time.