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
This commit is contained in:
parent
285802bdd5
commit
c5ebe66ce9
|
@ -377,6 +377,9 @@ class PropertyUnspecifiedError(HeatException):
|
||||||
super(PropertyUnspecifiedError, self).__init__(**kwargs)
|
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):
|
class UpdateReplace(Exception):
|
||||||
"""Raised when resource update requires replacement."""
|
"""Raised when resource update requires replacement."""
|
||||||
def __init__(self, resource_name='Unknown'):
|
def __init__(self, resource_name='Unknown'):
|
||||||
|
|
|
@ -93,7 +93,7 @@ class CheckResource(object):
|
||||||
check_resource_update(rsrc, tmpl.id, resource_data,
|
check_resource_update(rsrc, tmpl.id, resource_data,
|
||||||
self.engine_id,
|
self.engine_id,
|
||||||
stack)
|
stack)
|
||||||
except exception.UpdateReplace:
|
except resource.UpdateReplace:
|
||||||
new_res_id = rsrc.make_replacement(tmpl.id)
|
new_res_id = rsrc.make_replacement(tmpl.id)
|
||||||
LOG.info(_LI("Replacing resource with new id %s"),
|
LOG.info(_LI("Replacing resource with new id %s"),
|
||||||
new_res_id)
|
new_res_id)
|
||||||
|
|
|
@ -61,6 +61,10 @@ def _register_class(resource_type, resource_class):
|
||||||
resources.global_env().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):
|
class PollDelay(Exception):
|
||||||
"""Exception to delay polling of the resource.
|
"""Exception to delay polling of the resource.
|
||||||
|
|
||||||
|
@ -582,10 +586,10 @@ class Resource(object):
|
||||||
changed_properties_set,
|
changed_properties_set,
|
||||||
after_props,
|
after_props,
|
||||||
before_props):
|
before_props):
|
||||||
raise exception.UpdateReplace(self)
|
raise UpdateReplace(self)
|
||||||
|
|
||||||
if not changed_properties_set.issubset(update_allowed_set):
|
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)
|
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):
|
prev_resource, check_init_complete=True):
|
||||||
if self.status == self.FAILED or (self.stack.convergence and (
|
if self.status == self.FAILED or (self.stack.convergence and (
|
||||||
self.action, self.status) == (self.DELETE, self.COMPLETE)):
|
self.action, self.status) == (self.DELETE, self.COMPLETE)):
|
||||||
raise exception.UpdateReplace(self)
|
raise UpdateReplace(self)
|
||||||
|
|
||||||
if check_init_complete and (self.action == self.INIT
|
if check_init_complete and (self.action == self.INIT
|
||||||
and self.status == self.COMPLETE):
|
and self.status == self.COMPLETE):
|
||||||
raise exception.UpdateReplace(self)
|
raise UpdateReplace(self)
|
||||||
|
|
||||||
if self.needs_replace(after_props):
|
if self.needs_replace(after_props):
|
||||||
raise exception.UpdateReplace(self)
|
raise UpdateReplace(self)
|
||||||
|
|
||||||
if before != after.freeze():
|
if before != after.freeze():
|
||||||
return True
|
return True
|
||||||
|
@ -1078,7 +1082,7 @@ class Resource(object):
|
||||||
self._add_event(self.UPDATE, self.FAILED, six.text_type(ex))
|
self._add_event(self.UPDATE, self.FAILED, six.text_type(ex))
|
||||||
raise failure
|
raise failure
|
||||||
else:
|
else:
|
||||||
raise exception.UpdateReplace(self.name)
|
raise UpdateReplace(self.name)
|
||||||
|
|
||||||
def update_convergence(self, template_id, resource_data, engine_id,
|
def update_convergence(self, template_id, resource_data, engine_id,
|
||||||
timeout, new_stack):
|
timeout, new_stack):
|
||||||
|
@ -1138,7 +1142,7 @@ class Resource(object):
|
||||||
prev_resource, check_init_complete):
|
prev_resource, check_init_complete):
|
||||||
tmpl_diff = self.update_template_diff(after.freeze(), before)
|
tmpl_diff = self.update_template_diff(after.freeze(), before)
|
||||||
if tmpl_diff and self.needs_replace_with_tmpl_diff(tmpl_diff):
|
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)
|
self.update_template_diff_properties(after_props, before_props)
|
||||||
return True
|
return True
|
||||||
|
@ -1160,7 +1164,7 @@ class Resource(object):
|
||||||
if 'update' in actions:
|
if 'update' in actions:
|
||||||
raise exception.ResourceActionRestricted(action='update')
|
raise exception.ResourceActionRestricted(action='update')
|
||||||
return True
|
return True
|
||||||
except exception.UpdateReplace:
|
except UpdateReplace:
|
||||||
if 'replace' in actions:
|
if 'replace' in actions:
|
||||||
raise exception.ResourceActionRestricted(action='replace')
|
raise exception.ResourceActionRestricted(action='replace')
|
||||||
raise
|
raise
|
||||||
|
@ -1179,7 +1183,7 @@ class Resource(object):
|
||||||
|
|
||||||
if cfg.CONF.observe_on_update and before_props:
|
if cfg.CONF.observe_on_update and before_props:
|
||||||
if not self.resource_id:
|
if not self.resource_id:
|
||||||
raise exception.UpdateReplace(self)
|
raise UpdateReplace(self)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
resource_reality = self.get_live_state(before_props)
|
resource_reality = self.get_live_state(before_props)
|
||||||
|
@ -1187,7 +1191,7 @@ class Resource(object):
|
||||||
self._update_properties_with_live_state(before_props,
|
self._update_properties_with_live_state(before_props,
|
||||||
resource_reality)
|
resource_reality)
|
||||||
except exception.EntityNotFound:
|
except exception.EntityNotFound:
|
||||||
raise exception.UpdateReplace(self)
|
raise UpdateReplace(self)
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
LOG.warning(_LW("Resource cannot be updated with it's "
|
LOG.warning(_LW("Resource cannot be updated with it's "
|
||||||
"live state in case of next "
|
"live state in case of next "
|
||||||
|
@ -1268,12 +1272,12 @@ class Resource(object):
|
||||||
|
|
||||||
self.updated_time = datetime.utcnow()
|
self.updated_time = datetime.utcnow()
|
||||||
|
|
||||||
with self._action_recorder(action, exception.UpdateReplace):
|
with self._action_recorder(action, UpdateReplace):
|
||||||
after_props.validate()
|
after_props.validate()
|
||||||
|
|
||||||
tmpl_diff = self.update_template_diff(after.freeze(), before)
|
tmpl_diff = self.update_template_diff(after.freeze(), before)
|
||||||
if tmpl_diff and self.needs_replace_with_tmpl_diff(tmpl_diff):
|
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,
|
prop_diff = self.update_template_diff_properties(after_props,
|
||||||
before_props)
|
before_props)
|
||||||
|
@ -1291,7 +1295,7 @@ class Resource(object):
|
||||||
failure = exception.ResourceFailure(ae, self, action)
|
failure = exception.ResourceFailure(ae, self, action)
|
||||||
self._add_event(action, self.FAILED, six.text_type(ae))
|
self._add_event(action, self.FAILED, six.text_type(ae))
|
||||||
raise failure
|
raise failure
|
||||||
except exception.UpdateReplace:
|
except UpdateReplace:
|
||||||
# catch all UpdateReplace exceptions
|
# catch all UpdateReplace exceptions
|
||||||
self._prepare_update_replace(action)
|
self._prepare_update_replace(action)
|
||||||
raise
|
raise
|
||||||
|
@ -2116,7 +2120,7 @@ class Resource(object):
|
||||||
|
|
||||||
def handle_update(self, json_snippet, tmpl_diff, prop_diff):
|
def handle_update(self, json_snippet, tmpl_diff, prop_diff):
|
||||||
if prop_diff:
|
if prop_diff:
|
||||||
raise exception.UpdateReplace(self.name)
|
raise UpdateReplace(self.name)
|
||||||
|
|
||||||
def metadata_update(self, new_metadata=None):
|
def metadata_update(self, new_metadata=None):
|
||||||
"""No-op for resources which don't explicitly override this method."""
|
"""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
|
# If resource is in CHECK_FAILED state, raise UpdateReplace
|
||||||
# to replace the failed stack.
|
# to replace the failed stack.
|
||||||
if self.state == (self.CHECK, self.FAILED):
|
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
|
# Always issue an update to the remote stack and let the individual
|
||||||
# resources in it decide if they need updating.
|
# 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():
|
if inp.input_data() != old_inputs[name].input_data():
|
||||||
LOG.debug('Replacing SW Deployment due to change in '
|
LOG.debug('Replacing SW Deployment due to change in '
|
||||||
'input "%s"', name)
|
'input "%s"', name)
|
||||||
raise exception.UpdateReplace
|
raise resource.UpdateReplace
|
||||||
|
|
||||||
return self._handle_action(self.UPDATE, config=config)
|
return self._handle_action(self.UPDATE, config=config)
|
||||||
|
|
||||||
|
|
|
@ -15,11 +15,11 @@ import uuid
|
||||||
|
|
||||||
from oslo_serialization import jsonutils
|
from oslo_serialization import jsonutils
|
||||||
|
|
||||||
from heat.common import exception
|
|
||||||
from heat.common.i18n import _
|
from heat.common.i18n import _
|
||||||
from heat.engine import attributes
|
from heat.engine import attributes
|
||||||
from heat.engine import constraints
|
from heat.engine import constraints
|
||||||
from heat.engine import properties
|
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.aws.cfn import wait_condition_handle as aws_wch
|
||||||
from heat.engine.resources import signal_responder
|
from heat.engine.resources import signal_responder
|
||||||
from heat.engine.resources import wait_condition as wc_base
|
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')
|
support_status = support.SupportStatus(version='2014.1')
|
||||||
|
|
||||||
def update(self, after, before=None, prev_resource=None):
|
def update(self, after, before=None, prev_resource=None):
|
||||||
raise exception.UpdateReplace(self.name)
|
raise resource.UpdateReplace(self.name)
|
||||||
|
|
||||||
|
|
||||||
def resource_mapping():
|
def resource_mapping():
|
||||||
|
|
|
@ -97,17 +97,17 @@ class StackResource(resource.Resource):
|
||||||
|
|
||||||
# FIXME (ricolin): seems currently can not call super here
|
# FIXME (ricolin): seems currently can not call super here
|
||||||
if self.nested() is None and self.status == self.FAILED:
|
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
|
# If stack resource is in CHECK_FAILED state, raise UpdateReplace
|
||||||
# to replace the failed stack.
|
# to replace the failed stack.
|
||||||
if self.state == (self.CHECK, self.FAILED):
|
if self.state == (self.CHECK, self.FAILED):
|
||||||
raise exception.UpdateReplace(self)
|
raise resource.UpdateReplace(self)
|
||||||
|
|
||||||
if (check_init_complete and
|
if (check_init_complete and
|
||||||
self.nested() is None and
|
self.nested() is None and
|
||||||
self.action == self.INIT and self.status == self.COMPLETE):
|
self.action == self.INIT and self.status == self.COMPLETE):
|
||||||
raise exception.UpdateReplace(self)
|
raise resource.UpdateReplace(self)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ from heat.common import exception
|
||||||
from heat.common.i18n import _LI
|
from heat.common.i18n import _LI
|
||||||
from heat.common.i18n import repr_wrapper
|
from heat.common.i18n import repr_wrapper
|
||||||
from heat.engine import dependencies
|
from heat.engine import dependencies
|
||||||
|
from heat.engine import resource
|
||||||
from heat.engine import scheduler
|
from heat.engine import scheduler
|
||||||
from heat.objects import resource as resource_objects
|
from heat.objects import resource as resource_objects
|
||||||
|
|
||||||
|
@ -158,7 +159,7 @@ class StackUpdate(object):
|
||||||
try:
|
try:
|
||||||
yield self._update_in_place(existing_res,
|
yield self._update_in_place(existing_res,
|
||||||
new_res)
|
new_res)
|
||||||
except exception.UpdateReplace:
|
except resource.UpdateReplace:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
# Save updated resource definition to backup stack
|
# Save updated resource definition to backup stack
|
||||||
|
@ -268,7 +269,7 @@ class StackUpdate(object):
|
||||||
updated_props, current_props,
|
updated_props, current_props,
|
||||||
None):
|
None):
|
||||||
updated_keys.append(key)
|
updated_keys.append(key)
|
||||||
except exception.UpdateReplace:
|
except resource.UpdateReplace:
|
||||||
replaced_keys.append(key)
|
replaced_keys.append(key)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -23,6 +23,7 @@ from heat.common import exception
|
||||||
from heat.common import short_id
|
from heat.common import short_id
|
||||||
from heat.common import template_format
|
from heat.common import template_format
|
||||||
from heat.engine.clients.os import nova
|
from heat.engine.clients.os import nova
|
||||||
|
from heat.engine import resource
|
||||||
from heat.engine.resources.aws.ec2 import eip
|
from heat.engine.resources.aws.ec2 import eip
|
||||||
from heat.engine import rsrc_defn
|
from heat.engine import rsrc_defn
|
||||||
from heat.engine import scheduler
|
from heat.engine import scheduler
|
||||||
|
@ -889,7 +890,7 @@ class AllocTest(common.HeatTestCase):
|
||||||
before = self.create_association(t, stack, 'IPAssoc')
|
before = self.create_association(t, stack, 'IPAssoc')
|
||||||
after = rsrc_defn.ResourceDefinition(before.name, before.type(),
|
after = rsrc_defn.ResourceDefinition(before.name, before.type(),
|
||||||
after_props)
|
after_props)
|
||||||
self.assertTrue(exception.UpdateReplace,
|
self.assertTrue(resource.UpdateReplace,
|
||||||
before._needs_update(after, before, after_props,
|
before._needs_update(after, before, after_props,
|
||||||
before_props, None))
|
before_props, None))
|
||||||
|
|
||||||
|
@ -914,7 +915,7 @@ class AllocTest(common.HeatTestCase):
|
||||||
after = rsrc_defn.ResourceDefinition(before.name, before.type(),
|
after = rsrc_defn.ResourceDefinition(before.name, before.type(),
|
||||||
after_props)
|
after_props)
|
||||||
updater = scheduler.TaskRunner(before.update, after)
|
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):
|
def test_update_association_with_NetworkInterfaceId_or_InstanceId(self):
|
||||||
self.mock_create_floatingip()
|
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.os import nova
|
||||||
from heat.engine.clients import progress
|
from heat.engine.clients import progress
|
||||||
from heat.engine import environment
|
from heat.engine import environment
|
||||||
|
from heat.engine import resource
|
||||||
from heat.engine.resources.aws.ec2 import instance as instances
|
from heat.engine.resources.aws.ec2 import instance as instances
|
||||||
from heat.engine.resources import scheduler_hints as sh
|
from heat.engine.resources import scheduler_hints as sh
|
||||||
from heat.engine import scheduler
|
from heat.engine import scheduler
|
||||||
|
@ -1177,7 +1178,7 @@ class InstancesTest(common.HeatTestCase):
|
||||||
update_props['ImageId'] = 'mustreplace'
|
update_props['ImageId'] = 'mustreplace'
|
||||||
update_template = instance.t.freeze(properties=update_props)
|
update_template = instance.t.freeze(properties=update_props)
|
||||||
updater = scheduler.TaskRunner(instance.update, update_template)
|
updater = scheduler.TaskRunner(instance.update, update_template)
|
||||||
self.assertRaises(exception.UpdateReplace, updater)
|
self.assertRaises(resource.UpdateReplace, updater)
|
||||||
|
|
||||||
self.m.VerifyAll()
|
self.m.VerifyAll()
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from heat.common import exception
|
|
||||||
from heat.common.i18n import _
|
from heat.common.i18n import _
|
||||||
from heat.engine import attributes
|
from heat.engine import attributes
|
||||||
from heat.engine import properties
|
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):
|
def handle_update(self, json_snippet=None, tmpl_diff=None, prop_diff=None):
|
||||||
for prop in prop_diff:
|
for prop in prop_diff:
|
||||||
if '!' in prop:
|
if '!' in prop:
|
||||||
raise exception.UpdateReplace(self.name)
|
raise resource.UpdateReplace(self.name)
|
||||||
self.data_set(prop, prop_diff.get(prop), redact=False)
|
self.data_set(prop, prop_diff.get(prop), redact=False)
|
||||||
|
|
||||||
def _resolve_attribute(self, name):
|
def _resolve_attribute(self, name):
|
||||||
|
|
|
@ -110,7 +110,7 @@ class CheckWorkflowUpdateTest(common.HeatTestCase):
|
||||||
def test_is_update_traversal_raise_update_replace(
|
def test_is_update_traversal_raise_update_replace(
|
||||||
self, tr, mock_mr, mock_cru, mock_crc, mock_pcr, mock_csc,
|
self, tr, mock_mr, mock_cru, mock_crc, mock_pcr, mock_csc,
|
||||||
mock_cid):
|
mock_cid):
|
||||||
mock_cru.side_effect = exception.UpdateReplace
|
mock_cru.side_effect = resource.UpdateReplace
|
||||||
tr.return_value = 317
|
tr.return_value = 317
|
||||||
self.worker.check_resource(
|
self.worker.check_resource(
|
||||||
self.ctx, self.resource.id, self.stack.current_traversal, {},
|
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.common import template_format
|
||||||
from heat.engine.clients.os import aodh
|
from heat.engine.clients.os import aodh
|
||||||
from heat.engine.clients.os import ceilometer
|
from heat.engine.clients.os import ceilometer
|
||||||
|
from heat.engine import resource
|
||||||
from heat.engine.resources.openstack.aodh import alarm
|
from heat.engine.resources.openstack.aodh import alarm
|
||||||
from heat.engine import rsrc_defn
|
from heat.engine import rsrc_defn
|
||||||
from heat.engine import scheduler
|
from heat.engine import scheduler
|
||||||
|
@ -239,7 +240,7 @@ class AodhAlarmTest(common.HeatTestCase):
|
||||||
properties)
|
properties)
|
||||||
|
|
||||||
updater = scheduler.TaskRunner(rsrc.update, snippet)
|
updater = scheduler.TaskRunner(rsrc.update, snippet)
|
||||||
self.assertRaises(exception.UpdateReplace, updater)
|
self.assertRaises(resource.UpdateReplace, updater)
|
||||||
|
|
||||||
def test_mem_alarm_suspend_resume(self):
|
def test_mem_alarm_suspend_resume(self):
|
||||||
"""Tests suspending and resuming of the alarm.
|
"""Tests suspending and resuming of the alarm.
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
|
|
||||||
import copy
|
import copy
|
||||||
|
|
||||||
from heat.common import exception
|
|
||||||
from heat.common import template_format
|
from heat.common import template_format
|
||||||
|
from heat.engine import resource
|
||||||
from heat.engine.resources.openstack.heat import cloud_watch
|
from heat.engine.resources.openstack.heat import cloud_watch
|
||||||
from heat.engine import rsrc_defn
|
from heat.engine import rsrc_defn
|
||||||
from heat.engine import scheduler
|
from heat.engine import scheduler
|
||||||
|
@ -125,7 +125,7 @@ class CloudWatchAlarmTest(common.HeatTestCase):
|
||||||
props)
|
props)
|
||||||
|
|
||||||
updater = scheduler.TaskRunner(rsrc.update, snippet)
|
updater = scheduler.TaskRunner(rsrc.update, snippet)
|
||||||
self.assertRaises(exception.UpdateReplace, updater)
|
self.assertRaises(resource.UpdateReplace, updater)
|
||||||
|
|
||||||
scheduler.TaskRunner(rsrc.delete)()
|
scheduler.TaskRunner(rsrc.delete)()
|
||||||
self.m.VerifyAll()
|
self.m.VerifyAll()
|
||||||
|
|
|
@ -21,6 +21,7 @@ from heat.common import grouputils
|
||||||
from heat.common import short_id
|
from heat.common import short_id
|
||||||
from heat.common import template_format
|
from heat.common import template_format
|
||||||
from heat.engine.clients.os import neutron
|
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.resources.openstack.heat import instance_group as instgrp
|
||||||
from heat.engine import rsrc_defn
|
from heat.engine import rsrc_defn
|
||||||
from heat.engine import scheduler
|
from heat.engine import scheduler
|
||||||
|
@ -209,7 +210,7 @@ class TestLaunchConfig(common.HeatTestCase):
|
||||||
metadata)
|
metadata)
|
||||||
# Changing metadata in the second update triggers UpdateReplace
|
# Changing metadata in the second update triggers UpdateReplace
|
||||||
updater = scheduler.TaskRunner(rsrc.update, update_snippet)
|
updater = scheduler.TaskRunner(rsrc.update, update_snippet)
|
||||||
self.assertRaises(exception.UpdateReplace, updater)
|
self.assertRaises(resource.UpdateReplace, updater)
|
||||||
|
|
||||||
|
|
||||||
class LoadbalancerReloadTest(common.HeatTestCase):
|
class LoadbalancerReloadTest(common.HeatTestCase):
|
||||||
|
|
|
@ -24,6 +24,7 @@ from heat.common.i18n import _
|
||||||
from heat.common import template_format
|
from heat.common import template_format
|
||||||
from heat.engine.clients.os import heat_plugin
|
from heat.engine.clients.os import heat_plugin
|
||||||
from heat.engine import environment
|
from heat.engine import environment
|
||||||
|
from heat.engine import resource
|
||||||
from heat.engine.resources.openstack.heat import remote_stack
|
from heat.engine.resources.openstack.heat import remote_stack
|
||||||
from heat.engine import rsrc_defn
|
from heat.engine import rsrc_defn
|
||||||
from heat.engine import scheduler
|
from heat.engine import scheduler
|
||||||
|
@ -616,7 +617,7 @@ class RemoteStackTest(tests_common.HeatTestCase):
|
||||||
update_snippet = rsrc_defn.ResourceDefinition(rsrc.name,
|
update_snippet = rsrc_defn.ResourceDefinition(rsrc.name,
|
||||||
rsrc.type(),
|
rsrc.type(),
|
||||||
props)
|
props)
|
||||||
self.assertRaises(exception.UpdateReplace,
|
self.assertRaises(resource.UpdateReplace,
|
||||||
scheduler.TaskRunner(rsrc.update, update_snippet))
|
scheduler.TaskRunner(rsrc.update, update_snippet))
|
||||||
|
|
||||||
def test_update_failed(self):
|
def test_update_failed(self):
|
||||||
|
@ -686,5 +687,5 @@ class RemoteStackTest(tests_common.HeatTestCase):
|
||||||
update_snippet = rsrc_defn.ResourceDefinition(rsrc.name,
|
update_snippet = rsrc_defn.ResourceDefinition(rsrc.name,
|
||||||
rsrc.type(),
|
rsrc.type(),
|
||||||
props)
|
props)
|
||||||
self.assertRaises(exception.UpdateReplace,
|
self.assertRaises(resource.UpdateReplace,
|
||||||
scheduler.TaskRunner(rsrc.update, update_snippet))
|
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 nova
|
||||||
from heat.engine.clients.os import swift
|
from heat.engine.clients.os import swift
|
||||||
from heat.engine.clients.os import zaqar
|
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.resources.openstack.heat import software_deployment as sd
|
||||||
from heat.engine import rsrc_defn
|
from heat.engine import rsrc_defn
|
||||||
from heat.engine import stack as parser
|
from heat.engine import stack as parser
|
||||||
|
@ -860,7 +861,7 @@ class SoftwareDeploymentTest(common.HeatTestCase):
|
||||||
props.update(prop_diff)
|
props.update(prop_diff)
|
||||||
snippet = rsrc_defn.ResourceDefinition(rsrc.name, rsrc.type(), props)
|
snippet = rsrc_defn.ResourceDefinition(rsrc.name, rsrc.type(), props)
|
||||||
|
|
||||||
self.assertRaises(exc.UpdateReplace,
|
self.assertRaises(resource.UpdateReplace,
|
||||||
self.deployment.handle_update,
|
self.deployment.handle_update,
|
||||||
snippet, None, prop_diff)
|
snippet, None, prop_diff)
|
||||||
|
|
||||||
|
|
|
@ -20,12 +20,12 @@ from oslo_serialization import jsonutils as json
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
import six
|
import six
|
||||||
|
|
||||||
from heat.common import exception
|
|
||||||
from heat.common import identifier
|
from heat.common import identifier
|
||||||
from heat.common import template_format
|
from heat.common import template_format
|
||||||
from heat.engine.clients.os import heat_plugin
|
from heat.engine.clients.os import heat_plugin
|
||||||
from heat.engine.clients.os import swift as swift_plugin
|
from heat.engine.clients.os import swift as swift_plugin
|
||||||
from heat.engine import environment
|
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.resources.openstack.heat import wait_condition_handle as h_wch
|
||||||
from heat.engine import stack as parser
|
from heat.engine import stack as parser
|
||||||
from heat.engine import template as tmpl
|
from heat.engine import template as tmpl
|
||||||
|
@ -513,4 +513,4 @@ class HeatWaitConditionTest(common.HeatTestCase):
|
||||||
handle = self.stack['update_wait_handle']
|
handle = self.stack['update_wait_handle']
|
||||||
self.assertEqual((handle.CREATE, handle.COMPLETE), handle.state)
|
self.assertEqual((handle.CREATE, handle.COMPLETE), handle.state)
|
||||||
self.assertRaises(
|
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 exception
|
||||||
from heat.common import template_format
|
from heat.common import template_format
|
||||||
|
from heat.engine import resource
|
||||||
from heat.engine.resources.openstack.manila import security_service
|
from heat.engine.resources.openstack.manila import security_service
|
||||||
from heat.engine import scheduler
|
from heat.engine import scheduler
|
||||||
from heat.engine import template
|
from heat.engine import template
|
||||||
|
@ -138,7 +139,7 @@ class ManilaSecurityServiceTest(common.HeatTestCase):
|
||||||
rsrc_defns = template.Template(t).resource_definitions(self.stack)
|
rsrc_defns = template.Template(t).resource_definitions(self.stack)
|
||||||
new_ss = rsrc_defns['security_service']
|
new_ss = rsrc_defns['security_service']
|
||||||
self.assertEqual(0, self.client.security_services.update.call_count)
|
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))
|
scheduler.TaskRunner(ss.update, new_ss))
|
||||||
msg = 'The Resource security_service requires replacement.'
|
msg = 'The Resource security_service requires replacement.'
|
||||||
self.assertEqual(msg, six.text_type(err))
|
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.update.return_value = new_workflows
|
||||||
self.mistral.workflows.delete.return_value = None
|
self.mistral.workflows.delete.return_value = None
|
||||||
|
|
||||||
err = self.assertRaises(exception.UpdateReplace,
|
err = self.assertRaises(resource.UpdateReplace,
|
||||||
scheduler.TaskRunner(wf.update,
|
scheduler.TaskRunner(wf.update,
|
||||||
new_workflow))
|
new_workflow))
|
||||||
msg = 'The Resource workflow requires replacement.'
|
msg = 'The Resource workflow requires replacement.'
|
||||||
|
|
|
@ -22,6 +22,7 @@ import six
|
||||||
|
|
||||||
from heat.common import exception
|
from heat.common import exception
|
||||||
from heat.common import template_format
|
from heat.common import template_format
|
||||||
|
from heat.engine import resource
|
||||||
from heat.engine import rsrc_defn
|
from heat.engine import rsrc_defn
|
||||||
from heat.engine import scheduler
|
from heat.engine import scheduler
|
||||||
from heat.tests import common
|
from heat.tests import common
|
||||||
|
@ -486,7 +487,7 @@ class NeutronPortTest(common.HeatTestCase):
|
||||||
new_props['network'] = new_props.pop('network_id')
|
new_props['network'] = new_props.pop('network_id')
|
||||||
update_snippet = rsrc_defn.ResourceDefinition(port.name, port.type(),
|
update_snippet = rsrc_defn.ResourceDefinition(port.name, port.type(),
|
||||||
new_props)
|
new_props)
|
||||||
self.assertRaises(exception.UpdateReplace, port._needs_update,
|
self.assertRaises(resource.UpdateReplace, port._needs_update,
|
||||||
update_snippet, port.frozen_definition(),
|
update_snippet, port.frozen_definition(),
|
||||||
new_props, port.properties, None)
|
new_props, port.properties, None)
|
||||||
|
|
||||||
|
@ -605,7 +606,7 @@ class NeutronPortTest(common.HeatTestCase):
|
||||||
update_snippet = rsrc_defn.ResourceDefinition(port.name, port.type(),
|
update_snippet = rsrc_defn.ResourceDefinition(port.name, port.type(),
|
||||||
new_props)
|
new_props)
|
||||||
updater = scheduler.TaskRunner(port.update, update_snippet)
|
updater = scheduler.TaskRunner(port.update, update_snippet)
|
||||||
self.assertRaises(exception.UpdateReplace, updater)
|
self.assertRaises(resource.UpdateReplace, updater)
|
||||||
|
|
||||||
self.m.VerifyAll()
|
self.m.VerifyAll()
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ import six
|
||||||
|
|
||||||
from heat.common import exception
|
from heat.common import exception
|
||||||
from heat.engine.clients.os import nova
|
from heat.engine.clients.os import nova
|
||||||
|
from heat.engine import resource
|
||||||
from heat.engine.resources.openstack.nova import keypair
|
from heat.engine.resources.openstack.nova import keypair
|
||||||
from heat.engine import scheduler
|
from heat.engine import scheduler
|
||||||
from heat.tests import common
|
from heat.tests import common
|
||||||
|
@ -153,7 +154,7 @@ class NovaKeyPairTest(common.HeatTestCase):
|
||||||
self.fake_keypairs.delete('my_key')
|
self.fake_keypairs.delete('my_key')
|
||||||
self.m.ReplayAll()
|
self.m.ReplayAll()
|
||||||
updater = scheduler.TaskRunner(res.update, res.t)
|
updater = scheduler.TaskRunner(res.update, res.t)
|
||||||
self.assertRaises(exception.UpdateReplace, updater)
|
self.assertRaises(resource.UpdateReplace, updater)
|
||||||
|
|
||||||
self.m.ReplayAll()
|
self.m.ReplayAll()
|
||||||
|
|
||||||
|
|
|
@ -1850,7 +1850,7 @@ class ServersTest(common.HeatTestCase):
|
||||||
update_props['flavor'] = 'm1.small'
|
update_props['flavor'] = 'm1.small'
|
||||||
update_template = server.t.freeze(properties=update_props)
|
update_template = server.t.freeze(properties=update_props)
|
||||||
updater = scheduler.TaskRunner(server.update, update_template)
|
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(servers.Server, 'prepare_for_replace')
|
||||||
def test_server_update_server_flavor_policy_update(self, mock_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_props['flavor'] = 'm1.small'
|
||||||
update_template = server.t.freeze(properties=update_props)
|
update_template = server.t.freeze(properties=update_props)
|
||||||
updater = scheduler.TaskRunner(server.update, update_template)
|
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(servers.Server, 'prepare_for_replace')
|
||||||
@mock.patch.object(nova.NovaClientPlugin, '_create')
|
@mock.patch.object(nova.NovaClientPlugin, '_create')
|
||||||
|
@ -1885,7 +1885,7 @@ class ServersTest(common.HeatTestCase):
|
||||||
update_template = server.t.freeze(properties=update_props)
|
update_template = server.t.freeze(properties=update_props)
|
||||||
server.action = server.CREATE
|
server.action = server.CREATE
|
||||||
updater = scheduler.TaskRunner(server.update, update_template)
|
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(servers.Server, 'prepare_for_replace')
|
||||||
@mock.patch.object(nova.NovaClientPlugin, '_create')
|
@mock.patch.object(nova.NovaClientPlugin, '_create')
|
||||||
|
@ -1923,7 +1923,7 @@ class ServersTest(common.HeatTestCase):
|
||||||
update_props['image'] = image_id
|
update_props['image'] = image_id
|
||||||
update_template = server.t.freeze(properties=update_props)
|
update_template = server.t.freeze(properties=update_props)
|
||||||
updater = scheduler.TaskRunner(server.update, update_template)
|
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',
|
def _test_server_update_image_rebuild(self, status, policy='REBUILD',
|
||||||
password=None):
|
password=None):
|
||||||
|
@ -2042,7 +2042,7 @@ class ServersTest(common.HeatTestCase):
|
||||||
update_props['image_update_policy'] = 'REPLACE'
|
update_props['image_update_policy'] = 'REPLACE'
|
||||||
update_template = server.t.freeze(properties=update_props)
|
update_template = server.t.freeze(properties=update_props)
|
||||||
updater = scheduler.TaskRunner(server.update, update_template)
|
updater = scheduler.TaskRunner(server.update, update_template)
|
||||||
self.assertRaises(exception.UpdateReplace, updater)
|
self.assertRaises(resource.UpdateReplace, updater)
|
||||||
|
|
||||||
def test_server_status_build(self):
|
def test_server_status_build(self):
|
||||||
return_server = self.fc.servers.list()[0]
|
return_server = self.fc.servers.list()[0]
|
||||||
|
@ -3412,7 +3412,7 @@ class ServersTest(common.HeatTestCase):
|
||||||
update_props['image_update_policy'] = 'REPLACE'
|
update_props['image_update_policy'] = 'REPLACE'
|
||||||
update_template = server.t.freeze(properties=update_props)
|
update_template = server.t.freeze(properties=update_props)
|
||||||
updater = scheduler.TaskRunner(server.update, update_template)
|
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):
|
def test_server_properties_validation_create_and_update_fail(self):
|
||||||
return_server = self.fc.servers.list()[1]
|
return_server = self.fc.servers.list()[1]
|
||||||
|
|
|
@ -14,9 +14,9 @@
|
||||||
import mock
|
import mock
|
||||||
import six
|
import six
|
||||||
|
|
||||||
from heat.common import exception
|
|
||||||
from heat.common import template_format
|
from heat.common import template_format
|
||||||
from heat.engine.clients import client_plugin
|
from heat.engine.clients import client_plugin
|
||||||
|
from heat.engine import resource
|
||||||
from heat.engine.resources.openstack.zaqar import queue
|
from heat.engine.resources.openstack.zaqar import queue
|
||||||
from heat.engine import rsrc_defn
|
from heat.engine import rsrc_defn
|
||||||
from heat.engine import scheduler
|
from heat.engine import scheduler
|
||||||
|
@ -207,7 +207,7 @@ class ZaqarMessageQueueTest(common.HeatTestCase):
|
||||||
new_queue = resource_defns['MyQueue2']
|
new_queue = resource_defns['MyQueue2']
|
||||||
|
|
||||||
scheduler.TaskRunner(queue.create)()
|
scheduler.TaskRunner(queue.create)()
|
||||||
err = self.assertRaises(exception.UpdateReplace,
|
err = self.assertRaises(resource.UpdateReplace,
|
||||||
scheduler.TaskRunner(queue.update,
|
scheduler.TaskRunner(queue.update,
|
||||||
new_queue))
|
new_queue))
|
||||||
msg = 'The Resource MyQueue2 requires replacement.'
|
msg = 'The Resource MyQueue2 requires replacement.'
|
||||||
|
|
|
@ -1721,7 +1721,7 @@ class HotStackTest(common.HeatTestCase):
|
||||||
rsrc_defn.ResourceDefinition('AResource',
|
rsrc_defn.ResourceDefinition('AResource',
|
||||||
'ResourceWithPropsType',
|
'ResourceWithPropsType',
|
||||||
properties={'Foo': 'abc'})
|
properties={'Foo': 'abc'})
|
||||||
).WithSideEffects(check_props).AndRaise(exception.UpdateReplace)
|
).WithSideEffects(check_props).AndRaise(resource.UpdateReplace)
|
||||||
self.m.ReplayAll()
|
self.m.ReplayAll()
|
||||||
|
|
||||||
self.stack.update(updated_stack)
|
self.stack.update(updated_stack)
|
||||||
|
@ -1767,7 +1767,7 @@ class HotStackTest(common.HeatTestCase):
|
||||||
rsrc_defn.ResourceDefinition('AResource',
|
rsrc_defn.ResourceDefinition('AResource',
|
||||||
'ResourceWithPropsType',
|
'ResourceWithPropsType',
|
||||||
properties={'Foo': 'abc'})
|
properties={'Foo': 'abc'})
|
||||||
).WithSideEffects(check_props).AndRaise(exception.UpdateReplace)
|
).WithSideEffects(check_props).AndRaise(resource.UpdateReplace)
|
||||||
self.m.ReplayAll()
|
self.m.ReplayAll()
|
||||||
|
|
||||||
self.stack.update(updated_stack)
|
self.stack.update(updated_stack)
|
||||||
|
|
|
@ -465,7 +465,7 @@ class ResourceTest(common.HeatTestCase):
|
||||||
res.prepare_for_replace = mock.Mock()
|
res.prepare_for_replace = mock.Mock()
|
||||||
|
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
exception.UpdateReplace, scheduler.TaskRunner(res.update, utmpl))
|
resource.UpdateReplace, scheduler.TaskRunner(res.update, utmpl))
|
||||||
self.assertTrue(res.prepare_for_replace.called)
|
self.assertTrue(res.prepare_for_replace.called)
|
||||||
|
|
||||||
def test_update_replace_prepare_replace_error(self):
|
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.stack.state_set('ROLLBACK', 'IN_PROGRESS', 'Simulate rollback')
|
||||||
|
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
exception.UpdateReplace, scheduler.TaskRunner(res.update, utmpl))
|
resource.UpdateReplace, scheduler.TaskRunner(res.update, utmpl))
|
||||||
self.assertTrue(res.restore_prev_rsrc.called)
|
self.assertTrue(res.restore_prev_rsrc.called)
|
||||||
|
|
||||||
def test_update_replace_rollback_restore_prev_rsrc_error(self):
|
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
|
# resource in failed status and hasn't nested will enter
|
||||||
# UpdateReplace flow
|
# UpdateReplace flow
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
exception.UpdateReplace, scheduler.TaskRunner(res.update, utmpl))
|
resource.UpdateReplace, scheduler.TaskRunner(res.update, utmpl))
|
||||||
|
|
||||||
self.m.VerifyAll()
|
self.m.VerifyAll()
|
||||||
|
|
||||||
|
@ -748,7 +748,7 @@ class ResourceTest(common.HeatTestCase):
|
||||||
self.stack.context)
|
self.stack.context)
|
||||||
after_props = new_t.properties(res.properties_schema,
|
after_props = new_t.properties(res.properties_schema,
|
||||||
self.stack.context)
|
self.stack.context)
|
||||||
self.assertRaises(exception.UpdateReplace,
|
self.assertRaises(resource.UpdateReplace,
|
||||||
res.update_template_diff_properties,
|
res.update_template_diff_properties,
|
||||||
after_props, before_props)
|
after_props, before_props)
|
||||||
|
|
||||||
|
@ -1071,12 +1071,12 @@ class ResourceTest(common.HeatTestCase):
|
||||||
self.m.StubOutWithMock(generic_rsrc.ResourceWithProps, 'handle_update')
|
self.m.StubOutWithMock(generic_rsrc.ResourceWithProps, 'handle_update')
|
||||||
prop_diff = {'Foo': 'xyz'}
|
prop_diff = {'Foo': 'xyz'}
|
||||||
generic_rsrc.ResourceWithProps.handle_update(
|
generic_rsrc.ResourceWithProps.handle_update(
|
||||||
utmpl, mock.ANY, prop_diff).AndRaise(exception.UpdateReplace(
|
utmpl, mock.ANY, prop_diff).AndRaise(resource.UpdateReplace(
|
||||||
res.name))
|
res.name))
|
||||||
self.m.ReplayAll()
|
self.m.ReplayAll()
|
||||||
# should be re-raised so parser.Stack can handle replacement
|
# should be re-raised so parser.Stack can handle replacement
|
||||||
updater = scheduler.TaskRunner(res.update, utmpl)
|
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.',
|
self.assertEqual('The Resource test_resource requires replacement.',
|
||||||
six.text_type(ex))
|
six.text_type(ex))
|
||||||
self.m.VerifyAll()
|
self.m.VerifyAll()
|
||||||
|
@ -1096,11 +1096,11 @@ class ResourceTest(common.HeatTestCase):
|
||||||
self.m.StubOutWithMock(generic_rsrc.ResourceWithProps, 'handle_update')
|
self.m.StubOutWithMock(generic_rsrc.ResourceWithProps, 'handle_update')
|
||||||
prop_diff = {'Foo': 'xyz'}
|
prop_diff = {'Foo': 'xyz'}
|
||||||
generic_rsrc.ResourceWithProps.handle_update(
|
generic_rsrc.ResourceWithProps.handle_update(
|
||||||
utmpl, mock.ANY, prop_diff).AndRaise(exception.UpdateReplace())
|
utmpl, mock.ANY, prop_diff).AndRaise(resource.UpdateReplace())
|
||||||
self.m.ReplayAll()
|
self.m.ReplayAll()
|
||||||
# should be re-raised so parser.Stack can handle replacement
|
# should be re-raised so parser.Stack can handle replacement
|
||||||
updater = scheduler.TaskRunner(res.update, utmpl)
|
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.',
|
self.assertEqual('The Resource Unknown requires replacement.',
|
||||||
six.text_type(ex))
|
six.text_type(ex))
|
||||||
self.m.VerifyAll()
|
self.m.VerifyAll()
|
||||||
|
@ -1114,7 +1114,7 @@ class ResourceTest(common.HeatTestCase):
|
||||||
self.assertEqual((res.INIT, res.COMPLETE), res.state)
|
self.assertEqual((res.INIT, res.COMPLETE), res.state)
|
||||||
|
|
||||||
prop = {'Foo': 'abc'}
|
prop = {'Foo': 'abc'}
|
||||||
self.assertRaises(exception.UpdateReplace,
|
self.assertRaises(resource.UpdateReplace,
|
||||||
res._needs_update, tmpl, tmpl, prop, prop, res)
|
res._needs_update, tmpl, tmpl, prop, prop, res)
|
||||||
|
|
||||||
def test_need_update_in_create_failed_state_for_resource(self):
|
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.update_allowed_properties = ('Foo',)
|
||||||
res.state_set(res.CREATE, res.FAILED)
|
res.state_set(res.CREATE, res.FAILED)
|
||||||
prop = {'Foo': 'abc'}
|
prop = {'Foo': 'abc'}
|
||||||
self.assertRaises(exception.UpdateReplace,
|
self.assertRaises(resource.UpdateReplace,
|
||||||
res._needs_update, tmpl, tmpl, prop, prop, res)
|
res._needs_update, tmpl, tmpl, prop, prop, res)
|
||||||
|
|
||||||
def test_convg_need_update_in_delete_complete_state_for_resource(self):
|
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.stack.convergence = True
|
||||||
res.state_set(res.DELETE, res.COMPLETE)
|
res.state_set(res.DELETE, res.COMPLETE)
|
||||||
prop = {'Foo': 'abc'}
|
prop = {'Foo': 'abc'}
|
||||||
self.assertRaises(exception.UpdateReplace,
|
self.assertRaises(resource.UpdateReplace,
|
||||||
res._needs_update, tmpl, tmpl, prop, prop, res)
|
res._needs_update, tmpl, tmpl, prop, prop, res)
|
||||||
|
|
||||||
def test_update_fail_missing_req_prop(self):
|
def test_update_fail_missing_req_prop(self):
|
||||||
|
@ -2050,7 +2050,7 @@ class ResourceTest(common.HeatTestCase):
|
||||||
new_temp, stack_id=self.stack.id)
|
new_temp, stack_id=self.stack.id)
|
||||||
|
|
||||||
res_data = {}
|
res_data = {}
|
||||||
self.assertRaises(exception.UpdateReplace, res.update_convergence,
|
self.assertRaises(resource.UpdateReplace, res.update_convergence,
|
||||||
new_temp.id, res_data, 'engine-007',
|
new_temp.id, res_data, 'engine-007',
|
||||||
-1, new_stack)
|
-1, new_stack)
|
||||||
|
|
||||||
|
@ -2144,10 +2144,10 @@ class ResourceTest(common.HeatTestCase):
|
||||||
|
|
||||||
res_data = {(1, True): {u'id': 4, u'name': 'A', 'attrs': {}},
|
res_data = {(1, True): {u'id': 4, u'name': 'A', 'attrs': {}},
|
||||||
(2, True): {u'id': 3, u'name': 'B', '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_stack = parser.Stack(utils.dummy_context(), 'test_stack',
|
||||||
new_temp, stack_id=self.stack.id)
|
new_temp, stack_id=self.stack.id)
|
||||||
self.assertRaises(exception.UpdateReplace,
|
self.assertRaises(resource.UpdateReplace,
|
||||||
res.update_convergence, new_temp.id, res_data,
|
res.update_convergence, new_temp.id, res_data,
|
||||||
'engine-007', 120, new_stack)
|
'engine-007', 120, new_stack)
|
||||||
|
|
||||||
|
@ -2180,7 +2180,7 @@ class ResourceTest(common.HeatTestCase):
|
||||||
tr = scheduler.TaskRunner(res.update_convergence, 'new_tmpl_id', {},
|
tr = scheduler.TaskRunner(res.update_convergence, 'new_tmpl_id', {},
|
||||||
'engine-007', self.dummy_timeout,
|
'engine-007', self.dummy_timeout,
|
||||||
new_stack)
|
new_stack)
|
||||||
self.assertRaises(exception.UpdateReplace, tr)
|
self.assertRaises(resource.UpdateReplace, tr)
|
||||||
self.assertTrue(res.restore_prev_rsrc.called)
|
self.assertTrue(res.restore_prev_rsrc.called)
|
||||||
|
|
||||||
def test_convergence_update_replace_rollback_restore_prev_rsrc_error(self):
|
def test_convergence_update_replace_rollback_restore_prev_rsrc_error(self):
|
||||||
|
@ -3888,7 +3888,7 @@ class TestLiveStateUpdate(common.HeatTestCase):
|
||||||
updated_props={'Foo': 'bca'},
|
updated_props={'Foo': 'bca'},
|
||||||
expected_error=True,
|
expected_error=True,
|
||||||
resource_id='1234',
|
resource_id='1234',
|
||||||
expected=exception.UpdateReplace
|
expected=resource.UpdateReplace
|
||||||
)),
|
)),
|
||||||
('live_state_not_found_id', dict(
|
('live_state_not_found_id', dict(
|
||||||
live_state=exception.EntityNotFound(entity='resource',
|
live_state=exception.EntityNotFound(entity='resource',
|
||||||
|
@ -3896,7 +3896,7 @@ class TestLiveStateUpdate(common.HeatTestCase):
|
||||||
updated_props={'Foo': 'bca'},
|
updated_props={'Foo': 'bca'},
|
||||||
expected_error=True,
|
expected_error=True,
|
||||||
resource_id=None,
|
resource_id=None,
|
||||||
expected=exception.UpdateReplace
|
expected=resource.UpdateReplace
|
||||||
))
|
))
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -4137,7 +4137,7 @@ class ResourceUpdateRestrictionTest(common.HeatTestCase):
|
||||||
snippet = rsrc_defn.ResourceDefinition('bar',
|
snippet = rsrc_defn.ResourceDefinition('bar',
|
||||||
'TestResourceType',
|
'TestResourceType',
|
||||||
props)
|
props)
|
||||||
error = self.assertRaises(exception.UpdateReplace,
|
error = self.assertRaises(resource.UpdateReplace,
|
||||||
scheduler.TaskRunner(res.update, snippet))
|
scheduler.TaskRunner(res.update, snippet))
|
||||||
self.assertIn('requires replacement', six.text_type(error))
|
self.assertIn('requires replacement', six.text_type(error))
|
||||||
self.assertEqual(1, prep_replace.call_count)
|
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',
|
self.new_stack = parser.Stack(utils.dummy_context(), 'test_stack',
|
||||||
template.Template(self.tmpl,
|
template.Template(self.tmpl,
|
||||||
env=self.env))
|
env=self.env))
|
||||||
error = self.assertRaises(exception.UpdateReplace,
|
error = self.assertRaises(resource.UpdateReplace,
|
||||||
scheduler.TaskRunner(res.update_convergence,
|
scheduler.TaskRunner(res.update_convergence,
|
||||||
self.stack.t.id,
|
self.stack.t.id,
|
||||||
{},
|
{},
|
||||||
|
|
|
@ -22,6 +22,7 @@ import six
|
||||||
|
|
||||||
from heat.common import exception
|
from heat.common import exception
|
||||||
from heat.common import template_format
|
from heat.common import template_format
|
||||||
|
from heat.engine import resource
|
||||||
from heat.engine.resources import stack_resource
|
from heat.engine.resources import stack_resource
|
||||||
from heat.engine import stack as parser
|
from heat.engine import stack as parser
|
||||||
from heat.engine import template as templatem
|
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.state_set(self.parent_resource.INIT,
|
||||||
self.parent_resource.FAILED)
|
self.parent_resource.FAILED)
|
||||||
self.parent_resource._nested = None
|
self.parent_resource._nested = None
|
||||||
self.assertRaises(exception.UpdateReplace,
|
self.assertRaises(resource.UpdateReplace,
|
||||||
self.parent_resource._needs_update,
|
self.parent_resource._needs_update,
|
||||||
self.parent_resource.t,
|
self.parent_resource.t,
|
||||||
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.state_set(self.parent_resource.INIT,
|
||||||
self.parent_resource.COMPLETE)
|
self.parent_resource.COMPLETE)
|
||||||
self.parent_resource._nested = None
|
self.parent_resource._nested = None
|
||||||
self.assertRaises(exception.UpdateReplace,
|
self.assertRaises(resource.UpdateReplace,
|
||||||
self.parent_resource._needs_update,
|
self.parent_resource._needs_update,
|
||||||
self.parent_resource.t,
|
self.parent_resource.t,
|
||||||
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 = mock.MagicMock(return_value=self.nested)
|
||||||
self.parent_resource._nested = self.nested
|
self.parent_resource._nested = self.nested
|
||||||
|
|
||||||
self.assertRaises(exception.UpdateReplace,
|
self.assertRaises(resource.UpdateReplace,
|
||||||
self.parent_resource._needs_update,
|
self.parent_resource._needs_update,
|
||||||
self.parent_resource.t,
|
self.parent_resource.t,
|
||||||
self.parent_resource.t,
|
self.parent_resource.t,
|
||||||
|
|
|
@ -396,7 +396,7 @@ class StackUpdateTest(common.HeatTestCase):
|
||||||
|
|
||||||
def check_and_raise(*args):
|
def check_and_raise(*args):
|
||||||
self.assertEqual('abc', self.stack['AResource'].properties['Foo'])
|
self.assertEqual('abc', self.stack['AResource'].properties['Foo'])
|
||||||
raise exception.UpdateReplace
|
raise resource.UpdateReplace
|
||||||
|
|
||||||
mock_upd = self.patchobject(generic_rsrc.ResourceWithProps,
|
mock_upd = self.patchobject(generic_rsrc.ResourceWithProps,
|
||||||
'update_template_diff',
|
'update_template_diff',
|
||||||
|
|
Loading…
Reference in New Issue