Begin move of UpdateReplace back to its rightful location

A deeply misguided effort to move all exceptions out of the
heat.engine.resource module, where they belong, and into the
heat.common.exception module, where they largely do not, broke the API for
third-party resource plugins. Unfortunately this happened a couple of
releases back already, so we can't simply put UpdateReplace back where it
belongs as that would also break the de-facto third-party API.

This change adds an alias in the correct location and a comment indicating
that it will move back at some time in the future. It also switches all of
the in-tree uses back to heat.engine.resource.UpdateReplace, in the hope
that third-party developers will be more inclined to copy from that.

This reverts commit 4e2cfb991a.

Change-Id: Iedd5d07d6c0c07e39e51a0fb810665b3e9c61f87
Closes-Bug: #1611104
changes/17/352617/3
Zane Bitter 6 years ago
parent 285802bdd5
commit c5ebe66ce9
  1. 3
      heat/common/exception.py
  2. 2
      heat/engine/check_resource.py
  3. 32
      heat/engine/resource.py
  4. 2
      heat/engine/resources/openstack/heat/remote_stack.py
  5. 2
      heat/engine/resources/openstack/heat/software_deployment.py
  6. 4
      heat/engine/resources/openstack/heat/wait_condition_handle.py
  7. 6
      heat/engine/resources/stack_resource.py
  8. 5
      heat/engine/update.py
  9. 5
      heat/tests/aws/test_eip.py
  10. 3
      heat/tests/aws/test_instance.py
  11. 3
      heat/tests/convergence/framework/fake_resource.py
  12. 2
      heat/tests/engine/test_check_resource.py
  13. 3
      heat/tests/openstack/aodh/test_alarm.py
  14. 4
      heat/tests/openstack/heat/test_cw_alarm.py
  15. 3
      heat/tests/openstack/heat/test_instance_group.py
  16. 5
      heat/tests/openstack/heat/test_remote_stack.py
  17. 3
      heat/tests/openstack/heat/test_software_deployment.py
  18. 4
      heat/tests/openstack/heat/test_waitcondition.py
  19. 3
      heat/tests/openstack/manila/test_security_service.py
  20. 2
      heat/tests/openstack/mistral/test_workflow.py
  21. 5
      heat/tests/openstack/neutron/test_neutron_port.py
  22. 3
      heat/tests/openstack/nova/test_keypair.py
  23. 12
      heat/tests/openstack/nova/test_server.py
  24. 4
      heat/tests/openstack/zaqar/test_queue.py
  25. 4
      heat/tests/test_hot.py
  26. 38
      heat/tests/test_resource.py
  27. 7
      heat/tests/test_stack_resource.py
  28. 2
      heat/tests/test_stack_update.py

@ -377,6 +377,9 @@ class PropertyUnspecifiedError(HeatException):
super(PropertyUnspecifiedError, self).__init__(**kwargs)
# Do not reference this here - in the future it will move back to its
# correct (and original) location in heat.engine.resource. Reference it as
# heat.engine.resource.UpdateReplace instead.
class UpdateReplace(Exception):
"""Raised when resource update requires replacement."""
def __init__(self, resource_name='Unknown'):

@ -93,7 +93,7 @@ class CheckResource(object):
check_resource_update(rsrc, tmpl.id, resource_data,
self.engine_id,
stack)
except exception.UpdateReplace:
except resource.UpdateReplace:
new_res_id = rsrc.make_replacement(tmpl.id)
LOG.info(_LI("Replacing resource with new id %s"),
new_res_id)

@ -61,6 +61,10 @@ def _register_class(resource_type, resource_class):
resources.global_env().register_class(resource_type, resource_class)
# Attention developers about to move/delete this: STOP IT!!!
UpdateReplace = exception.UpdateReplace
class PollDelay(Exception):
"""Exception to delay polling of the resource.
@ -582,10 +586,10 @@ class Resource(object):
changed_properties_set,
after_props,
before_props):
raise exception.UpdateReplace(self)
raise UpdateReplace(self)
if not changed_properties_set.issubset(update_allowed_set):
raise exception.UpdateReplace(self.name)
raise UpdateReplace(self.name)
return dict((k, after_props.get(k)) for k in changed_properties_set)
@ -1054,14 +1058,14 @@ class Resource(object):
prev_resource, check_init_complete=True):
if self.status == self.FAILED or (self.stack.convergence and (
self.action, self.status) == (self.DELETE, self.COMPLETE)):
raise exception.UpdateReplace(self)
raise UpdateReplace(self)
if check_init_complete and (self.action == self.INIT
and self.status == self.COMPLETE):
raise exception.UpdateReplace(self)
raise UpdateReplace(self)
if self.needs_replace(after_props):
raise exception.UpdateReplace(self)
raise UpdateReplace(self)
if before != after.freeze():
return True
@ -1078,7 +1082,7 @@ class Resource(object):
self._add_event(self.UPDATE, self.FAILED, six.text_type(ex))
raise failure
else:
raise exception.UpdateReplace(self.name)
raise UpdateReplace(self.name)
def update_convergence(self, template_id, resource_data, engine_id,
timeout, new_stack):
@ -1138,7 +1142,7 @@ class Resource(object):
prev_resource, check_init_complete):
tmpl_diff = self.update_template_diff(after.freeze(), before)
if tmpl_diff and self.needs_replace_with_tmpl_diff(tmpl_diff):
raise exception.UpdateReplace(self)
raise UpdateReplace(self)
self.update_template_diff_properties(after_props, before_props)
return True
@ -1160,7 +1164,7 @@ class Resource(object):
if 'update' in actions:
raise exception.ResourceActionRestricted(action='update')
return True
except exception.UpdateReplace:
except UpdateReplace:
if 'replace' in actions:
raise exception.ResourceActionRestricted(action='replace')
raise
@ -1179,7 +1183,7 @@ class Resource(object):
if cfg.CONF.observe_on_update and before_props:
if not self.resource_id:
raise exception.UpdateReplace(self)
raise UpdateReplace(self)
try:
resource_reality = self.get_live_state(before_props)
@ -1187,7 +1191,7 @@ class Resource(object):
self._update_properties_with_live_state(before_props,
resource_reality)
except exception.EntityNotFound:
raise exception.UpdateReplace(self)
raise UpdateReplace(self)
except Exception as ex:
LOG.warning(_LW("Resource cannot be updated with it's "
"live state in case of next "
@ -1268,12 +1272,12 @@ class Resource(object):
self.updated_time = datetime.utcnow()
with self._action_recorder(action, exception.UpdateReplace):
with self._action_recorder(action, UpdateReplace):
after_props.validate()
tmpl_diff = self.update_template_diff(after.freeze(), before)
if tmpl_diff and self.needs_replace_with_tmpl_diff(tmpl_diff):
raise exception.UpdateReplace(self)
raise UpdateReplace(self)
prop_diff = self.update_template_diff_properties(after_props,
before_props)
@ -1291,7 +1295,7 @@ class Resource(object):
failure = exception.ResourceFailure(ae, self, action)
self._add_event(action, self.FAILED, six.text_type(ae))
raise failure
except exception.UpdateReplace:
except UpdateReplace:
# catch all UpdateReplace exceptions
self._prepare_update_replace(action)
raise
@ -2116,7 +2120,7 @@ class Resource(object):
def handle_update(self, json_snippet, tmpl_diff, prop_diff):
if prop_diff:
raise exception.UpdateReplace(self.name)
raise UpdateReplace(self.name)
def metadata_update(self, new_metadata=None):
"""No-op for resources which don't explicitly override this method."""

@ -216,7 +216,7 @@ class RemoteStack(resource.Resource):
# If resource is in CHECK_FAILED state, raise UpdateReplace
# to replace the failed stack.
if self.state == (self.CHECK, self.FAILED):
raise exception.UpdateReplace(self)
raise resource.UpdateReplace(self)
# Always issue an update to the remote stack and let the individual
# resources in it decide if they need updating.

@ -449,7 +449,7 @@ class SoftwareDeployment(signal_responder.SignalResponder):
if inp.input_data() != old_inputs[name].input_data():
LOG.debug('Replacing SW Deployment due to change in '
'input "%s"', name)
raise exception.UpdateReplace
raise resource.UpdateReplace
return self._handle_action(self.UPDATE, config=config)

@ -15,11 +15,11 @@ import uuid
from oslo_serialization import jsonutils
from heat.common import exception
from heat.common.i18n import _
from heat.engine import attributes
from heat.engine import constraints
from heat.engine import properties
from heat.engine import resource
from heat.engine.resources.aws.cfn import wait_condition_handle as aws_wch
from heat.engine.resources import signal_responder
from heat.engine.resources import wait_condition as wc_base
@ -233,7 +233,7 @@ class UpdateWaitConditionHandle(aws_wch.WaitConditionHandle):
support_status = support.SupportStatus(version='2014.1')
def update(self, after, before=None, prev_resource=None):
raise exception.UpdateReplace(self.name)
raise resource.UpdateReplace(self.name)
def resource_mapping():

@ -97,17 +97,17 @@ class StackResource(resource.Resource):
# FIXME (ricolin): seems currently can not call super here
if self.nested() is None and self.status == self.FAILED:
raise exception.UpdateReplace(self)
raise resource.UpdateReplace(self)
# If stack resource is in CHECK_FAILED state, raise UpdateReplace
# to replace the failed stack.
if self.state == (self.CHECK, self.FAILED):
raise exception.UpdateReplace(self)
raise resource.UpdateReplace(self)
if (check_init_complete and
self.nested() is None and
self.action == self.INIT and self.status == self.COMPLETE):
raise exception.UpdateReplace(self)
raise resource.UpdateReplace(self)
return True

@ -18,6 +18,7 @@ from heat.common import exception
from heat.common.i18n import _LI
from heat.common.i18n import repr_wrapper
from heat.engine import dependencies
from heat.engine import resource
from heat.engine import scheduler
from heat.objects import resource as resource_objects
@ -158,7 +159,7 @@ class StackUpdate(object):
try:
yield self._update_in_place(existing_res,
new_res)
except exception.UpdateReplace:
except resource.UpdateReplace:
pass
else:
# Save updated resource definition to backup stack
@ -268,7 +269,7 @@ class StackUpdate(object):
updated_props, current_props,
None):
updated_keys.append(key)
except exception.UpdateReplace:
except resource.UpdateReplace:
replaced_keys.append(key)
return {

@ -23,6 +23,7 @@ from heat.common import exception
from heat.common import short_id
from heat.common import template_format
from heat.engine.clients.os import nova
from heat.engine import resource
from heat.engine.resources.aws.ec2 import eip
from heat.engine import rsrc_defn
from heat.engine import scheduler
@ -889,7 +890,7 @@ class AllocTest(common.HeatTestCase):
before = self.create_association(t, stack, 'IPAssoc')
after = rsrc_defn.ResourceDefinition(before.name, before.type(),
after_props)
self.assertTrue(exception.UpdateReplace,
self.assertTrue(resource.UpdateReplace,
before._needs_update(after, before, after_props,
before_props, None))
@ -914,7 +915,7 @@ class AllocTest(common.HeatTestCase):
after = rsrc_defn.ResourceDefinition(before.name, before.type(),
after_props)
updater = scheduler.TaskRunner(before.update, after)
self.assertRaises(exception.UpdateReplace, updater)
self.assertRaises(resource.UpdateReplace, updater)
def test_update_association_with_NetworkInterfaceId_or_InstanceId(self):
self.mock_create_floatingip()

@ -27,6 +27,7 @@ from heat.engine.clients.os import neutron
from heat.engine.clients.os import nova
from heat.engine.clients import progress
from heat.engine import environment
from heat.engine import resource
from heat.engine.resources.aws.ec2 import instance as instances
from heat.engine.resources import scheduler_hints as sh
from heat.engine import scheduler
@ -1177,7 +1178,7 @@ class InstancesTest(common.HeatTestCase):
update_props['ImageId'] = 'mustreplace'
update_template = instance.t.freeze(properties=update_props)
updater = scheduler.TaskRunner(instance.update, update_template)
self.assertRaises(exception.UpdateReplace, updater)
self.assertRaises(resource.UpdateReplace, updater)
self.m.VerifyAll()

@ -11,7 +11,6 @@
# License for the specific language governing permissions and limitations
# under the License.
from heat.common import exception
from heat.common.i18n import _
from heat.engine import attributes
from heat.engine import properties
@ -85,7 +84,7 @@ class TestResource(resource.Resource):
def handle_update(self, json_snippet=None, tmpl_diff=None, prop_diff=None):
for prop in prop_diff:
if '!' in prop:
raise exception.UpdateReplace(self.name)
raise resource.UpdateReplace(self.name)
self.data_set(prop, prop_diff.get(prop), redact=False)
def _resolve_attribute(self, name):

@ -110,7 +110,7 @@ class CheckWorkflowUpdateTest(common.HeatTestCase):
def test_is_update_traversal_raise_update_replace(
self, tr, mock_mr, mock_cru, mock_crc, mock_pcr, mock_csc,
mock_cid):
mock_cru.side_effect = exception.UpdateReplace
mock_cru.side_effect = resource.UpdateReplace
tr.return_value = 317
self.worker.check_resource(
self.ctx, self.resource.id, self.stack.current_traversal, {},

@ -22,6 +22,7 @@ from heat.common import exception
from heat.common import template_format
from heat.engine.clients.os import aodh
from heat.engine.clients.os import ceilometer
from heat.engine import resource
from heat.engine.resources.openstack.aodh import alarm
from heat.engine import rsrc_defn
from heat.engine import scheduler
@ -239,7 +240,7 @@ class AodhAlarmTest(common.HeatTestCase):
properties)
updater = scheduler.TaskRunner(rsrc.update, snippet)
self.assertRaises(exception.UpdateReplace, updater)
self.assertRaises(resource.UpdateReplace, updater)
def test_mem_alarm_suspend_resume(self):
"""Tests suspending and resuming of the alarm.

@ -14,8 +14,8 @@
import copy
from heat.common import exception
from heat.common import template_format
from heat.engine import resource
from heat.engine.resources.openstack.heat import cloud_watch
from heat.engine import rsrc_defn
from heat.engine import scheduler
@ -125,7 +125,7 @@ class CloudWatchAlarmTest(common.HeatTestCase):
props)
updater = scheduler.TaskRunner(rsrc.update, snippet)
self.assertRaises(exception.UpdateReplace, updater)
self.assertRaises(resource.UpdateReplace, updater)
scheduler.TaskRunner(rsrc.delete)()
self.m.VerifyAll()

@ -21,6 +21,7 @@ from heat.common import grouputils
from heat.common import short_id
from heat.common import template_format
from heat.engine.clients.os import neutron
from heat.engine import resource
from heat.engine.resources.openstack.heat import instance_group as instgrp
from heat.engine import rsrc_defn
from heat.engine import scheduler
@ -209,7 +210,7 @@ class TestLaunchConfig(common.HeatTestCase):
metadata)
# Changing metadata in the second update triggers UpdateReplace
updater = scheduler.TaskRunner(rsrc.update, update_snippet)
self.assertRaises(exception.UpdateReplace, updater)
self.assertRaises(resource.UpdateReplace, updater)
class LoadbalancerReloadTest(common.HeatTestCase):

@ -24,6 +24,7 @@ from heat.common.i18n import _
from heat.common import template_format
from heat.engine.clients.os import heat_plugin
from heat.engine import environment
from heat.engine import resource
from heat.engine.resources.openstack.heat import remote_stack
from heat.engine import rsrc_defn
from heat.engine import scheduler
@ -616,7 +617,7 @@ class RemoteStackTest(tests_common.HeatTestCase):
update_snippet = rsrc_defn.ResourceDefinition(rsrc.name,
rsrc.type(),
props)
self.assertRaises(exception.UpdateReplace,
self.assertRaises(resource.UpdateReplace,
scheduler.TaskRunner(rsrc.update, update_snippet))
def test_update_failed(self):
@ -686,5 +687,5 @@ class RemoteStackTest(tests_common.HeatTestCase):
update_snippet = rsrc_defn.ResourceDefinition(rsrc.name,
rsrc.type(),
props)
self.assertRaises(exception.UpdateReplace,
self.assertRaises(resource.UpdateReplace,
scheduler.TaskRunner(rsrc.update, update_snippet))

@ -26,6 +26,7 @@ from heat.common import template_format
from heat.engine.clients.os import nova
from heat.engine.clients.os import swift
from heat.engine.clients.os import zaqar
from heat.engine import resource
from heat.engine.resources.openstack.heat import software_deployment as sd
from heat.engine import rsrc_defn
from heat.engine import stack as parser
@ -860,7 +861,7 @@ class SoftwareDeploymentTest(common.HeatTestCase):
props.update(prop_diff)
snippet = rsrc_defn.ResourceDefinition(rsrc.name, rsrc.type(), props)
self.assertRaises(exc.UpdateReplace,
self.assertRaises(resource.UpdateReplace,
self.deployment.handle_update,
snippet, None, prop_diff)

@ -20,12 +20,12 @@ from oslo_serialization import jsonutils as json
from oslo_utils import timeutils
import six
from heat.common import exception
from heat.common import identifier
from heat.common import template_format
from heat.engine.clients.os import heat_plugin
from heat.engine.clients.os import swift as swift_plugin
from heat.engine import environment
from heat.engine import resource
from heat.engine.resources.openstack.heat import wait_condition_handle as h_wch
from heat.engine import stack as parser
from heat.engine import template as tmpl
@ -513,4 +513,4 @@ class HeatWaitConditionTest(common.HeatTestCase):
handle = self.stack['update_wait_handle']
self.assertEqual((handle.CREATE, handle.COMPLETE), handle.state)
self.assertRaises(
exception.UpdateReplace, handle.update, None, None)
resource.UpdateReplace, handle.update, None, None)

@ -16,6 +16,7 @@ import six
from heat.common import exception
from heat.common import template_format
from heat.engine import resource
from heat.engine.resources.openstack.manila import security_service
from heat.engine import scheduler
from heat.engine import template
@ -138,7 +139,7 @@ class ManilaSecurityServiceTest(common.HeatTestCase):
rsrc_defns = template.Template(t).resource_definitions(self.stack)
new_ss = rsrc_defns['security_service']
self.assertEqual(0, self.client.security_services.update.call_count)
err = self.assertRaises(exception.UpdateReplace,
err = self.assertRaises(resource.UpdateReplace,
scheduler.TaskRunner(ss.update, new_ss))
msg = 'The Resource security_service requires replacement.'
self.assertEqual(msg, six.text_type(err))

@ -472,7 +472,7 @@ class TestMistralWorkflow(common.HeatTestCase):
self.mistral.workflows.update.return_value = new_workflows
self.mistral.workflows.delete.return_value = None
err = self.assertRaises(exception.UpdateReplace,
err = self.assertRaises(resource.UpdateReplace,
scheduler.TaskRunner(wf.update,
new_workflow))
msg = 'The Resource workflow requires replacement.'

@ -22,6 +22,7 @@ import six
from heat.common import exception
from heat.common import template_format
from heat.engine import resource
from heat.engine import rsrc_defn
from heat.engine import scheduler
from heat.tests import common
@ -486,7 +487,7 @@ class NeutronPortTest(common.HeatTestCase):
new_props['network'] = new_props.pop('network_id')
update_snippet = rsrc_defn.ResourceDefinition(port.name, port.type(),
new_props)
self.assertRaises(exception.UpdateReplace, port._needs_update,
self.assertRaises(resource.UpdateReplace, port._needs_update,
update_snippet, port.frozen_definition(),
new_props, port.properties, None)
@ -605,7 +606,7 @@ class NeutronPortTest(common.HeatTestCase):
update_snippet = rsrc_defn.ResourceDefinition(port.name, port.type(),
new_props)
updater = scheduler.TaskRunner(port.update, update_snippet)
self.assertRaises(exception.UpdateReplace, updater)
self.assertRaises(resource.UpdateReplace, updater)
self.m.VerifyAll()

@ -18,6 +18,7 @@ import six
from heat.common import exception
from heat.engine.clients.os import nova
from heat.engine import resource
from heat.engine.resources.openstack.nova import keypair
from heat.engine import scheduler
from heat.tests import common
@ -153,7 +154,7 @@ class NovaKeyPairTest(common.HeatTestCase):
self.fake_keypairs.delete('my_key')
self.m.ReplayAll()
updater = scheduler.TaskRunner(res.update, res.t)
self.assertRaises(exception.UpdateReplace, updater)
self.assertRaises(resource.UpdateReplace, updater)
self.m.ReplayAll()

@ -1850,7 +1850,7 @@ class ServersTest(common.HeatTestCase):
update_props['flavor'] = 'm1.small'
update_template = server.t.freeze(properties=update_props)
updater = scheduler.TaskRunner(server.update, update_template)
self.assertRaises(exception.UpdateReplace, updater)
self.assertRaises(resource.UpdateReplace, updater)
@mock.patch.object(servers.Server, 'prepare_for_replace')
def test_server_update_server_flavor_policy_update(self, mock_replace):
@ -1868,7 +1868,7 @@ class ServersTest(common.HeatTestCase):
update_props['flavor'] = 'm1.small'
update_template = server.t.freeze(properties=update_props)
updater = scheduler.TaskRunner(server.update, update_template)
self.assertRaises(exception.UpdateReplace, updater)
self.assertRaises(resource.UpdateReplace, updater)
@mock.patch.object(servers.Server, 'prepare_for_replace')
@mock.patch.object(nova.NovaClientPlugin, '_create')
@ -1885,7 +1885,7 @@ class ServersTest(common.HeatTestCase):
update_template = server.t.freeze(properties=update_props)
server.action = server.CREATE
updater = scheduler.TaskRunner(server.update, update_template)
self.assertRaises(exception.UpdateReplace, updater)
self.assertRaises(resource.UpdateReplace, updater)
@mock.patch.object(servers.Server, 'prepare_for_replace')
@mock.patch.object(nova.NovaClientPlugin, '_create')
@ -1923,7 +1923,7 @@ class ServersTest(common.HeatTestCase):
update_props['image'] = image_id
update_template = server.t.freeze(properties=update_props)
updater = scheduler.TaskRunner(server.update, update_template)
self.assertRaises(exception.UpdateReplace, updater)
self.assertRaises(resource.UpdateReplace, updater)
def _test_server_update_image_rebuild(self, status, policy='REBUILD',
password=None):
@ -2042,7 +2042,7 @@ class ServersTest(common.HeatTestCase):
update_props['image_update_policy'] = 'REPLACE'
update_template = server.t.freeze(properties=update_props)
updater = scheduler.TaskRunner(server.update, update_template)
self.assertRaises(exception.UpdateReplace, updater)
self.assertRaises(resource.UpdateReplace, updater)
def test_server_status_build(self):
return_server = self.fc.servers.list()[0]
@ -3412,7 +3412,7 @@ class ServersTest(common.HeatTestCase):
update_props['image_update_policy'] = 'REPLACE'
update_template = server.t.freeze(properties=update_props)
updater = scheduler.TaskRunner(server.update, update_template)
self.assertRaises(exception.UpdateReplace, updater)
self.assertRaises(resource.UpdateReplace, updater)
def test_server_properties_validation_create_and_update_fail(self):
return_server = self.fc.servers.list()[1]

@ -14,9 +14,9 @@
import mock
import six
from heat.common import exception
from heat.common import template_format
from heat.engine.clients import client_plugin
from heat.engine import resource
from heat.engine.resources.openstack.zaqar import queue
from heat.engine import rsrc_defn
from heat.engine import scheduler
@ -207,7 +207,7 @@ class ZaqarMessageQueueTest(common.HeatTestCase):
new_queue = resource_defns['MyQueue2']
scheduler.TaskRunner(queue.create)()
err = self.assertRaises(exception.UpdateReplace,
err = self.assertRaises(resource.UpdateReplace,
scheduler.TaskRunner(queue.update,
new_queue))
msg = 'The Resource MyQueue2 requires replacement.'

@ -1721,7 +1721,7 @@ class HotStackTest(common.HeatTestCase):
rsrc_defn.ResourceDefinition('AResource',
'ResourceWithPropsType',
properties={'Foo': 'abc'})
).WithSideEffects(check_props).AndRaise(exception.UpdateReplace)
).WithSideEffects(check_props).AndRaise(resource.UpdateReplace)
self.m.ReplayAll()
self.stack.update(updated_stack)
@ -1767,7 +1767,7 @@ class HotStackTest(common.HeatTestCase):
rsrc_defn.ResourceDefinition('AResource',
'ResourceWithPropsType',
properties={'Foo': 'abc'})
).WithSideEffects(check_props).AndRaise(exception.UpdateReplace)
).WithSideEffects(check_props).AndRaise(resource.UpdateReplace)
self.m.ReplayAll()
self.stack.update(updated_stack)

@ -465,7 +465,7 @@ class ResourceTest(common.HeatTestCase):
res.prepare_for_replace = mock.Mock()
self.assertRaises(
exception.UpdateReplace, scheduler.TaskRunner(res.update, utmpl))
resource.UpdateReplace, scheduler.TaskRunner(res.update, utmpl))
self.assertTrue(res.prepare_for_replace.called)
def test_update_replace_prepare_replace_error(self):
@ -500,7 +500,7 @@ class ResourceTest(common.HeatTestCase):
self.stack.state_set('ROLLBACK', 'IN_PROGRESS', 'Simulate rollback')
self.assertRaises(
exception.UpdateReplace, scheduler.TaskRunner(res.update, utmpl))
resource.UpdateReplace, scheduler.TaskRunner(res.update, utmpl))
self.assertTrue(res.restore_prev_rsrc.called)
def test_update_replace_rollback_restore_prev_rsrc_error(self):
@ -536,7 +536,7 @@ class ResourceTest(common.HeatTestCase):
# resource in failed status and hasn't nested will enter
# UpdateReplace flow
self.assertRaises(
exception.UpdateReplace, scheduler.TaskRunner(res.update, utmpl))
resource.UpdateReplace, scheduler.TaskRunner(res.update, utmpl))
self.m.VerifyAll()
@ -748,7 +748,7 @@ class ResourceTest(common.HeatTestCase):
self.stack.context)
after_props = new_t.properties(res.properties_schema,
self.stack.context)
self.assertRaises(exception.UpdateReplace,
self.assertRaises(resource.UpdateReplace,
res.update_template_diff_properties,
after_props, before_props)
@ -1071,12 +1071,12 @@ class ResourceTest(common.HeatTestCase):
self.m.StubOutWithMock(generic_rsrc.ResourceWithProps, 'handle_update')
prop_diff = {'Foo': 'xyz'}
generic_rsrc.ResourceWithProps.handle_update(
utmpl, mock.ANY, prop_diff).AndRaise(exception.UpdateReplace(
utmpl, mock.ANY, prop_diff).AndRaise(resource.UpdateReplace(
res.name))
self.m.ReplayAll()
# should be re-raised so parser.Stack can handle replacement
updater = scheduler.TaskRunner(res.update, utmpl)
ex = self.assertRaises(exception.UpdateReplace, updater)
ex = self.assertRaises(resource.UpdateReplace, updater)
self.assertEqual('The Resource test_resource requires replacement.',
six.text_type(ex))
self.m.VerifyAll()
@ -1096,11 +1096,11 @@ class ResourceTest(common.HeatTestCase):
self.m.StubOutWithMock(generic_rsrc.ResourceWithProps, 'handle_update')
prop_diff = {'Foo': 'xyz'}
generic_rsrc.ResourceWithProps.handle_update(
utmpl, mock.ANY, prop_diff).AndRaise(exception.UpdateReplace())
utmpl, mock.ANY, prop_diff).AndRaise(resource.UpdateReplace())
self.m.ReplayAll()
# should be re-raised so parser.Stack can handle replacement
updater = scheduler.TaskRunner(res.update, utmpl)
ex = self.assertRaises(exception.UpdateReplace, updater)
ex = self.assertRaises(resource.UpdateReplace, updater)
self.assertEqual('The Resource Unknown requires replacement.',
six.text_type(ex))
self.m.VerifyAll()
@ -1114,7 +1114,7 @@ class ResourceTest(common.HeatTestCase):
self.assertEqual((res.INIT, res.COMPLETE), res.state)
prop = {'Foo': 'abc'}
self.assertRaises(exception.UpdateReplace,
self.assertRaises(resource.UpdateReplace,
res._needs_update, tmpl, tmpl, prop, prop, res)
def test_need_update_in_create_failed_state_for_resource(self):
@ -1126,7 +1126,7 @@ class ResourceTest(common.HeatTestCase):
res.update_allowed_properties = ('Foo',)
res.state_set(res.CREATE, res.FAILED)
prop = {'Foo': 'abc'}
self.assertRaises(exception.UpdateReplace,
self.assertRaises(resource.UpdateReplace,
res._needs_update, tmpl, tmpl, prop, prop, res)
def test_convg_need_update_in_delete_complete_state_for_resource(self):
@ -1139,7 +1139,7 @@ class ResourceTest(common.HeatTestCase):
res.stack.convergence = True
res.state_set(res.DELETE, res.COMPLETE)
prop = {'Foo': 'abc'}
self.assertRaises(exception.UpdateReplace,
self.assertRaises(resource.UpdateReplace,
res._needs_update, tmpl, tmpl, prop, prop, res)
def test_update_fail_missing_req_prop(self):
@ -2050,7 +2050,7 @@ class ResourceTest(common.HeatTestCase):
new_temp, stack_id=self.stack.id)
res_data = {}
self.assertRaises(exception.UpdateReplace, res.update_convergence,
self.assertRaises(resource.UpdateReplace, res.update_convergence,
new_temp.id, res_data, 'engine-007',
-1, new_stack)
@ -2144,10 +2144,10 @@ class ResourceTest(common.HeatTestCase):
res_data = {(1, True): {u'id': 4, u'name': 'A', 'attrs': {}},
(2, True): {u'id': 3, u'name': 'B', 'attrs': {}}}
mock_update.side_effect = exception.UpdateReplace
mock_update.side_effect = resource.UpdateReplace
new_stack = parser.Stack(utils.dummy_context(), 'test_stack',
new_temp, stack_id=self.stack.id)
self.assertRaises(exception.UpdateReplace,
self.assertRaises(resource.UpdateReplace,
res.update_convergence, new_temp.id, res_data,
'engine-007', 120, new_stack)
@ -2180,7 +2180,7 @@ class ResourceTest(common.HeatTestCase):
tr = scheduler.TaskRunner(res.update_convergence, 'new_tmpl_id', {},
'engine-007', self.dummy_timeout,
new_stack)
self.assertRaises(exception.UpdateReplace, tr)
self.assertRaises(resource.UpdateReplace, tr)
self.assertTrue(res.restore_prev_rsrc.called)
def test_convergence_update_replace_rollback_restore_prev_rsrc_error(self):
@ -3888,7 +3888,7 @@ class TestLiveStateUpdate(common.HeatTestCase):
updated_props={'Foo': 'bca'},
expected_error=True,
resource_id='1234',
expected=exception.UpdateReplace
expected=resource.UpdateReplace
)),
('live_state_not_found_id', dict(
live_state=exception.EntityNotFound(entity='resource',
@ -3896,7 +3896,7 @@ class TestLiveStateUpdate(common.HeatTestCase):
updated_props={'Foo': 'bca'},
expected_error=True,
resource_id=None,
expected=exception.UpdateReplace
expected=resource.UpdateReplace
))
]
@ -4137,7 +4137,7 @@ class ResourceUpdateRestrictionTest(common.HeatTestCase):
snippet = rsrc_defn.ResourceDefinition('bar',
'TestResourceType',
props)
error = self.assertRaises(exception.UpdateReplace,
error = self.assertRaises(resource.UpdateReplace,
scheduler.TaskRunner(res.update, snippet))
self.assertIn('requires replacement', six.text_type(error))
self.assertEqual(1, prep_replace.call_count)
@ -4190,7 +4190,7 @@ class ResourceUpdateRestrictionTest(common.HeatTestCase):
self.new_stack = parser.Stack(utils.dummy_context(), 'test_stack',
template.Template(self.tmpl,
env=self.env))
error = self.assertRaises(exception.UpdateReplace,
error = self.assertRaises(resource.UpdateReplace,
scheduler.TaskRunner(res.update_convergence,
self.stack.t.id,
{},

@ -22,6 +22,7 @@ import six
from heat.common import exception
from heat.common import template_format
from heat.engine import resource
from heat.engine.resources import stack_resource
from heat.engine import stack as parser
from heat.engine import template as templatem
@ -539,7 +540,7 @@ class StackResourceTest(StackResourceBaseTest):
self.parent_resource.state_set(self.parent_resource.INIT,
self.parent_resource.FAILED)
self.parent_resource._nested = None
self.assertRaises(exception.UpdateReplace,
self.assertRaises(resource.UpdateReplace,
self.parent_resource._needs_update,
self.parent_resource.t,
self.parent_resource.t,
@ -556,7 +557,7 @@ class StackResourceTest(StackResourceBaseTest):
self.parent_resource.state_set(self.parent_resource.INIT,
self.parent_resource.COMPLETE)
self.parent_resource._nested = None
self.assertRaises(exception.UpdateReplace,
self.assertRaises(resource.UpdateReplace,
self.parent_resource._needs_update,
self.parent_resource.t,
self.parent_resource.t,
@ -577,7 +578,7 @@ class StackResourceTest(StackResourceBaseTest):
self.parent_resource.nested = mock.MagicMock(return_value=self.nested)
self.parent_resource._nested = self.nested
self.assertRaises(exception.UpdateReplace,
self.assertRaises(resource.UpdateReplace,
self.parent_resource._needs_update,
self.parent_resource.t,
self.parent_resource.t,

@ -396,7 +396,7 @@ class StackUpdateTest(common.HeatTestCase):
def check_and_raise(*args):
self.assertEqual('abc', self.stack['AResource'].properties['Foo'])
raise exception.UpdateReplace
raise resource.UpdateReplace
mock_upd = self.patchobject(generic_rsrc.ResourceWithProps,
'update_template_diff',

Loading…
Cancel
Save