blob: 025c0ad257a41e342c12937582e2366540687540 [file] [log] [blame]
Michal Jagiello6e88d542023-04-19 09:53:38 +00001{% macro color(failing, total) %}
2{% if failing == 0 %}
3is-success
4{% else %}
5{% if (failing / total) <= 0.1 %}
6is-warning
7{% else %}
8is-danger
9{% endif %}
10{% endif %}
11{% endmacro %}
12
13{% macro percentage(failing, total) %}
14{{ ((total - failing) / total) | round }}
15{% endmacro %}
16
17{% macro statistic(resource_name, failing, total) %}
18{% set success = total - failing %}
19<div class="level-item has-text-centered">
20 <div>
21 <p class="heading">{{ resource_name | capitalize }}</p>
22 <p class="title">{{ success }}/{{ total }}</p>
23 <progress class="progress {{ color(failing, total) }}" value="{{ success }}" max="{{ total }}">{{ percentage(failing, total) }}</progress>
24 </div>
25 </div>
26{% endmacro %}
27
28{% macro pods_table(pods) %}
29<div id="pods" class="table-container">
30 <table class="table is-fullwidth is-striped is-hoverable">
31 <thead>
32 <tr>
33 <th>Name</th>
34 <th>Ready</th>
35 <th>Status</th>
36 <th>Reason</th>
37 <th>Restarts</th>
38 </tr>
39 </thead>
40 <tbody>
41 {% for pod in pods %}
42 <tr>
43 <td><a href="./pod-{{ pod.name }}.html" title="{{ pod.name }}">{{ pod.k8s.metadata.name }}</a></td>
44 {% if pod.init_done %}
45 <td>{{ pod.running_containers }}/{{ (pod.containers | length) }}</td>
46 {% else %}
47 <td>Init:{{ pod.runned_init_containers }}/{{ (pod.init_containers | length) }}</td>
48 {% endif %}
49 <td>{{ pod.k8s.status.phase }}</td>
50 <td>{{ pod.k8s.status.reason }}</td>
51 {% if pod.init_done %}
52 <td>{{ pod.restart_count }}</td>
53 {% else %}
54 <td>{{ pod.init_restart_count }}</td>
55 {% endif %}
56 </tr>
57 {% endfor %}
58 </tbody>
59 </table>
60</div>
61{% endmacro %}
62
63{% macro key_value_description_list(title, dict) %}
64<dt><strong>{{ title | capitalize }}:</strong></dt>
65<dd>
66 {% if dict %}
67 {% for key, value in dict.items() %}
68 {% if loop.first %}
69 <dl>
70 {% endif %}
71 <dt>{{ key }}:</dt>
72 <dd>{{ value }}</dd>
73 {% if loop.last %}
74 </dl>
75 {% endif %}
76 {% endfor %}
77 {% endif %}
78</dd>
79{% endmacro %}
80
81{% macro description(k8s) %}
82<div class="container">
83 <h1 class="title is-1">Description</h1>
84 <div class="content">
85 <dl>
86 {% if k8s.spec.type %}
87 <dt><strong>Type:</strong></dt>
88 <dd>{{ k8s.spec.type }}</dd>
89 {% if (k8s.spec.type | lower) == "clusterip" %}
90 <dt><strong>Headless:</strong></dt>
91 <dd>{% if (k8s.spec.cluster_ip | lower) == "none" %}Yes{% else %}No{% endif %}</dd>
92 {% endif %}
93 {% endif %}
94 {{ key_value_description_list('Labels', k8s.metadata.labels) | indent(width=6) }}
95 {{ key_value_description_list('Annotations', k8s.metadata.annotations) | indent(width=6) }}
96 {% if k8s.spec.selector %}
97 {% if k8s.spec.selector.match_labels %}
98 {{ key_value_description_list('Selector', k8s.spec.selector.match_labels) | indent(width=6) }}
99 {% else %}
100 {{ key_value_description_list('Selector', k8s.spec.selector) | indent(width=6) }}
101 {% endif %}
102 {% endif %}
103 {% if k8s.phase %}
104 <dt><strong>Status:</strong></dt>
105 <dd>{{ k8s.phase }}</dd>
106 {% endif %}
107 {% if k8s.metadata.owner_references %}
108 <dt><strong>Controlled By:</strong></dt>
109 <dd>{{ k8s.metadata.owner_references[0].kind }}/{{ k8s.metadata.owner_references[0].name }}</dd>
110 {% endif %}
111 </dl>
112 </div>
113</div>
114{% endmacro %}
115
116{% macro pods_container(pods, parent, has_title=True) %}
117<div class="container">
118 {% if has_title %}
119 <h1 class="title is-1">Pods</h1>
120 {% endif %}
121 {% if (pods | length) > 0 %}
122 {{ pods_table(pods) | indent(width=2) }}
123 {% else %}
124 <div class="notification is-warning">{{ parent }} has no pods!</div>
125 {% endif %}
126</div>
127{% endmacro %}
128
129{% macro two_level_breadcrumb(title, name) %}
130<section class="section">
131 <div class="container">
132 <nav class="breadcrumb" aria-label="breadcrumbs">
133 <ul>
134 <li><a href="./index.html">Summary</a></li>
135 <li class="is-active"><a href="#" aria-current="page">{{ title | capitalize }} {{ name }}</a></li>
136 </ul>
137 </nav>
138 </div>
139</section>
140{% endmacro %}
141
142{% macro pod_parent_summary(title, name, failed_pods, pods) %}
143{{ summary(title, name, [{'title': 'Pod', 'failing': failed_pods, 'total': (pods | length)}]) }}
144{% endmacro %}
145
146{% macro number_ok(number, none_value, total=None) %}
147{% if number %}
148{% if total and number < total %}
149<span class="tag is-warning">{{ number }}</span>
150{% else %}
151{{ number }}
152{% endif %}
153{% else %}
154<span class="tag is-warning">{{ none_value }}</span>
155{% endif %}
156{% endmacro %}
157
158{% macro summary(title, name, statistics) %}
159<section class="hero is-light">
160 <div class="hero-body">
161 <div class="container">
162 <h1 class="title is-1">
163 {{ title | capitalize }} {{ name }} Summary
164 </h1>
165 <nav class="level">
166 {% for stat in statistics %}
167 {% if stat.total > 0 %}
168 {{ statistic(stat.title, stat.failing, stat.total) | indent(width=8) }}
169 {% endif %}
170 {% endfor %}
171 </nav>
172 </div>
173 </div>
174</section>
175{% endmacro %}
176
177<!DOCTYPE html>
178<html>
179 <head>
180 <meta charset="utf-8">
181 <meta name="viewport" content="width=device-width, initial-scale=1">
182 <title>Tests results - {% block title %}{% endblock %}</title>
183 <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@0.9.0/css/bulma.min.css">
184 <script defer src="https://use.fontawesome.com/releases/v5.3.1/js/all.js"></script>
185 {% block more_head %}{% endblock %}
186 </head>
187 <body>
188 <nav class="navbar" role="navigation" aria-label="main navigation">
189 <div class="navbar-brand">
190 <a class="navbar-item" href="https://www.onap.org">
191 <img src="https://www.onap.org/wp-content/uploads/sites/20/2017/02/logo_onap_2017.png" width="234" height="50">
192 </a>
193
194 <a role="button" class="navbar-burger burger" aria-label="menu" aria-expanded="false" data-target="navbarBasicExample">
195 <span aria-hidden="true"></span>
196 <span aria-hidden="true"></span>
197 <span aria-hidden="true"></span>
198 </a>
199 </div>
200
201 <div id="navbarBasicExample" class="navbar-menu">
202 <div class="navbar-start">
203 <a class="navbar-item">
204 Summary
205 </a>
206 </div>
207 </div>
208 </nav>
209
210 {% block content %}{% endblock %}
211
212 <footer class="footer">
213 <div class="container">
214 <div class="columns">
215 <div class="column">
216 <p class="has-text-grey-light">
217 <a href="https://bulma.io/made-with-bulma/">
218 <img src="https://bulma.io/images/made-with-bulma.png" alt="Made with Bulma" width="128" height="24">
219 </a>
220 </div>
221 <div class="column">
222 <a class="has-text-grey" href="https://gitlab.com/Orange-OpenSource/lfn/tools/kubernetes-status" style="border-bottom: 1px solid currentColor;">
223 Improve this page on Gitlab
224 </a>
225 </p>
226 </div>
227 </div>
228 </div>
229 </footer>
230 </body>
231</html>
232