hypervisor annotation show if base domain is initialized or not

This commit is contained in:
Josh Patterson
2025-03-06 15:26:08 -05:00
parent 6c472dd383
commit f30938ed59
7 changed files with 53 additions and 65 deletions
+1 -1
View File
@@ -22,7 +22,7 @@ hypervisor_annotation:
- group: socore
- defaults:
HYPERVISORS: {{ HYPERVISORS }}
base_domain_ready: {{ salt['pillar.get']('base_domain_ready', False) }}
baseDomainStatus: {{ salt['pillar.get']('baseDomain:status', 'Initialized') }}
{% for role in HYPERVISORS %}
{% for hypervisor in HYPERVISORS[role].keys() %}
@@ -1,36 +0,0 @@
# This is the start of an example of what this file will look like. It will be generated by Salt, so this yaml file is not used by Salt.
hypervisor:
hosts:
jpphype1VMs:
description: Hypervisor Configuration
file: true
global: true
syntax: json
title: jpphype1
uiElements:
- field: hostname
label: Enter the hostname
- field: role
label: sensor or searchnode
- field: network_mode
label: Choose static4 or dhcp4. If static4, populate IP details below.
- field: ip4
label: IP Address with netmask. ex. 192.168.1.10/24
- field: gw4
label: Gateway
- field: dns4
label: DNS. Comma separated list. ex. 192.168.1.1,8.8.8.8
- field: search4
label: Search domain
- field: cpu
label: 'CPU cores to assign. Free: 120 | Total: 128'
- field: memory
label: 'Memory to assign, in GB. Free: 112 | Total: 128'
- field: disk
label: 'Disk(s) for passthrough. Comma separated list. Free: 2 | Total: 1,2'
- field: copper
label: 'Copper port(s) for passthrough. Comma separated list. Free: 3,4 |
Total: 1,2,3,4'
- field: sfp
label: 'SFP port(s) for passthrough. Comma separated list. Free: 5,6,7,8 |
Total: 5,6,7,8'
@@ -24,26 +24,32 @@
| Available | {{ cpu_free }} | {{ mem_free }} | {{ disk_free | replace('\n', ',') if disk_free else 'None' }} | {{ copper_free | replace('\n', ',') if copper_free else 'None' }} | {{ sfp_free | replace('\n', ',') if sfp_free else 'None' }} |
| Total | {{ cpu_total }} | {{ mem_total }} | {{ disk_total | replace('\n', ',') }} | {{ copper_total | replace('\n', ',') }} | {{ sfp_total | replace('\n', ',') }} |
{%- if vm_list %}
{%- if baseDomainStatus == 'Initialized' %}
{%- if vm_list %}
#### Virtual Machines
Status values: {% for step in PROCESS_STEPS %}{{ step }}{% if not loop.last %}, {% endif %}{% endfor %}. "Last Updated" shows when status changed. After "Highstate Triggered", only "Destroyed Instance" updates the timestamp.
| Name | Status | CPU Cores | Memory (GB)| Disk | Copper | SFP | Last Updated |
|--------------------|--------------------|-----------|------------|------|--------|------|---------------------|
{%- for hostname, vm_data in vm_list.items() %}
{%- set vm_status = vm_data.get('status', {}).get('status', 'Unknown') %}
{%- set is_destroyed = vm_status == 'Destroyed Instance' %}
{%- if is_destroyed %}
{%- for hostname, vm_data in vm_list.items() %}
{%- set vm_status = vm_data.get('status', {}).get('status', 'Unknown') %}
{%- set is_destroyed = vm_status == 'Destroyed Instance' %}
{%- if is_destroyed %}
| {{ hostname }} | {{ vm_status }} | - | - | - | - | - | {{ vm_data.get('status', {}).get('timestamp', 'Never') | replace('T', ' ') | regex_replace('\\.[0-9]+', '') }} |
{%- else %}
{%- else %}
| {{ hostname }} | {{ vm_status }} | {{ vm_data.get('config', {}).get('cpu', 'N/A') }} | {{ vm_data.get('config', {}).get('memory', 'N/A') }} | {{ vm_data.get('config', {}).get('disk', []) | join(',') if vm_data.get('config', {}).get('disk') else '-' }} | {{ vm_data.get('config', {}).get('copper', []) | join(',') if vm_data.get('config', {}).get('copper') else '-' }} | {{ vm_data.get('config', {}).get('sfp', []) | join(',') if vm_data.get('config', {}).get('sfp') else '-' }} | {{ vm_data.get('status', {}).get('timestamp', 'Never') | replace('T', ' ') | regex_replace('\\.[0-9]+', '') }} |
{%- endif %}
{%- endfor %}
{%- else %}
{%- endif %}
{%- endfor %}
{%- else %}
#### Virtual Machines
Status values: {% for step in PROCESS_STEPS %}{{ step }}{% if not loop.last %}, {% endif %}{% endfor %}. "Last Updated" shows when status changed. After "Highstate Triggered", only "Destroyed Instance" updates the timestamp.
No Virtual Machines Found
{%- endif %}
{%- else %}
#### WARNING
Base domain has not been initialized.
{%- endif %}
{%- endmacro -%}
@@ -174,7 +180,7 @@ No Virtual Machines Found
{%- endif -%}
{%- do updated_elements.append(updated_field) -%}
{%- endfor -%}
{%- if base_domain_ready -%}
{%- if baseDomainStatus == 'Initialized' %}
{%- do updated_template.update({'uiElements': updated_elements}) -%}
{%- else -%}
{%- do updated_template.pop('uiElements') -%}