mirror of
https://github.com/Security-Onion-Solutions/securityonion.git
synced 2025-12-06 17:22:49 +01:00
change description formatting. include full vm name in HYPERVISORS
This commit is contained in:
@@ -79,7 +79,7 @@
|
||||
}
|
||||
}) %}
|
||||
{% endif %}
|
||||
{% do vms.update({hostname: vm_data}) %}
|
||||
{% do vms.update({hostname ~ '_' ~ role: vm_data}) %}
|
||||
{% else %}
|
||||
{% do salt.log.info('salt/hypervisor/map.jinja: Config file empty: ' ~ vm_file) %}
|
||||
{% endif %}
|
||||
@@ -87,8 +87,8 @@
|
||||
|
||||
{# Find and add destroyed VMs from status files #}
|
||||
{% set processed_vms = [] %}
|
||||
{% for vm_name, vm_data in vms.items() %}
|
||||
{% do processed_vms.append(vm_name) %}
|
||||
{% for vm_full_name, vm_data in vms.items() %}
|
||||
{% do processed_vms.append(vm_full_name) %}
|
||||
{% endfor %}
|
||||
|
||||
{# Find all status files for this hypervisor #}
|
||||
@@ -117,7 +117,7 @@
|
||||
{% set hostname = vm_name.split('_')[0] %}
|
||||
|
||||
{# Skip already processed VMs #}
|
||||
{% if hostname in processed_vms %}
|
||||
{% if vm_name in processed_vms %}
|
||||
{% continue %}
|
||||
{% endif %}
|
||||
|
||||
@@ -127,11 +127,11 @@
|
||||
|
||||
{# Only process files with "Destroyed Instance" status #}
|
||||
{% if status_data and status_data.status == 'Destroyed Instance' %}
|
||||
{% do salt.log.info('salt/hypervisor/map.jinja: Found VM with Destroyed Instance status: ' ~ hostname) %}
|
||||
{% do salt.log.info('salt/hypervisor/map.jinja: Found VM with Destroyed Instance status: ' ~ vm_name) %}
|
||||
|
||||
{# Add to vms with minimal config #}
|
||||
{% do vms.update({
|
||||
hostname: {
|
||||
vm_name: {
|
||||
'status': status_data,
|
||||
'config': {}
|
||||
}
|
||||
|
||||
@@ -390,8 +390,8 @@ def check_hardware_availability(hypervisor_path: str, vm_name: str, requested_hw
|
||||
continue
|
||||
|
||||
vm_config = read_json_file(vm_file)
|
||||
if 'config' not in vm_config or vm_config.get('status') != 'running':
|
||||
log.debug("Skipping VM %s (not running)", basename)
|
||||
if 'config' not in vm_config:
|
||||
log.debug("Skipping VM %s (no config found)", basename)
|
||||
continue
|
||||
|
||||
config = vm_config['config']
|
||||
@@ -469,9 +469,7 @@ def create_vm_tracking_file(hypervisor_path: str, vm_name: str, config: dict) ->
|
||||
set_socore_ownership(os.path.dirname(file_path))
|
||||
|
||||
data = {
|
||||
'config': config,
|
||||
'status': 'creating',
|
||||
'timestamp': datetime.now().isoformat()
|
||||
'config': config
|
||||
}
|
||||
# Write file and set ownership
|
||||
write_json_file(file_path, data)
|
||||
@@ -648,11 +646,9 @@ def process_vm_creation(hypervisor_path: str, vm_config: dict) -> None:
|
||||
# Execute command
|
||||
result = subprocess.run(cmd, capture_output=True, text=True, check=True)
|
||||
|
||||
# Update tracking file status with timestamp
|
||||
# Update tracking file if needed
|
||||
tracking_file = os.path.join(hypervisor_path, vm_name)
|
||||
data = read_json_file(tracking_file)
|
||||
data['status'] = 'running'
|
||||
data['timestamp'] = datetime.now().isoformat()
|
||||
write_json_file(tracking_file, data)
|
||||
|
||||
except subprocess.CalledProcessError as e:
|
||||
|
||||
@@ -18,55 +18,30 @@
|
||||
{%- set TEMPLATE = ANNOTATION.hypervisor.hosts.pop('defaultHost') -%}
|
||||
|
||||
{%- macro update_description(description, cpu_free, mem_free, disk_free, copper_free, sfp_free, vm_list, cpu_total, mem_total, disk_total, copper_total, sfp_total) -%}
|
||||
# Hypervisor Configuration: {{ description }}
|
||||
|
||||
## Resource Summary
|
||||
#### Resource Summary
|
||||
| | CPU Cores | Memory (GB) | Disk | Copper | SFP |
|
||||
|-----------|-----------|-------------|-------------|-------------|-------------|
|
||||
| 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 %}
|
||||
## Virtual Machines
|
||||
VMs can have the following status values: {% for step in PROCESS_STEPS %}{{ step }}{% if not loop.last %}, {% endif %}{% endfor %}. The "Last Updated" timestamp shows when the VM status was last changed. After reaching "Highstate Triggered" status, additional highstate runs will not update the timestamp. Only changing to "Destroyed Instance" status will update the timestamp again.
|
||||
#### 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' %}
|
||||
{%- set vm_role = vm_data.get('config', {}).get('role', 'unknown') %}
|
||||
{%- set name = hostname ~ (('_' ~ vm_role) if not is_destroyed and vm_role != 'unknown' else '') %}
|
||||
| {{ name }} | {{ vm_status }} |
|
||||
{%- if is_destroyed -%}
|
||||
-
|
||||
{%- else -%}
|
||||
{{ vm_data.get('config', {}).get('cpu', 'N/A') }}
|
||||
{%- endif %} |
|
||||
{%- if is_destroyed -%}
|
||||
-
|
||||
{%- else -%}
|
||||
{{ vm_data.get('config', {}).get('memory', 'N/A') }}
|
||||
{%- endif %} |
|
||||
{%- if is_destroyed -%}
|
||||
-
|
||||
{%- else -%}
|
||||
{{ vm_data.get('config', {}).get('disk', '-') | replace('\n', ',') if vm_data.get('config', {}).get('disk') else '-' }}
|
||||
{%- endif %} |
|
||||
{%- if is_destroyed -%}
|
||||
-
|
||||
{%- else -%}
|
||||
{{ vm_data.get('config', {}).get('copper', '-') | replace('\n', ',') if vm_data.get('config', {}).get('copper') else '-' }}
|
||||
{%- endif %} |
|
||||
{%- if is_destroyed -%}
|
||||
-
|
||||
{%- else -%}
|
||||
{{ vm_data.get('config', {}).get('sfp', '-') | replace('\n', ',') if vm_data.get('config', {}).get('sfp') else '-' }}
|
||||
{%- endif %} | {{ vm_data.get('status', {}).get('timestamp', 'Never') | replace('T', ' ') | regex_replace('\\.[0-9]+', '') }} |
|
||||
{%- if is_destroyed %}
|
||||
| {{ hostname }} | {{ vm_status }} | - | - | - | - | - | {{ vm_data.get('status', {}).get('timestamp', 'Never') | replace('T', ' ') | regex_replace('\\.[0-9]+', '') }} |
|
||||
{%- 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', '-') | replace('\n', ',') if vm_data.get('config', {}).get('disk') else '-' }} | {{ vm_data.get('config', {}).get('copper', '-') | replace('\n', ',') if vm_data.get('config', {}).get('copper') else '-' }} | {{ vm_data.get('config', {}).get('sfp', '-') | replace('\n', ',') if vm_data.get('config', {}).get('sfp') else '-' }} | {{ vm_data.get('status', {}).get('timestamp', 'Never') | replace('T', ' ') | regex_replace('\\.[0-9]+', '') }} |
|
||||
{%- endif %}
|
||||
{%- endfor %}
|
||||
{%- else %}
|
||||
## Virtual Machines
|
||||
VMs can have the following status values: {% for step in PROCESS_STEPS %}{{ step }}{% if not loop.last %}, {% endif %}{% endfor %}. The "Last Updated" timestamp shows when the VM status was last changed. After reaching "Highstate Triggered" status, additional highstate runs will not update the timestamp. Only changing to "Destroyed Instance" status will update the timestamp again.
|
||||
#### 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 %}
|
||||
|
||||
Reference in New Issue
Block a user