summaryrefslogtreecommitdiffstats
path: root/nova/virt
diff options
context:
space:
mode:
authorIsaku Yamahata <yamahata@valinux.co.jp>2011-12-14 16:15:52 +0900
committerIsaku Yamahata <yamahata@valinux.co.jp>2012-01-12 18:46:49 +0900
commit932f3aafd1c735a8ec9e158a94ebb983d6baeb0e (patch)
treee167a00a6cbc64d31ff5f3c7a3a5b42d2c01306d /nova/virt
parent6ece432be0cfb7356636806ab3c046eff17d494b (diff)
Unbreak start instance and fixes bug 905270
This patch fixes the bug 905270 https://bugs.launchpad.net/nova/+bug/905270 According to EC2 documentation, EBS-instances that initiated shutdown result in stopped state. And then it can be started again. (On the other hand non-EBS instance result in terminted when instance initiated shutdown) However, the current nova case, the shutdowned instance always results in terminated status. As related issues are - describe-instance-attribute instance_initiated_shutdown_behavior doesn't work correctly - instance attribute disable_api_termination isn't supported - stop instance was broken by the change set of the following. It needs unbreak. > commit eb03d47fecd3bfc24243da29ee01679b334a08fe > Author: Vishvananda Ishaya <vishvananda@gmail.com> > Date: Fri Sep 23 09:22:32 2011 -0700 > > Remove AoE, Clean up volume code > > * Removes Ata Over Ethernet > * Adds drivers to libvirt for volumes > * Adds initialize_connection and terminate_connection to volume api > * Passes connection info back through volume api > > Change-Id: I1b1626f40bebe8466ab410fb174683293c7c474f This patch - unbreak start instance - implement instance_initiated_shutdown_behavior and make it EC2 compatible - implement disable_api_termination --- Changes 5 -> 6: - fixes to catch up 26b7b9457a5899ecca93fd67d3879efcad4e4968 Changes 4 -> 5: - HACKING compilance Changes 3 -> 4: - rebased to 4c5586a28fd7a085369c49f6039876ffdc86b526 sqlalchemy migrate version Changes 2 -> 3: - rename long name to shorter one s/instance_initiated_shutdown_behavior/shutdown_terminate/g s/disable_api_termination/disable_terminate/g as suggested Kevin L. Mitchell - improved nova.api.ec2.cloud._state_description - pep8 - broken out patches are available for easy review at git://github.com/yamahata/nova.git lp905270-2 Changes 1 -> 2: - fixed an unit test failure pointed out by Mark. (I think ebtabls failure strongly suggests installation problem) - introduce vm_states.SHUTOFF and put instance state which is in power_state.{NOSTATE, SHUTOFF} into vm_states.SHUTOFF. - simplified logic a bit by vm_states.SHUTOFF as suggested by Vish. - instance_initiated_shutdown_behavior:String(255) => instance_initiated_shutdown_terminate:Boolean() as suggested by Vish. - Added Johannes Erdfelt to reviews as they written the vm_states state machine checker. I'd have liked to add David Subiros either, but he doesn't seem to be a registered user of the gerrit. Change-Id: Ibeb94f65137feadad2c343913b39195e3f96a35e
Diffstat (limited to 'nova/virt')
-rw-r--r--nova/virt/driver.py4
-rw-r--r--nova/virt/fake.py3
-rw-r--r--nova/virt/hyperv.py3
-rw-r--r--nova/virt/libvirt/connection.py10
-rw-r--r--nova/virt/vmwareapi_conn.py3
-rw-r--r--nova/virt/xenapi_conn.py3
6 files changed, 12 insertions, 14 deletions
diff --git a/nova/virt/driver.py b/nova/virt/driver.py
index 0342d394d..e03793561 100644
--- a/nova/virt/driver.py
+++ b/nova/virt/driver.py
@@ -152,8 +152,7 @@ class ComputeDriver(object):
"""
raise NotImplementedError()
- def destroy(self, instance, network_info, block_device_info=None,
- cleanup=True):
+ def destroy(self, instance, network_info, block_device_info=None):
"""Destroy (shutdown and delete) the specified instance.
If the instance is not found (for example if networking failed), this
@@ -165,7 +164,6 @@ class ComputeDriver(object):
:py:meth:`~nova.network.manager.NetworkManager.get_instance_nw_info`
:param block_device_info: Information about block devices that should
be detached from the instance.
- :param cleanup:
"""
# TODO(Vek): Need to pass context in for access to auth_token
diff --git a/nova/virt/fake.py b/nova/virt/fake.py
index aeb5d6916..b9fd8f30c 100644
--- a/nova/virt/fake.py
+++ b/nova/virt/fake.py
@@ -162,8 +162,7 @@ class FakeConnection(driver.ComputeDriver):
def resume(self, instance):
pass
- def destroy(self, instance, network_info, block_device_info=None,
- cleanup=True):
+ def destroy(self, instance, network_info, block_device_info=None):
key = instance['name']
if key in self.instances:
del self.instances[key]
diff --git a/nova/virt/hyperv.py b/nova/virt/hyperv.py
index 2207499b2..3d3427d50 100644
--- a/nova/virt/hyperv.py
+++ b/nova/virt/hyperv.py
@@ -374,8 +374,7 @@ class HyperVConnection(driver.ComputeDriver):
raise exception.InstanceNotFound(instance_id=instance.id)
self._set_vm_state(instance.name, 'Reboot')
- def destroy(self, instance, network_info, block_device_info=None,
- cleanup=True):
+ def destroy(self, instance, network_info, block_device_info=None):
"""Destroy the VM. Also destroy the associated VHD disk files"""
LOG.debug(_("Got request to destroy vm %s"), instance.name)
vm = self._lookup(instance.name)
diff --git a/nova/virt/libvirt/connection.py b/nova/virt/libvirt/connection.py
index 2e2327533..cfcda9f84 100644
--- a/nova/virt/libvirt/connection.py
+++ b/nova/virt/libvirt/connection.py
@@ -304,8 +304,8 @@ class LibvirtConnection(driver.ComputeDriver):
for (network, mapping) in network_info:
self.vif_driver.unplug(instance, network, mapping)
- def destroy(self, instance, network_info, block_device_info=None,
- cleanup=True):
+ def _destroy(self, instance, network_info, block_device_info=None,
+ cleanup=True):
instance_name = instance['name']
try:
@@ -393,6 +393,10 @@ class LibvirtConnection(driver.ComputeDriver):
return True
+ def destroy(self, instance, network_info, block_device_info=None):
+ return self._destroy(instance, network_info, block_device_info,
+ cleanup=True)
+
def _cleanup(self, instance):
target = os.path.join(FLAGS.instances_path, instance['name'])
instance_name = instance['name']
@@ -554,7 +558,7 @@ class LibvirtConnection(driver.ComputeDriver):
# NOTE(itoumsn): self.shutdown() and wait instead of self.destroy() is
# better because we cannot ensure flushing dirty buffers
# in the guest OS. But, in case of KVM, shutdown() does not work...
- self.destroy(instance, network_info, cleanup=False)
+ self._destroy(instance, network_info, cleanup=False)
self.unplug_vifs(instance, network_info)
self.plug_vifs(instance, network_info)
self.firewall_driver.setup_basic_filtering(instance, network_info)
diff --git a/nova/virt/vmwareapi_conn.py b/nova/virt/vmwareapi_conn.py
index ef61b3e01..620407c78 100644
--- a/nova/virt/vmwareapi_conn.py
+++ b/nova/virt/vmwareapi_conn.py
@@ -137,8 +137,7 @@ class VMWareESXConnection(driver.ComputeDriver):
"""Reboot VM instance."""
self._vmops.reboot(instance, network_info)
- def destroy(self, instance, network_info, block_device_info=None,
- cleanup=True):
+ def destroy(self, instance, network_info, block_device_info=None):
"""Destroy VM instance."""
self._vmops.destroy(instance, network_info)
diff --git a/nova/virt/xenapi_conn.py b/nova/virt/xenapi_conn.py
index 951db00e8..e672a3cb5 100644
--- a/nova/virt/xenapi_conn.py
+++ b/nova/virt/xenapi_conn.py
@@ -232,8 +232,7 @@ class XenAPIConnection(driver.ComputeDriver):
"""
self._vmops.inject_file(instance, b64_path, b64_contents)
- def destroy(self, instance, network_info, block_device_info=None,
- cleanup=True):
+ def destroy(self, instance, network_info, block_device_info=None):
"""Destroy VM instance"""
self._vmops.destroy(instance, network_info)