From c2d64a6269ad2ff29f11354a6b155c38c7a1add4 Mon Sep 17 00:00:00 2001 From: knguyen100000010 <63071572+knguyen100000010@users.noreply.github.com> Date: Fri, 16 Feb 2024 08:46:04 -0500 Subject: [PATCH] add az distribution pie chart (#1452) --- .../templates/groups/group_side_panel.html | 8 +++++ .../templates/groups/host_az_dist.tmpl | 31 +++++++++++++++++++ .../deploy_board/webapp/arcee_urls.py | 1 + .../deploy_board/webapp/group_view.py | 18 ++++++++++- 4 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 deploy-board/deploy_board/templates/groups/host_az_dist.tmpl diff --git a/deploy-board/deploy_board/templates/groups/group_side_panel.html b/deploy-board/deploy_board/templates/groups/group_side_panel.html index eea9c687c3..4e2eb9c66f 100644 --- a/deploy-board/deploy_board/templates/groups/group_side_panel.html +++ b/deploy-board/deploy_board/templates/groups/group_side_panel.html @@ -71,6 +71,14 @@

Group Config

{% endif %} +
+ + Availability Zone Distribution + +
+

Environments

diff --git a/deploy-board/deploy_board/templates/groups/host_az_dist.tmpl b/deploy-board/deploy_board/templates/groups/host_az_dist.tmpl new file mode 100644 index 0000000000..a5c4fe866f --- /dev/null +++ b/deploy-board/deploy_board/templates/groups/host_az_dist.tmpl @@ -0,0 +1,31 @@ +{% load utils %} + +{% block content %} +
+

Host Distribution Among Availability Zones

+ +
+ + + + +{% endblock %} \ No newline at end of file diff --git a/deploy-board/deploy_board/webapp/arcee_urls.py b/deploy-board/deploy_board/webapp/arcee_urls.py index 6e5536918b..e4d2b49b3d 100644 --- a/deploy-board/deploy_board/webapp/arcee_urls.py +++ b/deploy-board/deploy_board/webapp/arcee_urls.py @@ -67,6 +67,7 @@ url(r'^groups/names', group_view.get_group_names), url(r'^groups/search/(?P[a-zA-Z0-9\-_]+)/$', group_view.search_groups), url(r'^groups/search/$', group_view.group_landing), + url(r'^groups/(?P[a-zA-Z0-9\-_]+)/host-az-dist/$', group_view.get_host_az_dist), url(r'^groups/(?P[a-zA-Z0-9\-_]+)/$', group_view.GroupDetailView.as_view()), url(r'^groups/(?P[a-zA-Z0-9\-_]+)/config/$', group_view.GroupConfigView.as_view()), url(r'^groups/(?P[a-zA-Z0-9\-_]+)/envs/', group_view.get_envs), diff --git a/deploy-board/deploy_board/webapp/group_view.py b/deploy-board/deploy_board/webapp/group_view.py index 3e952c2f39..a284ee0dad 100644 --- a/deploy-board/deploy_board/webapp/group_view.py +++ b/deploy-board/deploy_board/webapp/group_view.py @@ -13,7 +13,7 @@ # limitations under the License. -from deploy_board.settings import IS_PINTEREST, PHOBOS_URL +from deploy_board.settings import CMDB_API_HOST, IS_PINTEREST, PHOBOS_URL from django.middleware.csrf import get_token from django.shortcuts import render, redirect from django.views.generic import View @@ -21,7 +21,9 @@ from django.http import HttpResponse from django.contrib import messages from django.contrib.messages import get_messages +from collections import Counter import json +import requests import logging import traceback from itertools import groupby @@ -1464,6 +1466,20 @@ def get_health_check_activities(request, group_name): }) +def get_host_az_dist(request, group_name): + host_az_dist = requests.post(url = CMDB_API_HOST+"/v2/query", json={ + "query": "tags.Autoscaling:{} AND state:running".format(group_name), + "fields": "location" + } + ) + + counter = Counter([x['location'] for x in host_az_dist.json()]) + + return render(request, 'groups/host_az_dist.tmpl', { + 'labels': list(counter.keys()), + 'data': list(counter.values()), + }) + def get_health_check_details(request, id): health_check = autoscaling_groups_helper.get_health_check(request, id) env = environs_helper.get(request, health_check.get('env_id'))