blob: ad4cce320e876da57d6acba80030dc668685dbbf [file] [log] [blame]
Dennis Dmitriev6f59add2016-10-18 13:45:27 +03001# Copyright 2016 Mirantis, Inc.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14import copy
15import os
16import pkg_resources
17
18from oslo_config import cfg
19from oslo_config import generator
20
21from tcp_tests.helpers import ext
22from tcp_tests.helpers import oslo_cfg_types as ct
23from tcp_tests import settings
24
Dennis Dmitriev9b02c8b2017-11-13 15:31:35 +020025print("\n" + "-" * 10 + " Initialize oslo.config variables with defaults"
26 " from environment" + "-" * 10)
Dennis Dmitriev6f59add2016-10-18 13:45:27 +030027
28_default_conf = pkg_resources.resource_filename(
Dennis Dmitrievab83ea42017-05-12 16:52:45 +030029 __name__, 'templates/{0}/underlay.yaml'.format(settings.LAB_CONFIG_NAME))
Dennis Dmitriev6860ba62016-11-01 21:43:46 +020030
31_default_salt_steps = pkg_resources.resource_filename(
Dennis Dmitrievab83ea42017-05-12 16:52:45 +030032 __name__, 'templates/{0}/salt.yaml'.format(settings.LAB_CONFIG_NAME))
Dennis Dmitriev9dada8a2017-08-30 17:38:55 +030033_default_environment_template_dir = pkg_resources.resource_filename(
34 __name__, 'environment/')
Dmitry Tyzhnenko8f6a63e2017-09-05 15:37:23 +030035_default_templates_dir = pkg_resources.resource_filename(
36 __name__, 'templates/')
Dennis Dmitriev6860ba62016-11-01 21:43:46 +020037_default_common_services_steps = pkg_resources.resource_filename(
38 __name__,
Dennis Dmitrievab83ea42017-05-12 16:52:45 +030039 'templates/{0}/common-services.yaml'.format(
Dennis Dmitriev2a13a132016-11-04 00:56:23 +020040 settings.LAB_CONFIG_NAME))
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +030041_default_oss_steps = pkg_resources.resource_filename(
42 __name__,
43 'templates/{0}/oss.yaml'.format(
44 settings.LAB_CONFIG_NAME))
Dennis Dmitrievf3f90a52017-08-10 14:37:05 +030045_default_decapod_steps = pkg_resources.resource_filename(
46 __name__,
47 'templates/{0}/decapod.yaml'.format(
48 settings.LAB_CONFIG_NAME))
Dennis Dmitriev6860ba62016-11-01 21:43:46 +020049_default_openstack_steps = pkg_resources.resource_filename(
Dennis Dmitrievab83ea42017-05-12 16:52:45 +030050 __name__, 'templates/{0}/openstack.yaml'.format(
Dennis Dmitriev2a13a132016-11-04 00:56:23 +020051 settings.LAB_CONFIG_NAME))
Dina Belovae6fdffb2017-09-19 13:58:34 -070052_default_opencontrail_prepare_tests_steps_path = \
53 pkg_resources.resource_filename(
54 __name__, 'templates/{0}/opencontrail.yaml'.format(
55 settings.LAB_CONFIG_NAME))
Tatyana Leontovichc8b8ca22017-05-19 13:37:05 +030056_default_sl_prepare_tests_steps_path = pkg_resources.resource_filename(
57 __name__, 'templates/{0}/sl.yaml'.format(
58 settings.LAB_CONFIG_NAME))
Tatyana Leontovich460f7df2017-11-13 15:45:06 +020059_default_ceph_prepare_tests_steps_path = pkg_resources.resource_filename(
60 __name__, 'templates/{0}/ceph.yaml'.format(
61 settings.LAB_CONFIG_NAME))
Artem Panchenko0594cd72017-06-12 13:25:26 +030062_default_k8s_steps = pkg_resources.resource_filename(
63 __name__, 'templates/{0}/k8s.yaml'.format(
64 settings.LAB_CONFIG_NAME))
Dmitry Tyzhnenkob8641832017-11-07 17:02:47 +020065_default_net_mgm = os.environ.get("NET_MGMT", "admin-pool01")
66
Dennis Dmitriev6f59add2016-10-18 13:45:27 +030067
68hardware_opts = [
69 ct.Cfg('manager', ct.String(),
70 help="Hardware manager name", default="devops"),
71 ct.Cfg('conf_path', ct.String(),
72 help="Hardware config file", default=_default_conf),
73 ct.Cfg('current_snapshot', ct.String(),
74 help="Latest environment status name",
75 default=ext.SNAPSHOT.hardware),
76]
77
78
79underlay_opts = [
80 ct.Cfg('ssh', ct.JSONList(),
81 help="""SSH Settings for Underlay: [{
82 'node_name': node1,
Dennis Dmitriev23e5d192016-10-31 11:27:10 +020083 'roles': ['salt-master', 'salt-minion', ],
Dennis Dmitriev6f59add2016-10-18 13:45:27 +030084 'host': hostname,
85 'login': login,
86 'password': password,
87 'address_pool': (optional),
88 'port': (optional),
89 'keys': [(optional)],
90 }, ...]""", default=[]),
91 ct.Cfg('roles', ct.JSONList(),
92 help="Node roles managed by underlay in the environment",
Dennis Dmitriev53d3b772016-10-18 14:31:58 +030093 default=[ext.UNDERLAY_NODE_ROLES.salt_master,
vrovachev99228d32017-06-08 19:46:10 +040094 ext.UNDERLAY_NODE_ROLES.salt_minion,
Victor Ryzhenkin66d39372017-09-28 19:25:48 +040095 ext.UNDERLAY_NODE_ROLES.k8s_controller]),
Dennis Dmitriev7b9538f2017-05-15 17:01:34 +030096 ct.Cfg('bootstrap_timeout', ct.Integer(),
97 help="Timeout of waiting SSH for nodes with specified roles",
Dennis Dmitriev4558ee92018-01-31 08:14:08 -040098 default=600),
Dennis Dmitriev6f59add2016-10-18 13:45:27 +030099 ct.Cfg('nameservers', ct.JSONList(),
100 help="IP addresses of DNS servers",
101 default=[]),
102 ct.Cfg('upstream_dns_servers', ct.JSONList(),
103 help="IP addresses of upstream DNS servers (dnsmasq)",
104 default=[]),
105 ct.Cfg('lvm', ct.JSONDict(),
106 help="LVM settings for Underlay", default={}),
Dennis Dmitriev99b26fe2017-04-26 12:34:44 +0300107 ct.Cfg('address_pools', ct.JSONDict(),
108 help="""Address pools (dynamically) allocated for the environment.
109 May be used to determine CIDR for a specific network from
110 tests or during the deployment process.
111 {'pool_name1': '<cidr>', 'pool_name2': '<cidr>', ...}""",
112 default={}),
Artem Panchenkodb0a97f2017-06-27 19:09:13 +0300113 ct.Cfg('ssh_keys', ct.JSONList(), default=[],
114 help="SSH key pair(s) for root. If the option is left empty, "
115 "then a key pair will be generated automatically"),
116 ct.Cfg('ssh_key_file', ct.String(), default=os.path.abspath('./id_rsa'),
117 help='Path (local) to file with private key authorized on nodes'),
Dmitry Tyzhnenkob8641832017-11-07 17:02:47 +0200118 ct.Cfg('net_mgmt', ct.String(), default=_default_net_mgm)
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300119]
120
Dennis Dmitriev6860ba62016-11-01 21:43:46 +0200121
122salt_deploy_opts = [
123 ct.Cfg('salt_steps_path', ct.String(),
124 help="Path to YAML with steps to deploy salt",
125 default=_default_salt_steps),
Dennis Dmitriev9dada8a2017-08-30 17:38:55 +0300126 ct.Cfg('environment_template_dir', ct.String(),
127 help="Path to directory with Environment template and inventory",
128 default=_default_environment_template_dir),
Dmitry Tyzhnenko8f6a63e2017-09-05 15:37:23 +0300129 ct.Cfg('templates_dir', ct.String(),
130 help="Path to directory with templates",
131 default=_default_templates_dir),
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300132]
Dennis Dmitriev6860ba62016-11-01 21:43:46 +0200133salt_opts = [
134 ct.Cfg('salt_master_host', ct.IPAddress(),
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300135 help="", default='0.0.0.0'),
Dennis Dmitriev2d60c8e2017-05-12 18:34:01 +0300136 ct.Cfg('salt_master_port', ct.String(),
137 help="", default='6969'),
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300138]
139
Dennis Dmitriev6860ba62016-11-01 21:43:46 +0200140common_services_deploy_opts = [
141 ct.Cfg('common_services_steps_path', ct.String(),
142 help="Path to YAML with steps to deploy common services",
143 default=_default_common_services_steps),
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300144]
145
Dennis Dmitriev6860ba62016-11-01 21:43:46 +0200146common_services_opts = [
Dennis Dmitriev2cbf2352016-11-11 15:34:21 +0200147 ct.Cfg('common_services_installed', ct.Boolean(),
Dennis Dmitriev6860ba62016-11-01 21:43:46 +0200148 help="", default=False),
149]
150
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +0300151oss_deploy_opts = [
152 ct.Cfg('oss_steps_path', ct.String(),
153 help="Path to YAML with steps to deploy OSS Tools",
154 default=_default_oss_steps),
155]
156
157oss_opts = [
158 ct.Cfg('oss_installed', ct.Boolean(),
159 help="", default=False),
160]
161
Dennis Dmitrievf3f90a52017-08-10 14:37:05 +0300162decapod_deploy_opts = [
163 ct.Cfg('decapod_steps_path', ct.String(),
164 help="Path to YAML with steps to deploy Ceph with Decapod",
165 default=_default_decapod_steps),
166]
167
168decapod_opts = [
169 ct.Cfg('decapod_installed', ct.Boolean(),
170 help="", default=False),
171]
172
Dennis Dmitriev6860ba62016-11-01 21:43:46 +0200173openstack_deploy_opts = [
174 ct.Cfg('openstack_steps_path', ct.String(),
175 help="Path to YAML with steps to deploy openstack",
176 default=_default_openstack_steps),
Tatyana Leontovichc72604d2018-01-04 17:58:00 +0200177 ct.Cfg('horizon_host', ct.IPAddress(),
178 help="", default='0.0.0.0'),
179 ct.Cfg('horizon_port', ct.String(),
180 help="", default='5000'),
181 ct.Cfg('horizon_user', ct.String(),
182 help="", default='admin'),
183 ct.Cfg('horizon_password', ct.String(),
184 help="", default='workshop'),
Dennis Dmitriev6860ba62016-11-01 21:43:46 +0200185]
186openstack_opts = [
Dennis Dmitriev2cbf2352016-11-11 15:34:21 +0200187 ct.Cfg('openstack_installed', ct.Boolean(),
Dennis Dmitriev6860ba62016-11-01 21:43:46 +0200188 help="", default=False),
Dennis Dmitriev2cbf2352016-11-11 15:34:21 +0200189 ct.Cfg('openstack_keystone_endpoint', ct.String(),
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300190 help="", default=''),
191]
192
Dennis Dmitriev2cbf2352016-11-11 15:34:21 +0200193opencontrail_opts = [
194 ct.Cfg('opencontrail_tags', ct.String(),
195 help="", default=''),
196 ct.Cfg('opencontrail_features', ct.String(),
197 help="", default=''),
198 ct.Cfg('opencontrail_prepare_tests_steps_path', ct.String(),
199 help="Path to YAML with steps to prepare contrail-tests",
200 default=_default_opencontrail_prepare_tests_steps_path),
201]
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300202
Tatyana Leontovichc8b8ca22017-05-19 13:37:05 +0300203sl_deploy_opts = [
204 ct.Cfg('sl_steps_path', ct.String(),
205 help="Path to YAML with steps to deploy sl",
206 default=_default_sl_prepare_tests_steps_path),
Tatyana Leontovichf00b2342017-07-04 18:26:25 +0300207 ct.Cfg('docker_image_alertmanager', ct.String(),
Dennis Dmitriev257a9382018-02-15 04:00:46 +0200208 default='{0}/openstack-docker/alertmanager:{1}'.format(
209 settings.DOCKER_REGISTRY, settings.DOCKER_IMAGES_SL_TAG)),
Tatyana Leontovichf00b2342017-07-04 18:26:25 +0300210 ct.Cfg('docker_image_pushgateway', ct.String(),
Dennis Dmitriev257a9382018-02-15 04:00:46 +0200211 default='{0}/openstack-docker/pushgateway:{1}'.format(
212 settings.DOCKER_REGISTRY, settings.DOCKER_IMAGES_SL_TAG)),
Tatyana Leontovichf00b2342017-07-04 18:26:25 +0300213 ct.Cfg('docker_image_prometheus', ct.String(),
Dennis Dmitriev257a9382018-02-15 04:00:46 +0200214 default='{0}/openstack-docker/prometheus:{1}'.format(
215 settings.DOCKER_REGISTRY, settings.DOCKER_IMAGES_SL_TAG)),
Tatyana Leontovichf00b2342017-07-04 18:26:25 +0300216 ct.Cfg('docker_image_remote_agent', ct.String(),
Dennis Dmitriev257a9382018-02-15 04:00:46 +0200217 default='{0}/openstack-docker/telegraf:{1}'.format(
218 settings.DOCKER_REGISTRY, settings.DOCKER_IMAGES_SL_TAG)),
Tatyana Leontovichf00b2342017-07-04 18:26:25 +0300219 ct.Cfg('docker_image_remote_storage_adapter', ct.String(),
Dennis Dmitriev257a9382018-02-15 04:00:46 +0200220 default='{0}/openstack-docker/remote_storage_adapter:{1}'.format(
221 settings.DOCKER_REGISTRY, settings.DOCKER_IMAGES_SL_TAG)),
222 ct.Cfg('docker_image_prometheus_relay', ct.String(),
223 default='{0}/openstack-docker/prometheus_relay:{1}'.format(
224 settings.DOCKER_REGISTRY, settings.DOCKER_IMAGES_SL_TAG)),
225 ct.Cfg('docker_image_grafana', ct.String(),
226 default='{0}/mirantis/external/grafana:{1}'.format(
227 settings.DOCKER_REGISTRY, settings.DOCKER_IMAGES_SL_TAG)),
Dennis Dmitriev86f63e82017-11-09 00:07:45 +0200228 # SalesForce connection options for pushkin
Dennis Dmitrievce5ed8b2017-11-09 00:44:19 +0200229 ct.Cfg('sfdc_sandbox_enabled', ct.String(), default='False'),
Dennis Dmitriev86f63e82017-11-09 00:07:45 +0200230 ct.Cfg('sfdc_auth_url', ct.String(), default=''),
231 ct.Cfg('sfdc_username', ct.String(), default=''),
232 ct.Cfg('sfdc_password', ct.String(), default=''),
233 ct.Cfg('sfdc_consumer_key', ct.String(), default=''),
234 ct.Cfg('sfdc_consumer_secret', ct.String(), default=''),
235 ct.Cfg('sfdc_organization_id', ct.String(), default=''),
Tatyana Leontovichc8b8ca22017-05-19 13:37:05 +0300236]
Tatyana Leontovichf00b2342017-07-04 18:26:25 +0300237
Tatyana Leontovichc8b8ca22017-05-19 13:37:05 +0300238sl_opts = [
239 ct.Cfg('sl_installed', ct.Boolean(),
240 help="", default=False),
sgudzbf4de572017-11-23 14:37:01 +0200241 ct.Cfg('sl_version', ct.String(),
242 help="StackLight version. Could be 1 or 2", default=''),
Tatyana Leontovich09b7b012017-07-10 12:53:45 +0300243 ct.Cfg('sl_vip_host', ct.IPAddress(),
244 help="Vip address for SL services", default='0.0.0.0'),
245 ct.Cfg('sl_prometheus_port', ct.String(),
246 help="Prometheus port", default='15010'),
247 ct.Cfg('sl_prometheus_proto', ct.String(),
248 help="Proemtheus protocol", default='http'),
Tatyana Leontovichc8b8ca22017-05-19 13:37:05 +0300249]
250
Tatyana Leontovich460f7df2017-11-13 15:45:06 +0200251ceph_deploy_opts = [
252 ct.Cfg('ceph_steps_path', ct.String(),
253 help="Path to YAML with steps to deploy sl",
Tatyana Leontovicha754ce52017-11-13 16:46:43 +0200254 default=_default_ceph_prepare_tests_steps_path),
Tatyana Leontovich460f7df2017-11-13 15:45:06 +0200255]
256
257ceph_opts = [
Tatyana Leontovicha754ce52017-11-13 16:46:43 +0200258 ct.Cfg('ceph_installed', ct.Boolean(),
Tatyana Leontovich460f7df2017-11-13 15:45:06 +0200259 help="", default=False),
Tatyana Leontovich460f7df2017-11-13 15:45:06 +0200260]
261
Artem Panchenkoedf70ef2017-06-13 09:14:34 +0300262k8s_deploy_opts = [
Artem Panchenko0594cd72017-06-12 13:25:26 +0300263 ct.Cfg('k8s_steps_path', ct.String(),
264 help="Path to YAML with steps to deploy Kubernetes",
265 default=_default_k8s_steps),
266 ct.Cfg('kubernetes_admin_user', ct.String(), default='admin'),
267 ct.Cfg('kubernetes_admin_password', ct.String(),
268 default='sbPfel23ZigJF3Bm'),
Artem Panchenkoedf70ef2017-06-13 09:14:34 +0300269 ct.Cfg('kubernetes_docker_package', ct.String(), default=''),
270 ct.Cfg('kubernetes_hyperkube_image', ct.String(),
Tatyanka Leontovich5e37fec2018-03-08 05:36:00 -0500271 default='{}/mirantis/kubernetes/hyperkube-amd64:v1.8.6-5'.format(
Artem Panchenkoedf70ef2017-06-13 09:14:34 +0300272 settings.DOCKER_REGISTRY)),
273 ct.Cfg('kubernetes_calico_image', ct.String(),
274 default='{}/mirantis/projectcalico/calico/node:latest'.format(
275 settings.DOCKER_REGISTRY)),
276 ct.Cfg('kubernetes_calicoctl_image', ct.String(),
277 default='{}/mirantis/projectcalico/calico/ctl:latest'.format(
278 settings.DOCKER_REGISTRY)),
279 ct.Cfg('kubernetes_calico_cni_image', ct.String(),
280 default='{}/mirantis/projectcalico/calico/cni:latest'.format(
281 settings.DOCKER_REGISTRY)),
Artem Panchenko0594cd72017-06-12 13:25:26 +0300282 ct.Cfg('kubernetes_netchecker_enabled', ct.Boolean(),
283 help="", default=True),
Artem Panchenkoedf70ef2017-06-13 09:14:34 +0300284 ct.Cfg('kubernetes_netchecker_agent_image', ct.String(),
Tatyana Leontovicha96264a2018-01-25 14:13:50 +0200285 default='mirantis/k8s-netchecker-agent:latest'),
Artem Panchenkoedf70ef2017-06-13 09:14:34 +0300286 ct.Cfg('kubernetes_netchecker_server_image', ct.String(),
Tatyana Leontovicha96264a2018-01-25 14:13:50 +0200287 default='mirantis/k8s-netchecker-server:latest'),
Artem Panchenko501e67e2017-06-14 14:59:18 +0300288 ct.Cfg('kubernetes_calico_policy_enabled', ct.Boolean(),
289 help="", default=False),
290 ct.Cfg('kubernetes_calico_policy_image', ct.String(),
291 default='calico/kube-policy-controller:v0.5.4'),
292 ct.Cfg('kubernetes_helm_enabled', ct.Boolean(),
Tatyana Leontovich038dc7d2017-09-22 16:25:59 +0300293 help="", default=False),
Victor Ryzhenkin0bf0bb02017-07-06 18:57:05 +0400294 ct.Cfg('kubernetes_virtlet_enabled', ct.Boolean(),
Tatyana Leontovich038dc7d2017-09-22 16:25:59 +0300295 help="", default=False),
Victor Ryzhenkin0bf0bb02017-07-06 18:57:05 +0400296 ct.Cfg('kubernetes_virtlet_image', ct.String(),
Sergii Golovatiukc1b62f42017-10-06 13:24:32 +0200297 help="", default='mirantis/virtlet:v0.8.0'),
Victor Ryzhenkin14354ac2017-09-27 17:42:30 +0400298 ct.Cfg('kubernetes_externaldns_enabled', ct.Boolean(),
299 help="", default=False),
300 ct.Cfg('kubernetes_externaldns_image', ct.String(),
301 help="", default='mirantis/external-dns:latest'),
302 ct.Cfg('kubernetes_externaldns_provider', ct.String(),
303 help="", default='coredns'),
304 ct.Cfg('kubernetes_coredns_enabled', ct.Boolean(),
Victor Ryzhenkin2a5806e2017-12-18 20:23:53 +0400305 help="", default=False),
306 ct.Cfg('kubelet_fail_on_swap', ct.Boolean(),
Victor Ryzhenkin14354ac2017-09-27 17:42:30 +0400307 help="", default=False)
Artem Panchenkoedf70ef2017-06-13 09:14:34 +0300308]
309
310k8s_opts = [
Artem Panchenko0594cd72017-06-12 13:25:26 +0300311 ct.Cfg('k8s_installed', ct.Boolean(),
312 help="", default=False),
Artem Panchenkoedf70ef2017-06-13 09:14:34 +0300313 ct.Cfg('kube_host', ct.IPAddress(),
314 help="", default='0.0.0.0'),
315 ct.Cfg('kube_apiserver_port', ct.Integer(),
316 help="", default=443),
vrovacheva9d08332017-06-22 20:01:59 +0400317 ct.Cfg("k8s_conformance_run", ct.Boolean(),
318 default=False),
Victor Ryzhenkin8ff3c3f2018-01-17 19:37:05 +0400319 ct.Cfg("run_extended_virtlet_conformance", ct.Boolean(),
320 default=False),
vrovacheva9d08332017-06-22 20:01:59 +0400321 ct.Cfg('k8s_conformance_image', ct.String(),
Dennis Dmitriev75776c52017-12-26 18:22:53 +0200322 default='docker-prod-virtual.docker.mirantis.net/mirantis/'
Tatyanka Leontovich5e37fec2018-03-08 05:36:00 -0500323 'kubernetes/k8s-conformance:v1.8.6-5')
Artem Panchenkoedf70ef2017-06-13 09:14:34 +0300324]
325
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300326_group_opts = [
327 ('hardware', hardware_opts),
328 ('underlay', underlay_opts),
Dennis Dmitriev6860ba62016-11-01 21:43:46 +0200329 ('salt_deploy', salt_deploy_opts),
330 ('salt', salt_opts),
331 ('common_services_deploy', common_services_deploy_opts),
332 ('common_services', common_services_opts),
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +0300333 ('oss_deploy', oss_deploy_opts),
334 ('oss', oss_opts),
Dennis Dmitrievf3f90a52017-08-10 14:37:05 +0300335 ('decapod_deploy', decapod_deploy_opts),
336 ('decapod', decapod_opts),
Dennis Dmitriev6860ba62016-11-01 21:43:46 +0200337 ('openstack_deploy', openstack_deploy_opts),
338 ('openstack', openstack_opts),
Dennis Dmitriev2cbf2352016-11-11 15:34:21 +0200339 ('opencontrail', opencontrail_opts),
Tatyana Leontovichc8b8ca22017-05-19 13:37:05 +0300340 ('stack_light', sl_opts),
341 ('sl_deploy', sl_deploy_opts),
Tatyana Leontovicha754ce52017-11-13 16:46:43 +0200342 ('ceph', ceph_opts),
343 ('ceph_deploy', ceph_deploy_opts),
Artem Panchenkoedf70ef2017-06-13 09:14:34 +0300344 ('k8s_deploy', k8s_deploy_opts),
345 ('k8s', k8s_opts),
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300346]
347
348
349def register_opts(config):
350 config.register_group(cfg.OptGroup(name='hardware',
351 title="Hardware settings", help=""))
352 config.register_opts(group='hardware', opts=hardware_opts)
353
354 config.register_group(cfg.OptGroup(name='underlay',
355 title="Underlay configuration", help=""))
356 config.register_opts(group='underlay', opts=underlay_opts)
357
Dennis Dmitriev6860ba62016-11-01 21:43:46 +0200358 config.register_group(cfg.OptGroup(name='salt_deploy',
359 title="salt deploy configuration", help=""))
360 config.register_opts(group='salt_deploy', opts=salt_deploy_opts)
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300361
Dennis Dmitriev6860ba62016-11-01 21:43:46 +0200362 config.register_group(cfg.OptGroup(name='salt',
363 title="salt config and credentials", help=""))
364 config.register_opts(group='salt', opts=salt_opts)
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300365
Dennis Dmitriev6860ba62016-11-01 21:43:46 +0200366 config.register_group(cfg.OptGroup(name='common_services',
367 title="Common services for Openstack", help=""))
368 config.register_opts(group='common_services', opts=common_services_opts)
369
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300370 config.register_group(
Dennis Dmitriev6860ba62016-11-01 21:43:46 +0200371 cfg.OptGroup(name='common_services_deploy',
372 title="Common services for Openstack deploy config",
373 help=""))
374 config.register_opts(group='common_services_deploy',
375 opts=common_services_deploy_opts)
376
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +0300377 config.register_group(cfg.OptGroup(name='oss',
378 title="Operational Support System Tools", help=""))
379 config.register_opts(group='oss', opts=oss_opts)
380
381 config.register_group(cfg.OptGroup(name='oss_deploy',
382 title="OSS deploy config", help=""))
383 config.register_opts(group='oss_deploy',
384 opts=oss_deploy_opts)
385
Dennis Dmitrievf3f90a52017-08-10 14:37:05 +0300386 config.register_group(cfg.OptGroup(name='decapod',
387 title="Decapod options for Ceph", help=""))
388 config.register_opts(group='decapod', opts=decapod_opts)
389
390 config.register_group(cfg.OptGroup(name='decapod_deploy',
391 title="Decapod deploy config", help=""))
392 config.register_opts(group='decapod_deploy',
393 opts=decapod_deploy_opts)
394
Dennis Dmitriev6860ba62016-11-01 21:43:46 +0200395 config.register_group(cfg.OptGroup(name='openstack',
396 title="Openstack config and credentials", help=""))
397 config.register_opts(group='openstack', opts=openstack_opts)
398
399 config.register_group(
400 cfg.OptGroup(name='openstack_deploy',
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300401 title="Openstack deploy config and credentials",
402 help=""))
Dennis Dmitriev6860ba62016-11-01 21:43:46 +0200403 config.register_opts(group='openstack_deploy', opts=openstack_deploy_opts)
Dennis Dmitriev2cbf2352016-11-11 15:34:21 +0200404
405 config.register_group(cfg.OptGroup(name='opencontrail',
406 title="Options for Juniper contrail-tests", help=""))
407 config.register_opts(group='opencontrail', opts=opencontrail_opts)
Dmitry Tyzhnenko8f6a63e2017-09-05 15:37:23 +0300408 config.register_group(
409 cfg.OptGroup(name='stack_light',
410 title="StackLight config and credentials", help=""))
Tatyana Leontovich5acc82a2017-05-23 15:41:35 +0300411 config.register_opts(group='stack_light', opts=sl_opts)
Tatyana Leontovichc8b8ca22017-05-19 13:37:05 +0300412 config.register_group(
413 cfg.OptGroup(name='sl_deploy',
Dennis Dmitrievf3f90a52017-08-10 14:37:05 +0300414 title="SL deploy config and credentials",
415 help=""))
Tatyana Leontovichc8b8ca22017-05-19 13:37:05 +0300416 config.register_opts(group='sl_deploy', opts=sl_deploy_opts)
Artem Panchenkoedf70ef2017-06-13 09:14:34 +0300417
418 config.register_group(cfg.OptGroup(name='k8s_deploy',
419 title="K8s deploy configuration"))
420 config.register_opts(group='k8s_deploy', opts=k8s_deploy_opts)
421
422 config.register_group(cfg.OptGroup(name='k8s',
423 title="K8s config and credentials"))
424 config.register_opts(group='k8s', opts=k8s_opts)
Tatyana Leontovicha754ce52017-11-13 16:46:43 +0200425 config.register_group(cfg.OptGroup(name='ceph',
426 title="ceph config", help=""))
427 config.register_opts(group='ceph', opts=ceph_opts)
428
429 config.register_group(
430 cfg.OptGroup(name='ceph_deploy',
431 title="Ceph deploy config ",
432 help=""))
433 config.register_opts(group='ceph_deploy', opts=ceph_deploy_opts)
434
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300435 return config
436
437
438def load_config(config_files):
439 config = cfg.CONF
440 register_opts(config)
441 config(args=[], default_config_files=config_files)
442 return config
443
444
445def reload_snapshot_config(config, test_config_path):
446 """Reset config to the state from test_config file"""
447 config(args=[], default_config_files=[test_config_path])
448 return config
449
450
451def list_opts():
452 """Return a list of oslo.config options available in the tcp_tests.
453 """
454 return [(group, copy.deepcopy(opts)) for group, opts in _group_opts]
455
456
457def list_current_opts(config):
458 """Return a list of oslo.config options available in the tcp_tests.
459 """
460 result_opts = []
461 for group, opts in _group_opts:
462 current_opts = copy.deepcopy(opts)
463 for opt in current_opts:
464 if hasattr(config, group):
465 if hasattr(config[group], opt.name):
466 opt.default = getattr(config[group], opt.name)
467 result_opts.append((group, current_opts))
468 return result_opts
469
470
471def save_config(config, snapshot_name, env_name=None):
472 if env_name is None:
473 env_name = 'config'
474 test_config_path = os.path.join(
475 settings.LOGS_DIR, '{0}_{1}.ini'.format(env_name, snapshot_name))
476
477 with open(test_config_path, 'w') as output_file:
478 formatter = generator._OptFormatter(output_file=output_file)
479 for group, opts in list_current_opts(config):
480 formatter.format_group(group)
481 for opt in opts:
482 formatter.format(opt, group, minimal=True)
483 formatter.write('\n')
484 formatter.write('\n')