From a8af2fd844fd70676c2cf11a8c56a4569d84d863 Mon Sep 17 00:00:00 2001 From: Steven Hardy Date: Thu, 24 Oct 2013 10:47:58 +0100 Subject: [PATCH] Use resource_id_set to clear resource ID's self.resource_id = None is used in several resources, which is wrong, we should be explicitly updating the resource_id in the DB via the resource_id_set function. Change-Id: I41e1326fe7e1da364c8e6dd68f572df484beffb3 --- heat/engine/resources/instance.py | 4 ++-- heat/engine/resources/security_group.py | 4 ++-- heat/engine/resources/server.py | 2 +- heat/engine/resources/volume.py | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/heat/engine/resources/instance.py b/heat/engine/resources/instance.py index 383a20a44b..410c0fa4a0 100644 --- a/heat/engine/resources/instance.py +++ b/heat/engine/resources/instance.py @@ -484,7 +484,7 @@ class Instance(resource.Resource): try: server.get() except clients.novaclient.exceptions.NotFound: - self.resource_id = None + self.resource_id_set(None) break def _detach_volumes_task(self): @@ -507,7 +507,7 @@ class Instance(resource.Resource): try: server = self.nova().servers.get(self.resource_id) except clients.novaclient.exceptions.NotFound: - self.resource_id = None + self.resource_id_set(None) return server_delete_task = scheduler.TaskRunner(self._delete_server, diff --git a/heat/engine/resources/security_group.py b/heat/engine/resources/security_group.py index 429a31a044..683e2ae67a 100644 --- a/heat/engine/resources/security_group.py +++ b/heat/engine/resources/security_group.py @@ -189,7 +189,7 @@ class SecurityGroup(resource.Resource): pass self.nova().security_groups.delete(self.resource_id) - self.resource_id = None + self.resource_id_set(None) def _handle_delete_neutron(self): from neutronclient.common.exceptions import NeutronClientException @@ -215,7 +215,7 @@ class SecurityGroup(resource.Resource): except NeutronClientException as ex: if ex.status_code != 404: raise - self.resource_id = None + self.resource_id_set(None) def FnGetRefId(self): if self.properties['VpcId']: diff --git a/heat/engine/resources/server.py b/heat/engine/resources/server.py index 7951de127a..0210d29838 100644 --- a/heat/engine/resources/server.py +++ b/heat/engine/resources/server.py @@ -472,7 +472,7 @@ class Server(resource.Resource): delete = scheduler.TaskRunner(nova_utils.delete_server, server) delete(wait_time=0.2) - self.resource_id = None + self.resource_id_set(None) def handle_suspend(self): ''' diff --git a/heat/engine/resources/volume.py b/heat/engine/resources/volume.py index 69964645e2..db2930cf47 100644 --- a/heat/engine/resources/volume.py +++ b/heat/engine/resources/volume.py @@ -124,7 +124,7 @@ class Volume(resource.Resource): yield vol.get() except clients.cinderclient.exceptions.NotFound: - self.resource_id = None + self.resource_id_set(None) if volume_backups is not None: def handle_snapshot_delete(self, state):