diff --git a/lib/backend.py b/lib/backend.py index b903d6287c93bf734f1966591a309fd9e236f5a8..761628ca55d38817db0f21ff0760cec5faef13d0 100644 --- a/lib/backend.py +++ b/lib/backend.py @@ -1099,6 +1099,11 @@ def InstanceShutdown(instance, timeout): if iname in hyper.ListInstances(): _Fail("Could not shutdown instance %s even by destroy", iname) + try: + hyper.CleanupInstance(instance.name) + except errors.HypervisorError, err: + logging.warning("Failed to execute post-shutdown cleanup step: %s", err) + _RemoveBlockDevLinks(iname, instance.disks) diff --git a/lib/hypervisor/hv_base.py b/lib/hypervisor/hv_base.py index af7aa957596c910a8754ecc5092b8929ac0ca786..58db39599a3165d22317ed0f64445c642cb1df76 100644 --- a/lib/hypervisor/hv_base.py +++ b/lib/hypervisor/hv_base.py @@ -130,6 +130,18 @@ class BaseHypervisor(object): """ raise NotImplementedError + def CleanupInstance(self, instance_name): + """Cleanup after a stopped instance + + This is an optional method, used by hypervisors that need to cleanup after + an instance has been stopped. + + @type instance_name: string + @param instance_name: instance name to cleanup after + + """ + pass + def RebootInstance(self, instance): """Reboot an instance.""" raise NotImplementedError