mirror of
https://github.com/Security-Onion-Solutions/securityonion.git
synced 2025-12-08 02:02:50 +01:00
hypervisor annotation show if base domain is initialized or not
This commit is contained in:
@@ -430,9 +430,9 @@ def _apply_dyanno_hypervisor_state():
|
|||||||
# Initialize the LocalClient
|
# Initialize the LocalClient
|
||||||
local = salt.client.LocalClient()
|
local = salt.client.LocalClient()
|
||||||
|
|
||||||
# Target the salt master (localhost) to apply the soc.dyanno.hypervisor state
|
# Target the salt master to apply the soc.dyanno.hypervisor state
|
||||||
target = MANAGER_HOSTNAME + '_*'
|
target = MANAGER_HOSTNAME + '_*'
|
||||||
state_result = local.cmd(target, 'state.apply', ['soc.dyanno.hypervisor'], tgt_type='glob', concurrent=True)
|
state_result = local.cmd(target, 'state.apply', ['soc.dyanno.hypervisor', "pillar={'baseDomain': {'status': 'PreInit'}}", 'concurrent=True'], tgt_type='glob')
|
||||||
log.debug(f"DYANNO: state_result: {state_result}")
|
log.debug(f"DYANNO: state_result: {state_result}")
|
||||||
# Check if state was applied successfully
|
# Check if state was applied successfully
|
||||||
if state_result:
|
if state_result:
|
||||||
|
|||||||
@@ -157,6 +157,17 @@ configure_network_predictable_sool9:
|
|||||||
- onchanges:
|
- onchanges:
|
||||||
- cmd: create_vm_sool9
|
- cmd: create_vm_sool9
|
||||||
|
|
||||||
|
# Fire event here that causes soc.dyanno.hypervisor state to be applied
|
||||||
|
base_domain_ready:
|
||||||
|
event.send:
|
||||||
|
- name: soc/dyanno/hypervisor/baseDomain
|
||||||
|
- data:
|
||||||
|
status: 'Initialized'
|
||||||
|
- require:
|
||||||
|
- cmd: configure_network_predictable_sool9
|
||||||
|
- onchanges:
|
||||||
|
- cmd: create_vm_sool9
|
||||||
|
|
||||||
{% else %}
|
{% else %}
|
||||||
{{sls}}_no_license_detected:
|
{{sls}}_no_license_detected:
|
||||||
test.fail_without_changes:
|
test.fail_without_changes:
|
||||||
|
|||||||
@@ -11,6 +11,16 @@
|
|||||||
|
|
||||||
{% if 'hvn' in salt['pillar.get']('features', []) %}
|
{% if 'hvn' in salt['pillar.get']('features', []) %}
|
||||||
|
|
||||||
|
{% do salt.log.info('dyanno_hypervisor_orch: Running') %}
|
||||||
|
{% set vm_name = None %}
|
||||||
|
{% set hypervisor = None %}
|
||||||
|
{% set status = None %}
|
||||||
|
{% set data = pillar.get('data', {}) %}
|
||||||
|
{% set tag = pillar.get('tag', '') %}
|
||||||
|
{% set timestamp = data.get('_stamp') %}
|
||||||
|
{% do salt.log.debug('dyanno_hypervisor_orch: tag: ' ~ tag) %}
|
||||||
|
{% do salt.log.debug('dyanno_hypervisor_orch: Received data: ' ~ data|json|string) %}
|
||||||
|
|
||||||
{# Macro to find hypervisor name from VM status file #}
|
{# Macro to find hypervisor name from VM status file #}
|
||||||
{% macro find_hypervisor_from_status(vm_name) -%}
|
{% macro find_hypervisor_from_status(vm_name) -%}
|
||||||
{%- set path = salt['file.find']('/opt/so/saltstack/local/salt/hypervisor/hosts/',type='f', name=vm_name ~ '.status') -%}
|
{%- set path = salt['file.find']('/opt/so/saltstack/local/salt/hypervisor/hosts/',type='f', name=vm_name ~ '.status') -%}
|
||||||
@@ -28,22 +38,17 @@
|
|||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
{%- endmacro %}
|
{%- endmacro %}
|
||||||
|
|
||||||
{% do salt.log.info('dyanno_hypervisor_orch: Running') %}
|
|
||||||
|
|
||||||
{% set data = pillar.get('data', {}) %}
|
|
||||||
{% set tag = pillar.get('tag', '') %}
|
|
||||||
{% set timestamp = data.get('_stamp') %}
|
|
||||||
{% do salt.log.debug('dyanno_hypervisor_orch: tag: ' ~ tag) %}
|
|
||||||
{% do salt.log.debug('dyanno_hypervisor_orch: Received data: ' ~ data|json|string) %}
|
|
||||||
|
|
||||||
{# Our custom tag #}
|
{# Our custom tag #}
|
||||||
{% if tag.startswith('soc/dyanno/hypervisor') %}
|
{% if tag.startswith('soc/dyanno/hypervisor') %}
|
||||||
{% set status_data = data.get('data')%}
|
{% set status_data = data.get('data')%}
|
||||||
{% do salt.log.debug('dyanno_hypervisor_orch: Received data: ' ~ status_data|json|string) %}
|
{% do salt.log.debug('dyanno_hypervisor_orch: Received data: ' ~ status_data|json|string) %}
|
||||||
|
{% if not tag.endswith('/baseDomain') %}
|
||||||
{% do salt.log.debug('dyanno_hypervisor_orch: Setting vm_name, hypervisor and status') %}
|
{% do salt.log.debug('dyanno_hypervisor_orch: Setting vm_name, hypervisor and status') %}
|
||||||
{% set vm_name = status_data.get('vm_name') %}
|
{% set vm_name = status_data.get('vm_name') %}
|
||||||
{% set hypervisor = status_data.get('hypervisor') %}
|
{% set hypervisor = status_data.get('hypervisor') %}
|
||||||
|
{% endif %}
|
||||||
{% set status = status_data.get('status') %}
|
{% set status = status_data.get('status') %}
|
||||||
|
{% set hypervisor = data.get('id') %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{# setup/so-minion tag #}
|
{# setup/so-minion tag #}
|
||||||
@@ -80,6 +85,7 @@
|
|||||||
|
|
||||||
{% do salt.log.info('dyanno_hypervisor_orch: vm_name: ' ~ vm_name ~ ' hypervisor: ' ~ hypervisor ~ ' status: ' ~ status) %}
|
{% do salt.log.info('dyanno_hypervisor_orch: vm_name: ' ~ vm_name ~ ' hypervisor: ' ~ hypervisor ~ ' status: ' ~ status) %}
|
||||||
|
|
||||||
|
{% if vm_name and hypervisor and timestamp and status and tag %}
|
||||||
write_vm_status:
|
write_vm_status:
|
||||||
salt.state:
|
salt.state:
|
||||||
- tgt: 'G@role:so-manager or G@role:so-managersearch or G@role:so-standalone or G@role:so-eval'
|
- tgt: 'G@role:so-manager or G@role:so-managersearch or G@role:so-standalone or G@role:so-eval'
|
||||||
@@ -94,6 +100,7 @@ write_vm_status:
|
|||||||
timestamp: {{ timestamp }}
|
timestamp: {{ timestamp }}
|
||||||
status: {{ status }}
|
status: {{ status }}
|
||||||
event_tag: {{ tag }}
|
event_tag: {{ tag }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{# Check if the base domain exists / is ready for VMs #}
|
{# Check if the base domain exists / is ready for VMs #}
|
||||||
{#% set file_exists = False %}
|
{#% set file_exists = False %}
|
||||||
@@ -113,6 +120,11 @@ update_hypervisor_annotation:
|
|||||||
- sls:
|
- sls:
|
||||||
- soc.dyanno.hypervisor
|
- soc.dyanno.hypervisor
|
||||||
- concurrent: True
|
- concurrent: True
|
||||||
|
{% if tag == ('soc/dyanno/hypervisor/baseDomain') %}
|
||||||
|
- pillar:
|
||||||
|
baseDomain:
|
||||||
|
status: {{ status }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% do salt.log.info('dyanno_hypervisor_orch: Completed') %}
|
{% do salt.log.info('dyanno_hypervisor_orch: Completed') %}
|
||||||
|
|
||||||
|
|||||||
@@ -83,11 +83,6 @@ enable_startup_states:
|
|||||||
- regex: '^startup_states: highstate$'
|
- regex: '^startup_states: highstate$'
|
||||||
- unless: pgrep so-setup
|
- unless: pgrep so-setup
|
||||||
|
|
||||||
# manager with hypervisors with need this beacon added to the minion config
|
|
||||||
#beacons:
|
|
||||||
# add_virtual_node_beacon:
|
|
||||||
# - base_path: /opt/so/saltstack/local/salt/hypervisor/hosts/*/add_*
|
|
||||||
|
|
||||||
# prior to 2.4.30 this managed file would restart the salt-minion service when updated
|
# prior to 2.4.30 this managed file would restart the salt-minion service when updated
|
||||||
# since this file is currently only adding a sleep timer on service start
|
# since this file is currently only adding a sleep timer on service start
|
||||||
# it is not required to restart the service
|
# it is not required to restart the service
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ hypervisor_annotation:
|
|||||||
- group: socore
|
- group: socore
|
||||||
- defaults:
|
- defaults:
|
||||||
HYPERVISORS: {{ HYPERVISORS }}
|
HYPERVISORS: {{ HYPERVISORS }}
|
||||||
base_domain_ready: {{ salt['pillar.get']('base_domain_ready', False) }}
|
baseDomainStatus: {{ salt['pillar.get']('baseDomain:status', 'Initialized') }}
|
||||||
|
|
||||||
{% for role in HYPERVISORS %}
|
{% for role in HYPERVISORS %}
|
||||||
{% for hypervisor in HYPERVISORS[role].keys() %}
|
{% 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,6 +24,7 @@
|
|||||||
| 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' }} |
|
| 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', ',') }} |
|
| Total | {{ cpu_total }} | {{ mem_total }} | {{ disk_total | replace('\n', ',') }} | {{ copper_total | replace('\n', ',') }} | {{ sfp_total | replace('\n', ',') }} |
|
||||||
|
|
||||||
|
{%- if baseDomainStatus == 'Initialized' %}
|
||||||
{%- if vm_list %}
|
{%- if vm_list %}
|
||||||
#### Virtual Machines
|
#### 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.
|
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.
|
||||||
@@ -45,6 +46,11 @@ Status values: {% for step in PROCESS_STEPS %}{{ step }}{% if not loop.last %},
|
|||||||
|
|
||||||
No Virtual Machines Found
|
No Virtual Machines Found
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
{%- else %}
|
||||||
|
#### WARNING
|
||||||
|
|
||||||
|
Base domain has not been initialized.
|
||||||
|
{%- endif %}
|
||||||
{%- endmacro -%}
|
{%- endmacro -%}
|
||||||
|
|
||||||
{%- macro update_label(label, total, free) -%}
|
{%- macro update_label(label, total, free) -%}
|
||||||
@@ -174,7 +180,7 @@ No Virtual Machines Found
|
|||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
{%- do updated_elements.append(updated_field) -%}
|
{%- do updated_elements.append(updated_field) -%}
|
||||||
{%- endfor -%}
|
{%- endfor -%}
|
||||||
{%- if base_domain_ready -%}
|
{%- if baseDomainStatus == 'Initialized' %}
|
||||||
{%- do updated_template.update({'uiElements': updated_elements}) -%}
|
{%- do updated_template.update({'uiElements': updated_elements}) -%}
|
||||||
{%- else -%}
|
{%- else -%}
|
||||||
{%- do updated_template.pop('uiElements') -%}
|
{%- do updated_template.pop('uiElements') -%}
|
||||||
|
|||||||
Reference in New Issue
Block a user