Merge "Add parameter_groups and conditions params for StackTemplate"

This commit is contained in:
Jenkins 2017-08-28 16:13:51 +00:00 committed by Gerrit Code Review
commit 23107f2513
2 changed files with 22 additions and 0 deletions

View File

@ -42,3 +42,14 @@ class StackTemplate(resource.Resource):
#: Key and value pairs that contain definition of resources in the
#: template
resources = resource.Body('resources', type=dict)
# List parameters grouped.
parameter_groups = resource.Body('parameter_groups', type=list)
# Restrict conditions.
conditions = resource.Body('conditions', type=dict)
def to_dict(self):
mapping = super(StackTemplate, self).to_dict()
mapping.pop('location')
mapping.pop('id')
mapping.pop('name')
return mapping

View File

@ -10,6 +10,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import copy
import testtools
from openstack.orchestration.v1 import stack_template
@ -53,3 +54,13 @@ class TestStackTemplate(testtools.TestCase):
self.assertEqual(FAKE['outputs'], sot.outputs)
self.assertEqual(FAKE['parameters'], sot.parameters)
self.assertEqual(FAKE['resources'], sot.resources)
def test_to_dict(self):
fake_sot = copy.deepcopy(FAKE)
fake_sot['parameter_groups'] = [{
"description": "server parameters",
"parameters": ["key_name", "image_id"],
"label": "server_parameters"}]
fake_sot['conditions'] = {"cd1": True}
sot = stack_template.StackTemplate(**fake_sot)
self.assertEqual(fake_sot, sot.to_dict())