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
This commit is contained in:
Zane Bitter 2017-02-17 13:33:05 -05:00
parent 48fb66bdf3
commit 454d81d082
2 changed files with 35 additions and 13 deletions

View File

@ -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

31
heat/engine/status.py Normal file
View File

@ -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',
)