dynamic annotations

This commit is contained in:
m0duspwnens
2024-10-11 10:46:07 -04:00
parent 0b0ff62bc5
commit dcc1738978
7 changed files with 142 additions and 60 deletions

View File

@@ -1,61 +1,79 @@
hypervisor:
model1:
hardware:
cpu:
total: 128
free: 128
memory:
total: 128
free: 128
disks:
free:
3: pci_0000_c7_00_0
4: pci_0000_c8_00_0
claimed:
1: pci_0000_c5_00_0
2: pci_0000_c6_00_0
copper:
free:
1: pci_0000_c4_00_0
2: pci_0000_c4_00_1
3: pci_0000_c4_00_2
4: pci_0000_c4_00_3
claimed: {}
sfp:
free:
5: pci_0000_41_00_0
6: pci_0000_41_00_1
claimed: {}
model2:
hardware:
cpu:
total: 128
free: 128
memory:
total: 512
free: 512
disks:
free:
3: pci_0000_c8_00_0
4: pci_0000_c9_00_0
5: pci_0000_c10_00_0
6: pci_0000_c11_00_0
claimed:
1: pci_0000_c6_00_0
2: pci_0000_c7_00_0
copper:
free:
1: pci_0000_c4_00_0
2: pci_0000_c4_00_1
3: pci_0000_c4_00_2
4: pci_0000_c4_00_3
5: pci_0000_c5_00_0
6: pci_0000_c5_00_1
7: pci_0000_c5_00_2
8: pci_0000_c5_00_3
claimed: {}
sfp:
free:
9: pci_0000_41_00_0
10: pci_0000_41_00_1
claimed: {}
nodes:
jpphype1:
add_guest: []
guests:
- sen1_sensor:
cpu: 2
mem: 8192
jpphype1:
guests:
sen1_sensor:
hardware:
cpu: 2
mem: 8192
models:
model1:
hardware:
cpu:
total: 128
free: 128
memory:
total: 128
free: 128
disks:
free:
3: pci_0000_c7_00_0
4: pci_0000_c8_00_0
claimed:
1: pci_0000_c5_00_0
2: pci_0000_c6_00_0
copper:
free:
1: pci_0000_c4_00_0
2: pci_0000_c4_00_1
3: pci_0000_c4_00_2
4: pci_0000_c4_00_3
claimed: {}
sfp:
free:
5: pci_0000_41_00_0
6: pci_0000_41_00_1
claimed: {}
model2:
hardware:
cpu:
total: 128
free: 128
memory:
total: 512
free: 512
disks:
free:
3: pci_0000_c8_00_0
4: pci_0000_c9_00_0
5: pci_0000_c10_00_0
6: pci_0000_c11_00_0
claimed:
1: pci_0000_c6_00_0
2: pci_0000_c7_00_0
copper:
free:
1: pci_0000_c4_00_0
2: pci_0000_c4_00_1
3: pci_0000_c4_00_2
4: pci_0000_c4_00_3
5: pci_0000_c5_00_0
6: pci_0000_c5_00_1
7: pci_0000_c5_00_2
8: pci_0000_c5_00_3
claimed: {}
sfp:
free:
9: pci_0000_41_00_0
10: pci_0000_41_00_1
claimed: {}

View File

@@ -0,0 +1,29 @@
{% set HYPERVISORHOSTS = salt['pillar.get']('hypervisor:hosts', {}) %}
{% import_yaml 'setup/virt/sensor.yaml' as SENSOR %}
{% import_yaml 'setup/virt/searchnode.yaml' as SEARCHNODE %}
{% set vars = {
'sensor': SENSOR,
'searchnode': SEARCHNODE
} %}
{% for host, guestDetails in HYPERVISORHOSTS.items() %}
{% if guestDetails['add_guest'] | length > 0 %}
{% for newGuest in guestDetails['add_guest'] %}
{% set indx = guestDetails['add_guest'].index(newGuest) %}
{% do guestDetails['add_guest'].pop(indx) %}
{% set NODETYPE = newGuest.split('_') | last %}
{% do guestDetails['guests'].update({
newGuest: {
'cpu': vars[NODETYPE].CPU,
'memory': vars[NODETYPE].MEMORY,
'disk': vars[NODETYPE].DISKS,
'copper': vars[NODETYPE].COPPER,
'sfp': vars[NODETYPE].SFP
}
}) %}
{% endfor %}
{% endif %}
{% endfor %}

View File

View File

@@ -0,0 +1,35 @@
hypervisor:
hosts:
defaultHost:
add_guest:
description: List of hypervisor nodes.
forcedType: "[]string"
global: True
multiline: True
guests:
defaultGuest:
copper:
description: Copper nics
forcedType: "[]int"
global: True
multiline: True
sfp:
description: sfp nics
forcedType: "[]int"
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