Import and convert to oslo loopingcall.
Import the oslo looping call implementation (which is a copy of nova's), delete nova's local copy, convert all users to the new location. It should be noted that the oslo implementation of FixedIntervalLoopingCall measures time from the start of the periodic task, not the end, so periodic tasks will run with a constant frequency instead of the frequency changing depending on how long the periodic task takes to run. Change-Id: Ia62ce1988f5373c09146efa6b3b1d1dc094d50c4
This commit is contained in:
parent
4c82958f3d
commit
0490eab24c
@ -29,6 +29,7 @@ from oslo.config import cfg
|
||||
|
||||
from nova import exception
|
||||
from nova.openstack.common import log as logging
|
||||
from nova.openstack.common import loopingcall
|
||||
from nova import paths
|
||||
from nova import utils
|
||||
from nova.virt.baremetal import baremetal_states
|
||||
@ -149,10 +150,10 @@ class IPMI(base.PowerManager):
|
||||
|
||||
if self._is_power("on"):
|
||||
self.state = baremetal_states.ACTIVE
|
||||
raise utils.LoopingCallDone()
|
||||
raise loopingcall.LoopingCallDone()
|
||||
if self.retries > CONF.baremetal.ipmi_power_retry:
|
||||
self.state = baremetal_states.ERROR
|
||||
raise utils.LoopingCallDone()
|
||||
raise loopingcall.LoopingCallDone()
|
||||
try:
|
||||
self.retries += 1
|
||||
self._exec_ipmitool("power on")
|
||||
@ -160,7 +161,7 @@ class IPMI(base.PowerManager):
|
||||
LOG.exception(_("IPMI power on failed"))
|
||||
|
||||
self.retries = 0
|
||||
timer = utils.FixedIntervalLoopingCall(_wait_for_power_on)
|
||||
timer = loopingcall.FixedIntervalLoopingCall(_wait_for_power_on)
|
||||
timer.start(interval=0.5).wait()
|
||||
|
||||
def _power_off(self):
|
||||
@ -171,10 +172,10 @@ class IPMI(base.PowerManager):
|
||||
|
||||
if self._is_power("off"):
|
||||
self.state = baremetal_states.DELETED
|
||||
raise utils.LoopingCallDone()
|
||||
raise loopingcall.LoopingCallDone()
|
||||
if self.retries > CONF.baremetal.ipmi_power_retry:
|
||||
self.state = baremetal_states.ERROR
|
||||
raise utils.LoopingCallDone()
|
||||
raise loopingcall.LoopingCallDone()
|
||||
try:
|
||||
self.retries += 1
|
||||
self._exec_ipmitool("power off")
|
||||
@ -182,7 +183,7 @@ class IPMI(base.PowerManager):
|
||||
LOG.exception(_("IPMI power off failed"))
|
||||
|
||||
self.retries = 0
|
||||
timer = utils.FixedIntervalLoopingCall(_wait_for_power_off)
|
||||
timer = loopingcall.FixedIntervalLoopingCall(_wait_for_power_off)
|
||||
timer.start(interval=0.5).wait()
|
||||
|
||||
def _set_pxe_for_next_boot(self):
|
||||
|
@ -30,8 +30,8 @@ from nova import exception
|
||||
from nova.openstack.common.db import exception as db_exc
|
||||
from nova.openstack.common import fileutils
|
||||
from nova.openstack.common import log as logging
|
||||
from nova.openstack.common import loopingcall
|
||||
from nova.openstack.common import timeutils
|
||||
from nova import utils
|
||||
from nova.virt.baremetal import baremetal_states
|
||||
from nova.virt.baremetal import base
|
||||
from nova.virt.baremetal import db
|
||||
@ -458,7 +458,7 @@ class PXE(base.NodeDriver):
|
||||
if instance['uuid'] != row.get('instance_uuid'):
|
||||
locals['error'] = _("Node associated with another instance"
|
||||
" while waiting for deploy of %s")
|
||||
raise utils.LoopingCallDone()
|
||||
raise loopingcall.LoopingCallDone()
|
||||
|
||||
status = row.get('task_state')
|
||||
if (status == baremetal_states.DEPLOYING
|
||||
@ -470,7 +470,7 @@ class PXE(base.NodeDriver):
|
||||
baremetal_states.ACTIVE):
|
||||
LOG.info(_("PXE deploy completed for instance %s")
|
||||
% instance['uuid'])
|
||||
raise utils.LoopingCallDone()
|
||||
raise loopingcall.LoopingCallDone()
|
||||
elif status == baremetal_states.DEPLOYFAIL:
|
||||
locals['error'] = _("PXE deploy failed for instance %s")
|
||||
except exception.NodeNotFound:
|
||||
@ -482,11 +482,11 @@ class PXE(base.NodeDriver):
|
||||
locals['error'] = _("Timeout reached while waiting for "
|
||||
"PXE deploy of instance %s")
|
||||
if locals['error']:
|
||||
raise utils.LoopingCallDone()
|
||||
raise loopingcall.LoopingCallDone()
|
||||
|
||||
expiration = timeutils.utcnow() + datetime.timedelta(
|
||||
seconds=CONF.baremetal.pxe_deploy_timeout)
|
||||
timer = utils.FixedIntervalLoopingCall(_wait_for_deploy)
|
||||
timer = loopingcall.FixedIntervalLoopingCall(_wait_for_deploy)
|
||||
timer.start(interval=1).wait()
|
||||
|
||||
if locals['error']:
|
||||
|
Loading…
Reference in New Issue
Block a user