Merge "Define resource actions/statuses in a separate class"

This commit is contained in:
Jenkins 2017-03-31 01:35:34 +00:00 committed by Gerrit Code Review
commit 0cae06d38c
2 changed files with 35 additions and 13 deletions

View File

@ -40,6 +40,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
@ -93,18 +94,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.
@ -151,7 +141,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',
)