dynamic annotations

This commit is contained in:
m0duspwnens
2024-10-22 09:03:02 -04:00
parent dcc1738978
commit 0476585370
4 changed files with 57 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
soc_hypervisor_pillar:
file.managed:
- name: /opt/so/saltstack/local/pillar/hypervisor/soc_hypervisor.sls
- source: salt://hypervisor/pillar.map.jinja
- template: jinja

View File

@@ -0,0 +1,35 @@
hypervisor:
hosts:
defaultHost:
add_guest:
description: Add a new guest to the hypervisor.
forcedType: "[]string"
global: True
multiline: True
guests:
defaultGuest:
copper:
description: Copper nics
forcedType: "[]int"
global: True
multiline: True
sfp:
description: sfp nics
forcedType: string
global: True
multiline: True
disks:
description: disk
forcedType: "[]int"
global: True
multiline: True
cpu:
description: cpu
forcedType: int
global: True
multiline: True
memory:
description: mem
forcedType: int
global: True
multiline: True

View File

@@ -0,0 +1,5 @@
hypervisor_annotation:
file.managed:
- name: /opt/so/saltstack/default/salt/hypervisor/soc_hypervisor.yaml
- source: salt://soc/dynamic_annotations/hypervisor/soc_hypervisor.yaml.jinja
- template: jinja

View File

@@ -0,0 +1,12 @@
{% import_yaml 'soc/dynamic_annotations/hypervisor/hypervisor.yaml' as ANNOTATION %}
{% set HYPERVISORS = salt['pillar.get']('hypervisor:nodes', {}) %}
{% set TEMPLATE = ANNOTATION.hypervisor.hosts.pop('defaultHost') %}
{# remove defaultGuest so that it is not shown in Grid Configuration UI #}
{% do TEMPLATE['guests'].pop('defaultGuest') %}
{% for hypervisor in HYPERVISORS.hypervisor %}
{% do ANNOTATION.hypervisor.hosts.update({hypervisor: TEMPLATE}) %}
{% endfor %}
{{ ANNOTATION | yaml(False) }}