This commit is contained in:
Josh Patterson
2025-04-03 13:44:13 -04:00
parent 3083e3bc63
commit 445afca6ee
27 changed files with 41 additions and 46 deletions

View File

@@ -121,8 +121,8 @@ def _check_license():
log.error("LICENSE: No license_id found in license file")
return False
if 'hvn' not in features:
log.error("LICENSE: 'hvn' feature not found in license")
if 'vrt' not in features:
log.error("LICENSE: 'vrt' feature not found in license")
return False
log.info("LICENSE: License validation successful")
@@ -506,7 +506,7 @@ def setup_environment(vm_name: str = 'sool9', disk_size: str = '220G', minion_id
if not _check_license():
return {
'success': False,
'error': 'Invalid license or missing hvn feature',
'error': 'Invalid license or missing vrt feature',
'vm_result': None
}
@@ -670,7 +670,7 @@ def create_vm(vm_name: str, disk_size: str = '220G'):
if not _check_license():
return {
'success': False,
'error': 'Invalid license or missing hvn feature',
'error': 'Invalid license or missing vrt feature',
}
try:
@@ -958,11 +958,6 @@ def regenerate_ssh_keys():
else:
print("Failed to regenerate SSH keys")
"""
# Check license before proceeding
if not _check_license():
log.error("MAIN: Invalid license or missing hvn feature")
return False
log.info("MAIN: Starting SSH key regeneration")
try:
# Verify current state

View File

@@ -11,7 +11,7 @@
# in the software, and you may not remove or obscure any functionality in the
# software that is protected by the license key."
{% if 'hvn' in salt['pillar.get']('features', []) -%}
{% if 'vrt' in salt['pillar.get']('features', []) -%}
"""
Script for emitting VM deployment status events to the Salt event bus.

View File

@@ -11,7 +11,7 @@
{% from 'allowed_states.map.jinja' import allowed_states %}
{% if sls in allowed_states %}
{% if 'hvn' in salt['pillar.get']('features', []) %}
{% if 'vrt' in salt['pillar.get']('features', []) %}
hypervisor_log_dir:
file.directory:

View File

@@ -9,7 +9,7 @@
in the software, and you may not remove or obscure any functionality in the
software that is protected by the license key." #}
{% if 'hvn' in salt['pillar.get']('features', []) %}
{% if 'vrt' in salt['pillar.get']('features', []) %}
{# Import defaults.yaml for model hardware capabilities #}
{% import_yaml 'hypervisor/defaults.yaml' as DEFAULTS %}

View File

@@ -11,7 +11,7 @@
# in the software, and you may not remove or obscure any functionality in the
# software that is protected by the license key."
{% if 'hvn' in salt['pillar.get']('features', []) %}
{% if 'vrt' in salt['pillar.get']('features', []) %}
"""
Script for managing hardware configurations of KVM virtual machines. This script provides

View File

@@ -11,7 +11,7 @@
# in the software, and you may not remove or obscure any functionality in the
# software that is protected by the license key."
{% if 'hvn' in salt['pillar.get']('features', []) -%}
{% if 'vrt' in salt['pillar.get']('features', []) -%}
"""
Script for modifying network configurations within QCOW2 virtual machine images. This script provides

View File

@@ -11,7 +11,7 @@
{% from 'allowed_states.map.jinja' import allowed_states %}
{% if sls.split('.')[0] in allowed_states or sls in allowed_states %}
{% if 'hvn' in salt['pillar.get']('features', []) %}
{% if 'vrt' in salt['pillar.get']('features', []) %}
include:
- libvirt.packages

View File

@@ -11,7 +11,7 @@
{% from 'allowed_states.map.jinja' import allowed_states %}
{% if sls in allowed_states %}
{% if 'hvn' in salt['pillar.get']('features', []) %}
{% if 'vrt' in salt['pillar.get']('features', []) %}
{% from 'libvirt/map.jinja' import LIBVIRTMERGED %}
include:

View File

@@ -11,7 +11,7 @@
{% from 'allowed_states.map.jinja' import allowed_states %}
{% if sls.split('.')[0] in allowed_states or sls in allowed_states %}
{% if 'hvn' in salt['pillar.get']('features', []) %}
{% if 'vrt' in salt['pillar.get']('features', []) %}
# allows for creating vm images
# any node manipulating images needs this

View File

@@ -11,7 +11,7 @@
{% from 'allowed_states.map.jinja' import allowed_states %}
{% if sls.split('.')[0] in allowed_states or sls in allowed_states %}
{% if 'hvn' in salt['pillar.get']('features', []) %}
{% if 'vrt' in salt['pillar.get']('features', []) %}
{% from 'vars/globals.map.jinja' import GLOBALS %}
{% if GLOBALS.is_manager %}

View File

@@ -11,7 +11,7 @@
{% from 'allowed_states.map.jinja' import allowed_states %}
{% if sls.split('.')[0] in allowed_states %}
{% if 'hvn' in salt['pillar.get']('features', []) %}
{% if 'vrt' in salt['pillar.get']('features', []) %}
{% set manager_hostname = grains.id.split('_')[0] %}
# Check if hypervisor environment has been set up

View File

@@ -235,7 +235,7 @@ function acceptminion() {
if [[ "$MINION_ID" == *"_hypervisor" ]]; then
FEATURES=$(/usr/sbin/so-yaml.py get /opt/so/saltstack/local/pillar/soc/license.sls features)
if [[ $? -ne 0 || ! "$FEATURES" =~ "hvn" ]]; then
if [[ $? -ne 0 || ! "$FEATURES" =~ "vrt" ]]; then
error_msg="Hypervisor nodes are a feature supported only for customers with a valid license.\n Contact Security Onion Solutions, LLC via our website at https://securityonionsolutions.com\n for more information about purchasing a license to enable this feature."
log "ERROR" "$error_msg"
echo -e "Error: $error_msg"
@@ -869,7 +869,7 @@ function createRECEIVER() {
function createHYPERVISOR() {
log "INFO" "Creating HYPERVISOR configuration for minion $MINION_ID"
FEATURES=$(/usr/sbin/so-yaml.py get /opt/so/saltstack/local/pillar/soc/license.sls features)
if [[ $? -ne 0 || ! "$FEATURES" =~ "hvn" ]]; then
if [[ $? -ne 0 || ! "$FEATURES" =~ "vrt" ]]; then
error_msg="Hypervisor nodes are a feature supported only for customers with a valid license.\n Contact Security Onion Solutions, LLC via our website at https://securityonionsolutions.com\n for more information about purchasing a license to enable this feature."
log "ERROR" "$error_msg"
echo -e "Error: $error_msg"
@@ -964,7 +964,7 @@ function updateMineAndApplyStates() {
# We don't want a hypervisor node to highstate until the image is downloaded and built. This will be triggered from the setup_hypervisor runner
if [[ "$NODETYPE" == "HYPERVISOR" ]]; then
FEATURES=$(/usr/sbin/so-yaml.py get /opt/so/saltstack/local/pillar/soc/license.sls features)
if [[ $? -ne 0 || ! "$FEATURES" =~ "hvn" ]]; then
if [[ $? -ne 0 || ! "$FEATURES" =~ "vrt" ]]; then
error_msg="Hypervisor nodes are a feature supported only for customers with a valid license.\n Contact Security Onion Solutions, LLC via our website at https://securityonionsolutions.com\n for more information about purchasing a license to enable this feature."
log "ERROR" "$error_msg"
echo -e "Error: $error_msg"
@@ -1058,7 +1058,7 @@ case "$OPERATION" in
"addVM")
log "INFO" "Adding VM minion $MINION_ID"
FEATURES=$(/usr/sbin/so-yaml.py get /opt/so/saltstack/local/pillar/soc/license.sls features)
if [[ $? -ne 0 || ! "$FEATURES" =~ "hvn" ]]; then
if [[ $? -ne 0 || ! "$FEATURES" =~ "vrt" ]]; then
error_msg="Hypervisor nodes are a feature supported only for customers with a valid license.\n Contact Security Onion Solutions, LLC via our website at https://securityonionsolutions.com\n for more information about purchasing a license to enable this feature."
log "ERROR" "$error_msg"
echo -e "Error: $error_msg"

View File

@@ -11,7 +11,7 @@
# in the software, and you may not remove or obscure any functionality in the
# software that is protected by the license key."
{% if 'hvn' in salt['pillar.get']('features', []) -%}
{% if 'vrt' in salt['pillar.get']('features', []) -%}
"""
Script for automated virtual machine provisioning and configuration in Security Onion's virtualization infrastructure.

View File

@@ -9,7 +9,7 @@
# in the software, and you may not remove or obscure any functionality in the
# software that is protected by the license key."
{% if 'hvn' in salt['pillar.get']('features', []) %}
{% if 'vrt' in salt['pillar.get']('features', []) %}
{% do salt.log.info('dyanno_hypervisor_orch: Running') %}
{% set vm_name = None %}

View File

@@ -9,7 +9,7 @@
# in the software, and you may not remove or obscure any functionality in the
# software that is protected by the license key."
{% if 'hvn' in salt['pillar.get']('features', []) %}
{% if 'vrt' in salt['pillar.get']('features', []) %}
{% do salt.log.debug('vm_pillar_clean_orch: Running') %}
{% set vm_name = pillar.get('vm_name') %}

View File

@@ -11,7 +11,7 @@
{% from 'allowed_states.map.jinja' import allowed_states %}
{% if sls in allowed_states %}
{% if 'hvn' in salt['pillar.get']('features', []) %}
{% if 'vrt' in salt['pillar.get']('features', []) %}
{% from 'salt/map.jinja' import SALTVERSION %}
{% set HYPERVISORS = salt['pillar.get']('hypervisor:nodes', {} ) %}

View File

@@ -11,7 +11,7 @@
{% from 'allowed_states.map.jinja' import allowed_states %}
{% if sls.split('.')[:2]|join('.') in allowed_states %}
{% if 'hvn' in salt['pillar.get']('features', []) %}
{% if 'vrt' in salt['pillar.get']('features', []) %}
reactor_config_hypervisor:
file.managed:
- name: /etc/salt/master.d/reactor_hypervisor.conf

View File

@@ -63,7 +63,7 @@ State Files:
- <vm_name>.error: Error state with detailed message
Notes:
- Requires 'hvn' feature license
- Requires 'vrt' feature license
- Uses hypervisor's sosmodel grain for hardware capabilities
- Hardware allocation based on model-specific configurations
- All created files maintain socore ownership
@@ -80,7 +80,7 @@ Description:
- Lock remains until clean shutdown or error
2. License Validation
- Verifies 'hvn' feature is licensed
- Verifies 'vrt' feature is licensed
- Prevents operation if license is invalid
3. Configuration Processing
@@ -567,7 +567,7 @@ def mark_invalid_hardware(hypervisor_path: str, vm_name: str, config: dict, erro
log.error("Failed to create invalid hardware file: %s", str(e))
raise
def validate_hvn_license() -> bool:
def validate_vrt_license() -> bool:
"""Check if the license file exists and contains required values."""
if not os.path.exists(LICENSE_PATH):
log.error("License file not found at %s", LICENSE_PATH)
@@ -588,7 +588,7 @@ def validate_hvn_license() -> bool:
log.error("No license_id found in license file")
return False
if 'hvn' not in features:
if 'vrt' not in features:
log.error("Hypervisor nodes are a feature supported only for customers with a valid license.\n"
"Contact Security Onion Solutions, LLC via our website at https://securityonionsolutions.com\n"
"for more information about purchasing a license to enable this feature.")
@@ -889,7 +889,7 @@ def start(interval: int = DEFAULT_INTERVAL,
"""
log.info("Starting virtual node manager engine")
if not validate_hvn_license():
if not validate_vrt_license():
return
# Attempt to acquire lock

View File

@@ -14,7 +14,7 @@
include:
- salt.minion
{% if 'hvn' in salt['pillar.get']('features', []) %}
{% if 'vrt' in salt['pillar.get']('features', []) %}
- salt.cloud
- salt.cloud.reactor_config_hypervisor
@@ -48,11 +48,11 @@ pillarWatch_engine:
- name: /etc/salt/engines/pillarWatch.py
- source: salt://salt/engines/master/pillarWatch.py
{% if 'hvn' in salt['pillar.get']('features', []) %}
hvn_engine_config:
{% if 'vrt' in salt['pillar.get']('features', []) %}
vrt_engine_config:
file.managed:
- name: /etc/salt/master.d/hvn_engine.conf
- source: salt://salt/files/hvn_engine.conf
- name: /etc/salt/master.d/vrt_engine.conf
- source: salt://salt/files/vrt_engine.conf
- watch_in:
- service: salt_master_service

View File

@@ -9,7 +9,7 @@
# in the software, and you may not remove or obscure any functionality in the
# software that is protected by the license key."
{% if 'hvn' in salt['pillar.get']('features') and salt['grains.get']('salt-cloud', {}) %}
{% if 'vrt' in salt['pillar.get']('features') and salt['grains.get']('salt-cloud', {}) %}
include:
- sensor.vm.network

View File

@@ -9,7 +9,7 @@
# in the software, and you may not remove or obscure any functionality in the
# software that is protected by the license key."
{% if 'hvn' in salt['pillar.get']('features', []) %}
{% if 'vrt' in salt['pillar.get']('features', []) %}
{% set mainint = salt['pillar.get']('host:mainint', 'enp1s0') %}
{% set interfaces = salt['network.interfaces']() %}

View File

@@ -9,7 +9,7 @@
# in the software, and you may not remove or obscure any functionality in the
# software that is protected by the license key."
{% if 'hvn' in salt['pillar.get']('features', []) %}
{% if 'vrt' in salt['pillar.get']('features', []) %}
{% from 'hypervisor/map.jinja' import HYPERVISORS %}

View File

@@ -9,7 +9,7 @@
in the software, and you may not remove or obscure any functionality in the
software that is protected by the license key." #}
{%- if 'hvn' in salt['pillar.get']('features', []) -%}
{%- if 'vrt' in salt['pillar.get']('features', []) -%}
{%- import_yaml 'soc/dyanno/hypervisor/hypervisor.yaml' as ANNOTATION -%}
{%- from 'hypervisor/map.jinja' import HYPERVISORS -%}

View File

@@ -9,7 +9,7 @@
# in the software, and you may not remove or obscure any functionality in the
# software that is protected by the license key."
{% if 'hvn' in salt['pillar.get']('features', []) %}
{% if 'vrt' in salt['pillar.get']('features', []) %}
{# Import the process steps from map.jinja #}
{% from 'soc/dyanno/hypervisor/map.jinja' import PROCESS_STEPS %}

View File

@@ -155,7 +155,7 @@ base:
- stig
- kafka
'*_managerhype and I@features:hvn and G@saltversion:{{saltversion}}':
'*_managerhype and I@features:vrt and G@saltversion:{{saltversion}}':
- match: compound
- manager.hypervisor
@@ -299,7 +299,7 @@ base:
- elasticfleet.install_agent_grid
- schedule
'*_hypervisor and I@features:hvn and G@saltversion:{{saltversion}}':
'*_hypervisor and I@features:vrt and G@saltversion:{{saltversion}}':
- match: compound
- ssl
- sensoroni

View File

@@ -9,7 +9,7 @@
# in the software, and you may not remove or obscure any functionality in the
# software that is protected by the license key."
{% if 'hvn' in salt['pillar.get']('features', []) %}
{% if 'vrt' in salt['pillar.get']('features', []) %}
# Send highstate trigger event for VM deployment status tracking
# so-salt-emit-vm-deployment-status sets event_tag = f'soc/dyanno/hypervisor/{status.lower()}'