summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2017-06-19 15:26:53 +0000
committerGerrit Code Review <review@openstack.org>2017-06-19 15:26:53 +0000
commit77eec6867a064e8764745375940cf085be958c2f (patch)
tree4d11c37aa6b11120eaf914ebaec5cc8e98ff5a07
parentf3e084dc85c0d95fadd078c6297a40136779ee5c (diff)
parent8d086b171099f0a968f1fdd1b39706ec64a52f56 (diff)
Merge "Add storage sample environments"
-rw-r--r--environments/cinder-netapp-config.yaml4
-rw-r--r--environments/puppet-ceph-external.yaml4
-rw-r--r--environments/ssl/tls-endpoints-public-dns.yaml2
-rw-r--r--environments/ssl/tls-endpoints-public-ip.yaml2
-rw-r--r--environments/ssl/tls-everywhere-endpoints-dns.yaml2
-rw-r--r--environments/storage/cinder-netapp-config.yaml119
-rw-r--r--environments/storage/cinder-nfs.yaml27
-rw-r--r--environments/storage/enable-ceph.yaml35
-rw-r--r--environments/storage/external-ceph.yaml78
-rw-r--r--environments/storage/glance-nfs.yaml34
-rw-r--r--sample-env-generator/storage.yaml133
-rwxr-xr-xtripleo_heat_templates/environment_generator.py40
-rw-r--r--tripleo_heat_templates/tests/test_environment_generator.py39
13 files changed, 503 insertions, 16 deletions
diff --git a/environments/cinder-netapp-config.yaml b/environments/cinder-netapp-config.yaml
index dfd1589..83ecbbe 100644
--- a/environments/cinder-netapp-config.yaml
+++ b/environments/cinder-netapp-config.yaml
@@ -1,3 +1,7 @@
1# *************************************************************************************
2# DEPRECATED: Use tripleo-heat-templates/environments/storage/cinder-netapp-config.yaml
3# instead.
4# *************************************************************************************
1# A Heat environment file which can be used to enable a 5# A Heat environment file which can be used to enable a
2# a Cinder NetApp backend, configured via puppet 6# a Cinder NetApp backend, configured via puppet
3resource_registry: 7resource_registry:
diff --git a/environments/puppet-ceph-external.yaml b/environments/puppet-ceph-external.yaml
index 5f8b02a..2f577c2 100644
--- a/environments/puppet-ceph-external.yaml
+++ b/environments/puppet-ceph-external.yaml
@@ -1,3 +1,7 @@
1# ******************************************************************************
2# DEPRECATED: Use tripleo-heat-templates/environments/storage/ceph-external.yaml
3# instead.
4# ******************************************************************************
1# A Heat environment file which can be used to enable the 5# A Heat environment file which can be used to enable the
2# use of an externally managed Ceph cluster. 6# use of an externally managed Ceph cluster.
3resource_registry: 7resource_registry:
diff --git a/environments/ssl/tls-endpoints-public-dns.yaml b/environments/ssl/tls-endpoints-public-dns.yaml
index d1cab98..216afec 100644
--- a/environments/ssl/tls-endpoints-public-dns.yaml
+++ b/environments/ssl/tls-endpoints-public-dns.yaml
@@ -11,7 +11,7 @@
11parameter_defaults: 11parameter_defaults:
12 # Mapping of service endpoint -> protocol. Typically set via parameter_defaults in the resource registry. 12 # Mapping of service endpoint -> protocol. Typically set via parameter_defaults in the resource registry.
13 # Type: json 13 # Type: json
14 EndpointMap: 14 EndpointMap:
15 AodhAdmin: {protocol: 'http', port: '8042', host: 'IP_ADDRESS'} 15 AodhAdmin: {protocol: 'http', port: '8042', host: 'IP_ADDRESS'}
16 AodhInternal: {protocol: 'http', port: '8042', host: 'IP_ADDRESS'} 16 AodhInternal: {protocol: 'http', port: '8042', host: 'IP_ADDRESS'}
17 AodhPublic: {protocol: 'https', port: '13042', host: 'CLOUDNAME'} 17 AodhPublic: {protocol: 'https', port: '13042', host: 'CLOUDNAME'}
diff --git a/environments/ssl/tls-endpoints-public-ip.yaml b/environments/ssl/tls-endpoints-public-ip.yaml
index cb41dc1..d216ab7 100644
--- a/environments/ssl/tls-endpoints-public-ip.yaml
+++ b/environments/ssl/tls-endpoints-public-ip.yaml
@@ -11,7 +11,7 @@
11parameter_defaults: 11parameter_defaults:
12 # Mapping of service endpoint -> protocol. Typically set via parameter_defaults in the resource registry. 12 # Mapping of service endpoint -> protocol. Typically set via parameter_defaults in the resource registry.
13 # Type: json 13 # Type: json
14 EndpointMap: 14 EndpointMap:
15 AodhAdmin: {protocol: 'http', port: '8042', host: 'IP_ADDRESS'} 15 AodhAdmin: {protocol: 'http', port: '8042', host: 'IP_ADDRESS'}
16 AodhInternal: {protocol: 'http', port: '8042', host: 'IP_ADDRESS'} 16 AodhInternal: {protocol: 'http', port: '8042', host: 'IP_ADDRESS'}
17 AodhPublic: {protocol: 'https', port: '13042', host: 'IP_ADDRESS'} 17 AodhPublic: {protocol: 'https', port: '13042', host: 'IP_ADDRESS'}
diff --git a/environments/ssl/tls-everywhere-endpoints-dns.yaml b/environments/ssl/tls-everywhere-endpoints-dns.yaml
index 7ae7f3a..63157dd 100644
--- a/environments/ssl/tls-everywhere-endpoints-dns.yaml
+++ b/environments/ssl/tls-everywhere-endpoints-dns.yaml
@@ -11,7 +11,7 @@
11parameter_defaults: 11parameter_defaults:
12 # Mapping of service endpoint -> protocol. Typically set via parameter_defaults in the resource registry. 12 # Mapping of service endpoint -> protocol. Typically set via parameter_defaults in the resource registry.
13 # Type: json 13 # Type: json
14 EndpointMap: 14 EndpointMap:
15 AodhAdmin: {protocol: 'https', port: '8042', host: 'CLOUDNAME'} 15 AodhAdmin: {protocol: 'https', port: '8042', host: 'CLOUDNAME'}
16 AodhInternal: {protocol: 'https', port: '8042', host: 'CLOUDNAME'} 16 AodhInternal: {protocol: 'https', port: '8042', host: 'CLOUDNAME'}
17 AodhPublic: {protocol: 'https', port: '13042', host: 'CLOUDNAME'} 17 AodhPublic: {protocol: 'https', port: '13042', host: 'CLOUDNAME'}
diff --git a/environments/storage/cinder-netapp-config.yaml b/environments/storage/cinder-netapp-config.yaml
new file mode 100644
index 0000000..4cdba09
--- /dev/null
+++ b/environments/storage/cinder-netapp-config.yaml
@@ -0,0 +1,119 @@
1# *******************************************************************
2# This file was created automatically by the sample environment
3# generator. Developers should use `tox -e genconfig` to update it.
4# Users are recommended to make changes to a copy of the file instead
5# of the original, if any customizations are needed.
6# *******************************************************************
7# title: Enable the Cinder NetApp Backend
8# description: |
9# A Heat environment file which can be used to enable a
10# a Cinder NetApp backend, configured via puppet
11parameter_defaults:
12 #
13 # Type: string
14 CinderNetappBackendName: tripleo_netapp
15
16 #
17 # Type: string
18 CinderNetappControllerIps: ''
19
20 #
21 # Type: string
22 CinderNetappCopyOffloadToolPath: ''
23
24 #
25 # Type: string
26 CinderNetappEseriesHostType: linux_dm_mp
27
28 #
29 # Type: string
30 CinderNetappHostType: ''
31
32 #
33 # Mandatory. This parameter must be set by the user.
34 # Type: string
35 CinderNetappLogin: <None>
36
37 #
38 # Type: string
39 CinderNetappNfsMountOptions: ''
40
41 #
42 # Type: string
43 CinderNetappNfsShares: ''
44
45 #
46 # Type: string
47 CinderNetappNfsSharesConfig: /etc/cinder/shares.conf
48
49 #
50 # Type: string
51 CinderNetappPartnerBackendName: ''
52
53 #
54 # Mandatory. This parameter must be set by the user.
55 # Type: string
56 CinderNetappPassword: <None>
57
58 #
59 # Type: string
60 CinderNetappSaPassword: ''
61
62 #
63 # Mandatory. This parameter must be set by the user.
64 # Type: string
65 CinderNetappServerHostname: <None>
66
67 #
68 # Type: string
69 CinderNetappServerPort: 80
70
71 #
72 # Type: string
73 CinderNetappSizeMultiplier: 1.2
74
75 #
76 # Type: string
77 CinderNetappStorageFamily: ontap_cluster
78
79 #
80 # Type: string
81 CinderNetappStoragePools: ''
82
83 #
84 # Type: string
85 CinderNetappStorageProtocol: nfs
86
87 #
88 # Type: string
89 CinderNetappTransportType: http
90
91 #
92 # Type: string
93 CinderNetappVfiler: ''
94
95 #
96 # Type: string
97 CinderNetappVolumeList: ''
98
99 #
100 # Type: string
101 CinderNetappVserver: ''
102
103 #
104 # Type: string
105 CinderNetappWebservicePath: /devmgr/v2
106
107 # ******************************************************
108 # Static parameters - these are values that must be
109 # included in the environment but should not be changed.
110 # ******************************************************
111 #
112 # Type: boolean
113 CinderEnableNetappBackend: True
114
115 # *********************
116 # End static parameters
117 # *********************
118resource_registry:
119 OS::TripleO::ControllerExtraConfigPre: ../../puppet/extraconfig/pre_deploy/controller/cinder-netapp.yaml
diff --git a/environments/storage/cinder-nfs.yaml b/environments/storage/cinder-nfs.yaml
new file mode 100644
index 0000000..2de3e78
--- /dev/null
+++ b/environments/storage/cinder-nfs.yaml
@@ -0,0 +1,27 @@
1# *******************************************************************
2# This file was created automatically by the sample environment
3# generator. Developers should use `tox -e genconfig` to update it.
4# Users are recommended to make changes to a copy of the file instead
5# of the original, if any customizations are needed.
6# *******************************************************************
7# title: Enable Cinder NFS Backend
8# description: |
9# Configure and include this environment to enable the use of an NFS
10# share as the backend for Cinder.
11parameter_defaults:
12 # Whether to enable or not the Iscsi backend for Cinder
13 # Type: boolean
14 CinderEnableIscsiBackend: False
15
16 # Whether to enable or not the NFS backend for Cinder
17 # Type: boolean
18 CinderEnableNfsBackend: True
19
20 # Mount options for NFS mounts used by Cinder NFS backend. Effective when CinderEnableNfsBackend is true.
21 # Type: string
22 CinderNfsMountOptions: ''
23
24 # NFS servers used by Cinder NFS backend. Effective when CinderEnableNfsBackend is true.
25 # Type: comma_delimited_list
26 CinderNfsServers: 192.168.122.1:/export/cinder
27
diff --git a/environments/storage/enable-ceph.yaml b/environments/storage/enable-ceph.yaml
new file mode 100644
index 0000000..c629f74
--- /dev/null
+++ b/environments/storage/enable-ceph.yaml
@@ -0,0 +1,35 @@
1# *******************************************************************
2# This file was created automatically by the sample environment
3# generator. Developers should use `tox -e genconfig` to update it.
4# Users are recommended to make changes to a copy of the file instead
5# of the original, if any customizations are needed.
6# *******************************************************************
7# title: Enable Ceph Storage Backend
8# description: |
9# Include this environment to enable Ceph as the backend for
10# Cinder, Nova, Gnocchi, and Glance.
11parameter_defaults:
12 # The short name of the Cinder Backup backend to use.
13 # Type: string
14 CinderBackupBackend: rbd
15
16 # Whether to enable or not the Iscsi backend for Cinder
17 # Type: boolean
18 CinderEnableIscsiBackend: False
19
20 # Whether to enable or not the Rbd backend for Cinder
21 # Type: boolean
22 CinderEnableRbdBackend: True
23
24 # The short name of the Glance backend to use. Should be one of swift, rbd, or file
25 # Type: string
26 GlanceBackend: rbd
27
28 # The short name of the Gnocchi backend to use. Should be one of swift, rbd, or file
29 # Type: string
30 GnocchiBackend: rbd
31
32 # Whether to enable or not the Rbd backend for Nova
33 # Type: boolean
34 NovaEnableRbdBackend: True
35
diff --git a/environments/storage/external-ceph.yaml b/environments/storage/external-ceph.yaml
new file mode 100644
index 0000000..f1c9d51
--- /dev/null
+++ b/environments/storage/external-ceph.yaml
@@ -0,0 +1,78 @@
1# *******************************************************************
2# This file was created automatically by the sample environment
3# generator. Developers should use `tox -e genconfig` to update it.
4# Users are recommended to make changes to a copy of the file instead
5# of the original, if any customizations are needed.
6# *******************************************************************
7# title: Deploy Using an External Ceph Cluster
8# description: |
9# A Heat environment file which can be used to enable the
10# use of an externally managed Ceph cluster.
11parameter_defaults:
12 # The Ceph admin client key. Can be created with ceph-authtool --gen-print-key.
13 # Type: string
14 CephAdminKey: ''
15
16 # The Ceph client key. Can be created with ceph-authtool --gen-print-key. Currently only used for external Ceph deployments to create the openstack user keyring.
17 # Mandatory. This parameter must be set by the user.
18 # Type: string
19 CephClientKey: <None>
20
21 #
22 # Type: string
23 CephClientUserName: openstack
24
25 # The Ceph cluster FSID. Must be a UUID.
26 # Mandatory. This parameter must be set by the user.
27 # Type: string
28 CephClusterFSID: <None>
29
30 # List of externally managed Ceph Mon Host IPs. Only used for external Ceph deployments.
31 # Type: string
32 CephExternalMonHost: ''
33
34 # Whether to enable or not the Iscsi backend for Cinder
35 # Type: boolean
36 CinderEnableIscsiBackend: False
37
38 # Whether to enable or not the Rbd backend for Cinder
39 # Type: boolean
40 CinderEnableRbdBackend: True
41
42 #
43 # Type: string
44 CinderRbdPoolName: volumes
45
46 # The short name of the Glance backend to use. Should be one of swift, rbd, or file
47 # Type: string
48 GlanceBackend: rbd
49
50 #
51 # Type: string
52 GlanceRbdPoolName: images
53
54 # The short name of the Gnocchi backend to use. Should be one of swift, rbd, or file
55 # Type: string
56 GnocchiBackend: rbd
57
58 #
59 # Type: string
60 GnocchiRbdPoolName: metrics
61
62 # Whether to enable or not the Rbd backend for Nova
63 # Type: boolean
64 NovaEnableRbdBackend: True
65
66 #
67 # Type: string
68 NovaRbdPoolName: vms
69
70 # The default features enabled when creating a block device image. Only applies to format 2 images. Set to '1' for Jewel clients using older Ceph servers.
71 # Type: string
72 RbdDefaultFeatures: ''
73
74resource_registry:
75 OS::TripleO::Services::CephClient: OS::Heat::None
76 OS::TripleO::Services::CephExternal: ../../puppet/services/ceph-external.yaml
77 OS::TripleO::Services::CephMon: OS::Heat::None
78 OS::TripleO::Services::CephOSD: OS::Heat::None
diff --git a/environments/storage/glance-nfs.yaml b/environments/storage/glance-nfs.yaml
new file mode 100644
index 0000000..3c13930
--- /dev/null
+++ b/environments/storage/glance-nfs.yaml
@@ -0,0 +1,34 @@
1# *******************************************************************
2# This file was created automatically by the sample environment
3# generator. Developers should use `tox -e genconfig` to update it.
4# Users are recommended to make changes to a copy of the file instead
5# of the original, if any customizations are needed.
6# *******************************************************************
7# title: Enable Glance NFS Backend
8# description: |
9# Configure and include this environment to enable the use of an NFS
10# share as the backend for Glance.
11parameter_defaults:
12 # NFS mount options for image storage (when GlanceNfsEnabled is true)
13 # Type: string
14 GlanceNfsOptions: intr,context=system_u:object_r:glance_var_lib_t:s0
15
16 # NFS share to mount for image storage (when GlanceNfsEnabled is true)
17 # Type: string
18 GlanceNfsShare: ''
19
20 # ******************************************************
21 # Static parameters - these are values that must be
22 # included in the environment but should not be changed.
23 # ******************************************************
24 # The short name of the Glance backend to use. Should be one of swift, rbd, or file
25 # Type: string
26 GlanceBackend: file
27
28 # When using GlanceBackend 'file', mount NFS share for image storage.
29 # Type: boolean
30 GlanceNfsEnabled: True
31
32 # *********************
33 # End static parameters
34 # *********************
diff --git a/sample-env-generator/storage.yaml b/sample-env-generator/storage.yaml
new file mode 100644
index 0000000..aa0385c
--- /dev/null
+++ b/sample-env-generator/storage.yaml
@@ -0,0 +1,133 @@
1environments:
2 -
3 name: storage/enable-ceph
4 title: Enable Ceph Storage Backend
5 files:
6 puppet/services/cinder-volume.yaml:
7 parameters:
8 - CinderEnableIscsiBackend
9 - CinderEnableRbdBackend
10 puppet/services/cinder-backup.yaml:
11 parameters:
12 - CinderBackupBackend
13 puppet/services/nova-compute.yaml:
14 parameters:
15 - NovaEnableRbdBackend
16 puppet/services/glance-api.yaml:
17 parameters:
18 - GlanceBackend
19 puppet/services/gnocchi-api.yaml:
20 parameters:
21 - GnocchiBackend
22 sample_values:
23 CinderEnableIscsiBackend: False
24 CinderEnableRbdBackend: True
25 CinderBackupBackend: rbd
26 NovaEnableRbdBackend: True
27 GlanceBackend: rbd
28 GnocchiBackend: rbd
29 description: |
30 Include this environment to enable Ceph as the backend for
31 Cinder, Nova, Gnocchi, and Glance.
32 -
33 name: storage/cinder-nfs
34 title: Enable Cinder NFS Backend
35 files:
36 puppet/services/cinder-volume.yaml:
37 parameters:
38 - CinderNfsMountOptions
39 - CinderNfsServers
40 - CinderEnableNfsBackend
41 - CinderEnableIscsiBackend
42 sample_values:
43 CinderEnableNfsBackend: True
44 CinderEnableIscsiBackend: False
45 CinderNfsServers: '192.168.122.1:/export/cinder'
46 description: |
47 Configure and include this environment to enable the use of an NFS
48 share as the backend for Cinder.
49 -
50 name: storage/glance-nfs
51 title: Enable Glance NFS Backend
52 files:
53 puppet/services/glance-api.yaml:
54 parameters:
55 - GlanceBackend
56 - GlanceNfsEnabled
57 - GlanceNfsShare
58 - GlanceNfsOptions
59 sample_values:
60 GlanceBackend: file
61 GlanceNfsEnabled: True
62 static:
63 - GlanceBackend
64 - GlanceNfsEnabled
65 description: |
66 Configure and include this environment to enable the use of an NFS
67 share as the backend for Glance.
68 -
69 name: storage/external-ceph
70 title: Deploy Using an External Ceph Cluster
71 files:
72 puppet/services/nova-compute.yaml:
73 parameters:
74 - NovaRbdPoolName
75 - NovaEnableRbdBackend
76 - CephClientUserName
77 puppet/services/cinder-volume.yaml:
78 parameters:
79 - CinderRbdPoolName
80 - CinderEnableIscsiBackend
81 - CinderEnableRbdBackend
82 puppet/services/glance-api.yaml:
83 parameters:
84 - GlanceRbdPoolName
85 - GlanceBackend
86 puppet/services/gnocchi-api.yaml:
87 parameters:
88 - GnocchiBackend
89 puppet/services/gnocchi-base.yaml:
90 parameters:
91 - GnocchiRbdPoolName
92 puppet/services/ceph-external.yaml:
93 parameters:
94 - CephClusterFSID
95 - CephClientKey
96 - CephExternalMonHost
97 - RbdDefaultFeatures
98 puppet/services/ceph-base.yaml:
99 parameters:
100 - CephAdminKey
101 sample_values:
102 CinderEnableIscsiBackend: False
103 CinderEnableRbdBackend: True
104 NovaEnableRbdBackend: True
105 GlanceBackend: rbd
106 GnocchiBackend: rbd
107 NovaRbdPoolName: vms
108 CinderRbdPoolName: volumes
109 GlanceRbdPoolName: images
110 GnocchiRbdPoolName: metrics
111 CephClientUserName: openstack
112 CephAdminKey: ''
113 description: |
114 A Heat environment file which can be used to enable the
115 use of an externally managed Ceph cluster.
116 resource_registry:
117 OS::TripleO::Services::CephExternal: ../../puppet/services/ceph-external.yaml
118 OS::TripleO::Services::CephMon: OS::Heat::None
119 OS::TripleO::Services::CephClient: OS::Heat::None
120 OS::TripleO::Services::CephOSD: OS::Heat::None
121 -
122 name: storage/cinder-netapp-config
123 title: Enable the Cinder NetApp Backend
124 description: |
125 A Heat environment file which can be used to enable a
126 a Cinder NetApp backend, configured via puppet
127 files:
128 puppet/services/cinder-backend-netapp.yaml:
129 parameters: all
130 static:
131 - CinderEnableNetappBackend
132 resource_registry:
133 OS::TripleO::ControllerExtraConfigPre: ../../puppet/extraconfig/pre_deploy/controller/cinder-netapp.yaml
diff --git a/tripleo_heat_templates/environment_generator.py b/tripleo_heat_templates/environment_generator.py
index 659a7d5..b3e327f 100755
--- a/tripleo_heat_templates/environment_generator.py
+++ b/tripleo_heat_templates/environment_generator.py
@@ -22,7 +22,7 @@ import yaml
22 22
23_PARAM_FORMAT = u""" # %(description)s 23_PARAM_FORMAT = u""" # %(description)s
24 %(mandatory)s# Type: %(type)s 24 %(mandatory)s# Type: %(type)s
25 %(name)s: %(default)s 25 %(name)s:%(default)s
26""" 26"""
27_STATIC_MESSAGE_START = ( 27_STATIC_MESSAGE_START = (
28 ' # ******************************************************\n' 28 ' # ******************************************************\n'
@@ -44,7 +44,14 @@ _FILE_HEADER = (
44 ) 44 )
45# Certain parameter names can't be changed, but shouldn't be shown because 45# Certain parameter names can't be changed, but shouldn't be shown because
46# they are never intended for direct user input. 46# they are never intended for direct user input.
47_PRIVATE_OVERRIDES = ['server', 'servers', 'NodeIndex'] 47_PRIVATE_OVERRIDES = ['server', 'servers', 'NodeIndex', 'DefaultPasswords']
48# Hidden params are not included by default when the 'all' option is used,
49# but can be explicitly included by referencing them in sample_defaults or
50# static. This allows us to generate sample environments using them when
51# necessary, but they won't be improperly included by accident.
52_HIDDEN_PARAMS = ['EndpointMap', 'RoleName', 'RoleParameters',
53 'ServiceNetMap',
54 ]
48 55
49 56
50def _create_output_dir(target_file): 57def _create_output_dir(target_file):
@@ -64,6 +71,8 @@ def _generate_environment(input_env, parent_env=None):
64 env.update(input_env) 71 env.update(input_env)
65 parameter_defaults = {} 72 parameter_defaults = {}
66 param_names = [] 73 param_names = []
74 sample_values = env.get('sample_values', {})
75 static_names = env.get('static', [])
67 for template_file, template_data in env['files'].items(): 76 for template_file, template_data in env['files'].items():
68 with open(template_file) as f: 77 with open(template_file) as f:
69 f_data = yaml.safe_load(f) 78 f_data = yaml.safe_load(f)
@@ -71,6 +80,10 @@ def _generate_environment(input_env, parent_env=None):
71 parameter_defaults.update(f_params) 80 parameter_defaults.update(f_params)
72 if template_data['parameters'] == 'all': 81 if template_data['parameters'] == 'all':
73 new_names = [k for k, v in f_params.items()] 82 new_names = [k for k, v in f_params.items()]
83 for hidden in _HIDDEN_PARAMS:
84 if (hidden not in (static_names + sample_values.keys()) and
85 hidden in new_names):
86 new_names.remove(hidden)
74 else: 87 else:
75 new_names = template_data['parameters'] 88 new_names = template_data['parameters']
76 missing_params = [name for name in new_names 89 missing_params = [name for name in new_names
@@ -82,7 +95,6 @@ def _generate_environment(input_env, parent_env=None):
82 env['name'])) 95 env['name']))
83 param_names += new_names 96 param_names += new_names
84 97
85 static_names = env.get('static', [])
86 static_defaults = {k: v for k, v in parameter_defaults.items() 98 static_defaults = {k: v for k, v in parameter_defaults.items()
87 if k in param_names and 99 if k in param_names and
88 k in static_names 100 k in static_names
@@ -93,7 +105,8 @@ def _generate_environment(input_env, parent_env=None):
93 not k.startswith('_') and 105 not k.startswith('_') and
94 k not in static_names 106 k not in static_names
95 } 107 }
96 for k, v in env.get('sample_values', {}).items(): 108
109 for k, v in sample_values.items():
97 if k in parameter_defaults: 110 if k in parameter_defaults:
98 parameter_defaults[k]['sample'] = v 111 parameter_defaults[k]['sample'] = v
99 if k in static_defaults: 112 if k in static_defaults:
@@ -108,17 +121,18 @@ def _generate_environment(input_env, parent_env=None):
108 default = '<None>' 121 default = '<None>'
109 if value.get('sample') is not None: 122 if value.get('sample') is not None:
110 default = value['sample'] 123 default = value['sample']
124 # We ultimately cast this to str for output anyway
125 default = str(default)
111 if default == '': 126 if default == '':
112 default = "''" 127 default = "''"
113 try: 128 # If the default value is something like %index%, yaml won't
114 # If the default value is something like %index%, yaml won't 129 # parse the output correctly unless we wrap it in quotes.
115 # parse the output correctly unless we wrap it in quotes. 130 # However, not all default values can be wrapped so we need to
116 # However, not all default values can be wrapped so we need to 131 # do it conditionally.
117 # do it conditionally. 132 if default.startswith('%'):
118 if default.startswith('%'): 133 default = "'%s'" % default
119 default = "'%s'" % default 134 if not default.startswith('\n'):
120 except AttributeError: 135 default = ' ' + default
121 pass
122 136
123 values = {'name': name, 137 values = {'name': name,
124 'type': value['type'], 138 'type': value['type'],
diff --git a/tripleo_heat_templates/tests/test_environment_generator.py b/tripleo_heat_templates/tests/test_environment_generator.py
index d0a622d..f4c4cdb 100644
--- a/tripleo_heat_templates/tests/test_environment_generator.py
+++ b/tripleo_heat_templates/tests/test_environment_generator.py
@@ -34,6 +34,10 @@ parameters:
34 default: 42 34 default: 42
35 description: Bar description 35 description: Bar description
36 type: number 36 type: number
37 EndpointMap:
38 default: {}
39 description: Parameter that should not be included by default
40 type: json
37resources: 41resources:
38 # None 42 # None
39''' 43'''
@@ -307,6 +311,41 @@ resource_registry:
307 OS::TripleO::FakeResource: fake-filename.yaml 311 OS::TripleO::FakeResource: fake-filename.yaml
308''', 312''',
309 }), 313 }),
314 ('basic-hidden',
315 {'template': basic_template,
316 'exception': None,
317 'input_file': '''environments:
318 -
319 name: basic
320 title: Basic Environment
321 description: Basic description
322 files:
323 foo.yaml:
324 parameters: all
325 sample_values:
326 EndpointMap: |-2
327
328 foo: bar
329''',
330 'expected_output': '''# title: Basic Environment
331# description: |
332# Basic description
333parameter_defaults:
334 # Bar description
335 # Type: number
336 BarParam: 42
337
338 # Parameter that should not be included by default
339 # Type: json
340 EndpointMap:
341 foo: bar
342
343 # Foo description
344 # Type: string
345 FooParam: foo
346
347''',
348 }),
310 ('missing-param', 349 ('missing-param',
311 {'template': basic_template, 350 {'template': basic_template,
312 'exception': RuntimeError, 351 'exception': RuntimeError,