blob: 86ef7b882ca5a4b27f5cfcab7bb1ae4868d7ac97 [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 Dmitriev2cbf2352016-11-11 15:34:21 +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/')
Dennis Dmitriev6860ba62016-11-01 21:43:46 +020035_default_common_services_steps = pkg_resources.resource_filename(
36 __name__,
Dennis Dmitrievab83ea42017-05-12 16:52:45 +030037 'templates/{0}/common-services.yaml'.format(
Dennis Dmitriev2a13a132016-11-04 00:56:23 +020038 settings.LAB_CONFIG_NAME))
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +030039_default_oss_steps = pkg_resources.resource_filename(
40 __name__,
41 'templates/{0}/oss.yaml'.format(
42 settings.LAB_CONFIG_NAME))
Dennis Dmitrievf3f90a52017-08-10 14:37:05 +030043_default_decapod_steps = pkg_resources.resource_filename(
44 __name__,
45 'templates/{0}/decapod.yaml'.format(
46 settings.LAB_CONFIG_NAME))
Dennis Dmitriev6860ba62016-11-01 21:43:46 +020047_default_openstack_steps = pkg_resources.resource_filename(
Dennis Dmitrievab83ea42017-05-12 16:52:45 +030048 __name__, 'templates/{0}/openstack.yaml'.format(
Dennis Dmitriev2a13a132016-11-04 00:56:23 +020049 settings.LAB_CONFIG_NAME))
Dennis Dmitriev2cbf2352016-11-11 15:34:21 +020050_default_opencontrail_prepare_tests_steps_path = pkg_resources.resource_filename(
Dennis Dmitrievab83ea42017-05-12 16:52:45 +030051 __name__, 'templates/{0}/opencontrail.yaml'.format(
Dennis Dmitriev2cbf2352016-11-11 15:34:21 +020052 settings.LAB_CONFIG_NAME))
Tatyana Leontovichc8b8ca22017-05-19 13:37:05 +030053_default_sl_prepare_tests_steps_path = pkg_resources.resource_filename(
54 __name__, 'templates/{0}/sl.yaml'.format(
55 settings.LAB_CONFIG_NAME))
vrovachevbc2f5ce2017-05-22 19:37:24 +040056_default_virtlet_prepare_tests_steps_path = pkg_resources.resource_filename(
57 __name__, 'templates/{0}/virtlet.yaml'.format(
58 settings.LAB_CONFIG_NAME))
Victor Ryzhenkin655587f2017-05-24 20:00:07 +040059_default_virtlet_ceph_prepare_tests_steps_path = pkg_resources.resource_filename(
60 __name__, 'templates/{0}/virtlet_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))
Dennis Dmitriev6f59add2016-10-18 13:45:27 +030065
66hardware_opts = [
67 ct.Cfg('manager', ct.String(),
68 help="Hardware manager name", default="devops"),
69 ct.Cfg('conf_path', ct.String(),
70 help="Hardware config file", default=_default_conf),
71 ct.Cfg('current_snapshot', ct.String(),
72 help="Latest environment status name",
73 default=ext.SNAPSHOT.hardware),
74]
75
76
77underlay_opts = [
78 ct.Cfg('ssh', ct.JSONList(),
79 help="""SSH Settings for Underlay: [{
80 'node_name': node1,
Dennis Dmitriev23e5d192016-10-31 11:27:10 +020081 'roles': ['salt-master', 'salt-minion', ],
Dennis Dmitriev6f59add2016-10-18 13:45:27 +030082 'host': hostname,
83 'login': login,
84 'password': password,
85 'address_pool': (optional),
86 'port': (optional),
87 'keys': [(optional)],
88 }, ...]""", default=[]),
89 ct.Cfg('roles', ct.JSONList(),
90 help="Node roles managed by underlay in the environment",
Dennis Dmitriev53d3b772016-10-18 14:31:58 +030091 default=[ext.UNDERLAY_NODE_ROLES.salt_master,
vrovachev99228d32017-06-08 19:46:10 +040092 ext.UNDERLAY_NODE_ROLES.salt_minion,
93 ext.UNDERLAY_NODE_ROLES.k8s_virtlet, ]),
Dennis Dmitriev7b9538f2017-05-15 17:01:34 +030094 ct.Cfg('bootstrap_timeout', ct.Integer(),
95 help="Timeout of waiting SSH for nodes with specified roles",
96 default=480),
Dennis Dmitriev6f59add2016-10-18 13:45:27 +030097 ct.Cfg('nameservers', ct.JSONList(),
98 help="IP addresses of DNS servers",
99 default=[]),
100 ct.Cfg('upstream_dns_servers', ct.JSONList(),
101 help="IP addresses of upstream DNS servers (dnsmasq)",
102 default=[]),
103 ct.Cfg('lvm', ct.JSONDict(),
104 help="LVM settings for Underlay", default={}),
Dennis Dmitriev99b26fe2017-04-26 12:34:44 +0300105 ct.Cfg('address_pools', ct.JSONDict(),
106 help="""Address pools (dynamically) allocated for the environment.
107 May be used to determine CIDR for a specific network from
108 tests or during the deployment process.
109 {'pool_name1': '<cidr>', 'pool_name2': '<cidr>', ...}""",
110 default={}),
Artem Panchenkodb0a97f2017-06-27 19:09:13 +0300111 ct.Cfg('ssh_keys', ct.JSONList(), default=[],
112 help="SSH key pair(s) for root. If the option is left empty, "
113 "then a key pair will be generated automatically"),
114 ct.Cfg('ssh_key_file', ct.String(), default=os.path.abspath('./id_rsa'),
115 help='Path (local) to file with private key authorized on nodes'),
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300116]
117
Dennis Dmitriev6860ba62016-11-01 21:43:46 +0200118
119salt_deploy_opts = [
120 ct.Cfg('salt_steps_path', ct.String(),
121 help="Path to YAML with steps to deploy salt",
122 default=_default_salt_steps),
Dennis Dmitriev9dada8a2017-08-30 17:38:55 +0300123 ct.Cfg('environment_template_dir', ct.String(),
124 help="Path to directory with Environment template and inventory",
125 default=_default_environment_template_dir),
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300126]
Dennis Dmitriev6860ba62016-11-01 21:43:46 +0200127salt_opts = [
128 ct.Cfg('salt_master_host', ct.IPAddress(),
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300129 help="", default='0.0.0.0'),
Dennis Dmitriev2d60c8e2017-05-12 18:34:01 +0300130 ct.Cfg('salt_master_port', ct.String(),
131 help="", default='6969'),
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300132]
133
Dennis Dmitriev6860ba62016-11-01 21:43:46 +0200134common_services_deploy_opts = [
135 ct.Cfg('common_services_steps_path', ct.String(),
136 help="Path to YAML with steps to deploy common services",
137 default=_default_common_services_steps),
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300138]
139
Dennis Dmitriev6860ba62016-11-01 21:43:46 +0200140common_services_opts = [
Dennis Dmitriev2cbf2352016-11-11 15:34:21 +0200141 ct.Cfg('common_services_installed', ct.Boolean(),
Dennis Dmitriev6860ba62016-11-01 21:43:46 +0200142 help="", default=False),
143]
144
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +0300145oss_deploy_opts = [
146 ct.Cfg('oss_steps_path', ct.String(),
147 help="Path to YAML with steps to deploy OSS Tools",
148 default=_default_oss_steps),
149]
150
151oss_opts = [
152 ct.Cfg('oss_installed', ct.Boolean(),
153 help="", default=False),
154]
155
Dennis Dmitrievf3f90a52017-08-10 14:37:05 +0300156decapod_deploy_opts = [
157 ct.Cfg('decapod_steps_path', ct.String(),
158 help="Path to YAML with steps to deploy Ceph with Decapod",
159 default=_default_decapod_steps),
160]
161
162decapod_opts = [
163 ct.Cfg('decapod_installed', ct.Boolean(),
164 help="", default=False),
165]
166
Dennis Dmitriev6860ba62016-11-01 21:43:46 +0200167openstack_deploy_opts = [
168 ct.Cfg('openstack_steps_path', ct.String(),
169 help="Path to YAML with steps to deploy openstack",
170 default=_default_openstack_steps),
171]
172openstack_opts = [
Dennis Dmitriev2cbf2352016-11-11 15:34:21 +0200173 ct.Cfg('openstack_installed', ct.Boolean(),
Dennis Dmitriev6860ba62016-11-01 21:43:46 +0200174 help="", default=False),
Dennis Dmitriev2cbf2352016-11-11 15:34:21 +0200175 ct.Cfg('openstack_keystone_endpoint', ct.String(),
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300176 help="", default=''),
177]
178
Dennis Dmitriev2cbf2352016-11-11 15:34:21 +0200179opencontrail_opts = [
180 ct.Cfg('opencontrail_tags', ct.String(),
181 help="", default=''),
182 ct.Cfg('opencontrail_features', ct.String(),
183 help="", default=''),
184 ct.Cfg('opencontrail_prepare_tests_steps_path', ct.String(),
185 help="Path to YAML with steps to prepare contrail-tests",
186 default=_default_opencontrail_prepare_tests_steps_path),
187]
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300188
Tatyana Leontovichc8b8ca22017-05-19 13:37:05 +0300189sl_deploy_opts = [
190 ct.Cfg('sl_steps_path', ct.String(),
191 help="Path to YAML with steps to deploy sl",
192 default=_default_sl_prepare_tests_steps_path),
Tatyana Leontovichf00b2342017-07-04 18:26:25 +0300193 ct.Cfg('docker_image_alertmanager', ct.String(),
194 default='{}/openstack-docker/alertmanager:latest'.format(
195 settings.DOCKER_REGISTRY)),
196 ct.Cfg('docker_image_pushgateway', ct.String(),
197 default='{}/openstack-docker/pushgateway:latest'.format(
198 settings.DOCKER_REGISTRY)),
199 ct.Cfg('docker_image_prometheus', ct.String(),
200 default='{}/openstack-docker/prometheus:latest'.format(
201 settings.DOCKER_REGISTRY)),
202 ct.Cfg('docker_image_remote_agent', ct.String(),
203 default='{}/openstack-docker/telegraf:latest'.format(
204 settings.DOCKER_REGISTRY)),
205 ct.Cfg('docker_image_remote_storage_adapter', ct.String(),
206 default='{}/openstack-docker/remote_storage_adapter:latest'.format(
207 settings.DOCKER_REGISTRY)),
Tatyana Leontovichc8b8ca22017-05-19 13:37:05 +0300208]
Tatyana Leontovichf00b2342017-07-04 18:26:25 +0300209
Tatyana Leontovichc8b8ca22017-05-19 13:37:05 +0300210sl_opts = [
211 ct.Cfg('sl_installed', ct.Boolean(),
212 help="", default=False),
Tatyana Leontovich09b7b012017-07-10 12:53:45 +0300213 ct.Cfg('sl_vip_host', ct.IPAddress(),
214 help="Vip address for SL services", default='0.0.0.0'),
215 ct.Cfg('sl_prometheus_port', ct.String(),
216 help="Prometheus port", default='15010'),
217 ct.Cfg('sl_prometheus_proto', ct.String(),
218 help="Proemtheus protocol", default='http'),
Tatyana Leontovichc8b8ca22017-05-19 13:37:05 +0300219]
220
vrovachevbc2f5ce2017-05-22 19:37:24 +0400221virtlet_deploy_opts = [
222 ct.Cfg('virtlet_steps_path', ct.String(),
223 help="Path to YAML with steps to deploy virtlet",
Victor Ryzhenkin655587f2017-05-24 20:00:07 +0400224 default=_default_virtlet_prepare_tests_steps_path),
225 ct.Cfg('virtlet_ceph_steps_path', ct.String(),
226 help="Path to YAML with steps to deploy one-node ceph cluster for "
227 "Virtlet Flexvolumes testing",
228 default=_default_virtlet_ceph_prepare_tests_steps_path)
vrovachevbc2f5ce2017-05-22 19:37:24 +0400229]
230
231virtlet_opts = [
232 ct.Cfg('virtlet_installed', ct.Boolean(),
233 help="", default=False),
Victor Ryzhenkin655587f2017-05-24 20:00:07 +0400234 ct.Cfg('ceph_installed', ct.Boolean(),
235 help="Determine, installed one-node ceph cluster or not",
236 default=False)
vrovachevbc2f5ce2017-05-22 19:37:24 +0400237]
Tatyana Leontovichc8b8ca22017-05-19 13:37:05 +0300238
Artem Panchenkoedf70ef2017-06-13 09:14:34 +0300239k8s_deploy_opts = [
Artem Panchenko0594cd72017-06-12 13:25:26 +0300240 ct.Cfg('k8s_steps_path', ct.String(),
241 help="Path to YAML with steps to deploy Kubernetes",
242 default=_default_k8s_steps),
243 ct.Cfg('kubernetes_admin_user', ct.String(), default='admin'),
244 ct.Cfg('kubernetes_admin_password', ct.String(),
245 default='sbPfel23ZigJF3Bm'),
Artem Panchenkoedf70ef2017-06-13 09:14:34 +0300246 ct.Cfg('kubernetes_docker_package', ct.String(), default=''),
247 ct.Cfg('kubernetes_hyperkube_image', ct.String(),
Tatyana Leontovichc6ef9a02017-08-28 18:03:46 +0300248 default='{}/mirantis/kubernetes/hyperkube-amd64:v1.7.3-1'.format(
Artem Panchenkoedf70ef2017-06-13 09:14:34 +0300249 settings.DOCKER_REGISTRY)),
250 ct.Cfg('kubernetes_calico_image', ct.String(),
251 default='{}/mirantis/projectcalico/calico/node:latest'.format(
252 settings.DOCKER_REGISTRY)),
253 ct.Cfg('kubernetes_calicoctl_image', ct.String(),
254 default='{}/mirantis/projectcalico/calico/ctl:latest'.format(
255 settings.DOCKER_REGISTRY)),
256 ct.Cfg('kubernetes_calico_cni_image', ct.String(),
257 default='{}/mirantis/projectcalico/calico/cni:latest'.format(
258 settings.DOCKER_REGISTRY)),
Artem Panchenko0594cd72017-06-12 13:25:26 +0300259 ct.Cfg('kubernetes_netchecker_enabled', ct.Boolean(),
260 help="", default=True),
Artem Panchenkoedf70ef2017-06-13 09:14:34 +0300261 ct.Cfg('kubernetes_netchecker_agent_image', ct.String(),
Tatyana Leontovichf00b2342017-07-04 18:26:25 +0300262 default='mirantis/k8s-netchecker-agent:stable'),
Artem Panchenkoedf70ef2017-06-13 09:14:34 +0300263 ct.Cfg('kubernetes_netchecker_server_image', ct.String(),
Tatyana Leontovichf00b2342017-07-04 18:26:25 +0300264 default='mirantis/k8s-netchecker-server:stable'),
Artem Panchenko501e67e2017-06-14 14:59:18 +0300265 ct.Cfg('kubernetes_calico_policy_enabled', ct.Boolean(),
266 help="", default=False),
267 ct.Cfg('kubernetes_calico_policy_image', ct.String(),
268 default='calico/kube-policy-controller:v0.5.4'),
269 ct.Cfg('kubernetes_helm_enabled', ct.Boolean(),
270 help="", default=True),
Victor Ryzhenkin0bf0bb02017-07-06 18:57:05 +0400271 ct.Cfg('kubernetes_virtlet_enabled', ct.Boolean(),
Sergii Golovatiuk44a43522017-07-20 12:55:13 +0200272 help="", default=True),
Victor Ryzhenkin0bf0bb02017-07-06 18:57:05 +0400273 ct.Cfg('kubernetes_virtlet_image', ct.String(),
Sergii Golovatiuk657cdcc2017-08-11 17:31:21 +0200274 help="", default='mirantis/virtlet:v0.7.0')
Artem Panchenkoedf70ef2017-06-13 09:14:34 +0300275]
276
277k8s_opts = [
Artem Panchenko0594cd72017-06-12 13:25:26 +0300278 ct.Cfg('k8s_installed', ct.Boolean(),
279 help="", default=False),
Artem Panchenkoedf70ef2017-06-13 09:14:34 +0300280 ct.Cfg('kube_host', ct.IPAddress(),
281 help="", default='0.0.0.0'),
282 ct.Cfg('kube_apiserver_port', ct.Integer(),
283 help="", default=443),
vrovacheva9d08332017-06-22 20:01:59 +0400284 ct.Cfg("k8s_conformance_run", ct.Boolean(),
285 default=False),
286 ct.Cfg('k8s_conformance_image', ct.String(),
287 default='docker-dev-virtual.docker.mirantis.net/mirantis/'
Tatyana Leontovichc6ef9a02017-08-28 18:03:46 +0300288 'kubernetes/k8s-conformance:v1.7.3-1_1503652362277')
Artem Panchenkoedf70ef2017-06-13 09:14:34 +0300289]
290
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300291_group_opts = [
292 ('hardware', hardware_opts),
293 ('underlay', underlay_opts),
Dennis Dmitriev6860ba62016-11-01 21:43:46 +0200294 ('salt_deploy', salt_deploy_opts),
295 ('salt', salt_opts),
296 ('common_services_deploy', common_services_deploy_opts),
297 ('common_services', common_services_opts),
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +0300298 ('oss_deploy', oss_deploy_opts),
299 ('oss', oss_opts),
Dennis Dmitrievf3f90a52017-08-10 14:37:05 +0300300 ('decapod_deploy', decapod_deploy_opts),
301 ('decapod', decapod_opts),
Dennis Dmitriev6860ba62016-11-01 21:43:46 +0200302 ('openstack_deploy', openstack_deploy_opts),
303 ('openstack', openstack_opts),
Dennis Dmitriev2cbf2352016-11-11 15:34:21 +0200304 ('opencontrail', opencontrail_opts),
Tatyana Leontovichc8b8ca22017-05-19 13:37:05 +0300305 ('stack_light', sl_opts),
306 ('sl_deploy', sl_deploy_opts),
vrovachevbc2f5ce2017-05-22 19:37:24 +0400307 ('virtlet_deploy', virtlet_deploy_opts),
308 ('virtlet', virtlet_opts),
Artem Panchenkoedf70ef2017-06-13 09:14:34 +0300309 ('k8s_deploy', k8s_deploy_opts),
310 ('k8s', k8s_opts),
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300311]
312
313
314def register_opts(config):
315 config.register_group(cfg.OptGroup(name='hardware',
316 title="Hardware settings", help=""))
317 config.register_opts(group='hardware', opts=hardware_opts)
318
319 config.register_group(cfg.OptGroup(name='underlay',
320 title="Underlay configuration", help=""))
321 config.register_opts(group='underlay', opts=underlay_opts)
322
Dennis Dmitriev6860ba62016-11-01 21:43:46 +0200323 config.register_group(cfg.OptGroup(name='salt_deploy',
324 title="salt deploy configuration", help=""))
325 config.register_opts(group='salt_deploy', opts=salt_deploy_opts)
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300326
Dennis Dmitriev6860ba62016-11-01 21:43:46 +0200327 config.register_group(cfg.OptGroup(name='salt',
328 title="salt config and credentials", help=""))
329 config.register_opts(group='salt', opts=salt_opts)
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300330
Dennis Dmitriev6860ba62016-11-01 21:43:46 +0200331 config.register_group(cfg.OptGroup(name='common_services',
332 title="Common services for Openstack", help=""))
333 config.register_opts(group='common_services', opts=common_services_opts)
334
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300335 config.register_group(
Dennis Dmitriev6860ba62016-11-01 21:43:46 +0200336 cfg.OptGroup(name='common_services_deploy',
337 title="Common services for Openstack deploy config",
338 help=""))
339 config.register_opts(group='common_services_deploy',
340 opts=common_services_deploy_opts)
341
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +0300342 config.register_group(cfg.OptGroup(name='oss',
343 title="Operational Support System Tools", help=""))
344 config.register_opts(group='oss', opts=oss_opts)
345
346 config.register_group(cfg.OptGroup(name='oss_deploy',
347 title="OSS deploy config", help=""))
348 config.register_opts(group='oss_deploy',
349 opts=oss_deploy_opts)
350
Dennis Dmitrievf3f90a52017-08-10 14:37:05 +0300351 config.register_group(cfg.OptGroup(name='decapod',
352 title="Decapod options for Ceph", help=""))
353 config.register_opts(group='decapod', opts=decapod_opts)
354
355 config.register_group(cfg.OptGroup(name='decapod_deploy',
356 title="Decapod deploy config", help=""))
357 config.register_opts(group='decapod_deploy',
358 opts=decapod_deploy_opts)
359
Dennis Dmitriev6860ba62016-11-01 21:43:46 +0200360 config.register_group(cfg.OptGroup(name='openstack',
361 title="Openstack config and credentials", help=""))
362 config.register_opts(group='openstack', opts=openstack_opts)
363
364 config.register_group(
365 cfg.OptGroup(name='openstack_deploy',
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300366 title="Openstack deploy config and credentials",
367 help=""))
Dennis Dmitriev6860ba62016-11-01 21:43:46 +0200368 config.register_opts(group='openstack_deploy', opts=openstack_deploy_opts)
Dennis Dmitriev2cbf2352016-11-11 15:34:21 +0200369
370 config.register_group(cfg.OptGroup(name='opencontrail',
371 title="Options for Juniper contrail-tests", help=""))
372 config.register_opts(group='opencontrail', opts=opencontrail_opts)
Tatyana Leontovichc8b8ca22017-05-19 13:37:05 +0300373 config.register_group(cfg.OptGroup(name='stack_light',
374 title="StackLight config and credentials", help=""))
Tatyana Leontovich5acc82a2017-05-23 15:41:35 +0300375 config.register_opts(group='stack_light', opts=sl_opts)
Tatyana Leontovichc8b8ca22017-05-19 13:37:05 +0300376 config.register_group(
377 cfg.OptGroup(name='sl_deploy',
Dennis Dmitrievf3f90a52017-08-10 14:37:05 +0300378 title="SL deploy config and credentials",
379 help=""))
Tatyana Leontovichc8b8ca22017-05-19 13:37:05 +0300380 config.register_opts(group='sl_deploy', opts=sl_deploy_opts)
vrovachevbc2f5ce2017-05-22 19:37:24 +0400381 config.register_group(cfg.OptGroup(name='virtlet_deploy',
382 title='Virtlet deploy config', help=""))
383 config.register_opts(group='virtlet_deploy', opts=virtlet_deploy_opts)
384 config.register_group(cfg.OptGroup(name='virtlet',
385 title='Virtlet config', help=""))
386 config.register_opts(group='virtlet', opts=virtlet_opts)
Artem Panchenkoedf70ef2017-06-13 09:14:34 +0300387
388 config.register_group(cfg.OptGroup(name='k8s_deploy',
389 title="K8s deploy configuration"))
390 config.register_opts(group='k8s_deploy', opts=k8s_deploy_opts)
391
392 config.register_group(cfg.OptGroup(name='k8s',
393 title="K8s config and credentials"))
394 config.register_opts(group='k8s', opts=k8s_opts)
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300395 return config
396
397
398def load_config(config_files):
399 config = cfg.CONF
400 register_opts(config)
401 config(args=[], default_config_files=config_files)
402 return config
403
404
405def reload_snapshot_config(config, test_config_path):
406 """Reset config to the state from test_config file"""
407 config(args=[], default_config_files=[test_config_path])
408 return config
409
410
411def list_opts():
412 """Return a list of oslo.config options available in the tcp_tests.
413 """
414 return [(group, copy.deepcopy(opts)) for group, opts in _group_opts]
415
416
417def list_current_opts(config):
418 """Return a list of oslo.config options available in the tcp_tests.
419 """
420 result_opts = []
421 for group, opts in _group_opts:
422 current_opts = copy.deepcopy(opts)
423 for opt in current_opts:
424 if hasattr(config, group):
425 if hasattr(config[group], opt.name):
426 opt.default = getattr(config[group], opt.name)
427 result_opts.append((group, current_opts))
428 return result_opts
429
430
431def save_config(config, snapshot_name, env_name=None):
432 if env_name is None:
433 env_name = 'config'
434 test_config_path = os.path.join(
435 settings.LOGS_DIR, '{0}_{1}.ini'.format(env_name, snapshot_name))
436
437 with open(test_config_path, 'w') as output_file:
438 formatter = generator._OptFormatter(output_file=output_file)
439 for group, opts in list_current_opts(config):
440 formatter.format_group(group)
441 for opt in opts:
442 formatter.format(opt, group, minimal=True)
443 formatter.write('\n')
444 formatter.write('\n')