From e599fa20977621b8986f6f3ff017de446fae0f78 Mon Sep 17 00:00:00 2001 From: Gonzalo Rafuls Date: Mon, 29 Jul 2019 08:45:43 -0400 Subject: [PATCH] Added logic to display percent of completion at cloud level. 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: https://github.com/redhat-performance/quads/issues/277 Change-Id: Ieb1b3369cfffe617aaf13d8aaa590a8b01fa9f16 --- quads/tools/create_input_assignments.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/quads/tools/create_input_assignments.py b/quads/tools/create_input_assignments.py index 9e0659c45..f62d0b96e 100755 --- a/quads/tools/create_input_assignments.py +++ b/quads/tools/create_input_assignments.py @@ -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"]: @@ -60,10 +60,16 @@ def print_summary(): style_tag_start = '' instack_link = os.path.join(conf["quads_url"], "cloud", "%s_instackenv.json" % cloud_name) instack_text = "download" + status = '' 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 = '' - instack_link = os.path.join(conf["quads_url"], "underconstruction") + instack_link = "#" instack_text = "validating" + status = '' % percent _data = ["[%s%s%s](#%s)" % (style_tag_start, cloud_name, style_tag_end, cloud_name), desc, owner, link] @@ -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( "%s%s%s" % (instack_link, style_tag_start, instack_text, style_tag_end) ) + _data.append(status) _data.append( "%sinventory%s" % (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( "%s%s%s" % (instack_link, style_tag_start, instack_text, style_tag_end)