blob: ecc5b8deda7d84173cede37dfb3bb45b58c56d76 [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 Dmitriev6860ba62016-11-01 21:43:46 +020033_default_common_services_steps = pkg_resources.resource_filename(
34 __name__,
Dennis Dmitrievab83ea42017-05-12 16:52:45 +030035 'templates/{0}/common-services.yaml'.format(
Dennis Dmitriev2a13a132016-11-04 00:56:23 +020036 settings.LAB_CONFIG_NAME))
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +030037_default_oss_steps = pkg_resources.resource_filename(
38 __name__,
39 'templates/{0}/oss.yaml'.format(
40 settings.LAB_CONFIG_NAME))
Dennis Dmitrievf3f90a52017-08-10 14:37:05 +030041_default_decapod_steps = pkg_resources.resource_filename(
42 __name__,
43 'templates/{0}/decapod.yaml'.format(
44 settings.LAB_CONFIG_NAME))
Dennis Dmitriev6860ba62016-11-01 21:43:46 +020045_default_openstack_steps = pkg_resources.resource_filename(
Dennis Dmitrievab83ea42017-05-12 16:52:45 +030046 __name__, 'templates/{0}/openstack.yaml'.format(
Dennis Dmitriev2a13a132016-11-04 00:56:23 +020047 settings.LAB_CONFIG_NAME))
Dennis Dmitriev2cbf2352016-11-11 15:34:21 +020048_default_opencontrail_prepare_tests_steps_path = pkg_resources.resource_filename(
Dennis Dmitrievab83ea42017-05-12 16:52:45 +030049 __name__, 'templates/{0}/opencontrail.yaml'.format(
Dennis Dmitriev2cbf2352016-11-11 15:34:21 +020050 settings.LAB_CONFIG_NAME))
Tatyana Leontovichc8b8ca22017-05-19 13:37:05 +030051_default_sl_prepare_tests_steps_path = pkg_resources.resource_filename(
52 __name__, 'templates/{0}/sl.yaml'.format(
53 settings.LAB_CONFIG_NAME))
vrovachevbc2f5ce2017-05-22 19:37:24 +040054_default_virtlet_prepare_tests_steps_path = pkg_resources.resource_filename(
55 __name__, 'templates/{0}/virtlet.yaml'.format(
56 settings.LAB_CONFIG_NAME))
Victor Ryzhenkin655587f2017-05-24 20:00:07 +040057_default_virtlet_ceph_prepare_tests_steps_path = pkg_resources.resource_filename(
58 __name__, 'templates/{0}/virtlet_ceph.yaml'.format(
59 settings.LAB_CONFIG_NAME))
Artem Panchenko0594cd72017-06-12 13:25:26 +030060_default_k8s_steps = pkg_resources.resource_filename(
61 __name__, 'templates/{0}/k8s.yaml'.format(
62 settings.LAB_CONFIG_NAME))
Dennis Dmitriev6f59add2016-10-18 13:45:27 +030063
64hardware_opts = [
65 ct.Cfg('manager', ct.String(),
66 help="Hardware manager name", default="devops"),
67 ct.Cfg('conf_path', ct.String(),
68 help="Hardware config file", default=_default_conf),
69 ct.Cfg('current_snapshot', ct.String(),
70 help="Latest environment status name",
71 default=ext.SNAPSHOT.hardware),
72]
73
74
75underlay_opts = [
76 ct.Cfg('ssh', ct.JSONList(),
77 help="""SSH Settings for Underlay: [{
78 'node_name': node1,
Dennis Dmitriev23e5d192016-10-31 11:27:10 +020079 'roles': ['salt-master', 'salt-minion', ],
Dennis Dmitriev6f59add2016-10-18 13:45:27 +030080 'host': hostname,
81 'login': login,
82 'password': password,
83 'address_pool': (optional),
84 'port': (optional),
85 'keys': [(optional)],
86 }, ...]""", default=[]),
87 ct.Cfg('roles', ct.JSONList(),
88 help="Node roles managed by underlay in the environment",
Dennis Dmitriev53d3b772016-10-18 14:31:58 +030089 default=[ext.UNDERLAY_NODE_ROLES.salt_master,
vrovachev99228d32017-06-08 19:46:10 +040090 ext.UNDERLAY_NODE_ROLES.salt_minion,
91 ext.UNDERLAY_NODE_ROLES.k8s_virtlet, ]),
Dennis Dmitriev7b9538f2017-05-15 17:01:34 +030092 ct.Cfg('bootstrap_timeout', ct.Integer(),
93 help="Timeout of waiting SSH for nodes with specified roles",
94 default=480),
Dennis Dmitriev6f59add2016-10-18 13:45:27 +030095 ct.Cfg('nameservers', ct.JSONList(),
96 help="IP addresses of DNS servers",
97 default=[]),
98 ct.Cfg('upstream_dns_servers', ct.JSONList(),
99 help="IP addresses of upstream DNS servers (dnsmasq)",
100 default=[]),
101 ct.Cfg('lvm', ct.JSONDict(),
102 help="LVM settings for Underlay", default={}),
Dennis Dmitriev99b26fe2017-04-26 12:34:44 +0300103 ct.Cfg('address_pools', ct.JSONDict(),
104 help="""Address pools (dynamically) allocated for the environment.
105 May be used to determine CIDR for a specific network from
106 tests or during the deployment process.
107 {'pool_name1': '<cidr>', 'pool_name2': '<cidr>', ...}""",
108 default={}),
Artem Panchenkodb0a97f2017-06-27 19:09:13 +0300109 ct.Cfg('ssh_keys', ct.JSONList(), default=[],
110 help="SSH key pair(s) for root. If the option is left empty, "
111 "then a key pair will be generated automatically"),
112 ct.Cfg('ssh_key_file', ct.String(), default=os.path.abspath('./id_rsa'),
113 help='Path (local) to file with private key authorized on nodes'),
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300114]
115
Dennis Dmitriev6860ba62016-11-01 21:43:46 +0200116
117salt_deploy_opts = [
118 ct.Cfg('salt_steps_path', ct.String(),
119 help="Path to YAML with steps to deploy salt",
120 default=_default_salt_steps),
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300121]
Dennis Dmitriev6860ba62016-11-01 21:43:46 +0200122salt_opts = [
123 ct.Cfg('salt_master_host', ct.IPAddress(),
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300124 help="", default='0.0.0.0'),
Dennis Dmitriev2d60c8e2017-05-12 18:34:01 +0300125 ct.Cfg('salt_master_port', ct.String(),
126 help="", default='6969'),
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300127]
128
Dennis Dmitriev6860ba62016-11-01 21:43:46 +0200129common_services_deploy_opts = [
130 ct.Cfg('common_services_steps_path', ct.String(),
131 help="Path to YAML with steps to deploy common services",
132 default=_default_common_services_steps),
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300133]
134
Dennis Dmitriev6860ba62016-11-01 21:43:46 +0200135common_services_opts = [
Dennis Dmitriev2cbf2352016-11-11 15:34:21 +0200136 ct.Cfg('common_services_installed', ct.Boolean(),
Dennis Dmitriev6860ba62016-11-01 21:43:46 +0200137 help="", default=False),
138]
139
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +0300140oss_deploy_opts = [
141 ct.Cfg('oss_steps_path', ct.String(),
142 help="Path to YAML with steps to deploy OSS Tools",
143 default=_default_oss_steps),
144]
145
146oss_opts = [
147 ct.Cfg('oss_installed', ct.Boolean(),
148 help="", default=False),
149]
150
Dennis Dmitrievf3f90a52017-08-10 14:37:05 +0300151decapod_deploy_opts = [
152 ct.Cfg('decapod_steps_path', ct.String(),
153 help="Path to YAML with steps to deploy Ceph with Decapod",
154 default=_default_decapod_steps),
155]
156
157decapod_opts = [
158 ct.Cfg('decapod_installed', ct.Boolean(),
159 help="", default=False),
160]
161
Dennis Dmitriev6860ba62016-11-01 21:43:46 +0200162openstack_deploy_opts = [
163 ct.Cfg('openstack_steps_path', ct.String(),
164 help="Path to YAML with steps to deploy openstack",
165 default=_default_openstack_steps),
166]
167openstack_opts = [
Dennis Dmitriev2cbf2352016-11-11 15:34:21 +0200168 ct.Cfg('openstack_installed', ct.Boolean(),
Dennis Dmitriev6860ba62016-11-01 21:43:46 +0200169 help="", default=False),
Dennis Dmitriev2cbf2352016-11-11 15:34:21 +0200170 ct.Cfg('openstack_keystone_endpoint', ct.String(),
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300171 help="", default=''),
172]
173
Dennis Dmitriev2cbf2352016-11-11 15:34:21 +0200174opencontrail_opts = [
175 ct.Cfg('opencontrail_tags', ct.String(),
176 help="", default=''),
177 ct.Cfg('opencontrail_features', ct.String(),
178 help="", default=''),
179 ct.Cfg('opencontrail_prepare_tests_steps_path', ct.String(),
180 help="Path to YAML with steps to prepare contrail-tests",
181 default=_default_opencontrail_prepare_tests_steps_path),
182]
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300183
Tatyana Leontovichc8b8ca22017-05-19 13:37:05 +0300184sl_deploy_opts = [
185 ct.Cfg('sl_steps_path', ct.String(),
186 help="Path to YAML with steps to deploy sl",
187 default=_default_sl_prepare_tests_steps_path),
Tatyana Leontovichf00b2342017-07-04 18:26:25 +0300188 ct.Cfg('docker_image_alertmanager', ct.String(),
189 default='{}/openstack-docker/alertmanager:latest'.format(
190 settings.DOCKER_REGISTRY)),
191 ct.Cfg('docker_image_pushgateway', ct.String(),
192 default='{}/openstack-docker/pushgateway:latest'.format(
193 settings.DOCKER_REGISTRY)),
194 ct.Cfg('docker_image_prometheus', ct.String(),
195 default='{}/openstack-docker/prometheus:latest'.format(
196 settings.DOCKER_REGISTRY)),
197 ct.Cfg('docker_image_remote_agent', ct.String(),
198 default='{}/openstack-docker/telegraf:latest'.format(
199 settings.DOCKER_REGISTRY)),
200 ct.Cfg('docker_image_remote_storage_adapter', ct.String(),
201 default='{}/openstack-docker/remote_storage_adapter:latest'.format(
202 settings.DOCKER_REGISTRY)),
Tatyana Leontovichc8b8ca22017-05-19 13:37:05 +0300203]
Tatyana Leontovichf00b2342017-07-04 18:26:25 +0300204
Tatyana Leontovichc8b8ca22017-05-19 13:37:05 +0300205sl_opts = [
206 ct.Cfg('sl_installed', ct.Boolean(),
207 help="", default=False),
Tatyana Leontovich09b7b012017-07-10 12:53:45 +0300208 ct.Cfg('sl_vip_host', ct.IPAddress(),
209 help="Vip address for SL services", default='0.0.0.0'),
210 ct.Cfg('sl_prometheus_port', ct.String(),
211 help="Prometheus port", default='15010'),
212 ct.Cfg('sl_prometheus_proto', ct.String(),
213 help="Proemtheus protocol", default='http'),
Tatyana Leontovichc8b8ca22017-05-19 13:37:05 +0300214]
215
vrovachevbc2f5ce2017-05-22 19:37:24 +0400216virtlet_deploy_opts = [
217 ct.Cfg('virtlet_steps_path', ct.String(),
218 help="Path to YAML with steps to deploy virtlet",
Victor Ryzhenkin655587f2017-05-24 20:00:07 +0400219 default=_default_virtlet_prepare_tests_steps_path),
220 ct.Cfg('virtlet_ceph_steps_path', ct.String(),
221 help="Path to YAML with steps to deploy one-node ceph cluster for "
222 "Virtlet Flexvolumes testing",
223 default=_default_virtlet_ceph_prepare_tests_steps_path)
vrovachevbc2f5ce2017-05-22 19:37:24 +0400224]
225
226virtlet_opts = [
227 ct.Cfg('virtlet_installed', ct.Boolean(),
228 help="", default=False),
Victor Ryzhenkin655587f2017-05-24 20:00:07 +0400229 ct.Cfg('ceph_installed', ct.Boolean(),
230 help="Determine, installed one-node ceph cluster or not",
231 default=False)
vrovachevbc2f5ce2017-05-22 19:37:24 +0400232]
Tatyana Leontovichc8b8ca22017-05-19 13:37:05 +0300233
Artem Panchenkoedf70ef2017-06-13 09:14:34 +0300234k8s_deploy_opts = [
Artem Panchenko0594cd72017-06-12 13:25:26 +0300235 ct.Cfg('k8s_steps_path', ct.String(),
236 help="Path to YAML with steps to deploy Kubernetes",
237 default=_default_k8s_steps),
238 ct.Cfg('kubernetes_admin_user', ct.String(), default='admin'),
239 ct.Cfg('kubernetes_admin_password', ct.String(),
240 default='sbPfel23ZigJF3Bm'),
Artem Panchenkoedf70ef2017-06-13 09:14:34 +0300241 ct.Cfg('kubernetes_docker_package', ct.String(), default=''),
242 ct.Cfg('kubernetes_hyperkube_image', ct.String(),
vrovacheva9d08332017-06-22 20:01:59 +0400243 default='{}/mirantis/kubernetes/hyperkube-amd64:v1.6.4-3'.format(
Artem Panchenkoedf70ef2017-06-13 09:14:34 +0300244 settings.DOCKER_REGISTRY)),
245 ct.Cfg('kubernetes_calico_image', ct.String(),
246 default='{}/mirantis/projectcalico/calico/node:latest'.format(
247 settings.DOCKER_REGISTRY)),
248 ct.Cfg('kubernetes_calicoctl_image', ct.String(),
249 default='{}/mirantis/projectcalico/calico/ctl:latest'.format(
250 settings.DOCKER_REGISTRY)),
251 ct.Cfg('kubernetes_calico_cni_image', ct.String(),
252 default='{}/mirantis/projectcalico/calico/cni:latest'.format(
253 settings.DOCKER_REGISTRY)),
Artem Panchenko0594cd72017-06-12 13:25:26 +0300254 ct.Cfg('kubernetes_netchecker_enabled', ct.Boolean(),
255 help="", default=True),
Artem Panchenkoedf70ef2017-06-13 09:14:34 +0300256 ct.Cfg('kubernetes_netchecker_agent_image', ct.String(),
Tatyana Leontovichf00b2342017-07-04 18:26:25 +0300257 default='mirantis/k8s-netchecker-agent:stable'),
Artem Panchenkoedf70ef2017-06-13 09:14:34 +0300258 ct.Cfg('kubernetes_netchecker_server_image', ct.String(),
Tatyana Leontovichf00b2342017-07-04 18:26:25 +0300259 default='mirantis/k8s-netchecker-server:stable'),
Artem Panchenko501e67e2017-06-14 14:59:18 +0300260 ct.Cfg('kubernetes_calico_policy_enabled', ct.Boolean(),
261 help="", default=False),
262 ct.Cfg('kubernetes_calico_policy_image', ct.String(),
263 default='calico/kube-policy-controller:v0.5.4'),
264 ct.Cfg('kubernetes_helm_enabled', ct.Boolean(),
265 help="", default=True),
Victor Ryzhenkin0bf0bb02017-07-06 18:57:05 +0400266 ct.Cfg('kubernetes_virtlet_enabled', ct.Boolean(),
Sergii Golovatiuk44a43522017-07-20 12:55:13 +0200267 help="", default=True),
Victor Ryzhenkin0bf0bb02017-07-06 18:57:05 +0400268 ct.Cfg('kubernetes_virtlet_image', ct.String(),
Sergii Golovatiuk657cdcc2017-08-11 17:31:21 +0200269 help="", default='mirantis/virtlet:v0.7.0')
Artem Panchenkoedf70ef2017-06-13 09:14:34 +0300270]
271
272k8s_opts = [
Artem Panchenko0594cd72017-06-12 13:25:26 +0300273 ct.Cfg('k8s_installed', ct.Boolean(),
274 help="", default=False),
Artem Panchenkoedf70ef2017-06-13 09:14:34 +0300275 ct.Cfg('kube_host', ct.IPAddress(),
276 help="", default='0.0.0.0'),
277 ct.Cfg('kube_apiserver_port', ct.Integer(),
278 help="", default=443),
vrovacheva9d08332017-06-22 20:01:59 +0400279 ct.Cfg("k8s_conformance_run", ct.Boolean(),
280 default=False),
281 ct.Cfg('k8s_conformance_image', ct.String(),
282 default='docker-dev-virtual.docker.mirantis.net/mirantis/'
283 'kubernetes/k8s-conformance:v1.6.4-3_1495550936267')
Artem Panchenkoedf70ef2017-06-13 09:14:34 +0300284]
285
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300286_group_opts = [
287 ('hardware', hardware_opts),
288 ('underlay', underlay_opts),
Dennis Dmitriev6860ba62016-11-01 21:43:46 +0200289 ('salt_deploy', salt_deploy_opts),
290 ('salt', salt_opts),
291 ('common_services_deploy', common_services_deploy_opts),
292 ('common_services', common_services_opts),
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +0300293 ('oss_deploy', oss_deploy_opts),
294 ('oss', oss_opts),
Dennis Dmitrievf3f90a52017-08-10 14:37:05 +0300295 ('decapod_deploy', decapod_deploy_opts),
296 ('decapod', decapod_opts),
Dennis Dmitriev6860ba62016-11-01 21:43:46 +0200297 ('openstack_deploy', openstack_deploy_opts),
298 ('openstack', openstack_opts),
Dennis Dmitriev2cbf2352016-11-11 15:34:21 +0200299 ('opencontrail', opencontrail_opts),
Tatyana Leontovichc8b8ca22017-05-19 13:37:05 +0300300 ('stack_light', sl_opts),
301 ('sl_deploy', sl_deploy_opts),
vrovachevbc2f5ce2017-05-22 19:37:24 +0400302 ('virtlet_deploy', virtlet_deploy_opts),
303 ('virtlet', virtlet_opts),
Artem Panchenkoedf70ef2017-06-13 09:14:34 +0300304 ('k8s_deploy', k8s_deploy_opts),
305 ('k8s', k8s_opts),
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300306]
307
308
309def register_opts(config):
310 config.register_group(cfg.OptGroup(name='hardware',
311 title="Hardware settings", help=""))
312 config.register_opts(group='hardware', opts=hardware_opts)
313
314 config.register_group(cfg.OptGroup(name='underlay',
315 title="Underlay configuration", help=""))
316 config.register_opts(group='underlay', opts=underlay_opts)
317
Dennis Dmitriev6860ba62016-11-01 21:43:46 +0200318 config.register_group(cfg.OptGroup(name='salt_deploy',
319 title="salt deploy configuration", help=""))
320 config.register_opts(group='salt_deploy', opts=salt_deploy_opts)
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300321
Dennis Dmitriev6860ba62016-11-01 21:43:46 +0200322 config.register_group(cfg.OptGroup(name='salt',
323 title="salt config and credentials", help=""))
324 config.register_opts(group='salt', opts=salt_opts)
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300325
Dennis Dmitriev6860ba62016-11-01 21:43:46 +0200326 config.register_group(cfg.OptGroup(name='common_services',
327 title="Common services for Openstack", help=""))
328 config.register_opts(group='common_services', opts=common_services_opts)
329
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300330 config.register_group(
Dennis Dmitriev6860ba62016-11-01 21:43:46 +0200331 cfg.OptGroup(name='common_services_deploy',
332 title="Common services for Openstack deploy config",
333 help=""))
334 config.register_opts(group='common_services_deploy',
335 opts=common_services_deploy_opts)
336
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +0300337 config.register_group(cfg.OptGroup(name='oss',
338 title="Operational Support System Tools", help=""))
339 config.register_opts(group='oss', opts=oss_opts)
340
341 config.register_group(cfg.OptGroup(name='oss_deploy',
342 title="OSS deploy config", help=""))
343 config.register_opts(group='oss_deploy',
344 opts=oss_deploy_opts)
345
Dennis Dmitrievf3f90a52017-08-10 14:37:05 +0300346 config.register_group(cfg.OptGroup(name='decapod',
347 title="Decapod options for Ceph", help=""))
348 config.register_opts(group='decapod', opts=decapod_opts)
349
350 config.register_group(cfg.OptGroup(name='decapod_deploy',
351 title="Decapod deploy config", help=""))
352 config.register_opts(group='decapod_deploy',
353 opts=decapod_deploy_opts)
354
Dennis Dmitriev6860ba62016-11-01 21:43:46 +0200355 config.register_group(cfg.OptGroup(name='openstack',
356 title="Openstack config and credentials", help=""))
357 config.register_opts(group='openstack', opts=openstack_opts)
358
359 config.register_group(
360 cfg.OptGroup(name='openstack_deploy',
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300361 title="Openstack deploy config and credentials",
362 help=""))
Dennis Dmitriev6860ba62016-11-01 21:43:46 +0200363 config.register_opts(group='openstack_deploy', opts=openstack_deploy_opts)
Dennis Dmitriev2cbf2352016-11-11 15:34:21 +0200364
365 config.register_group(cfg.OptGroup(name='opencontrail',
366 title="Options for Juniper contrail-tests", help=""))
367 config.register_opts(group='opencontrail', opts=opencontrail_opts)
Tatyana Leontovichc8b8ca22017-05-19 13:37:05 +0300368 config.register_group(cfg.OptGroup(name='stack_light',
369 title="StackLight config and credentials", help=""))
Tatyana Leontovich5acc82a2017-05-23 15:41:35 +0300370 config.register_opts(group='stack_light', opts=sl_opts)
Tatyana Leontovichc8b8ca22017-05-19 13:37:05 +0300371 config.register_group(
372 cfg.OptGroup(name='sl_deploy',
Dennis Dmitrievf3f90a52017-08-10 14:37:05 +0300373 title="SL deploy config and credentials",
374 help=""))
Tatyana Leontovichc8b8ca22017-05-19 13:37:05 +0300375 config.register_opts(group='sl_deploy', opts=sl_deploy_opts)
vrovachevbc2f5ce2017-05-22 19:37:24 +0400376 config.register_group(cfg.OptGroup(name='virtlet_deploy',
377 title='Virtlet deploy config', help=""))
378 config.register_opts(group='virtlet_deploy', opts=virtlet_deploy_opts)
379 config.register_group(cfg.OptGroup(name='virtlet',
380 title='Virtlet config', help=""))
381 config.register_opts(group='virtlet', opts=virtlet_opts)
Artem Panchenkoedf70ef2017-06-13 09:14:34 +0300382
383 config.register_group(cfg.OptGroup(name='k8s_deploy',
384 title="K8s deploy configuration"))
385 config.register_opts(group='k8s_deploy', opts=k8s_deploy_opts)
386
387 config.register_group(cfg.OptGroup(name='k8s',
388 title="K8s config and credentials"))
389 config.register_opts(group='k8s', opts=k8s_opts)
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300390 return config
391
392
393def load_config(config_files):
394 config = cfg.CONF
395 register_opts(config)
396 config(args=[], default_config_files=config_files)
397 return config
398
399
400def reload_snapshot_config(config, test_config_path):
401 """Reset config to the state from test_config file"""
402 config(args=[], default_config_files=[test_config_path])
403 return config
404
405
406def list_opts():
407 """Return a list of oslo.config options available in the tcp_tests.
408 """
409 return [(group, copy.deepcopy(opts)) for group, opts in _group_opts]
410
411
412def list_current_opts(config):
413 """Return a list of oslo.config options available in the tcp_tests.
414 """
415 result_opts = []
416 for group, opts in _group_opts:
417 current_opts = copy.deepcopy(opts)
418 for opt in current_opts:
419 if hasattr(config, group):
420 if hasattr(config[group], opt.name):
421 opt.default = getattr(config[group], opt.name)
422 result_opts.append((group, current_opts))
423 return result_opts
424
425
426def save_config(config, snapshot_name, env_name=None):
427 if env_name is None:
428 env_name = 'config'
429 test_config_path = os.path.join(
430 settings.LOGS_DIR, '{0}_{1}.ini'.format(env_name, snapshot_name))
431
432 with open(test_config_path, 'w') as output_file:
433 formatter = generator._OptFormatter(output_file=output_file)
434 for group, opts in list_current_opts(config):
435 formatter.format_group(group)
436 for opt in opts:
437 formatter.format(opt, group, minimal=True)
438 formatter.write('\n')
439 formatter.write('\n')