diff options
author | Jenkins <jenkins@review.openstack.org> | 2016-08-15 21:28:55 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2016-08-15 21:28:55 +0000 |
commit | 7216e1d0f6bf1796c4cca1fb09308aaeb89786da (patch) | |
tree | 2902b2fb9d2b24ecf5e8ff9b3248e8574c86964b | |
parent | 816dc3ad3510db2fdba4d6b16b0c3229ad08475f (diff) | |
parent | 4c5a8714ee97db1c149522321cd1fd7a34c85ff5 (diff) | |
download | heat-7216e1d0f6bf1796c4cca1fb09308aaeb89786da.tar.gz |
Merge "Alias UpdateReplace in its rightful location" into stable/mitaka
-rw-r--r-- | heat/common/exception.py | 3 | ||||
-rw-r--r-- | heat/engine/resource.py | 32 | ||||
-rw-r--r-- | heat/engine/update.py | 5 |
3 files changed, 24 insertions, 16 deletions
diff --git a/heat/common/exception.py b/heat/common/exception.py index 3205e36cc..e721ee896 100644 --- a/heat/common/exception.py +++ b/heat/common/exception.py @@ -363,6 +363,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'): diff --git a/heat/engine/resource.py b/heat/engine/resource.py index dfea86f7f..bd373bd8d 100644 --- a/heat/engine/resource.py +++ b/heat/engine/resource.py @@ -59,6 +59,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 + + @six.python_2_unicode_compatible class Resource(object): ACTIONS = ( @@ -560,10 +564,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) @@ -959,14 +963,14 @@ class Resource(object): def _needs_update(self, after, before, after_props, before_props, prev_resource, check_init_complete=True): if self.status == self.FAILED: - 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 @@ -983,7 +987,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): @@ -1037,7 +1041,7 @@ class Resource(object): tmpl_diff = self.update_template_diff(function.resolve(after), 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) @@ -1060,7 +1064,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 @@ -1091,7 +1095,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) @@ -1099,7 +1103,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 " @@ -1136,13 +1140,13 @@ 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(function.resolve(after), 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) @@ -1159,7 +1163,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 try: if (self.stack.action == 'ROLLBACK' and @@ -1955,7 +1959,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.""" diff --git a/heat/engine/update.py b/heat/engine/update.py index b233ee9da..0431046ec 100644 --- a/heat/engine/update.py +++ b/heat/engine/update.py @@ -18,6 +18,7 @@ from heat.common import exception from heat.common.i18n import _LI from heat.common.i18n import repr_wraper from heat.engine import dependencies +from heat.engine import resource from heat.engine import scheduler from heat.objects import resource as resource_objects @@ -156,7 +157,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 @@ -266,7 +267,7 @@ class StackUpdate(object): updated_props, current_props, None): updated_keys.append(key) - except exception.UpdateReplace: + except resource.UpdateReplace: replaced_keys.append(key) return { |