From 454d81d08285102b4ee3442a600083e981ec3dcf Mon Sep 17 00:00:00 2001 From: Zane Bitter Date: Fri, 17 Feb 2017 13:33:05 -0500 Subject: [PATCH] Define resource actions/statuses in a separate class This is the easiest way to make use of them in multiple unrelated classes. Change-Id: I49d42921efe4044e7a60ef127b6a69dc0831c238 --- heat/engine/resource.py | 17 ++++------------- heat/engine/status.py | 31 +++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 13 deletions(-) create mode 100644 heat/engine/status.py diff --git a/heat/engine/resource.py b/heat/engine/resource.py index 8afa63665a..b87a501a74 100644 --- a/heat/engine/resource.py +++ b/heat/engine/resource.py @@ -42,6 +42,7 @@ from heat.engine import properties from heat.engine import resources from heat.engine import rsrc_defn from heat.engine import scheduler +from heat.engine import status from heat.engine import support from heat.objects import resource as resource_objects from heat.objects import resource_data as resource_data_objects @@ -95,18 +96,7 @@ class PollDelay(Exception): @six.python_2_unicode_compatible -class Resource(object): - ACTIONS = ( - INIT, CREATE, DELETE, UPDATE, ROLLBACK, - SUSPEND, RESUME, ADOPT, SNAPSHOT, CHECK, - ) = ( - 'INIT', 'CREATE', 'DELETE', 'UPDATE', 'ROLLBACK', - 'SUSPEND', 'RESUME', 'ADOPT', 'SNAPSHOT', 'CHECK', - ) - - STATUSES = (IN_PROGRESS, FAILED, COMPLETE - ) = ('IN_PROGRESS', 'FAILED', 'COMPLETE') - +class Resource(status.ResourceStatus): BASE_ATTRIBUTES = (SHOW, ) = ('show', ) # If True, this resource must be created before it can be referenced. @@ -153,7 +143,8 @@ class Resource(object): required_service_extension = None # no signal actions - no_signal_actions = (SUSPEND, DELETE) + no_signal_actions = (status.ResourceStatus.SUSPEND, + status.ResourceStatus.DELETE) # Whether all other resources need a metadata_update() after # a signal to this resource diff --git a/heat/engine/status.py b/heat/engine/status.py new file mode 100644 index 0000000000..bead07d427 --- /dev/null +++ b/heat/engine/status.py @@ -0,0 +1,31 @@ +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +class ResourceStatus(object): + + __slots__ = tuple() + + ACTIONS = ( + INIT, CREATE, DELETE, UPDATE, ROLLBACK, + SUSPEND, RESUME, ADOPT, SNAPSHOT, CHECK, + ) = ( + 'INIT', 'CREATE', 'DELETE', 'UPDATE', 'ROLLBACK', + 'SUSPEND', 'RESUME', 'ADOPT', 'SNAPSHOT', 'CHECK', + ) + + STATUSES = ( + IN_PROGRESS, FAILED, COMPLETE, + ) = ( + 'IN_PROGRESS', 'FAILED', 'COMPLETE', + )