Skip to content

Commit

Permalink
Added logic to display percent of completion at cloud level.
Browse files Browse the repository at this point in the history
Under cloud assignments wiki we want to display percentage of hosts
successfully moved. For this we want to check existing current
schedules per cloud plus the number of hosts which have already been
moved. We take both counts and calculate a percent out of those.

Related-to: #277
Change-Id: Ieb1b3369cfffe617aaf13d8aaa590a8b01fa9f16
  • Loading branch information
grafuls committed Jul 30, 2019
1 parent 8a2e180 commit e599fa2
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions quads/tools/create_input_assignments.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def print_header():

def print_summary():
_summary = []
_headers = ["**NAME**", "**SUMMARY**", "**OWNER**", "**REQUEST**"]
_headers = ["**NAME**", "**SUMMARY**", "**OWNER**", "**REQUEST**", "**STATUS**"]
if conf["openstack_management"]:
_headers.append("**INSTACKENV**")
if conf["gather_ansible_facts"]:
Expand Down Expand Up @@ -60,10 +60,16 @@ def print_summary():
style_tag_start = '<span style="color:green">'
instack_link = os.path.join(conf["quads_url"], "cloud", "%s_instackenv.json" % cloud_name)
instack_text = "download"
status = '<img src="http://www.yarntomato.com/percentbarmaker/button.php?barPosition=100&leftFill=%2476D275" alt="" />'
else:
cloud_obj = Cloud.objects(name=cloud_name).first()
scheduled_hosts = Schedule.current_schedule(cloud=cloud_obj).count()
moved_hosts = Host.objects(cloud=cloud_obj).count()
percent = moved_hosts / scheduled_hosts * 100
style_tag_start = '<span style="color:red">'
instack_link = os.path.join(conf["quads_url"], "underconstruction")
instack_link = "#"
instack_text = "validating"
status = '<img src="http://www.yarntomato.com/percentbarmaker/button.php?barPosition=%.0f&leftFill=%%24FFFF00" alt="" />' % percent

_data = ["[%s%s%s](#%s)" % (style_tag_start, cloud_name, style_tag_end, cloud_name), desc, owner, link]

Expand All @@ -81,20 +87,24 @@ def print_summary():
ansible_facts_link = os.path.join(conf["quads_url"], "underconstruction")
if cloud_name == "cloud01":
_data.append("")
_data.append(status)
_data.append("")
else:
_data.append(
"<a href=%s target=_blank>%s%s%s</a>"
% (instack_link, style_tag_start, instack_text, style_tag_end)
)
_data.append(status)
_data.append(
"<a href=%s target=_blank>%sinventory%s</a>"
% (ansible_facts_link, factstyle_tag_start, factstyle_tag_end)
)
else:
if cloud_name == "cloud01":
_data.append(status)
_data.append("")
else:
_data.append(status)
_data.append(
"<a href=%s target=_blank>%s%s%s</a>"
% (instack_link, style_tag_start, instack_text, style_tag_end)
Expand Down

0 comments on commit e599fa2

Please sign in to comment.