@@ -34,7 +34,7 @@ entities:
3434 )
3535
3636 presentations :
37- tree :
37+ tree : # Выводим дерево кластеров
3838 type : plantuml
3939 template : template/tree.puml
4040 source : >
@@ -68,7 +68,9 @@ entities:
6868 )];
6969 )
7070
71- cluster_deployment_diagram :
71+ # Выводим диаграмму развертывания систем. Вывод может происходить сразу группы кластеров.
72+ # Например, можно вывести все сервера prod.
73+ cluster_deployment_diagram :
7274 type : mermaid
7375 template : template/deployment_diagram.mmd
7476 source : >
@@ -146,95 +148,22 @@ entities:
146148
147149 )
148150
149- cluster_deployment_diagram_v1 : # Оставил для теста
150- type : mermaid
151- template : template/deployment_diagram.mmd
152- source : >
153- (
154- $cluster_id := $params.id;
155- $clusters := $.clusters;
156- $_clusters := $lookup($clusters, $cluster_id);
157- $systems := $.components;
158- $dep_units := deployment_units;
159- $nodes := $dep_units.$spread().(
160- $du_id := $keys()[0];
161- $system_id := $split($substringAfter($du_id, "."), ".", 3) ~> $join('.');
162- $_system := $lookup($systems, $system_id);
163- $assert($type($_system.title)="string", "Для deployment unit " & $du_id & " указан некорректный идентификатор. Идентификатор должен содержать в себе идентификатор cистемы. Система с идентификатором " & $system_id & " не найдена. Исправьте идентификатор и повторите операцию.");
164- $component_id := $substringAfter($du_id, ".");
165-
166- $du := $.*;
167- $node := $filter($du, function($v, $i, $a) {$contains($v."resource_allocation"."cluster", $cluster_id)}).
168- $merge([$ , {"du_id": $du_id }]).
169- $merge([$ , {"system_id": $system_id}]).
170- $merge([$ , {"component_id": $component_id}]).
171- $merge([$ , {"system_title": $_system.title}]).
172- $merge([$ , {"system_entity": $lookup( $systems, $component_id ).entity}]);
173-
174- $node.{
175- "du_id": $du_id,
176- "system_id": system_id,
177- "component_id": component_id,
178- "cluster": resource_allocation.cluster,
179- "namespace": $type(resource_allocation.namespace)="string" ? resource_allocation.namespace : system_title,
180- "cpu_type": resource_req.cpu_type,
181- "cpu": resource_req.cpu,
182- "ram": resource_req.ram,
183- "storage_type": resource_req.storage_type,
184- "storage_size": resource_req.storage_size
185- };
186- );
187-
188- $objects := $nodes{
189- `cluster`: {
190- `namespace`: {
191- "cpu": $sum(cpu) & "Core",
192- "ram": $sum(ram) & "Gb",
193- "storage_size": $sum(storage_size) & "Gb",
194- "namespace": $distinct(namespace),
195- "cluster": $distinct(cluster),
196- "system_id": $distinct(system_id)
197- }
198- }
199- };
200-
201- $du := function($cluster_du, $entity) {(
202- $join($cluster_du.*.(
203- $title := "";
204- $entity & "("& cluster & "_" & system_id & ", \"" & $title & "\",, \"" & "RAM " & ram & ";<br/> CPU: " & cpu & ";<br/> Storage: " & storage_size & "\")"
205- ), "\n") & "\n"
206- )};
207-
208- $code := $join($objects.$spread().(
209- $id := $keys()[0];
210- $cluster_temp := $lookup($clusters, $id);
211- "Deployment_Node(" & $id & ", \"" & $cluster_temp.title & "\", \"" & $cluster_temp.resource_type & "\") {\n" & $du($.*, $cluster_temp.entity) & "\n}" ;
212- ), "\n");
213-
214- {
215- "notation": "C4Deployment",
216- "code":
217- $count($nodes) > 0
218- ? $code
219- : "Deployment_Node(empty_node, \"\") {\nContainer(cempty, \"Заполните deployment units для этого кластера\")\n}",
220- "title": $_clusters.description
221- };
222-
223- )
224-
151+ # Выводим диаграмму развертывания конкретной системы.
152+ # Если разшифровка делается из конкретного кластера, то выведутся все DU расположенные на этом кластере
153+ # Если разшифровка делается для системы целиком, то выведутся все кластера со всеми DU этой системы
225154 system_deployment_diagram :
226155 type : mermaid
227156 template : template/deployment_diagram.mmd
228157 source : >
229158 (
230159 $options := $split($params.parent, ":");
231160 $system_id := $options[0];
232- /*$system_id := "swamp.crocodile";*/
161+ /*$system_id := "swamp.crocodile/sid ";*/
233162 $_systems := $.components;
234163 $system := $lookup($_systems, $system_id);
235164 $assert($type($system.title)="string", "В запрос system_deployment_diagram в качестве параметра передан некорректный идентификатор системы: " & $system_id & ". Исправьте идентификатор и повторите операцию.");
236165 $cluster_id := $options[1];
237- /*$cluster_id := "";*/
166+ /*$cluster_id := "prod.k8s ";*/
238167 $cluster_filtred := $type($cluster_id)="string" ? true: false;
239168 $dictionaries := dictionaries;
240169 $_clusters := $.clusters;
@@ -325,105 +254,8 @@ entities:
325254 };
326255 )
327256
328- system_deployment_diagram_v1 : # Оставил для теста
329- type : mermaid
330- template : template/deployment_diagram.mmd
331- source : >
332- (
333- $options := $split($params.parent, ":");
334- $system_id := $options[0];
335- $systems := $.components;
336- $_system := $lookup($systems, $system_id);
337- $assert($type($_system.title)="string", "В запрос system_deployment_diagram в качестве параметра передан некорректный идентификатор системы: " & $system_id & ". Исправьте идентификатор и повторите операцию.");
338- $cluster_id := $options[1];
339- $cluster_filtred := $count($options) = 2 ? true: false;
340- $clusters := $.clusters;
341- $dictionaries := dictionaries;
342- $dep_units := deployment_units;
343- $pattern := $eval("/^" & "[a-zA-Z0-9\\_]*" & "." & $system_id & "/");
344- $nodes := $dep_units.$sift(function($v, $k) {$k ~> $pattern}).$spread().(
345- $du_id := $keys()[0];
346- $system_id := $split($substringAfter($du_id, "."), ".", 3) ~> $join('.');
347- $component_id := $substringAfter($du_id, ".");
348- $du := $.*;
349- $node := $cluster_filtred = true
350- ? $filter($du, function($v, $i, $a) {$contains($v."resource_allocation"."cluster", $cluster_id)})
351- : $du;
352- $node.$merge([$ , {"du_id": $du_id }]).
353- $merge([$ , {"system_id": $system_id}]).
354- $merge([$ , {"component_id": $component_id}]).
355- $merge([$ , {"system": $system_id}]).(
356- $component := $lookup( $systems, $component_id);
357- $assert($type($component.title)="string", "Для deployment unit " & $du_id & " указан некорректный идентификатор. Идентификатор должен содержать в себе идентификатор run-time компоненты. Компонент с идентификатором " & $component_id & " не найден. Исправьте идентификатор и повторите операцию.");
358- $entity_dochub := $dictionaries."settings.entity".parameters[dochub=$component.entity];
359- $entity := $type($entity_dochub.dochub)="string" ? $entity_dochub.mermaid : "Container";
360- $merge([$ , {"component_title": $component.title}]).
361- $merge([$ , {"component_entity": $entity}])
362- {
363- "du_id": $du_id,
364- "component_id": component_id,
365- "system": system_id,
366- "cluster": resource_allocation.cluster,
367- "component_title": component_title,
368- "component_entity": component_entity,
369- "cpu_type": resource_req.cpu_type,
370- "cpu": resource_req.cpu,
371- "ram": resource_req.ram,
372- "storage_type": resource_req.storage_type,
373- "storage_size": resource_req.storage_size
374- }
375- );
376- );
377-
378- $objects := $nodes{
379- `cluster`: {
380- `system`: {
381- `du_id`: {
382- "id": du_id,
383- "cpu": cpu & "Core",
384- "cpu_type": cpu_type,
385- "ram": ram & "Gb",
386- "storage_size": storage_size & "Gb",
387- "storage_type": storage_type,
388- "component_title": component_title,
389- "component_entity": component_entity
390- }}
391- }
392- };
393-
394- $du := function($system_du) {(
395- $join($system_du.*.(
396- component_entity & "("& id & ", \"" &component_title & "\",, \"" & "<br/> RAM " & ram & ";<br/> CPU type: " & cpu_type & ";<br/> CPU: " & cpu & "; <br/>Storage type: " & storage_type & "; <br/>Storage: " & storage_size & "\")"
397- ), "\n") & "\n"
398- )};
399-
400- $system_du := function($cluster_du, $cluster_id) {(
401- $join($cluster_du.$spread().(
402- $system_id := $keys()[0];
403- $system := $lookup( $systems, $system_id);
404- $system_title :=$system.title;
405- $system_short_description :=$system.short_description;
406- "Deployment_Node(" & $cluster_id & "_" & $system_id & ", \"" & $system_title & "\", \"" & $system_short_description & "\") {\n" & $du($.*) & "\n}" ;
407- ), "\n") & "\n"
408- )};
409-
410- $code := $join($objects.$spread().(
411- $id := $keys()[0];
412- $cluster_temp := $lookup($clusters, $id);
413- "Deployment_Node(" & $id & ", \"" & $cluster_temp.description & "\", \"" & $cluster_temp.resource_type & "\") {\n" & $system_du($.*, $id) & "\n}" ;
414- ), "\n");
415-
416- {
417- "notation": "C4Deployment",
418- "code":
419- $count($nodes) > 0
420- ? $code
421- : "Deployment_Node(empty_node, \"\") {\nContainer(cempty, \"Заполните deployment units для этого кластера\")\n}",
422- "title": "Диаграммы развертывания для системы " & $_system.title
423- };
424- )
425-
426-
257+ # Для того чтобы сотруднику DevOps понять все ли компоненты он распределил делаем ему табличку где выбираем все DU из компонент
258+ # и смотрим привязал ли он их к кластеру
427259 system_deployment_table :
428260 location : test
429261 type : table
@@ -533,7 +365,7 @@ entities:
533365
534366
535367 # Лист проверки привязки deployment_units к кластеру для системы
536- check_system_du :
368+ deployment_card :
537369 type : markdown
538370 template : deployment_card.md
539371 source : >
0 commit comments