blob: 062e4218242b1546a858720bd9c736df444ed086 [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=''),
Tatyana Leontovichc08a54b2018-04-19 02:21:25 +0300211 ct.Cfg('horizon_check', ct.Boolean(),
Tatyana Leontovich69700712018-04-23 12:26:57 +0300212 help="", default=False),
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300213]
214
Dennis Dmitriev2cbf2352016-11-11 15:34:21 +0200215opencontrail_opts = [
216 ct.Cfg('opencontrail_tags', ct.String(),
217 help="", default=''),
218 ct.Cfg('opencontrail_features', ct.String(),
219 help="", default=''),
220 ct.Cfg('opencontrail_prepare_tests_steps_path', ct.String(),
221 help="Path to YAML with steps to prepare contrail-tests",
222 default=_default_opencontrail_prepare_tests_steps_path),
223]
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300224
Tatyana Leontovichc8b8ca22017-05-19 13:37:05 +0300225sl_deploy_opts = [
226 ct.Cfg('sl_steps_path', ct.String(),
227 help="Path to YAML with steps to deploy sl",
228 default=_default_sl_prepare_tests_steps_path),
Tatyana Leontovichf00b2342017-07-04 18:26:25 +0300229 ct.Cfg('docker_image_alertmanager', ct.String(),
Dennis Dmitriev257a9382018-02-15 04:00:46 +0200230 default='{0}/openstack-docker/alertmanager:{1}'.format(
231 settings.DOCKER_REGISTRY, settings.DOCKER_IMAGES_SL_TAG)),
Dmitry Kalashnik3eee60b2018-05-29 17:19:31 +0400232 ct.Cfg('docker_image_alerta', ct.String(),
233 default='{0}/mirantis/external/alerta-web:{1}'.format(
234 settings.DOCKER_REGISTRY, settings.DOCKER_IMAGES_SL_TAG)),
Tatyana Leontovichf00b2342017-07-04 18:26:25 +0300235 ct.Cfg('docker_image_pushgateway', ct.String(),
Dennis Dmitriev257a9382018-02-15 04:00:46 +0200236 default='{0}/openstack-docker/pushgateway:{1}'.format(
237 settings.DOCKER_REGISTRY, settings.DOCKER_IMAGES_SL_TAG)),
Tatyana Leontovichf00b2342017-07-04 18:26:25 +0300238 ct.Cfg('docker_image_prometheus', ct.String(),
Dennis Dmitriev257a9382018-02-15 04:00:46 +0200239 default='{0}/openstack-docker/prometheus:{1}'.format(
240 settings.DOCKER_REGISTRY, settings.DOCKER_IMAGES_SL_TAG)),
Tatyana Leontovichf00b2342017-07-04 18:26:25 +0300241 ct.Cfg('docker_image_remote_agent', ct.String(),
Dennis Dmitriev257a9382018-02-15 04:00:46 +0200242 default='{0}/openstack-docker/telegraf:{1}'.format(
243 settings.DOCKER_REGISTRY, settings.DOCKER_IMAGES_SL_TAG)),
Tatyana Leontovichf00b2342017-07-04 18:26:25 +0300244 ct.Cfg('docker_image_remote_storage_adapter', ct.String(),
Dennis Dmitriev257a9382018-02-15 04:00:46 +0200245 default='{0}/openstack-docker/remote_storage_adapter:{1}'.format(
246 settings.DOCKER_REGISTRY, settings.DOCKER_IMAGES_SL_TAG)),
247 ct.Cfg('docker_image_prometheus_relay', ct.String(),
248 default='{0}/openstack-docker/prometheus_relay:{1}'.format(
249 settings.DOCKER_REGISTRY, settings.DOCKER_IMAGES_SL_TAG)),
250 ct.Cfg('docker_image_grafana', ct.String(),
251 default='{0}/mirantis/external/grafana:{1}'.format(
252 settings.DOCKER_REGISTRY, settings.DOCKER_IMAGES_SL_TAG)),
Dennis Dmitriev86f63e82017-11-09 00:07:45 +0200253 # SalesForce connection options for pushkin
Dennis Dmitrievce5ed8b2017-11-09 00:44:19 +0200254 ct.Cfg('sfdc_sandbox_enabled', ct.String(), default='False'),
Dennis Dmitriev86f63e82017-11-09 00:07:45 +0200255 ct.Cfg('sfdc_auth_url', ct.String(), default=''),
256 ct.Cfg('sfdc_username', ct.String(), default=''),
257 ct.Cfg('sfdc_password', ct.String(), default=''),
258 ct.Cfg('sfdc_consumer_key', ct.String(), default=''),
259 ct.Cfg('sfdc_consumer_secret', ct.String(), default=''),
260 ct.Cfg('sfdc_organization_id', ct.String(), default=''),
Tatyana Leontovichc8b8ca22017-05-19 13:37:05 +0300261]
Tatyana Leontovichf00b2342017-07-04 18:26:25 +0300262
Tatyana Leontovichc8b8ca22017-05-19 13:37:05 +0300263sl_opts = [
264 ct.Cfg('sl_installed', ct.Boolean(),
265 help="", default=False),
sgudzbf4de572017-11-23 14:37:01 +0200266 ct.Cfg('sl_version', ct.String(),
267 help="StackLight version. Could be 1 or 2", default=''),
Tatyana Leontovich09b7b012017-07-10 12:53:45 +0300268 ct.Cfg('sl_vip_host', ct.IPAddress(),
269 help="Vip address for SL services", default='0.0.0.0'),
270 ct.Cfg('sl_prometheus_port', ct.String(),
271 help="Prometheus port", default='15010'),
272 ct.Cfg('sl_prometheus_proto', ct.String(),
273 help="Proemtheus protocol", default='http'),
Tatyana Leontovichc8b8ca22017-05-19 13:37:05 +0300274]
275
Tatyana Leontovich460f7df2017-11-13 15:45:06 +0200276ceph_deploy_opts = [
277 ct.Cfg('ceph_steps_path', ct.String(),
278 help="Path to YAML with steps to deploy sl",
Tatyana Leontovicha754ce52017-11-13 16:46:43 +0200279 default=_default_ceph_prepare_tests_steps_path),
Tatyana Leontovich460f7df2017-11-13 15:45:06 +0200280]
281
282ceph_opts = [
Tatyana Leontovicha754ce52017-11-13 16:46:43 +0200283 ct.Cfg('ceph_installed', ct.Boolean(),
Tatyana Leontovich460f7df2017-11-13 15:45:06 +0200284 help="", default=False),
Tatyana Leontovich460f7df2017-11-13 15:45:06 +0200285]
286
Artem Panchenkoedf70ef2017-06-13 09:14:34 +0300287k8s_deploy_opts = [
Artem Panchenko0594cd72017-06-12 13:25:26 +0300288 ct.Cfg('k8s_steps_path', ct.String(),
289 help="Path to YAML with steps to deploy Kubernetes",
290 default=_default_k8s_steps),
291 ct.Cfg('kubernetes_admin_user', ct.String(), default='admin'),
292 ct.Cfg('kubernetes_admin_password', ct.String(),
293 default='sbPfel23ZigJF3Bm'),
Artem Panchenkoedf70ef2017-06-13 09:14:34 +0300294 ct.Cfg('kubernetes_docker_package', ct.String(), default=''),
295 ct.Cfg('kubernetes_hyperkube_image', ct.String(),
Victor Ryzhenkin2687fa12018-05-24 16:28:17 +0400296 default='{}/mirantis/kubernetes/hyperkube-amd64:v1.8.13-11'.format(
297 settings.DOCKER_REGISTRY)),
298 ct.Cfg('kubernetes_pause_image', ct.String(),
299 default='{}/mirantis/kubernetes/pause-amd64:v1.8.13-11'.format(
Artem Panchenkoedf70ef2017-06-13 09:14:34 +0300300 settings.DOCKER_REGISTRY)),
301 ct.Cfg('kubernetes_calico_image', ct.String(),
Aleksei Kasatkin593596f2018-05-14 11:02:19 +0200302 default='{}/mirantis/projectcalico/calico/node:v2.6.9'.format(
Artem Panchenkoedf70ef2017-06-13 09:14:34 +0300303 settings.DOCKER_REGISTRY)),
Victor Ryzhenkin53f1b492018-05-09 17:30:17 +0400304 ct.Cfg('kubernetes_calico_calicoctl_image', ct.String(),
Aleksei Kasatkin593596f2018-05-14 11:02:19 +0200305 default='{}/mirantis/projectcalico/calico/ctl:v1.6.4'.format(
Artem Panchenkoedf70ef2017-06-13 09:14:34 +0300306 settings.DOCKER_REGISTRY)),
307 ct.Cfg('kubernetes_calico_cni_image', ct.String(),
Aleksei Kasatkin593596f2018-05-14 11:02:19 +0200308 default='{}/mirantis/projectcalico/calico/cni:v1.11.5'.format(
Artem Panchenkoedf70ef2017-06-13 09:14:34 +0300309 settings.DOCKER_REGISTRY)),
Artem Panchenko0594cd72017-06-12 13:25:26 +0300310 ct.Cfg('kubernetes_netchecker_enabled', ct.Boolean(),
311 help="", default=True),
Artem Panchenkoedf70ef2017-06-13 09:14:34 +0300312 ct.Cfg('kubernetes_netchecker_agent_image', ct.String(),
Aleksei Kasatkin593596f2018-05-14 11:02:19 +0200313 default='mirantis/k8s-netchecker-agent:v1.2.2'),
Artem Panchenkoedf70ef2017-06-13 09:14:34 +0300314 ct.Cfg('kubernetes_netchecker_server_image', ct.String(),
Aleksei Kasatkin593596f2018-05-14 11:02:19 +0200315 default='mirantis/k8s-netchecker-server:v1.2.2'),
Artem Panchenko501e67e2017-06-14 14:59:18 +0300316 ct.Cfg('kubernetes_calico_policy_enabled', ct.Boolean(),
317 help="", default=False),
318 ct.Cfg('kubernetes_calico_policy_image', ct.String(),
Aleksei Kasatkin593596f2018-05-14 11:02:19 +0200319 default='{}/mirantis/projectcalico/calico/kube-controllers:'
320 'v1.0.4'.format(settings.DOCKER_REGISTRY)),
Artem Panchenko501e67e2017-06-14 14:59:18 +0300321 ct.Cfg('kubernetes_helm_enabled', ct.Boolean(),
Tatyana Leontovich038dc7d2017-09-22 16:25:59 +0300322 help="", default=False),
Victor Ryzhenkin0bf0bb02017-07-06 18:57:05 +0400323 ct.Cfg('kubernetes_virtlet_enabled', ct.Boolean(),
Tatyana Leontovich038dc7d2017-09-22 16:25:59 +0300324 help="", default=False),
Victor Ryzhenkin0bf0bb02017-07-06 18:57:05 +0400325 ct.Cfg('kubernetes_virtlet_image', ct.String(),
Sergii Golovatiukc1b62f42017-10-06 13:24:32 +0200326 help="", default='mirantis/virtlet:v0.8.0'),
Victor Ryzhenkin14354ac2017-09-27 17:42:30 +0400327 ct.Cfg('kubernetes_externaldns_enabled', ct.Boolean(),
328 help="", default=False),
329 ct.Cfg('kubernetes_externaldns_image', ct.String(),
330 help="", default='mirantis/external-dns:latest'),
331 ct.Cfg('kubernetes_externaldns_provider', ct.String(),
332 help="", default='coredns'),
333 ct.Cfg('kubernetes_coredns_enabled', ct.Boolean(),
Victor Ryzhenkin2a5806e2017-12-18 20:23:53 +0400334 help="", default=False),
335 ct.Cfg('kubelet_fail_on_swap', ct.Boolean(),
Victor Ryzhenkin14354ac2017-09-27 17:42:30 +0400336 help="", default=False)
Artem Panchenkoedf70ef2017-06-13 09:14:34 +0300337]
338
339k8s_opts = [
Artem Panchenko0594cd72017-06-12 13:25:26 +0300340 ct.Cfg('k8s_installed', ct.Boolean(),
341 help="", default=False),
Artem Panchenkoedf70ef2017-06-13 09:14:34 +0300342 ct.Cfg('kube_host', ct.IPAddress(),
343 help="", default='0.0.0.0'),
344 ct.Cfg('kube_apiserver_port', ct.Integer(),
345 help="", default=443),
vrovacheva9d08332017-06-22 20:01:59 +0400346 ct.Cfg("k8s_conformance_run", ct.Boolean(),
347 default=False),
Victor Ryzhenkin8ff3c3f2018-01-17 19:37:05 +0400348 ct.Cfg("run_extended_virtlet_conformance", ct.Boolean(),
349 default=False),
vrovacheva9d08332017-06-22 20:01:59 +0400350 ct.Cfg('k8s_conformance_image', ct.String(),
Dennis Dmitriev75776c52017-12-26 18:22:53 +0200351 default='docker-prod-virtual.docker.mirantis.net/mirantis/'
Victor Ryzhenkin2687fa12018-05-24 16:28:17 +0400352 'kubernetes/k8s-conformance:v1.8.13-11')
Artem Panchenkoedf70ef2017-06-13 09:14:34 +0300353]
354
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300355_group_opts = [
356 ('hardware', hardware_opts),
357 ('underlay', underlay_opts),
Dennis Dmitriev6860ba62016-11-01 21:43:46 +0200358 ('salt_deploy', salt_deploy_opts),
359 ('salt', salt_opts),
360 ('common_services_deploy', common_services_deploy_opts),
361 ('common_services', common_services_opts),
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +0300362 ('oss_deploy', oss_deploy_opts),
363 ('oss', oss_opts),
sgudzb67ce732018-02-13 17:58:31 +0200364 ('drivetrain_deploy', drivetrain_deploy_opts),
365 ('drivetrain', drivetrain_opts),
Dennis Dmitrievf3f90a52017-08-10 14:37:05 +0300366 ('decapod_deploy', decapod_deploy_opts),
367 ('decapod', decapod_opts),
Dennis Dmitriev6860ba62016-11-01 21:43:46 +0200368 ('openstack_deploy', openstack_deploy_opts),
369 ('openstack', openstack_opts),
Dennis Dmitriev2cbf2352016-11-11 15:34:21 +0200370 ('opencontrail', opencontrail_opts),
Tatyana Leontovichc8b8ca22017-05-19 13:37:05 +0300371 ('stack_light', sl_opts),
372 ('sl_deploy', sl_deploy_opts),
Tatyana Leontovicha754ce52017-11-13 16:46:43 +0200373 ('ceph', ceph_opts),
374 ('ceph_deploy', ceph_deploy_opts),
Artem Panchenkoedf70ef2017-06-13 09:14:34 +0300375 ('k8s_deploy', k8s_deploy_opts),
376 ('k8s', k8s_opts),
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300377]
378
379
380def register_opts(config):
381 config.register_group(cfg.OptGroup(name='hardware',
382 title="Hardware settings", help=""))
383 config.register_opts(group='hardware', opts=hardware_opts)
384
385 config.register_group(cfg.OptGroup(name='underlay',
386 title="Underlay configuration", help=""))
387 config.register_opts(group='underlay', opts=underlay_opts)
388
Dennis Dmitriev6860ba62016-11-01 21:43:46 +0200389 config.register_group(cfg.OptGroup(name='salt_deploy',
390 title="salt deploy configuration", help=""))
391 config.register_opts(group='salt_deploy', opts=salt_deploy_opts)
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300392
Dennis Dmitriev6860ba62016-11-01 21:43:46 +0200393 config.register_group(cfg.OptGroup(name='salt',
394 title="salt config and credentials", help=""))
395 config.register_opts(group='salt', opts=salt_opts)
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300396
Dennis Dmitriev6860ba62016-11-01 21:43:46 +0200397 config.register_group(cfg.OptGroup(name='common_services',
398 title="Common services for Openstack", help=""))
399 config.register_opts(group='common_services', opts=common_services_opts)
400
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300401 config.register_group(
Dennis Dmitriev6860ba62016-11-01 21:43:46 +0200402 cfg.OptGroup(name='common_services_deploy',
403 title="Common services for Openstack deploy config",
404 help=""))
405 config.register_opts(group='common_services_deploy',
406 opts=common_services_deploy_opts)
407
Dennis Dmitrieveac3aab2017-07-12 16:36:41 +0300408 config.register_group(cfg.OptGroup(name='oss',
409 title="Operational Support System Tools", help=""))
410 config.register_opts(group='oss', opts=oss_opts)
411
412 config.register_group(cfg.OptGroup(name='oss_deploy',
413 title="OSS deploy config", help=""))
414 config.register_opts(group='oss_deploy',
415 opts=oss_deploy_opts)
416
sgudzb67ce732018-02-13 17:58:31 +0200417 config.register_group(cfg.OptGroup(name='drivetrain',
418 title="Drivetrain Tools", help=""))
419 config.register_opts(group='drivetrain', opts=drivetrain_opts)
420
421 config.register_group(cfg.OptGroup(name='drivetrain_deploy',
422 title="Drivetrain deploy config", help=""))
423 config.register_opts(group='drivetrain_deploy',
424 opts=drivetrain_deploy_opts)
425
Dennis Dmitrievf3f90a52017-08-10 14:37:05 +0300426 config.register_group(cfg.OptGroup(name='decapod',
427 title="Decapod options for Ceph", help=""))
428 config.register_opts(group='decapod', opts=decapod_opts)
429
430 config.register_group(cfg.OptGroup(name='decapod_deploy',
431 title="Decapod deploy config", help=""))
432 config.register_opts(group='decapod_deploy',
433 opts=decapod_deploy_opts)
434
Dennis Dmitriev6860ba62016-11-01 21:43:46 +0200435 config.register_group(cfg.OptGroup(name='openstack',
436 title="Openstack config and credentials", help=""))
437 config.register_opts(group='openstack', opts=openstack_opts)
438
439 config.register_group(
440 cfg.OptGroup(name='openstack_deploy',
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300441 title="Openstack deploy config and credentials",
442 help=""))
Dennis Dmitriev6860ba62016-11-01 21:43:46 +0200443 config.register_opts(group='openstack_deploy', opts=openstack_deploy_opts)
Dennis Dmitriev2cbf2352016-11-11 15:34:21 +0200444
445 config.register_group(cfg.OptGroup(name='opencontrail',
446 title="Options for Juniper contrail-tests", help=""))
447 config.register_opts(group='opencontrail', opts=opencontrail_opts)
Dmitry Tyzhnenko8f6a63e2017-09-05 15:37:23 +0300448 config.register_group(
449 cfg.OptGroup(name='stack_light',
450 title="StackLight config and credentials", help=""))
Tatyana Leontovich5acc82a2017-05-23 15:41:35 +0300451 config.register_opts(group='stack_light', opts=sl_opts)
Tatyana Leontovichc8b8ca22017-05-19 13:37:05 +0300452 config.register_group(
453 cfg.OptGroup(name='sl_deploy',
Dennis Dmitrievf3f90a52017-08-10 14:37:05 +0300454 title="SL deploy config and credentials",
455 help=""))
Tatyana Leontovichc8b8ca22017-05-19 13:37:05 +0300456 config.register_opts(group='sl_deploy', opts=sl_deploy_opts)
Artem Panchenkoedf70ef2017-06-13 09:14:34 +0300457
458 config.register_group(cfg.OptGroup(name='k8s_deploy',
459 title="K8s deploy configuration"))
460 config.register_opts(group='k8s_deploy', opts=k8s_deploy_opts)
461
462 config.register_group(cfg.OptGroup(name='k8s',
463 title="K8s config and credentials"))
464 config.register_opts(group='k8s', opts=k8s_opts)
Tatyana Leontovicha754ce52017-11-13 16:46:43 +0200465 config.register_group(cfg.OptGroup(name='ceph',
466 title="ceph config", help=""))
467 config.register_opts(group='ceph', opts=ceph_opts)
468
469 config.register_group(
470 cfg.OptGroup(name='ceph_deploy',
471 title="Ceph deploy config ",
472 help=""))
473 config.register_opts(group='ceph_deploy', opts=ceph_deploy_opts)
474
Dennis Dmitriev6f59add2016-10-18 13:45:27 +0300475 return config
476
477
478def load_config(config_files):
479 config = cfg.CONF
480 register_opts(config)
481 config(args=[], default_config_files=config_files)
482 return config
483
484
485def reload_snapshot_config(config, test_config_path):
486 """Reset config to the state from test_config file"""
487 config(args=[], default_config_files=[test_config_path])
488 return config
489
490
491def list_opts():
492 """Return a list of oslo.config options available in the tcp_tests.
493 """
494 return [(group, copy.deepcopy(opts)) for group, opts in _group_opts]
495
496
497def list_current_opts(config):
498 """Return a list of oslo.config options available in the tcp_tests.
499 """
500 result_opts = []
501 for group, opts in _group_opts:
502 current_opts = copy.deepcopy(opts)
503 for opt in current_opts:
504 if hasattr(config, group):
505 if hasattr(config[group], opt.name):
506 opt.default = getattr(config[group], opt.name)
507 result_opts.append((group, current_opts))
508 return result_opts
509
510
511def save_config(config, snapshot_name, env_name=None):
512 if env_name is None:
513 env_name = 'config'
514 test_config_path = os.path.join(
515 settings.LOGS_DIR, '{0}_{1}.ini'.format(env_name, snapshot_name))
516
517 with open(test_config_path, 'w') as output_file:
518 formatter = generator._OptFormatter(output_file=output_file)
519 for group, opts in list_current_opts(config):
520 formatter.format_group(group)
521 for opt in opts:
522 formatter.format(opt, group, minimal=True)
523 formatter.write('\n')
524 formatter.write('\n')