mirror of
https://github.com/Security-Onion-Solutions/securityonion.git
synced 2025-12-08 18:22:47 +01:00
use cron instead of schedule for vm init. ensure vm shutdown
This commit is contained in:
@@ -75,7 +75,19 @@ def run():
|
|||||||
c = 0
|
c = 0
|
||||||
while True:
|
while True:
|
||||||
if c == 60:
|
if c == 60:
|
||||||
logging.error("virtUpdate reactor: vm_name: %s failed to shutdown in time " % vm_name)
|
logging.error("virtUpdate reactor: vm_name: %s failed virt.shutdown in time " % vm_name)
|
||||||
|
return {}
|
||||||
|
r = local.cmd(hv_name, 'virt.shutdown', ['vm_=' + vm_name])
|
||||||
|
logging.error("virtUpdate reactor: virt.shutdown: %s return: %s " % (vm_name,r))
|
||||||
|
if r.get(hv_name):
|
||||||
|
break
|
||||||
|
c += 1
|
||||||
|
sleep(1)
|
||||||
|
|
||||||
|
c = 0
|
||||||
|
while True:
|
||||||
|
if c == 60:
|
||||||
|
logging.error("virtUpdate reactor: vm_name: %s failed to go inactive in time " % vm_name)
|
||||||
return {}
|
return {}
|
||||||
r = local.cmd(hv_name, 'virt.list_inactive_vms')
|
r = local.cmd(hv_name, 'virt.list_inactive_vms')
|
||||||
logging.error("virtUpdate reactor: virt.list_inactive_vms: %s " % r.get(hv_name))
|
logging.error("virtUpdate reactor: virt.list_inactive_vms: %s " % r.get(hv_name))
|
||||||
|
|||||||
@@ -1,7 +1,13 @@
|
|||||||
init_node_schedule:
|
# Copyright Security Onion Solutions LLC and/or licensed to Security Onion Solutions LLC under one
|
||||||
schedule.present:
|
# or more contributor license agreements. Licensed under the Elastic License 2.0 as shown at
|
||||||
- name: init_node
|
# https://securityonion.net/license; you may not use this file except in compliance with the
|
||||||
- function: state.sls
|
# Elastic License 2.0.
|
||||||
- job_args:
|
|
||||||
- setup.virt.init
|
# initially tried to use schedule.present here, but that state trys to return data to the master even if run with --local
|
||||||
- minutes: 1
|
# that causes it to fail since th firewall may not yet be open on the manager
|
||||||
|
init_node_cron:
|
||||||
|
cron.present:
|
||||||
|
- name: salt-call state.apply setup.virt.init
|
||||||
|
- identifier: init_node_cron
|
||||||
|
- user: root
|
||||||
|
- minute: '*/1'
|
||||||
|
|||||||
@@ -8,10 +8,12 @@ set_role_grain:
|
|||||||
- name: role
|
- name: role
|
||||||
- value: so-{{ grains.id.split("_") | last }}
|
- value: so-{{ grains.id.split("_") | last }}
|
||||||
|
|
||||||
# disable the initial schedule
|
# remove the initial cron
|
||||||
remove_init_node_schedule:
|
remove_init_node_cron:
|
||||||
schedule.absent:
|
cron.absent:
|
||||||
- name: init_node
|
- name: salt-call state.apply setup.virt.init
|
||||||
|
- identifier: init_node_cron
|
||||||
|
- user: root
|
||||||
|
|
||||||
set_highstate:
|
set_highstate:
|
||||||
file.append:
|
file.append:
|
||||||
|
|||||||
Reference in New Issue
Block a user