diff --git a/lib/hypervisor/hv_base.py b/lib/hypervisor/hv_base.py index 4eaade63f9502f34f549ca8ea89197011d6bf8b9..21784d2182b5f98acd0ecf62a7f3253aadc945bd 100644 --- a/lib/hypervisor/hv_base.py +++ b/lib/hypervisor/hv_base.py @@ -111,8 +111,17 @@ class BaseHypervisor(object): """Start an instance.""" raise NotImplementedError - def StopInstance(self, instance, force=False): - """Stop an instance.""" + def StopInstance(self, instance, force=False, retry=False): + """Stop an instance + + @type instance: L{objects.Instance} + @param instance: instance to stop + @type force: boolean + @param force: whether to do a "hard" stop (destroy) + @type retry: boolean + @param retry: whether this is just a retry call + + """ raise NotImplementedError def RebootInstance(self, instance): diff --git a/lib/hypervisor/hv_chroot.py b/lib/hypervisor/hv_chroot.py index 2ff41cd17b4bdd9c8e5cba1df84b4d31c327dc82..9c335e744dc43bf630c64247e3216f64505449d9 100644 --- a/lib/hypervisor/hv_chroot.py +++ b/lib/hypervisor/hv_chroot.py @@ -171,7 +171,7 @@ class ChrootManager(hv_base.BaseHypervisor): raise HypervisorError("Can't run the chroot start script: %s" % result.output) - def StopInstance(self, instance, force=False): + def StopInstance(self, instance, force=False, retry=False): """Stop an instance. This method has complicated cleanup tests, as we must: @@ -180,6 +180,8 @@ class ChrootManager(hv_base.BaseHypervisor): - finally unmount the instance dir """ + if retry: + return root_dir = "%s/%s" % (self._ROOT_DIR, instance.name) if not os.path.exists(root_dir): return diff --git a/lib/hypervisor/hv_fake.py b/lib/hypervisor/hv_fake.py index 393072c657002df79da62e787bac5ab0f5c86227..d53fff72a907a8aa5642cdb71ff696495b7b0da7 100644 --- a/lib/hypervisor/hv_fake.py +++ b/lib/hypervisor/hv_fake.py @@ -130,7 +130,7 @@ class FakeHypervisor(hv_base.BaseHypervisor): raise errors.HypervisorError("Failed to start instance %s: %s" % (instance.name, err)) - def StopInstance(self, instance, force=False): + def StopInstance(self, instance, force=False, retry=False): """Stop an instance. For the fake hypervisor, this just removes the file in the base diff --git a/lib/hypervisor/hv_kvm.py b/lib/hypervisor/hv_kvm.py index 74005f075042501fe5fbfeaf415b8584f08c148c..bd3334565e1b6231cad6b49616e5d83ddca645b5 100644 --- a/lib/hypervisor/hv_kvm.py +++ b/lib/hypervisor/hv_kvm.py @@ -535,10 +535,12 @@ class KVMHypervisor(hv_base.BaseHypervisor): if wait < 5: wait *= 1.3 - def StopInstance(self, instance, force=False): + def StopInstance(self, instance, force=False, retry=False): """Stop an instance. """ + if retry: + return pidfile, pid, alive = self._InstancePidAlive(instance.name) if pid > 0 and alive: if force or not instance.hvparams[constants.HV_ACPI]: diff --git a/lib/hypervisor/hv_xen.py b/lib/hypervisor/hv_xen.py index 32385a2982a1cb7dcf30570f34bdd4c176370fb4..28101023abfda7ce31766db061fab9da5399e417 100644 --- a/lib/hypervisor/hv_xen.py +++ b/lib/hypervisor/hv_xen.py @@ -178,10 +178,12 @@ class XenHypervisor(hv_base.BaseHypervisor): (instance.name, result.fail_reason, result.output)) - def StopInstance(self, instance, force=False): + def StopInstance(self, instance, force=False, retry=False): """Stop an instance. """ + if retry: + return self._RemoveConfigFile(instance.name) if force: command = ["xm", "destroy", instance.name]