From 0490eab24c83a956e50d6a08f685e4f50457a4a4 Mon Sep 17 00:00:00 2001 From: Michael Still Date: Tue, 9 Apr 2013 13:25:38 +1000 Subject: [PATCH] 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 --- nova/virt/baremetal/ipmi.py | 13 +++++++------ nova/virt/baremetal/pxe.py | 10 +++++----- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/nova/virt/baremetal/ipmi.py b/nova/virt/baremetal/ipmi.py index 7cc272c32b..d4377e6fac 100644 --- a/nova/virt/baremetal/ipmi.py +++ b/nova/virt/baremetal/ipmi.py @@ -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): diff --git a/nova/virt/baremetal/pxe.py b/nova/virt/baremetal/pxe.py index 6d4a2965bd..795099ebcf 100644 --- a/nova/virt/baremetal/pxe.py +++ b/nova/virt/baremetal/pxe.py @@ -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']: