summaryrefslogtreecommitdiffstats
path: root/nova/virt
diff options
context:
space:
mode:
authorJohannes Erdfelt <johannes.erdfelt@rackspace.com>2011-09-21 15:54:30 +0000
committerTarmac <>2011-09-21 15:54:30 +0000
commit7e3bebbe8e911851a7398b8d5ad81afb421dfd62 (patch)
treef633b43d1f5fa1eabac24300ba951a322bec1fed /nova/virt
parent1fc5abe0c63c6395e77c8031ae0a0b49e251f470 (diff)
parentad3f3d0f845fddb2658c427085e426e45b88ab4b (diff)
Instance deletions in Openstack are immediate. This can cause data to be lost accidentally.
This branch adds a new configuration flag, reclaim_instance_interval. The default of 0 results in the same behavior before this patch, immediate deletion of the instance. Any value greater than 0 will result in the instance being powered off immediately and then later the instance will be reclaimed. New actions, restore and forceDelete allow a previously deleted instance to be restored, or reclaimed immediately.
Diffstat (limited to 'nova/virt')
-rw-r--r--nova/virt/driver.py8
-rw-r--r--nova/virt/xenapi/vmops.py10
-rw-r--r--nova/virt/xenapi_conn.py8
3 files changed, 26 insertions, 0 deletions
diff --git a/nova/virt/driver.py b/nova/virt/driver.py
index fc47d8d2d..7edb2cf1a 100644
--- a/nova/virt/driver.py
+++ b/nova/virt/driver.py
@@ -287,6 +287,14 @@ class ComputeDriver(object):
# TODO(Vek): Need to pass context in for access to auth_token
raise NotImplementedError()
+ def power_off(self, instance):
+ """Power off the specified instance."""
+ raise NotImplementedError()
+
+ def power_on(self, instance):
+ """Power on the specified instance"""
+ raise NotImplementedError()
+
def update_available_resource(self, ctxt, host):
"""Updates compute manager resource info on ComputeNode table.
diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py
index 210b8fe65..988007bae 100644
--- a/nova/virt/xenapi/vmops.py
+++ b/nova/virt/xenapi/vmops.py
@@ -1002,6 +1002,16 @@ class VMOps(object):
self._release_bootlock(original_vm_ref)
self._start(instance, original_vm_ref)
+ def power_off(self, instance):
+ """Power off the specified instance."""
+ vm_ref = self._get_vm_opaque_ref(instance)
+ self._shutdown(instance, vm_ref, hard=True)
+
+ def power_on(self, instance):
+ """Power on the specified instance."""
+ vm_ref = self._get_vm_opaque_ref(instance)
+ self._start(instance, vm_ref)
+
def poll_rescued_instances(self, timeout):
"""Look for expirable rescued instances.
diff --git a/nova/virt/xenapi_conn.py b/nova/virt/xenapi_conn.py
index 7fc683a9f..79b02891d 100644
--- a/nova/virt/xenapi_conn.py
+++ b/nova/virt/xenapi_conn.py
@@ -250,6 +250,14 @@ class XenAPIConnection(driver.ComputeDriver):
"""Unrescue the specified instance"""
self._vmops.unrescue(instance, _callback)
+ def power_off(self, instance):
+ """Power off the specified instance"""
+ self._vmops.power_off(instance)
+
+ def power_on(self, instance):
+ """Power on the specified instance"""
+ self._vmops.power_on(instance)
+
def poll_rescued_instances(self, timeout):
"""Poll for rescued instances"""
self._vmops.poll_rescued_instances(timeout)