summaryrefslogtreecommitdiffstats
path: root/nova
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2013-06-27 08:50:47 +0000
committerGerrit Code Review <review@openstack.org>2013-06-27 08:50:47 +0000
commit2ab264fb3be94957685cca6a4975bbb8363e9ea2 (patch)
treec7cef0530f3be6d401ff1ee056bf649bcaa6cc76 /nova
parenta9bed2bab9a917ef288872d0f660e9f414281dc1 (diff)
parent2402055b955656c7fffa66018c7b8cfcc1596b1b (diff)
downloadnova-2ab264fb3be94957685cca6a4975bbb8363e9ea2.tar.gz
nova-2ab264fb3be94957685cca6a4975bbb8363e9ea2.tar.xz
nova-2ab264fb3be94957685cca6a4975bbb8363e9ea2.zip
Merge "Check the instance ID before creating it"
Diffstat (limited to 'nova')
-rwxr-xr-xnova/virt/libvirt/driver.py29
1 files changed, 16 insertions, 13 deletions
diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py
index f4ba24cc4..104965d49 100755
--- a/nova/virt/libvirt/driver.py
+++ b/nova/virt/libvirt/driver.py
@@ -1386,19 +1386,22 @@ class LibvirtDriver(driver.ComputeDriver):
state = LIBVIRT_POWER_STATE[state]
new_domid = dom.ID()
- if state in [power_state.SHUTDOWN,
- power_state.CRASHED]:
- LOG.info(_("Instance shutdown successfully."),
- instance=instance)
- self._create_domain(domain=dom)
- timer = loopingcall.FixedIntervalLoopingCall(
- self._wait_for_running, instance)
- timer.start(interval=0.5).wait()
- return True
- elif old_domid != new_domid:
- LOG.info(_("Instance may have been rebooted during soft "
- "reboot, so return now."), instance=instance)
- return True
+ # NOTE(ivoks): By checking domain IDs, we make sure we are
+ # not recreating domain that's already running.
+ if old_domid != new_domid:
+ if state in [power_state.SHUTDOWN,
+ power_state.CRASHED]:
+ LOG.info(_("Instance shutdown successfully."),
+ instance=instance)
+ self._create_domain(domain=dom)
+ timer = loopingcall.FixedIntervalLoopingCall(
+ self._wait_for_running, instance)
+ timer.start(interval=0.5).wait()
+ return True
+ else:
+ LOG.info(_("Instance may have been rebooted during soft "
+ "reboot, so return now."), instance=instance)
+ return True
greenthread.sleep(1)
return False