blob: 9d6d1e7abf9e1e0ad66f00f4980a0b3a50c81641 [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))
sgudzb67ce732018-02-13 17:58:31 +020045_default_drivetrain_steps = pkg_resources.resource_filename(
46 __name__,
47 'templates/{0}/drivetrain.yaml'.format(
48 settings.LAB_CONFIG_NAME))
Dennis Dmitrievf3f90a52017-08-10 14:37:05 +030049_default_decapod_steps = pkg_resources.resource_filename(
50 __name__,
51 'templates/{0}/decapod.yaml'.format(
52 settings.LAB_CONFIG_NAME))
Dennis Dmitriev6860ba62016-11-01 21:43:46 +020053_default_openstack_steps = pkg_resources.resource_filename(
Dennis Dmitrievab83ea42017-05-12 16:52:45 +030054 __name__, 'templates/{0}/openstack.yaml'.format(
Dennis Dmitriev2a13a132016-11-04 00:56:23 +020055 settings.LAB_CONFIG_NAME))
Dina Belovae6fdffb2017-09-19 13:58:34 -070056_default_opencontrail_prepare_tests_steps_path = \
57 pkg_resources.resource_filename(
58 __name__, 'templates/{0}/opencontrail.yaml'.format(
59 settings.LAB_CONFIG_NAME))
Tatyana Leontovichc8b8ca22017-05-19 13:37:05 +030060_default_sl_prepare_tests_steps_path = pkg_resources.resource_filename(
61 __name__, 'templates/{0}/sl.yaml'.format(
62 settings.LAB_CONFIG_NAME))
Tatyana Leontovich460f7df2017-11-13 15:45:06 +020063_default_ceph_prepare_tests_steps_path = pkg_resources.resource_filename(
64 __name__, 'templates/{0}/ceph.yaml'.format(
65 settings.LAB_CONFIG_NAME))
Artem Panchenko0594cd72017-06-12 13:25:26 +030066_default_k8s_steps = pkg_resources.resource_filename(
67 __name__, 'templates/{0}/k8s.yaml'.format(
68 settings.LAB_CONFIG_NAME))
Dmitry Tyzhnenkob8641832017-11-07 17:02:47 +020069_default_net_mgm = os.environ.get("NET_MGMT", "admin-pool01")
70
Dennis Dmitriev6f59add2016-10-18 13:45:27 +030071
72hardware_opts = [
73 ct.Cfg('manager', ct.String(),
74 help="Hardware manager name", default="devops"),
75 ct.Cfg('conf_path', ct.String(),
76 help="Hardware config file", default=_default_conf),
77 ct.Cfg('current_snapshot', ct.String(),
78 help="Latest environment status name",
79 default=ext.SNAPSHOT.hardware),
80]
81
82
83underlay_opts = [
84 ct.Cfg('ssh', ct.JSONList(),
85 help="""SSH Settings for Underlay: [{
86 'node_name': node1,
Dennis Dmitriev23e5d192016-10-31 11:27:10 +020087 'roles': ['salt-master', 'salt-minion', ],
Dennis Dmitriev6f59add2016-10-18 13:45:27 +030088 'host': hostname,
89 'login': login,
90 'password': password,
91 'address_pool': (optional),
92 'port': (optional),
93 'keys': [(optional)],
94 }, ...]""", default=[]),
95 ct.Cfg('roles', ct.JSONList(),
96 help="Node roles managed by underlay in the environment",
Dennis Dmitriev53d3b772016-10-18 14:31:58 +030097 default=[ext.UNDERLAY_NODE_ROLES.salt_master,
vrovachev99228d32017-06-08 19:46:10 +040098 ext.UNDERLAY_NODE_ROLES.salt_minion,
Victor Ryzhenkin66d39372017-09-28 19:25:48 +040099 ext.UNDERLAY_NODE_ROLES.k8s_controller]),
Dennis Dmitriev7b9538f2017-05-15 17:01:34 +0300100 ct.Cfg('bootstrap_timeout', ct.Integer(),
101 help="Timeout of waiting SSH for nodes with specified roles",
Dennis Dmitriev4558ee92018-01-31 08:14:08 -0400102 default=600),
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300103 ct.Cfg('nameservers', ct.JSONList(),
104 help="IP addresses of DNS servers",
105 default=[]),
106 ct.Cfg('upstream_dns_servers', ct.JSONList(),
107 help="IP addresses of upstream DNS servers (dnsmasq)",
108 default=[]),
109 ct.Cfg('lvm', ct.JSONDict(),
110 help="LVM settings for Underlay", default={}),
Dennis Dmitriev99b26fe2017-04-26 12:34:44 +0300111 ct.Cfg('address_pools', ct.JSONDict(),
112 help="""Address pools (dynamically) allocated for the environment.
113 May be used to determine CIDR for a specific network from
114 tests or during the deployment process.
115 {'pool_name1': '<cidr>', 'pool_name2': '<cidr>', ...}""",
116 default={}),
Artem Panchenkodb0a97f2017-06-27 19:09:13 +0300117 ct.Cfg('ssh_keys', ct.JSONList(), default=[],
118 help="SSH key pair(s) for root. If the option is left empty, "
119 "then a key pair will be generated automatically"),
120 ct.Cfg('ssh_key_file', ct.String(), default=os.path.abspath('./id_rsa'),
121 help='Path (local) to file with private key authorized on nodes'),
Dmitry Tyzhnenkob8641832017-11-07 17:02:47 +0200122 ct.Cfg('net_mgmt', ct.String(), default=_default_net_mgm)
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300123]
124
Dennis Dmitriev6860ba62016-11-01 21:43:46 +0200125
126salt_deploy_opts = [
127 ct.Cfg('salt_steps_path', ct.String(),
128 help="Path to YAML with steps to deploy salt",
129 default=_default_salt_steps),
Dennis Dmitriev9dada8a2017-08-30 17:38:55 +0300130 ct.Cfg('environment_template_dir', ct.String(),
131 help="Path to directory with Environment template and inventory",
132 default=_default_environment_template_dir),
Dmitry Tyzhnenko8f6a63e2017-09-05 15:37:23 +0300133 ct.Cfg('templates_dir', ct.String(),
134 help="Path to directory with templates",
135 default=_default_templates_dir),
Dennis Dmitriev5bcbdc52018-03-23 18:05:10 +0200136 ct.Cfg('salt_roles', ct.JSONList(),
137 help="Node roles to install salt-minions and manage by salt",
138 default=[ext.UNDERLAY_NODE_ROLES.salt_master,
139 ext.UNDERLAY_NODE_ROLES.salt_minion,
140 ext.UNDERLAY_NODE_ROLES.k8s_controller]),
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300141]
Dennis Dmitriev6860ba62016-11-01 21:43:46 +0200142salt_opts = [
143 ct.Cfg('salt_master_host', ct.IPAddress(),
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300144 help="", default='0.0.0.0'),
Dennis Dmitriev2d60c8e2017-05-12 18:34:01 +0300145 ct.Cfg('salt_master_port', ct.String(),
146 help="", default='6969'),
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300147]
148
Dennis Dmitriev6860ba62016-11-01 21:43:46 +0200149common_services_deploy_opts = [
150 ct.Cfg('common_services_steps_path', ct.String(),
151 help="Path to YAML with steps to deploy common services",
152 default=_default_common_services_steps),
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300153]
154
Dennis Dmitriev6860ba62016-11-01 21:43:46 +0200155common_services_opts = [
Dennis Dmitriev2cbf2352016-11-11 15:34:21 +0200156 ct.Cfg('common_services_installed', ct.Boolean(),
Dennis Dmitriev6860ba62016-11-01 21:43:46 +0200157 help="", default=False),
158]
159
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +0300160oss_deploy_opts = [
161 ct.Cfg('oss_steps_path', ct.String(),
162 help="Path to YAML with steps to deploy OSS Tools",
163 default=_default_oss_steps),
164]
165
166oss_opts = [
167 ct.Cfg('oss_installed', ct.Boolean(),
168 help="", default=False),
169]
170
sgudzb67ce732018-02-13 17:58:31 +0200171drivetrain_deploy_opts = [
172 ct.Cfg('drivetrain_steps_path', ct.String(),
173 help="Path to YAML with steps to deploy Drivetrain",
174 default=_default_drivetrain_steps),
175]
176
177drivetrain_opts = [
178 ct.Cfg('drivetrain_installed', ct.Boolean(),
179 help="", default=False),
180]
181
Dennis Dmitrievf3f90a52017-08-10 14:37:05 +0300182decapod_deploy_opts = [
183 ct.Cfg('decapod_steps_path', ct.String(),
184 help="Path to YAML with steps to deploy Ceph with Decapod",
185 default=_default_decapod_steps),
186]
187
188decapod_opts = [
189 ct.Cfg('decapod_installed', ct.Boolean(),
190 help="", default=False),
191]
192
Dennis Dmitriev6860ba62016-11-01 21:43:46 +0200193openstack_deploy_opts = [
194 ct.Cfg('openstack_steps_path', ct.String(),
195 help="Path to YAML with steps to deploy openstack",
196 default=_default_openstack_steps),
Tatyana Leontovichc72604d2018-01-04 17:58:00 +0200197 ct.Cfg('horizon_host', ct.IPAddress(),
198 help="", default='0.0.0.0'),
199 ct.Cfg('horizon_port', ct.String(),
200 help="", default='5000'),
201 ct.Cfg('horizon_user', ct.String(),
202 help="", default='admin'),
203 ct.Cfg('horizon_password', ct.String(),
204 help="", default='workshop'),
Dennis Dmitriev6860ba62016-11-01 21:43:46 +0200205]
206openstack_opts = [
Dennis Dmitriev2cbf2352016-11-11 15:34:21 +0200207 ct.Cfg('openstack_installed', ct.Boolean(),
Dennis Dmitriev6860ba62016-11-01 21:43:46 +0200208 help="", default=False),
Dennis Dmitriev2cbf2352016-11-11 15:34:21 +0200209 ct.Cfg('openstack_keystone_endpoint', ct.String(),
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300210 help="", default=''),
211]
212
Dennis Dmitriev2cbf2352016-11-11 15:34:21 +0200213opencontrail_opts = [
214 ct.Cfg('opencontrail_tags', ct.String(),
215 help="", default=''),
216 ct.Cfg('opencontrail_features', ct.String(),
217 help="", default=''),
218 ct.Cfg('opencontrail_prepare_tests_steps_path', ct.String(),
219 help="Path to YAML with steps to prepare contrail-tests",
220 default=_default_opencontrail_prepare_tests_steps_path),
221]
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300222
Tatyana Leontovichc8b8ca22017-05-19 13:37:05 +0300223sl_deploy_opts = [
224 ct.Cfg('sl_steps_path', ct.String(),
225 help="Path to YAML with steps to deploy sl",
226 default=_default_sl_prepare_tests_steps_path),
Tatyana Leontovichf00b2342017-07-04 18:26:25 +0300227 ct.Cfg('docker_image_alertmanager', ct.String(),
Dennis Dmitriev257a9382018-02-15 04:00:46 +0200228 default='{0}/openstack-docker/alertmanager:{1}'.format(
229 settings.DOCKER_REGISTRY, settings.DOCKER_IMAGES_SL_TAG)),
Tatyana Leontovichf00b2342017-07-04 18:26:25 +0300230 ct.Cfg('docker_image_pushgateway', ct.String(),
Dennis Dmitriev257a9382018-02-15 04:00:46 +0200231 default='{0}/openstack-docker/pushgateway:{1}'.format(
232 settings.DOCKER_REGISTRY, settings.DOCKER_IMAGES_SL_TAG)),
Tatyana Leontovichf00b2342017-07-04 18:26:25 +0300233 ct.Cfg('docker_image_prometheus', ct.String(),
Dennis Dmitriev257a9382018-02-15 04:00:46 +0200234 default='{0}/openstack-docker/prometheus:{1}'.format(
235 settings.DOCKER_REGISTRY, settings.DOCKER_IMAGES_SL_TAG)),
Tatyana Leontovichf00b2342017-07-04 18:26:25 +0300236 ct.Cfg('docker_image_remote_agent', ct.String(),
Dennis Dmitriev257a9382018-02-15 04:00:46 +0200237 default='{0}/openstack-docker/telegraf:{1}'.format(
238 settings.DOCKER_REGISTRY, settings.DOCKER_IMAGES_SL_TAG)),
Tatyana Leontovichf00b2342017-07-04 18:26:25 +0300239 ct.Cfg('docker_image_remote_storage_adapter', ct.String(),
Dennis Dmitriev257a9382018-02-15 04:00:46 +0200240 default='{0}/openstack-docker/remote_storage_adapter:{1}'.format(
241 settings.DOCKER_REGISTRY, settings.DOCKER_IMAGES_SL_TAG)),
242 ct.Cfg('docker_image_prometheus_relay', ct.String(),
243 default='{0}/openstack-docker/prometheus_relay:{1}'.format(
244 settings.DOCKER_REGISTRY, settings.DOCKER_IMAGES_SL_TAG)),
245 ct.Cfg('docker_image_grafana', ct.String(),
246 default='{0}/mirantis/external/grafana:{1}'.format(
247 settings.DOCKER_REGISTRY, settings.DOCKER_IMAGES_SL_TAG)),
Dennis Dmitriev86f63e82017-11-09 00:07:45 +0200248 # SalesForce connection options for pushkin
Dennis Dmitrievce5ed8b2017-11-09 00:44:19 +0200249 ct.Cfg('sfdc_sandbox_enabled', ct.String(), default='False'),
Dennis Dmitriev86f63e82017-11-09 00:07:45 +0200250 ct.Cfg('sfdc_auth_url', ct.String(), default=''),
251 ct.Cfg('sfdc_username', ct.String(), default=''),
252 ct.Cfg('sfdc_password', ct.String(), default=''),
253 ct.Cfg('sfdc_consumer_key', ct.String(), default=''),
254 ct.Cfg('sfdc_consumer_secret', ct.String(), default=''),
255 ct.Cfg('sfdc_organization_id', ct.String(), default=''),
Tatyana Leontovichc8b8ca22017-05-19 13:37:05 +0300256]
Tatyana Leontovichf00b2342017-07-04 18:26:25 +0300257
Tatyana Leontovichc8b8ca22017-05-19 13:37:05 +0300258sl_opts = [
259 ct.Cfg('sl_installed', ct.Boolean(),
260 help="", default=False),
sgudzbf4de572017-11-23 14:37:01 +0200261 ct.Cfg('sl_version', ct.String(),
262 help="StackLight version. Could be 1 or 2", default=''),
Tatyana Leontovich09b7b012017-07-10 12:53:45 +0300263 ct.Cfg('sl_vip_host', ct.IPAddress(),
264 help="Vip address for SL services", default='0.0.0.0'),
265 ct.Cfg('sl_prometheus_port', ct.String(),
266 help="Prometheus port", default='15010'),
267 ct.Cfg('sl_prometheus_proto', ct.String(),
268 help="Proemtheus protocol", default='http'),
Tatyana Leontovichc8b8ca22017-05-19 13:37:05 +0300269]
270
Tatyana Leontovich460f7df2017-11-13 15:45:06 +0200271ceph_deploy_opts = [
272 ct.Cfg('ceph_steps_path', ct.String(),
273 help="Path to YAML with steps to deploy sl",
Tatyana Leontovicha754ce52017-11-13 16:46:43 +0200274 default=_default_ceph_prepare_tests_steps_path),
Tatyana Leontovich460f7df2017-11-13 15:45:06 +0200275]
276
277ceph_opts = [
Tatyana Leontovicha754ce52017-11-13 16:46:43 +0200278 ct.Cfg('ceph_installed', ct.Boolean(),
Tatyana Leontovich460f7df2017-11-13 15:45:06 +0200279 help="", default=False),
Tatyana Leontovich460f7df2017-11-13 15:45:06 +0200280]
281
Artem Panchenkoedf70ef2017-06-13 09:14:34 +0300282k8s_deploy_opts = [
Artem Panchenko0594cd72017-06-12 13:25:26 +0300283 ct.Cfg('k8s_steps_path', ct.String(),
284 help="Path to YAML with steps to deploy Kubernetes",
285 default=_default_k8s_steps),
286 ct.Cfg('kubernetes_admin_user', ct.String(), default='admin'),
287 ct.Cfg('kubernetes_admin_password', ct.String(),
288 default='sbPfel23ZigJF3Bm'),
Artem Panchenkoedf70ef2017-06-13 09:14:34 +0300289 ct.Cfg('kubernetes_docker_package', ct.String(), default=''),
290 ct.Cfg('kubernetes_hyperkube_image', ct.String(),
Tatyana Leontovich7693c122018-03-30 12:14:27 +0300291 default='{}/mirantis/kubernetes/hyperkube-amd64:v1.8.9-7'.format(
Artem Panchenkoedf70ef2017-06-13 09:14:34 +0300292 settings.DOCKER_REGISTRY)),
293 ct.Cfg('kubernetes_calico_image', ct.String(),
294 default='{}/mirantis/projectcalico/calico/node:latest'.format(
295 settings.DOCKER_REGISTRY)),
296 ct.Cfg('kubernetes_calicoctl_image', ct.String(),
297 default='{}/mirantis/projectcalico/calico/ctl:latest'.format(
298 settings.DOCKER_REGISTRY)),
299 ct.Cfg('kubernetes_calico_cni_image', ct.String(),
300 default='{}/mirantis/projectcalico/calico/cni:latest'.format(
301 settings.DOCKER_REGISTRY)),
Artem Panchenko0594cd72017-06-12 13:25:26 +0300302 ct.Cfg('kubernetes_netchecker_enabled', ct.Boolean(),
303 help="", default=True),
Artem Panchenkoedf70ef2017-06-13 09:14:34 +0300304 ct.Cfg('kubernetes_netchecker_agent_image', ct.String(),
Tatyana Leontovicha96264a2018-01-25 14:13:50 +0200305 default='mirantis/k8s-netchecker-agent:latest'),
Artem Panchenkoedf70ef2017-06-13 09:14:34 +0300306 ct.Cfg('kubernetes_netchecker_server_image', ct.String(),
Tatyana Leontovicha96264a2018-01-25 14:13:50 +0200307 default='mirantis/k8s-netchecker-server:latest'),
Artem Panchenko501e67e2017-06-14 14:59:18 +0300308 ct.Cfg('kubernetes_calico_policy_enabled', ct.Boolean(),
309 help="", default=False),
310 ct.Cfg('kubernetes_calico_policy_image', ct.String(),
311 default='calico/kube-policy-controller:v0.5.4'),
312 ct.Cfg('kubernetes_helm_enabled', ct.Boolean(),
Tatyana Leontovich038dc7d2017-09-22 16:25:59 +0300313 help="", default=False),
Victor Ryzhenkin0bf0bb02017-07-06 18:57:05 +0400314 ct.Cfg('kubernetes_virtlet_enabled', ct.Boolean(),
Tatyana Leontovich038dc7d2017-09-22 16:25:59 +0300315 help="", default=False),
Victor Ryzhenkin0bf0bb02017-07-06 18:57:05 +0400316 ct.Cfg('kubernetes_virtlet_image', ct.String(),
Sergii Golovatiukc1b62f42017-10-06 13:24:32 +0200317 help="", default='mirantis/virtlet:v0.8.0'),
Victor Ryzhenkin14354ac2017-09-27 17:42:30 +0400318 ct.Cfg('kubernetes_externaldns_enabled', ct.Boolean(),
319 help="", default=False),
320 ct.Cfg('kubernetes_externaldns_image', ct.String(),
321 help="", default='mirantis/external-dns:latest'),
322 ct.Cfg('kubernetes_externaldns_provider', ct.String(),
323 help="", default='coredns'),
324 ct.Cfg('kubernetes_coredns_enabled', ct.Boolean(),
Victor Ryzhenkin2a5806e2017-12-18 20:23:53 +0400325 help="", default=False),
326 ct.Cfg('kubelet_fail_on_swap', ct.Boolean(),
Victor Ryzhenkin14354ac2017-09-27 17:42:30 +0400327 help="", default=False)
Artem Panchenkoedf70ef2017-06-13 09:14:34 +0300328]
329
330k8s_opts = [
Artem Panchenko0594cd72017-06-12 13:25:26 +0300331 ct.Cfg('k8s_installed', ct.Boolean(),
332 help="", default=False),
Artem Panchenkoedf70ef2017-06-13 09:14:34 +0300333 ct.Cfg('kube_host', ct.IPAddress(),
334 help="", default='0.0.0.0'),
335 ct.Cfg('kube_apiserver_port', ct.Integer(),
336 help="", default=443),
vrovacheva9d08332017-06-22 20:01:59 +0400337 ct.Cfg("k8s_conformance_run", ct.Boolean(),
338 default=False),
Victor Ryzhenkin8ff3c3f2018-01-17 19:37:05 +0400339 ct.Cfg("run_extended_virtlet_conformance", ct.Boolean(),
340 default=False),
vrovacheva9d08332017-06-22 20:01:59 +0400341 ct.Cfg('k8s_conformance_image', ct.String(),
Dennis Dmitriev75776c52017-12-26 18:22:53 +0200342 default='docker-prod-virtual.docker.mirantis.net/mirantis/'
Tatyana Leontovich7693c122018-03-30 12:14:27 +0300343 'kubernetes/k8s-conformance:v1.8.9-7')
Artem Panchenkoedf70ef2017-06-13 09:14:34 +0300344]
345
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300346_group_opts = [
347 ('hardware', hardware_opts),
348 ('underlay', underlay_opts),
Dennis Dmitriev6860ba62016-11-01 21:43:46 +0200349 ('salt_deploy', salt_deploy_opts),
350 ('salt', salt_opts),
351 ('common_services_deploy', common_services_deploy_opts),
352 ('common_services', common_services_opts),
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +0300353 ('oss_deploy', oss_deploy_opts),
354 ('oss', oss_opts),
sgudzb67ce732018-02-13 17:58:31 +0200355 ('drivetrain_deploy', drivetrain_deploy_opts),
356 ('drivetrain', drivetrain_opts),
Dennis Dmitrievf3f90a52017-08-10 14:37:05 +0300357 ('decapod_deploy', decapod_deploy_opts),
358 ('decapod', decapod_opts),
Dennis Dmitriev6860ba62016-11-01 21:43:46 +0200359 ('openstack_deploy', openstack_deploy_opts),
360 ('openstack', openstack_opts),
Dennis Dmitriev2cbf2352016-11-11 15:34:21 +0200361 ('opencontrail', opencontrail_opts),
Tatyana Leontovichc8b8ca22017-05-19 13:37:05 +0300362 ('stack_light', sl_opts),
363 ('sl_deploy', sl_deploy_opts),
Tatyana Leontovicha754ce52017-11-13 16:46:43 +0200364 ('ceph', ceph_opts),
365 ('ceph_deploy', ceph_deploy_opts),
Artem Panchenkoedf70ef2017-06-13 09:14:34 +0300366 ('k8s_deploy', k8s_deploy_opts),
367 ('k8s', k8s_opts),
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300368]
369
370
371def register_opts(config):
372 config.register_group(cfg.OptGroup(name='hardware',
373 title="Hardware settings", help=""))
374 config.register_opts(group='hardware', opts=hardware_opts)
375
376 config.register_group(cfg.OptGroup(name='underlay',
377 title="Underlay configuration", help=""))
378 config.register_opts(group='underlay', opts=underlay_opts)
379
Dennis Dmitriev6860ba62016-11-01 21:43:46 +0200380 config.register_group(cfg.OptGroup(name='salt_deploy',
381 title="salt deploy configuration", help=""))
382 config.register_opts(group='salt_deploy', opts=salt_deploy_opts)
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300383
Dennis Dmitriev6860ba62016-11-01 21:43:46 +0200384 config.register_group(cfg.OptGroup(name='salt',
385 title="salt config and credentials", help=""))
386 config.register_opts(group='salt', opts=salt_opts)
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300387
Dennis Dmitriev6860ba62016-11-01 21:43:46 +0200388 config.register_group(cfg.OptGroup(name='common_services',
389 title="Common services for Openstack", help=""))
390 config.register_opts(group='common_services', opts=common_services_opts)
391
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300392 config.register_group(
Dennis Dmitriev6860ba62016-11-01 21:43:46 +0200393 cfg.OptGroup(name='common_services_deploy',
394 title="Common services for Openstack deploy config",
395 help=""))
396 config.register_opts(group='common_services_deploy',
397 opts=common_services_deploy_opts)
398
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +0300399 config.register_group(cfg.OptGroup(name='oss',
400 title="Operational Support System Tools", help=""))
401 config.register_opts(group='oss', opts=oss_opts)
402
403 config.register_group(cfg.OptGroup(name='oss_deploy',
404 title="OSS deploy config", help=""))
405 config.register_opts(group='oss_deploy',
406 opts=oss_deploy_opts)
407
sgudzb67ce732018-02-13 17:58:31 +0200408 config.register_group(cfg.OptGroup(name='drivetrain',
409 title="Drivetrain Tools", help=""))
410 config.register_opts(group='drivetrain', opts=drivetrain_opts)
411
412 config.register_group(cfg.OptGroup(name='drivetrain_deploy',
413 title="Drivetrain deploy config", help=""))
414 config.register_opts(group='drivetrain_deploy',
415 opts=drivetrain_deploy_opts)
416
Dennis Dmitrievf3f90a52017-08-10 14:37:05 +0300417 config.register_group(cfg.OptGroup(name='decapod',
418 title="Decapod options for Ceph", help=""))
419 config.register_opts(group='decapod', opts=decapod_opts)
420
421 config.register_group(cfg.OptGroup(name='decapod_deploy',
422 title="Decapod deploy config", help=""))
423 config.register_opts(group='decapod_deploy',
424 opts=decapod_deploy_opts)
425
Dennis Dmitriev6860ba62016-11-01 21:43:46 +0200426 config.register_group(cfg.OptGroup(name='openstack',
427 title="Openstack config and credentials", help=""))
428 config.register_opts(group='openstack', opts=openstack_opts)
429
430 config.register_group(
431 cfg.OptGroup(name='openstack_deploy',
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300432 title="Openstack deploy config and credentials",
433 help=""))
Dennis Dmitriev6860ba62016-11-01 21:43:46 +0200434 config.register_opts(group='openstack_deploy', opts=openstack_deploy_opts)
Dennis Dmitriev2cbf2352016-11-11 15:34:21 +0200435
436 config.register_group(cfg.OptGroup(name='opencontrail',
437 title="Options for Juniper contrail-tests", help=""))
438 config.register_opts(group='opencontrail', opts=opencontrail_opts)
Dmitry Tyzhnenko8f6a63e2017-09-05 15:37:23 +0300439 config.register_group(
440 cfg.OptGroup(name='stack_light',
441 title="StackLight config and credentials", help=""))
Tatyana Leontovich5acc82a2017-05-23 15:41:35 +0300442 config.register_opts(group='stack_light', opts=sl_opts)
Tatyana Leontovichc8b8ca22017-05-19 13:37:05 +0300443 config.register_group(
444 cfg.OptGroup(name='sl_deploy',
Dennis Dmitrievf3f90a52017-08-10 14:37:05 +0300445 title="SL deploy config and credentials",
446 help=""))
Tatyana Leontovichc8b8ca22017-05-19 13:37:05 +0300447 config.register_opts(group='sl_deploy', opts=sl_deploy_opts)
Artem Panchenkoedf70ef2017-06-13 09:14:34 +0300448
449 config.register_group(cfg.OptGroup(name='k8s_deploy',
450 title="K8s deploy configuration"))
451 config.register_opts(group='k8s_deploy', opts=k8s_deploy_opts)
452
453 config.register_group(cfg.OptGroup(name='k8s',
454 title="K8s config and credentials"))
455 config.register_opts(group='k8s', opts=k8s_opts)
Tatyana Leontovicha754ce52017-11-13 16:46:43 +0200456 config.register_group(cfg.OptGroup(name='ceph',
457 title="ceph config", help=""))
458 config.register_opts(group='ceph', opts=ceph_opts)
459
460 config.register_group(
461 cfg.OptGroup(name='ceph_deploy',
462 title="Ceph deploy config ",
463 help=""))
464 config.register_opts(group='ceph_deploy', opts=ceph_deploy_opts)
465
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300466 return config
467
468
469def load_config(config_files):
470 config = cfg.CONF
471 register_opts(config)
472 config(args=[], default_config_files=config_files)
473 return config
474
475
476def reload_snapshot_config(config, test_config_path):
477 """Reset config to the state from test_config file"""
478 config(args=[], default_config_files=[test_config_path])
479 return config
480
481
482def list_opts():
483 """Return a list of oslo.config options available in the tcp_tests.
484 """
485 return [(group, copy.deepcopy(opts)) for group, opts in _group_opts]
486
487
488def list_current_opts(config):
489 """Return a list of oslo.config options available in the tcp_tests.
490 """
491 result_opts = []
492 for group, opts in _group_opts:
493 current_opts = copy.deepcopy(opts)
494 for opt in current_opts:
495 if hasattr(config, group):
496 if hasattr(config[group], opt.name):
497 opt.default = getattr(config[group], opt.name)
498 result_opts.append((group, current_opts))
499 return result_opts
500
501
502def save_config(config, snapshot_name, env_name=None):
503 if env_name is None:
504 env_name = 'config'
505 test_config_path = os.path.join(
506 settings.LOGS_DIR, '{0}_{1}.ini'.format(env_name, snapshot_name))
507
508 with open(test_config_path, 'w') as output_file:
509 formatter = generator._OptFormatter(output_file=output_file)
510 for group, opts in list_current_opts(config):
511 formatter.format_group(group)
512 for opt in opts:
513 formatter.format(opt, group, minimal=True)
514 formatter.write('\n')
515 formatter.write('\n')