diff options
| author | Alex Meade <alex.meade@rackspace.com> | 2011-12-02 11:36:38 -0500 |
|---|---|---|
| committer | Alex Meade <alex.meade@rackspace.com> | 2011-12-02 11:37:26 -0500 |
| commit | 91cfa62b4a09cafa8af0772c68d36de9216dc440 (patch) | |
| tree | d9e9498f2ab69e8e12c3b0e422b3dd78a3636a82 | |
| parent | 7fc79c41e9759310faf5a88f28981f0efb53d431 (diff) | |
| download | nova-91cfa62b4a09cafa8af0772c68d36de9216dc440.tar.gz nova-91cfa62b4a09cafa8af0772c68d36de9216dc440.tar.xz nova-91cfa62b4a09cafa8af0772c68d36de9216dc440.zip | |
EC2 rescue/unrescue is broken, bug 899225
Change-Id: I5a0b9c08a43e8c606d1c885cf7f47382fa4664a8
| -rw-r--r-- | nova/api/ec2/cloud.py | 18 | ||||
| -rw-r--r-- | nova/tests/api/ec2/test_cloud.py | 29 | ||||
| -rw-r--r-- | nova/tests/test_virt_drivers.py | 4 | ||||
| -rw-r--r-- | nova/virt/driver.py | 2 | ||||
| -rw-r--r-- | nova/virt/fake.py | 2 | ||||
| -rw-r--r-- | nova/virt/libvirt/connection.py | 2 |
6 files changed, 42 insertions, 15 deletions
diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py index eb4945412..17a1ff634 100644 --- a/nova/api/ec2/cloud.py +++ b/nova/api/ec2/cloud.py @@ -1289,14 +1289,6 @@ class CloudController(object): block_device_mapping=kwargs.get('block_device_mapping', {})) return self._format_run_instances(context, resv_id) - def _do_instance(self, action, context, ec2_id): - instance_id = ec2utils.ec2_id_to_id(ec2_id) - action(context, instance_id=instance_id) - - def _do_instances(self, action, context, instance_id): - for ec2_id in instance_id: - self._do_instance(action, context, ec2_id) - def terminate_instances(self, context, instance_id, **kwargs): """Terminate each instance in instance_id, which is a list of ec2 ids. instance_id is a kwarg so its name cannot be modified.""" @@ -1338,12 +1330,18 @@ class CloudController(object): def rescue_instance(self, context, instance_id, **kwargs): """This is an extension to the normal ec2_api""" - self._do_instance(self.compute_api.rescue, context, instance_id) + LOG.debug(_("Going to rescue instance %s") % instance_id) + _instance_id = ec2utils.ec2_id_to_id(instance_id) + instance = self.compute_api.get(context, _instance_id) + self.compute_api.rescue(context, instance) return True def unrescue_instance(self, context, instance_id, **kwargs): """This is an extension to the normal ec2_api""" - self._do_instance(self.compute_api.unrescue, context, instance_id) + LOG.debug(_("Going to unrescue instance %s") % instance_id) + _instance_id = ec2utils.ec2_id_to_id(instance_id) + instance = self.compute_api.get(context, _instance_id) + self.compute_api.unrescue(context, instance) return True def update_instance(self, context, instance_id, **kwargs): diff --git a/nova/tests/api/ec2/test_cloud.py b/nova/tests/api/ec2/test_cloud.py index 47100b7be..c206f070f 100644 --- a/nova/tests/api/ec2/test_cloud.py +++ b/nova/tests/api/ec2/test_cloud.py @@ -1376,6 +1376,35 @@ class CloudTestCase(test.TestCase): else: self.compute = self.start_service('compute') + def test_rescue_instances(self): + kwargs = {'image_id': 'ami-1', + 'instance_type': FLAGS.default_instance_type, + 'max_count': 1, } + instance_id = self._run_instance(**kwargs) + + result = self.cloud.stop_instances(self.context, [instance_id]) + self.assertTrue(result) + + result = self.cloud.rescue_instance(self.context, instance_id) + self.assertTrue(result) + + result = self.cloud.terminate_instances(self.context, [instance_id]) + self.assertTrue(result) + self._restart_compute_service() + + def test_unrescue_instances(self): + kwargs = {'image_id': 'ami-1', + 'instance_type': FLAGS.default_instance_type, + 'max_count': 1, } + instance_id = self._run_instance(**kwargs) + + result = self.cloud.unrescue_instance(self.context, instance_id) + self.assertTrue(result) + + result = self.cloud.terminate_instances(self.context, [instance_id]) + self.assertTrue(result) + self._restart_compute_service() + def test_stop_start_instance(self): """Makes sure stop/start instance works""" # enforce periodic tasks run in short time to avoid wait for 60s. diff --git a/nova/tests/test_virt_drivers.py b/nova/tests/test_virt_drivers.py index 137d6c9ca..8b4fa177f 100644 --- a/nova/tests/test_virt_drivers.py +++ b/nova/tests/test_virt_drivers.py @@ -145,7 +145,7 @@ class _VirtDriverTestCase(test.TestCase): @catch_notimplementederror def test_rescue(self): instance_ref, network_info = self._get_running_instance() - self.connection.rescue(self.ctxt, instance_ref, network_info) + self.connection.rescue(self.ctxt, instance_ref, network_info, None) @catch_notimplementederror def test_unrescue_unrescued_instance(self): @@ -155,7 +155,7 @@ class _VirtDriverTestCase(test.TestCase): @catch_notimplementederror def test_unrescue_rescued_instance(self): instance_ref, network_info = self._get_running_instance() - self.connection.rescue(self.ctxt, instance_ref, network_info) + self.connection.rescue(self.ctxt, instance_ref, network_info, None) self.connection.unrescue(instance_ref, network_info) @catch_notimplementederror diff --git a/nova/virt/driver.py b/nova/virt/driver.py index c2056f19d..e12be1f0e 100644 --- a/nova/virt/driver.py +++ b/nova/virt/driver.py @@ -296,7 +296,7 @@ class ComputeDriver(object): # TODO(Vek): Need to pass context in for access to auth_token raise NotImplementedError() - def rescue(self, context, instance, network_info): + def rescue(self, context, instance, network_info, image_meta): """Rescue the specified instance""" raise NotImplementedError() diff --git a/nova/virt/fake.py b/nova/virt/fake.py index e860f72d5..feb85b7f1 100644 --- a/nova/virt/fake.py +++ b/nova/virt/fake.py @@ -126,7 +126,7 @@ class FakeConnection(driver.ComputeDriver): def agent_update(self, instance, url, md5hash): pass - def rescue(self, context, instance, network_info): + def rescue(self, context, instance, network_info, image_meta): pass def unrescue(self, instance, network_info): diff --git a/nova/virt/libvirt/connection.py b/nova/virt/libvirt/connection.py index edaa11cbb..93507f6c0 100644 --- a/nova/virt/libvirt/connection.py +++ b/nova/virt/libvirt/connection.py @@ -595,7 +595,7 @@ class LibvirtConnection(driver.ComputeDriver): dom.create() @exception.wrap_exception() - def rescue(self, context, instance, network_info): + def rescue(self, context, instance, network_info, image_meta): """Loads a VM using rescue images. A rescue is normally performed when something goes wrong with the |
