1 # Copyright (c) 2017 Cable Television Laboratories, Inc. ("CableLabs")
2 # and others. All rights reserved.
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at:
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
16 STACK_DELETE_TIMEOUT = 1200
17 STACK_COMPLETE_TIMEOUT = 1200
19 STATUS_CREATE_FAILED = 'CREATE_FAILED'
20 STATUS_CREATE_COMPLETE = 'CREATE_COMPLETE'
21 STATUS_DELETE_COMPLETE = 'DELETE_COMPLETE'
22 STATUS_DELETE_FAILED = 'DELETE_FAILED'
25 class StackConfig(object):
27 Configuration for Heat stack
30 def __init__(self, **kwargs):
33 :param name: the stack's name (required)
34 :param template: the heat template in dict() format (required if
35 template_path attribute is None)
36 :param template_path: the location of the heat template file (required
37 if template attribute is None)
38 :param resource_files: List of file paths to the resources referred to
40 :param env_values: dict() of strings for substitution of template
41 default values (optional)
44 self.name = kwargs.get('name')
45 self.template = kwargs.get('template')
46 self.template_path = kwargs.get('template_path')
47 self.resource_files = kwargs.get('resource_files')
48 self.env_values = kwargs.get('env_values')
50 if 'stack_create_timeout' in kwargs:
51 self.stack_create_timeout = kwargs['stack_create_timeout']
53 self.stack_create_timeout = STACK_COMPLETE_TIMEOUT
56 raise StackConfigError('name is required')
58 if not self.template and not self.template_path:
59 raise StackConfigError('A Heat template is required')
61 if self.resource_files and not isinstance(self.resource_files, list):
62 raise StackConfigError(
63 'resource_files must be a list when not None')
65 def __eq__(self, other):
66 return (self.name == other.name and
67 self.template == other.template and
68 self.template_path == other.template_path and
69 self.env_values == other.env_values and
70 self.stack_create_timeout == other.stack_create_timeout)
73 class StackConfigError(Exception):
75 Exception to be thrown when an stack configuration are incorrect