Merge "Add wmi job terminate timeout cfg opt"
This commit is contained in:
commit
c29ff8bf92
@ -29,6 +29,11 @@ os_win_opts = [
|
||||
'almost all operations require a reference to a '
|
||||
'switch port. The cached objects are no longer valid '
|
||||
'if the VM they are associated with is destroyed.'),
|
||||
cfg.IntOpt('wmi_job_terminate_timeout',
|
||||
default=120,
|
||||
help='The default amount of seconds to wait when stopping '
|
||||
'pending WMI jobs. Setting this value to 0 will '
|
||||
'disable the timeout.'),
|
||||
]
|
||||
|
||||
CONF = cfg.CONF
|
||||
|
@ -1203,7 +1203,8 @@ class VMUtilsTestCase(test_base.OsWinBaseTestCase):
|
||||
|
||||
self._vmutils.stop_vm_jobs(mock.sentinel.vm_name)
|
||||
|
||||
self._vmutils._jobutils.stop_jobs.assert_called_once_with(mock_vm)
|
||||
self._vmutils._jobutils.stop_jobs.assert_called_once_with(
|
||||
mock_vm, None)
|
||||
|
||||
def test_set_secure_boot(self):
|
||||
vs_data = mock.MagicMock()
|
||||
|
@ -985,9 +985,9 @@ class VMUtils(baseutils.BaseUtilsVirt):
|
||||
pass
|
||||
return constants.VM_GEN_1
|
||||
|
||||
def stop_vm_jobs(self, vm_name):
|
||||
def stop_vm_jobs(self, vm_name, timeout=None):
|
||||
vm = self._lookup_vm_check(vm_name, as_vssd=False)
|
||||
self._jobutils.stop_jobs(vm)
|
||||
self._jobutils.stop_jobs(vm, timeout)
|
||||
|
||||
def enable_secure_boot(self, vm_name, msft_ca_required):
|
||||
"""Enables Secure Boot for the instance with the given name.
|
||||
|
@ -24,10 +24,13 @@ import monotonic
|
||||
from oslo_log import log as logging
|
||||
|
||||
from os_win import _utils
|
||||
import os_win.conf
|
||||
from os_win import constants
|
||||
from os_win import exceptions
|
||||
from os_win.utils import baseutils
|
||||
|
||||
CONF = os_win.conf.CONF
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@ -35,7 +38,6 @@ class JobUtils(baseutils.BaseUtilsVirt):
|
||||
|
||||
_CONCRETE_JOB_CLASS = "Msvm_ConcreteJob"
|
||||
|
||||
_DEFAULT_JOB_TERMINATE_TIMEOUT = 15 # seconds
|
||||
_KILL_JOB_STATE_CHANGE_REQUEST = 5
|
||||
|
||||
_completed_job_states = [constants.JOB_STATE_COMPLETED,
|
||||
@ -203,7 +205,7 @@ class JobUtils(baseutils.BaseUtilsVirt):
|
||||
def _is_job_completed(self, job):
|
||||
return job.JobState in self._completed_job_states
|
||||
|
||||
def stop_jobs(self, element, timeout=_DEFAULT_JOB_TERMINATE_TIMEOUT):
|
||||
def stop_jobs(self, element, timeout=None):
|
||||
"""Stops the Hyper-V jobs associated with the given resource.
|
||||
|
||||
:param element: string representing the path of the Hyper-V resource
|
||||
@ -214,6 +216,9 @@ class JobUtils(baseutils.BaseUtilsVirt):
|
||||
associated with the given resource and the given timeout amount of
|
||||
time has passed.
|
||||
"""
|
||||
if timeout is None:
|
||||
timeout = CONF.os_win.wmi_job_terminate_timeout
|
||||
|
||||
@_utils.retry_decorator(exceptions=exceptions.JobTerminateFailed,
|
||||
timeout=timeout, max_retry_count=None)
|
||||
def _stop_jobs_with_timeout():
|
||||
|
Loading…
Reference in New Issue
Block a user