Skip to content

Commit c28f663

Browse files
committed
aggregate results for regions in table
Signed-off-by: Matthias Büchse <[email protected]>
1 parent e8a3f04 commit c28f663

File tree

2 files changed

+29
-16
lines changed

2 files changed

+29
-16
lines changed

compliance-monitor/monitor.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -785,13 +785,34 @@ async def get_healthz(request: Request):
785785
return Response() # empty response with status 200
786786

787787

788-
def pick_filter(results, scope, subject):
788+
def pick_filter(results, scope, *subjects):
789789
"""Jinja filter to pick scope results from `results` for given `subject` and `scope`"""
790-
return results.get(subject, {}).get(scope, {})
790+
# simple case (backwards compatible): precisely one subject
791+
if len(subjects) == 1:
792+
return results.get(subjects[0], {}).get(scope, {})
793+
# generalized case: multiple subjects
794+
# in this case, drop None
795+
rs = [results.get(subject, {}).get(scope, {}) for subject in subjects]
796+
return [r for r in rs if r is not None]
797+
798+
799+
STATUS_ORDERING = {
800+
'effective': 10,
801+
'warn': 5,
802+
'deprecated': 1,
803+
}
791804

792805

793806
def summary_filter(scope_results):
794807
"""Jinja filter to construct summary from `scope_results`"""
808+
if not isinstance(scope_results, dict):
809+
# new generalized case: "aggregate" results for multiple subjects
810+
# simplified computation: just select the worst subject to represent the group
811+
scope_results = min(
812+
scope_results,
813+
default={},
814+
key=lambda sr: STATUS_ORDERING.get(sr.get('best_passed'), -1),
815+
)
795816
passed_str = scope_results.get('passed_str', '') or '–'
796817
best_passed = scope_results.get('best_passed')
797818
# avoid simple 🟢🔴 (hard to distinguish for color-blind folks)

compliance-monitor/templates/overview.md.j2

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,9 @@ Version numbers are suffixed by a symbol depending on state: * for _draft_, †
2222
| [CNDS](https://cnds.io/) | Public cloud for customers | artcodix GmbH |
2323
{#- #} [{{ results | pick(iaas, 'artcodix') | summary }}]({{ detail_url('artcodix', iaas) }}) {# -#}
2424
| [HM](https://ohm.muc.cloud.cnds.io/) |
25-
| [pluscloud open](https://www.plusserver.com/en/products/pluscloud-open)<br />(4 regions) | Public cloud for customers | plusserver GmbH | {# #}
26-
{#- #}prod1: [{{ results | pick(iaas, 'pco-prod1') | summary }}]({{ detail_url('pco-prod1', iaas) }}){# -#}
27-
<br />
28-
{#- #}prod2: [{{ results | pick(iaas, 'pco-prod2') | summary }}]({{ detail_url('pco-prod2', iaas) }}){# -#}
29-
<br />
30-
{#- #}prod3: [{{ results | pick(iaas, 'pco-prod3') | summary }}]({{ detail_url('pco-prod3', iaas) }}){# -#}
31-
<br />
32-
{#- #}prod4: [{{ results | pick(iaas, 'pco-prod4') | summary }}]({{ detail_url('pco-prod4', iaas) }}) {# -#}
33-
| [HM1](https://health.prod1.plusserver.sovereignit.cloud:3000/d/9ltTEmlnk/openstack-health-monitor2?orgId=1&var-mycloud=plus-pco)<br />[HM2](https://health.prod1.plusserver.sovereignit.cloud:3000/d/9ltTEmlnk/openstack-health-monitor2?orgId=1&var-mycloud=plus-prod2)<br />[HM3](https://health.prod1.plusserver.sovereignit.cloud:3000/d/9ltTEmlnk/openstack-health-monitor2?orgId=1&var-mycloud=plus-prod3)<br />[HM4](https://health.prod1.plusserver.sovereignit.cloud:3000/d/9ltTEmlnk/openstack-health-monitor2?orgId=1&var-mycloud=plus-prod4) |
25+
| [pluscloud open](https://www.plusserver.com/en/products/pluscloud-open) | Public cloud for customers (4 regions) | plusserver GmbH | {# #}
26+
{#- #}[{{ results | pick(iaas, 'pco-prod1', 'pco-prod2', 'pco-prod3', 'pco-prod4') | summary }}]({{ detail_url('pco-prod1', iaas) }}) {# -#}
27+
| [HM1](https://health.prod1.plusserver.sovereignit.cloud:3000/d/9ltTEmlnk/openstack-health-monitor2?orgId=1&var-mycloud=plus-pco) [HM2](https://health.prod1.plusserver.sovereignit.cloud:3000/d/9ltTEmlnk/openstack-health-monitor2?orgId=1&var-mycloud=plus-prod2) [HM3](https://health.prod1.plusserver.sovereignit.cloud:3000/d/9ltTEmlnk/openstack-health-monitor2?orgId=1&var-mycloud=plus-prod3) [HM4](https://health.prod1.plusserver.sovereignit.cloud:3000/d/9ltTEmlnk/openstack-health-monitor2?orgId=1&var-mycloud=plus-prod4) |
3428
| PoC WG-Cloud OSBA | Cloud PoC for FITKO | Cloud&amp;Heat Technologies GmbH |
3529
{#- #} [{{ results | pick(iaas, 'poc-wgcloud') | summary }}]({{ detail_url('poc-wgcloud', iaas) }}) {# -#}
3630
| [HM](https://health.poc-wgcloud.osba.sovereignit.cloud:3000/d/9ltTEmlnk/openstack-health-monitor2?var-mycloud=poc-wgcloud&orgId=1) |
@@ -40,11 +34,9 @@ Version numbers are suffixed by a symbol depending on state: * for _draft_, †
4034
| [ScaleUp Open Cloud](https://www.scaleuptech.com/cloud-hosting/) | Public cloud for customers | ScaleUp Technologies GmbH & Co. KG |
4135
{#- #} [{{ results | pick(iaas, 'scaleup-occ2') | summary }}]({{ detail_url('scaleup-occ2', iaas) }}) {# -#}
4236
| [HM](https://health.occ2.scaleup.sovereignit.cloud) |
43-
| [syseleven](https://www.syseleven.de/en/products-services/openstack-cloud/)<br />(2 SCS regions) | Public OpenStack Cloud | SysEleven GmbH | {# #}
44-
{#- #}dus2: [{{ results | pick(iaas, 'syseleven-dus2') | summary }}]({{ detail_url('syseleven-dus2', iaas) }}){# -#}
45-
<br />
46-
{#- #}ham1: [{{ results | pick(iaas, 'syseleven-ham1') | summary }}]({{ detail_url('syseleven-ham1', iaas) }}) {# -#}
47-
| (soon)<br />(soon) |
37+
| [syseleven](https://www.syseleven.de/en/products-services/openstack-cloud/) | Public OpenStack Cloud (2 SCS regions) | SysEleven GmbH | {# #}
38+
{#- #} [{{ results | pick(iaas, 'syseleven-dus2', 'syseleven-ham1') | summary }}]({{ detail_url('syseleven-dus2', iaas) }}) {# -#}
39+
| (soon) |
4840
| [Wavestack](https://www.noris.de/wavestack-cloud/) | Public cloud for customers | noris network AG/Wavecon GmbH |
4941
{#- #} [{{ results | pick(iaas, 'wavestack') | summary }}]({{ detail_url('wavestack', iaas) }}) {# -#}
5042
| [HM](https://health.wavestack1.sovereignit.cloud:3000/) |

0 commit comments

Comments
 (0)