Remove resource_id_set(None) calls
This removes resetting resource_id in delete, as the state is storing that information properly, and it doesn't provide any additional value. Change-Id: I71f17ab79adbad5286389c87f1fbd5c60c4a8d7f Closes-Bug: #1358492
This commit is contained in:
parent
b16ab3f48a
commit
5760718ba5
@ -132,13 +132,10 @@ class Order(resource.Resource):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
self.barbican().orders.delete(self.resource_id)
|
self.barbican().orders.delete(self.resource_id)
|
||||||
self.resource_id_set(None)
|
|
||||||
except client.barbican_client.HTTPClientError as exc:
|
except client.barbican_client.HTTPClientError as exc:
|
||||||
# This is the only exception the client raises
|
# This is the only exception the client raises
|
||||||
# Inspecting the message to see if it's a 'Not Found'
|
# Inspecting the message to see if it's a 'Not Found'
|
||||||
if 'Not Found' in six.text_type(exc):
|
if 'Not Found' not in six.text_type(exc):
|
||||||
self.resource_id_set(None)
|
|
||||||
else:
|
|
||||||
raise
|
raise
|
||||||
|
|
||||||
def _resolve_attribute(self, name):
|
def _resolve_attribute(self, name):
|
||||||
|
@ -137,13 +137,10 @@ class Secret(resource.Resource):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
self.barbican().secrets.delete(self.resource_id)
|
self.barbican().secrets.delete(self.resource_id)
|
||||||
self.resource_id_set(None)
|
|
||||||
except client.barbican_client.HTTPClientError as exc:
|
except client.barbican_client.HTTPClientError as exc:
|
||||||
# This is the only exception the client raises
|
# This is the only exception the client raises
|
||||||
# Inspecting the message to see if it's a 'Not Found'
|
# Inspecting the message to see if it's a 'Not Found'
|
||||||
if 'Not Found' in six.text_type(exc):
|
if 'Not Found' not in six.text_type(exc):
|
||||||
self.resource_id_set(None)
|
|
||||||
else:
|
|
||||||
raise
|
raise
|
||||||
|
|
||||||
def _resolve_attribute(self, name):
|
def _resolve_attribute(self, name):
|
||||||
|
@ -143,7 +143,6 @@ class TestOrder(HeatTestCase):
|
|||||||
self.assertEqual('foo', res.resource_id)
|
self.assertEqual('foo', res.resource_id)
|
||||||
|
|
||||||
scheduler.TaskRunner(res.delete)()
|
scheduler.TaskRunner(res.delete)()
|
||||||
self.assertIsNone(res.resource_id)
|
|
||||||
self.barbican.orders.delete.assert_called_once_with('foo')
|
self.barbican.orders.delete.assert_called_once_with('foo')
|
||||||
|
|
||||||
@mock.patch.object(client, 'barbican_client', new=mock.Mock())
|
@mock.patch.object(client, 'barbican_client', new=mock.Mock())
|
||||||
|
@ -160,7 +160,6 @@ class TestSecret(HeatTestCase):
|
|||||||
mock_delete = self.barbican.secrets.delete
|
mock_delete = self.barbican.secrets.delete
|
||||||
scheduler.TaskRunner(self.res.delete)()
|
scheduler.TaskRunner(self.res.delete)()
|
||||||
|
|
||||||
self.assertIsNone(self.res.resource_id)
|
|
||||||
mock_delete.assert_called_once_with('foo_id')
|
mock_delete.assert_called_once_with('foo_id')
|
||||||
|
|
||||||
@mock.patch.object(client, 'barbican_client', new=mock.Mock())
|
@mock.patch.object(client, 'barbican_client', new=mock.Mock())
|
||||||
|
@ -118,8 +118,6 @@ class NovaFlavor(resource.Resource):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.client_plugin('nova').ignore_not_found(e)
|
self.client_plugin('nova').ignore_not_found(e)
|
||||||
|
|
||||||
self.resource_id_set(None)
|
|
||||||
|
|
||||||
|
|
||||||
def resource_mapping():
|
def resource_mapping():
|
||||||
return {
|
return {
|
||||||
|
@ -195,7 +195,6 @@ class CloudDns(resource.Resource):
|
|||||||
dom.delete()
|
dom.delete()
|
||||||
except NotFound:
|
except NotFound:
|
||||||
pass
|
pass
|
||||||
self.resource_id_set(None)
|
|
||||||
|
|
||||||
|
|
||||||
def resource_mapping():
|
def resource_mapping():
|
||||||
|
@ -574,7 +574,6 @@ class CloudLoadBalancer(resource.Resource):
|
|||||||
else:
|
else:
|
||||||
if loadbalancer.status != 'DELETED':
|
if loadbalancer.status != 'DELETED':
|
||||||
loadbalancer.delete()
|
loadbalancer.delete()
|
||||||
self.resource_id_set(None)
|
|
||||||
|
|
||||||
def _remove_none(self, property_dict):
|
def _remove_none(self, property_dict):
|
||||||
"""Remove None values that would cause schema validation problems.
|
"""Remove None values that would cause schema validation problems.
|
||||||
|
@ -118,8 +118,6 @@ class GlanceImage(resource.Resource):
|
|||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
self.client_plugin().ignore_not_found(ex)
|
self.client_plugin().ignore_not_found(ex)
|
||||||
|
|
||||||
self.resource_id_set(None)
|
|
||||||
|
|
||||||
|
|
||||||
def resource_mapping():
|
def resource_mapping():
|
||||||
return {
|
return {
|
||||||
|
@ -836,7 +836,6 @@ class Instance(resource.Resource):
|
|||||||
deleter.start()
|
deleter.start()
|
||||||
if not deleter.step():
|
if not deleter.step():
|
||||||
return False
|
return False
|
||||||
self.resource_id_set(None)
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def handle_suspend(self):
|
def handle_suspend(self):
|
||||||
|
@ -214,7 +214,6 @@ class SecurityGroup(neutron.NeutronResource):
|
|||||||
self.neutron().delete_security_group(self.resource_id)
|
self.neutron().delete_security_group(self.resource_id)
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
self.client_plugin().ignore_not_found(ex)
|
self.client_plugin().ignore_not_found(ex)
|
||||||
self.resource_id_set(None)
|
|
||||||
|
|
||||||
def handle_update(self, json_snippet, tmpl_diff, prop_diff):
|
def handle_update(self, json_snippet, tmpl_diff, prop_diff):
|
||||||
props = self.prepare_update_properties(json_snippet)
|
props = self.prepare_update_properties(json_snippet)
|
||||||
|
@ -59,7 +59,6 @@ class ServerGroup(resource.Resource):
|
|||||||
self.nova().server_groups.delete(self.resource_id)
|
self.nova().server_groups.delete(self.resource_id)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.client_plugin('nova').ignore_not_found(e)
|
self.client_plugin('nova').ignore_not_found(e)
|
||||||
self.resource_id_set(None)
|
|
||||||
|
|
||||||
def physical_resource_name(self):
|
def physical_resource_name(self):
|
||||||
name = self.properties.get(self.NAME)
|
name = self.properties.get(self.NAME)
|
||||||
|
@ -309,7 +309,6 @@ class OSDBInstance(resource.Resource):
|
|||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
self.client_plugin().ignore_not_found(ex)
|
self.client_plugin().ignore_not_found(ex)
|
||||||
LOG.debug("Database instance %s not found." % self.resource_id)
|
LOG.debug("Database instance %s not found." % self.resource_id)
|
||||||
self.resource_id_set(None)
|
|
||||||
else:
|
else:
|
||||||
instance.delete()
|
instance.delete()
|
||||||
return instance
|
return instance
|
||||||
@ -326,7 +325,6 @@ class OSDBInstance(resource.Resource):
|
|||||||
self._refresh_instance(instance)
|
self._refresh_instance(instance)
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
self.client_plugin().ignore_not_found(ex)
|
self.client_plugin().ignore_not_found(ex)
|
||||||
self.resource_id_set(None)
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
@ -233,7 +233,6 @@ class SecurityGroup(resource.Resource):
|
|||||||
self.client_plugin('nova').ignore_not_found(e)
|
self.client_plugin('nova').ignore_not_found(e)
|
||||||
|
|
||||||
self.nova().security_groups.delete(self.resource_id)
|
self.nova().security_groups.delete(self.resource_id)
|
||||||
self.resource_id_set(None)
|
|
||||||
|
|
||||||
def _handle_delete_neutron(self):
|
def _handle_delete_neutron(self):
|
||||||
client = self.neutron()
|
client = self.neutron()
|
||||||
@ -255,7 +254,6 @@ class SecurityGroup(resource.Resource):
|
|||||||
client.delete_security_group(self.resource_id)
|
client.delete_security_group(self.resource_id)
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
self.client_plugin('neutron').ignore_not_found(ex)
|
self.client_plugin('neutron').ignore_not_found(ex)
|
||||||
self.resource_id_set(None)
|
|
||||||
|
|
||||||
def FnGetRefId(self):
|
def FnGetRefId(self):
|
||||||
if self.properties[self.VPC_ID]:
|
if self.properties[self.VPC_ID]:
|
||||||
|
@ -984,7 +984,6 @@ class Server(stack_user.StackUser):
|
|||||||
|
|
||||||
def check_delete_complete(self, deleter):
|
def check_delete_complete(self, deleter):
|
||||||
if deleter is None or deleter.step():
|
if deleter is None or deleter.step():
|
||||||
self.resource_id_set(None)
|
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -166,7 +166,6 @@ class Volume(resource.Resource):
|
|||||||
vol.get()
|
vol.get()
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
self.client_plugin().ignore_not_found(ex)
|
self.client_plugin().ignore_not_found(ex)
|
||||||
self.resource_id_set(None)
|
|
||||||
|
|
||||||
def handle_snapshot_delete(self, state):
|
def handle_snapshot_delete(self, state):
|
||||||
backup = state not in ((self.CREATE, self.FAILED),
|
backup = state not in ((self.CREATE, self.FAILED),
|
||||||
|
@ -541,7 +541,6 @@ class InstancesTest(HeatTestCase):
|
|||||||
self.m.ReplayAll()
|
self.m.ReplayAll()
|
||||||
|
|
||||||
scheduler.TaskRunner(instance.delete)()
|
scheduler.TaskRunner(instance.delete)()
|
||||||
self.assertIsNone(instance.resource_id)
|
|
||||||
self.assertEqual((instance.DELETE, instance.COMPLETE), instance.state)
|
self.assertEqual((instance.DELETE, instance.COMPLETE), instance.state)
|
||||||
self.m.VerifyAll()
|
self.m.VerifyAll()
|
||||||
|
|
||||||
|
@ -96,7 +96,6 @@ class NovaServerGroupTest(HeatTestCase):
|
|||||||
self.sg_mgr.delete.assert_called_once_with('test')
|
self.sg_mgr.delete.assert_called_once_with('test')
|
||||||
self.assertEqual((self.sg.DELETE, self.sg.COMPLETE),
|
self.assertEqual((self.sg.DELETE, self.sg.COMPLETE),
|
||||||
self.sg.state)
|
self.sg.state)
|
||||||
self.assertIsNone(self.sg.resource_id)
|
|
||||||
|
|
||||||
def test_sg_delete_not_found(self):
|
def test_sg_delete_not_found(self):
|
||||||
self._create_sg('test')
|
self._create_sg('test')
|
||||||
@ -105,4 +104,3 @@ class NovaServerGroupTest(HeatTestCase):
|
|||||||
self.sg_mgr.delete.assert_called_once_with('test')
|
self.sg_mgr.delete.assert_called_once_with('test')
|
||||||
self.assertEqual((self.sg.DELETE, self.sg.COMPLETE),
|
self.assertEqual((self.sg.DELETE, self.sg.COMPLETE),
|
||||||
self.sg.state)
|
self.sg.state)
|
||||||
self.assertIsNone(self.sg.resource_id)
|
|
||||||
|
@ -214,7 +214,6 @@ class OSDBInstanceTest(HeatTestCase):
|
|||||||
|
|
||||||
self.m.ReplayAll()
|
self.m.ReplayAll()
|
||||||
scheduler.TaskRunner(instance.delete)()
|
scheduler.TaskRunner(instance.delete)()
|
||||||
self.assertIsNone(instance.resource_id)
|
|
||||||
self.m.VerifyAll()
|
self.m.VerifyAll()
|
||||||
|
|
||||||
def test_osdatabase_delete_overlimit(self):
|
def test_osdatabase_delete_overlimit(self):
|
||||||
@ -237,7 +236,6 @@ class OSDBInstanceTest(HeatTestCase):
|
|||||||
|
|
||||||
self.m.ReplayAll()
|
self.m.ReplayAll()
|
||||||
scheduler.TaskRunner(instance.delete)()
|
scheduler.TaskRunner(instance.delete)()
|
||||||
self.assertIsNone(instance.resource_id)
|
|
||||||
self.m.VerifyAll()
|
self.m.VerifyAll()
|
||||||
|
|
||||||
def test_osdatabase_delete_resource_none(self):
|
def test_osdatabase_delete_resource_none(self):
|
||||||
@ -265,7 +263,6 @@ class OSDBInstanceTest(HeatTestCase):
|
|||||||
|
|
||||||
self.m.ReplayAll()
|
self.m.ReplayAll()
|
||||||
scheduler.TaskRunner(instance.delete)()
|
scheduler.TaskRunner(instance.delete)()
|
||||||
self.assertIsNone(instance.resource_id)
|
|
||||||
self.m.VerifyAll()
|
self.m.VerifyAll()
|
||||||
|
|
||||||
def test_osdatabase_invalid_attribute(self):
|
def test_osdatabase_invalid_attribute(self):
|
||||||
|
@ -929,7 +929,6 @@ class ServersTest(HeatTestCase):
|
|||||||
self.m.ReplayAll()
|
self.m.ReplayAll()
|
||||||
|
|
||||||
scheduler.TaskRunner(server.delete)()
|
scheduler.TaskRunner(server.delete)()
|
||||||
self.assertIsNone(server.resource_id)
|
|
||||||
self.assertEqual((server.DELETE, server.COMPLETE), server.state)
|
self.assertEqual((server.DELETE, server.COMPLETE), server.state)
|
||||||
self.m.VerifyAll()
|
self.m.VerifyAll()
|
||||||
|
|
||||||
@ -947,12 +946,6 @@ class ServersTest(HeatTestCase):
|
|||||||
get().AndRaise(fakes_v1_1.fake_exception())
|
get().AndRaise(fakes_v1_1.fake_exception())
|
||||||
mox.Replay(get)
|
mox.Replay(get)
|
||||||
|
|
||||||
scheduler.TaskRunner(server.delete)()
|
|
||||||
self.assertIsNone(server.resource_id)
|
|
||||||
self.assertEqual((server.DELETE, server.COMPLETE), server.state)
|
|
||||||
self.m.VerifyAll()
|
|
||||||
|
|
||||||
server.state_set(server.CREATE, server.COMPLETE, 'to delete again')
|
|
||||||
scheduler.TaskRunner(server.delete)()
|
scheduler.TaskRunner(server.delete)()
|
||||||
self.assertEqual((server.DELETE, server.COMPLETE), server.state)
|
self.assertEqual((server.DELETE, server.COMPLETE), server.state)
|
||||||
self.m.VerifyAll()
|
self.m.VerifyAll()
|
||||||
|
@ -217,10 +217,6 @@ class VolumeTest(HeatTestCase):
|
|||||||
fv.status = 'available'
|
fv.status = 'available'
|
||||||
scheduler.TaskRunner(rsrc.destroy)()
|
scheduler.TaskRunner(rsrc.destroy)()
|
||||||
|
|
||||||
# Test when volume already deleted
|
|
||||||
rsrc.state_set(rsrc.CREATE, rsrc.COMPLETE)
|
|
||||||
scheduler.TaskRunner(rsrc.destroy)()
|
|
||||||
|
|
||||||
self.m.VerifyAll()
|
self.m.VerifyAll()
|
||||||
|
|
||||||
def test_volume_default_az(self):
|
def test_volume_default_az(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user