Dennis Dmitriev | 6f59add | 2016-10-18 13:45:27 +0300 | [diff] [blame] | 1 | # 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. |
| 14 | import copy |
| 15 | import os |
| 16 | import pkg_resources |
| 17 | |
| 18 | from oslo_config import cfg |
| 19 | from oslo_config import generator |
| 20 | |
| 21 | from tcp_tests.helpers import ext |
| 22 | from tcp_tests.helpers import oslo_cfg_types as ct |
| 23 | from tcp_tests import settings |
| 24 | |
Dennis Dmitriev | 2cbf235 | 2016-11-11 15:34:21 +0200 | [diff] [blame] | 25 | print ("\n" + "-" * 10 + " Initialize oslo.config variables with defaults" |
| 26 | " from environment" + "-" * 10) |
Dennis Dmitriev | 6f59add | 2016-10-18 13:45:27 +0300 | [diff] [blame] | 27 | |
| 28 | _default_conf = pkg_resources.resource_filename( |
Dennis Dmitriev | ab83ea4 | 2017-05-12 16:52:45 +0300 | [diff] [blame] | 29 | __name__, 'templates/{0}/underlay.yaml'.format(settings.LAB_CONFIG_NAME)) |
Dennis Dmitriev | 6860ba6 | 2016-11-01 21:43:46 +0200 | [diff] [blame] | 30 | |
| 31 | _default_salt_steps = pkg_resources.resource_filename( |
Dennis Dmitriev | ab83ea4 | 2017-05-12 16:52:45 +0300 | [diff] [blame] | 32 | __name__, 'templates/{0}/salt.yaml'.format(settings.LAB_CONFIG_NAME)) |
Dennis Dmitriev | 9dada8a | 2017-08-30 17:38:55 +0300 | [diff] [blame] | 33 | _default_environment_template_dir = pkg_resources.resource_filename( |
| 34 | __name__, 'environment/') |
Dmitry Tyzhnenko | 8f6a63e | 2017-09-05 15:37:23 +0300 | [diff] [blame] | 35 | _default_templates_dir = pkg_resources.resource_filename( |
| 36 | __name__, 'templates/') |
Dennis Dmitriev | 6860ba6 | 2016-11-01 21:43:46 +0200 | [diff] [blame] | 37 | _default_common_services_steps = pkg_resources.resource_filename( |
| 38 | __name__, |
Dennis Dmitriev | ab83ea4 | 2017-05-12 16:52:45 +0300 | [diff] [blame] | 39 | 'templates/{0}/common-services.yaml'.format( |
Dennis Dmitriev | 2a13a13 | 2016-11-04 00:56:23 +0200 | [diff] [blame] | 40 | settings.LAB_CONFIG_NAME)) |
Dennis Dmitriev | eac3aab | 2017-07-12 16:36:41 +0300 | [diff] [blame] | 41 | _default_oss_steps = pkg_resources.resource_filename( |
| 42 | __name__, |
| 43 | 'templates/{0}/oss.yaml'.format( |
| 44 | settings.LAB_CONFIG_NAME)) |
Dennis Dmitriev | f3f90a5 | 2017-08-10 14:37:05 +0300 | [diff] [blame] | 45 | _default_decapod_steps = pkg_resources.resource_filename( |
| 46 | __name__, |
| 47 | 'templates/{0}/decapod.yaml'.format( |
| 48 | settings.LAB_CONFIG_NAME)) |
Dennis Dmitriev | 6860ba6 | 2016-11-01 21:43:46 +0200 | [diff] [blame] | 49 | _default_openstack_steps = pkg_resources.resource_filename( |
Dennis Dmitriev | ab83ea4 | 2017-05-12 16:52:45 +0300 | [diff] [blame] | 50 | __name__, 'templates/{0}/openstack.yaml'.format( |
Dennis Dmitriev | 2a13a13 | 2016-11-04 00:56:23 +0200 | [diff] [blame] | 51 | settings.LAB_CONFIG_NAME)) |
Dina Belova | e6fdffb | 2017-09-19 13:58:34 -0700 | [diff] [blame] | 52 | _default_opencontrail_prepare_tests_steps_path = \ |
| 53 | pkg_resources.resource_filename( |
| 54 | __name__, 'templates/{0}/opencontrail.yaml'.format( |
| 55 | settings.LAB_CONFIG_NAME)) |
Tatyana Leontovich | c8b8ca2 | 2017-05-19 13:37:05 +0300 | [diff] [blame] | 56 | _default_sl_prepare_tests_steps_path = pkg_resources.resource_filename( |
| 57 | __name__, 'templates/{0}/sl.yaml'.format( |
| 58 | settings.LAB_CONFIG_NAME)) |
vrovachev | bc2f5ce | 2017-05-22 19:37:24 +0400 | [diff] [blame] | 59 | _default_virtlet_prepare_tests_steps_path = pkg_resources.resource_filename( |
| 60 | __name__, 'templates/{0}/virtlet.yaml'.format( |
| 61 | settings.LAB_CONFIG_NAME)) |
Dina Belova | e6fdffb | 2017-09-19 13:58:34 -0700 | [diff] [blame] | 62 | _default_virtlet_ceph_prepare_tests_steps_path = \ |
| 63 | pkg_resources.resource_filename( |
| 64 | __name__, 'templates/{0}/virtlet_ceph.yaml'.format( |
| 65 | settings.LAB_CONFIG_NAME)) |
Artem Panchenko | 0594cd7 | 2017-06-12 13:25:26 +0300 | [diff] [blame] | 66 | _default_k8s_steps = pkg_resources.resource_filename( |
| 67 | __name__, 'templates/{0}/k8s.yaml'.format( |
| 68 | settings.LAB_CONFIG_NAME)) |
Dennis Dmitriev | 6f59add | 2016-10-18 13:45:27 +0300 | [diff] [blame] | 69 | |
| 70 | hardware_opts = [ |
| 71 | ct.Cfg('manager', ct.String(), |
| 72 | help="Hardware manager name", default="devops"), |
| 73 | ct.Cfg('conf_path', ct.String(), |
| 74 | help="Hardware config file", default=_default_conf), |
| 75 | ct.Cfg('current_snapshot', ct.String(), |
| 76 | help="Latest environment status name", |
| 77 | default=ext.SNAPSHOT.hardware), |
| 78 | ] |
| 79 | |
| 80 | |
| 81 | underlay_opts = [ |
| 82 | ct.Cfg('ssh', ct.JSONList(), |
| 83 | help="""SSH Settings for Underlay: [{ |
| 84 | 'node_name': node1, |
Dennis Dmitriev | 23e5d19 | 2016-10-31 11:27:10 +0200 | [diff] [blame] | 85 | 'roles': ['salt-master', 'salt-minion', ], |
Dennis Dmitriev | 6f59add | 2016-10-18 13:45:27 +0300 | [diff] [blame] | 86 | 'host': hostname, |
| 87 | 'login': login, |
| 88 | 'password': password, |
| 89 | 'address_pool': (optional), |
| 90 | 'port': (optional), |
| 91 | 'keys': [(optional)], |
| 92 | }, ...]""", default=[]), |
| 93 | ct.Cfg('roles', ct.JSONList(), |
| 94 | help="Node roles managed by underlay in the environment", |
Dennis Dmitriev | 53d3b77 | 2016-10-18 14:31:58 +0300 | [diff] [blame] | 95 | default=[ext.UNDERLAY_NODE_ROLES.salt_master, |
vrovachev | 99228d3 | 2017-06-08 19:46:10 +0400 | [diff] [blame] | 96 | ext.UNDERLAY_NODE_ROLES.salt_minion, |
Victor Ryzhenkin | 66d3937 | 2017-09-28 19:25:48 +0400 | [diff] [blame^] | 97 | ext.UNDERLAY_NODE_ROLES.k8s_virtlet, |
| 98 | ext.UNDERLAY_NODE_ROLES.k8s_controller]), |
Dennis Dmitriev | 7b9538f | 2017-05-15 17:01:34 +0300 | [diff] [blame] | 99 | ct.Cfg('bootstrap_timeout', ct.Integer(), |
| 100 | help="Timeout of waiting SSH for nodes with specified roles", |
| 101 | default=480), |
Dennis Dmitriev | 6f59add | 2016-10-18 13:45:27 +0300 | [diff] [blame] | 102 | ct.Cfg('nameservers', ct.JSONList(), |
| 103 | help="IP addresses of DNS servers", |
| 104 | default=[]), |
| 105 | ct.Cfg('upstream_dns_servers', ct.JSONList(), |
| 106 | help="IP addresses of upstream DNS servers (dnsmasq)", |
| 107 | default=[]), |
| 108 | ct.Cfg('lvm', ct.JSONDict(), |
| 109 | help="LVM settings for Underlay", default={}), |
Dennis Dmitriev | 99b26fe | 2017-04-26 12:34:44 +0300 | [diff] [blame] | 110 | ct.Cfg('address_pools', ct.JSONDict(), |
| 111 | help="""Address pools (dynamically) allocated for the environment. |
| 112 | May be used to determine CIDR for a specific network from |
| 113 | tests or during the deployment process. |
| 114 | {'pool_name1': '<cidr>', 'pool_name2': '<cidr>', ...}""", |
| 115 | default={}), |
Artem Panchenko | db0a97f | 2017-06-27 19:09:13 +0300 | [diff] [blame] | 116 | ct.Cfg('ssh_keys', ct.JSONList(), default=[], |
| 117 | help="SSH key pair(s) for root. If the option is left empty, " |
| 118 | "then a key pair will be generated automatically"), |
| 119 | ct.Cfg('ssh_key_file', ct.String(), default=os.path.abspath('./id_rsa'), |
| 120 | help='Path (local) to file with private key authorized on nodes'), |
Dennis Dmitriev | 6f59add | 2016-10-18 13:45:27 +0300 | [diff] [blame] | 121 | ] |
| 122 | |
Dennis Dmitriev | 6860ba6 | 2016-11-01 21:43:46 +0200 | [diff] [blame] | 123 | |
| 124 | salt_deploy_opts = [ |
| 125 | ct.Cfg('salt_steps_path', ct.String(), |
| 126 | help="Path to YAML with steps to deploy salt", |
| 127 | default=_default_salt_steps), |
Dennis Dmitriev | 9dada8a | 2017-08-30 17:38:55 +0300 | [diff] [blame] | 128 | ct.Cfg('environment_template_dir', ct.String(), |
| 129 | help="Path to directory with Environment template and inventory", |
| 130 | default=_default_environment_template_dir), |
Dmitry Tyzhnenko | 8f6a63e | 2017-09-05 15:37:23 +0300 | [diff] [blame] | 131 | ct.Cfg('templates_dir', ct.String(), |
| 132 | help="Path to directory with templates", |
| 133 | default=_default_templates_dir), |
Dennis Dmitriev | 6f59add | 2016-10-18 13:45:27 +0300 | [diff] [blame] | 134 | ] |
Dennis Dmitriev | 6860ba6 | 2016-11-01 21:43:46 +0200 | [diff] [blame] | 135 | salt_opts = [ |
| 136 | ct.Cfg('salt_master_host', ct.IPAddress(), |
Dennis Dmitriev | 6f59add | 2016-10-18 13:45:27 +0300 | [diff] [blame] | 137 | help="", default='0.0.0.0'), |
Dennis Dmitriev | 2d60c8e | 2017-05-12 18:34:01 +0300 | [diff] [blame] | 138 | ct.Cfg('salt_master_port', ct.String(), |
| 139 | help="", default='6969'), |
Dennis Dmitriev | 6f59add | 2016-10-18 13:45:27 +0300 | [diff] [blame] | 140 | ] |
| 141 | |
Dennis Dmitriev | 6860ba6 | 2016-11-01 21:43:46 +0200 | [diff] [blame] | 142 | common_services_deploy_opts = [ |
| 143 | ct.Cfg('common_services_steps_path', ct.String(), |
| 144 | help="Path to YAML with steps to deploy common services", |
| 145 | default=_default_common_services_steps), |
Dennis Dmitriev | 6f59add | 2016-10-18 13:45:27 +0300 | [diff] [blame] | 146 | ] |
| 147 | |
Dennis Dmitriev | 6860ba6 | 2016-11-01 21:43:46 +0200 | [diff] [blame] | 148 | common_services_opts = [ |
Dennis Dmitriev | 2cbf235 | 2016-11-11 15:34:21 +0200 | [diff] [blame] | 149 | ct.Cfg('common_services_installed', ct.Boolean(), |
Dennis Dmitriev | 6860ba6 | 2016-11-01 21:43:46 +0200 | [diff] [blame] | 150 | help="", default=False), |
| 151 | ] |
| 152 | |
Dennis Dmitriev | eac3aab | 2017-07-12 16:36:41 +0300 | [diff] [blame] | 153 | oss_deploy_opts = [ |
| 154 | ct.Cfg('oss_steps_path', ct.String(), |
| 155 | help="Path to YAML with steps to deploy OSS Tools", |
| 156 | default=_default_oss_steps), |
| 157 | ] |
| 158 | |
| 159 | oss_opts = [ |
| 160 | ct.Cfg('oss_installed', ct.Boolean(), |
| 161 | help="", default=False), |
| 162 | ] |
| 163 | |
Dennis Dmitriev | f3f90a5 | 2017-08-10 14:37:05 +0300 | [diff] [blame] | 164 | decapod_deploy_opts = [ |
| 165 | ct.Cfg('decapod_steps_path', ct.String(), |
| 166 | help="Path to YAML with steps to deploy Ceph with Decapod", |
| 167 | default=_default_decapod_steps), |
| 168 | ] |
| 169 | |
| 170 | decapod_opts = [ |
| 171 | ct.Cfg('decapod_installed', ct.Boolean(), |
| 172 | help="", default=False), |
| 173 | ] |
| 174 | |
Dennis Dmitriev | 6860ba6 | 2016-11-01 21:43:46 +0200 | [diff] [blame] | 175 | openstack_deploy_opts = [ |
| 176 | ct.Cfg('openstack_steps_path', ct.String(), |
| 177 | help="Path to YAML with steps to deploy openstack", |
| 178 | default=_default_openstack_steps), |
| 179 | ] |
| 180 | openstack_opts = [ |
Dennis Dmitriev | 2cbf235 | 2016-11-11 15:34:21 +0200 | [diff] [blame] | 181 | ct.Cfg('openstack_installed', ct.Boolean(), |
Dennis Dmitriev | 6860ba6 | 2016-11-01 21:43:46 +0200 | [diff] [blame] | 182 | help="", default=False), |
Dennis Dmitriev | 2cbf235 | 2016-11-11 15:34:21 +0200 | [diff] [blame] | 183 | ct.Cfg('openstack_keystone_endpoint', ct.String(), |
Dennis Dmitriev | 6f59add | 2016-10-18 13:45:27 +0300 | [diff] [blame] | 184 | help="", default=''), |
| 185 | ] |
| 186 | |
Dennis Dmitriev | 2cbf235 | 2016-11-11 15:34:21 +0200 | [diff] [blame] | 187 | opencontrail_opts = [ |
| 188 | ct.Cfg('opencontrail_tags', ct.String(), |
| 189 | help="", default=''), |
| 190 | ct.Cfg('opencontrail_features', ct.String(), |
| 191 | help="", default=''), |
| 192 | ct.Cfg('opencontrail_prepare_tests_steps_path', ct.String(), |
| 193 | help="Path to YAML with steps to prepare contrail-tests", |
| 194 | default=_default_opencontrail_prepare_tests_steps_path), |
| 195 | ] |
Dennis Dmitriev | 6f59add | 2016-10-18 13:45:27 +0300 | [diff] [blame] | 196 | |
Tatyana Leontovich | c8b8ca2 | 2017-05-19 13:37:05 +0300 | [diff] [blame] | 197 | sl_deploy_opts = [ |
| 198 | ct.Cfg('sl_steps_path', ct.String(), |
| 199 | help="Path to YAML with steps to deploy sl", |
| 200 | default=_default_sl_prepare_tests_steps_path), |
Tatyana Leontovich | f00b234 | 2017-07-04 18:26:25 +0300 | [diff] [blame] | 201 | ct.Cfg('docker_image_alertmanager', ct.String(), |
| 202 | default='{}/openstack-docker/alertmanager:latest'.format( |
| 203 | settings.DOCKER_REGISTRY)), |
| 204 | ct.Cfg('docker_image_pushgateway', ct.String(), |
| 205 | default='{}/openstack-docker/pushgateway:latest'.format( |
| 206 | settings.DOCKER_REGISTRY)), |
| 207 | ct.Cfg('docker_image_prometheus', ct.String(), |
| 208 | default='{}/openstack-docker/prometheus:latest'.format( |
| 209 | settings.DOCKER_REGISTRY)), |
| 210 | ct.Cfg('docker_image_remote_agent', ct.String(), |
| 211 | default='{}/openstack-docker/telegraf:latest'.format( |
| 212 | settings.DOCKER_REGISTRY)), |
| 213 | ct.Cfg('docker_image_remote_storage_adapter', ct.String(), |
| 214 | default='{}/openstack-docker/remote_storage_adapter:latest'.format( |
| 215 | settings.DOCKER_REGISTRY)), |
Tatyana Leontovich | c8b8ca2 | 2017-05-19 13:37:05 +0300 | [diff] [blame] | 216 | ] |
Tatyana Leontovich | f00b234 | 2017-07-04 18:26:25 +0300 | [diff] [blame] | 217 | |
Tatyana Leontovich | c8b8ca2 | 2017-05-19 13:37:05 +0300 | [diff] [blame] | 218 | sl_opts = [ |
| 219 | ct.Cfg('sl_installed', ct.Boolean(), |
| 220 | help="", default=False), |
Tatyana Leontovich | 09b7b01 | 2017-07-10 12:53:45 +0300 | [diff] [blame] | 221 | ct.Cfg('sl_vip_host', ct.IPAddress(), |
| 222 | help="Vip address for SL services", default='0.0.0.0'), |
| 223 | ct.Cfg('sl_prometheus_port', ct.String(), |
| 224 | help="Prometheus port", default='15010'), |
| 225 | ct.Cfg('sl_prometheus_proto', ct.String(), |
| 226 | help="Proemtheus protocol", default='http'), |
Tatyana Leontovich | c8b8ca2 | 2017-05-19 13:37:05 +0300 | [diff] [blame] | 227 | ] |
| 228 | |
vrovachev | bc2f5ce | 2017-05-22 19:37:24 +0400 | [diff] [blame] | 229 | virtlet_deploy_opts = [ |
| 230 | ct.Cfg('virtlet_steps_path', ct.String(), |
| 231 | help="Path to YAML with steps to deploy virtlet", |
Victor Ryzhenkin | 655587f | 2017-05-24 20:00:07 +0400 | [diff] [blame] | 232 | default=_default_virtlet_prepare_tests_steps_path), |
| 233 | ct.Cfg('virtlet_ceph_steps_path', ct.String(), |
| 234 | help="Path to YAML with steps to deploy one-node ceph cluster for " |
| 235 | "Virtlet Flexvolumes testing", |
| 236 | default=_default_virtlet_ceph_prepare_tests_steps_path) |
vrovachev | bc2f5ce | 2017-05-22 19:37:24 +0400 | [diff] [blame] | 237 | ] |
| 238 | |
| 239 | virtlet_opts = [ |
| 240 | ct.Cfg('virtlet_installed', ct.Boolean(), |
| 241 | help="", default=False), |
Victor Ryzhenkin | 655587f | 2017-05-24 20:00:07 +0400 | [diff] [blame] | 242 | ct.Cfg('ceph_installed', ct.Boolean(), |
| 243 | help="Determine, installed one-node ceph cluster or not", |
| 244 | default=False) |
vrovachev | bc2f5ce | 2017-05-22 19:37:24 +0400 | [diff] [blame] | 245 | ] |
Tatyana Leontovich | c8b8ca2 | 2017-05-19 13:37:05 +0300 | [diff] [blame] | 246 | |
Artem Panchenko | edf70ef | 2017-06-13 09:14:34 +0300 | [diff] [blame] | 247 | k8s_deploy_opts = [ |
Artem Panchenko | 0594cd7 | 2017-06-12 13:25:26 +0300 | [diff] [blame] | 248 | ct.Cfg('k8s_steps_path', ct.String(), |
| 249 | help="Path to YAML with steps to deploy Kubernetes", |
| 250 | default=_default_k8s_steps), |
| 251 | ct.Cfg('kubernetes_admin_user', ct.String(), default='admin'), |
| 252 | ct.Cfg('kubernetes_admin_password', ct.String(), |
| 253 | default='sbPfel23ZigJF3Bm'), |
Artem Panchenko | edf70ef | 2017-06-13 09:14:34 +0300 | [diff] [blame] | 254 | ct.Cfg('kubernetes_docker_package', ct.String(), default=''), |
| 255 | ct.Cfg('kubernetes_hyperkube_image', ct.String(), |
Tatyana Leontovich | 038dc7d | 2017-09-22 16:25:59 +0300 | [diff] [blame] | 256 | default='{}/mirantis/kubernetes/hyperkube-amd64:v1.7.5-2'.format( |
Artem Panchenko | edf70ef | 2017-06-13 09:14:34 +0300 | [diff] [blame] | 257 | settings.DOCKER_REGISTRY)), |
| 258 | ct.Cfg('kubernetes_calico_image', ct.String(), |
| 259 | default='{}/mirantis/projectcalico/calico/node:latest'.format( |
| 260 | settings.DOCKER_REGISTRY)), |
| 261 | ct.Cfg('kubernetes_calicoctl_image', ct.String(), |
| 262 | default='{}/mirantis/projectcalico/calico/ctl:latest'.format( |
| 263 | settings.DOCKER_REGISTRY)), |
| 264 | ct.Cfg('kubernetes_calico_cni_image', ct.String(), |
| 265 | default='{}/mirantis/projectcalico/calico/cni:latest'.format( |
| 266 | settings.DOCKER_REGISTRY)), |
Artem Panchenko | 0594cd7 | 2017-06-12 13:25:26 +0300 | [diff] [blame] | 267 | ct.Cfg('kubernetes_netchecker_enabled', ct.Boolean(), |
| 268 | help="", default=True), |
Artem Panchenko | edf70ef | 2017-06-13 09:14:34 +0300 | [diff] [blame] | 269 | ct.Cfg('kubernetes_netchecker_agent_image', ct.String(), |
Tatyana Leontovich | f00b234 | 2017-07-04 18:26:25 +0300 | [diff] [blame] | 270 | default='mirantis/k8s-netchecker-agent:stable'), |
Artem Panchenko | edf70ef | 2017-06-13 09:14:34 +0300 | [diff] [blame] | 271 | ct.Cfg('kubernetes_netchecker_server_image', ct.String(), |
Tatyana Leontovich | f00b234 | 2017-07-04 18:26:25 +0300 | [diff] [blame] | 272 | default='mirantis/k8s-netchecker-server:stable'), |
Artem Panchenko | 501e67e | 2017-06-14 14:59:18 +0300 | [diff] [blame] | 273 | ct.Cfg('kubernetes_calico_policy_enabled', ct.Boolean(), |
| 274 | help="", default=False), |
| 275 | ct.Cfg('kubernetes_calico_policy_image', ct.String(), |
| 276 | default='calico/kube-policy-controller:v0.5.4'), |
| 277 | ct.Cfg('kubernetes_helm_enabled', ct.Boolean(), |
Tatyana Leontovich | 038dc7d | 2017-09-22 16:25:59 +0300 | [diff] [blame] | 278 | help="", default=False), |
Victor Ryzhenkin | 0bf0bb0 | 2017-07-06 18:57:05 +0400 | [diff] [blame] | 279 | ct.Cfg('kubernetes_virtlet_enabled', ct.Boolean(), |
Tatyana Leontovich | 038dc7d | 2017-09-22 16:25:59 +0300 | [diff] [blame] | 280 | help="", default=False), |
Victor Ryzhenkin | 0bf0bb0 | 2017-07-06 18:57:05 +0400 | [diff] [blame] | 281 | ct.Cfg('kubernetes_virtlet_image', ct.String(), |
Victor Ryzhenkin | 14354ac | 2017-09-27 17:42:30 +0400 | [diff] [blame] | 282 | help="", default='mirantis/virtlet:v0.7.0'), |
| 283 | ct.Cfg('kubernetes_externaldns_enabled', ct.Boolean(), |
| 284 | help="", default=False), |
| 285 | ct.Cfg('kubernetes_externaldns_image', ct.String(), |
| 286 | help="", default='mirantis/external-dns:latest'), |
| 287 | ct.Cfg('kubernetes_externaldns_provider', ct.String(), |
| 288 | help="", default='coredns'), |
| 289 | ct.Cfg('kubernetes_coredns_enabled', ct.Boolean(), |
| 290 | help="", default=False) |
Artem Panchenko | edf70ef | 2017-06-13 09:14:34 +0300 | [diff] [blame] | 291 | ] |
| 292 | |
| 293 | k8s_opts = [ |
Artem Panchenko | 0594cd7 | 2017-06-12 13:25:26 +0300 | [diff] [blame] | 294 | ct.Cfg('k8s_installed', ct.Boolean(), |
| 295 | help="", default=False), |
Artem Panchenko | edf70ef | 2017-06-13 09:14:34 +0300 | [diff] [blame] | 296 | ct.Cfg('kube_host', ct.IPAddress(), |
| 297 | help="", default='0.0.0.0'), |
| 298 | ct.Cfg('kube_apiserver_port', ct.Integer(), |
| 299 | help="", default=443), |
vrovachev | a9d0833 | 2017-06-22 20:01:59 +0400 | [diff] [blame] | 300 | ct.Cfg("k8s_conformance_run", ct.Boolean(), |
| 301 | default=False), |
| 302 | ct.Cfg('k8s_conformance_image', ct.String(), |
| 303 | default='docker-dev-virtual.docker.mirantis.net/mirantis/' |
Tatyana Leontovich | 038dc7d | 2017-09-22 16:25:59 +0300 | [diff] [blame] | 304 | 'kubernetes/k8s-conformance:v1.7.5-2_1504192939316') |
Artem Panchenko | edf70ef | 2017-06-13 09:14:34 +0300 | [diff] [blame] | 305 | ] |
| 306 | |
Dennis Dmitriev | 6f59add | 2016-10-18 13:45:27 +0300 | [diff] [blame] | 307 | _group_opts = [ |
| 308 | ('hardware', hardware_opts), |
| 309 | ('underlay', underlay_opts), |
Dennis Dmitriev | 6860ba6 | 2016-11-01 21:43:46 +0200 | [diff] [blame] | 310 | ('salt_deploy', salt_deploy_opts), |
| 311 | ('salt', salt_opts), |
| 312 | ('common_services_deploy', common_services_deploy_opts), |
| 313 | ('common_services', common_services_opts), |
Dennis Dmitriev | eac3aab | 2017-07-12 16:36:41 +0300 | [diff] [blame] | 314 | ('oss_deploy', oss_deploy_opts), |
| 315 | ('oss', oss_opts), |
Dennis Dmitriev | f3f90a5 | 2017-08-10 14:37:05 +0300 | [diff] [blame] | 316 | ('decapod_deploy', decapod_deploy_opts), |
| 317 | ('decapod', decapod_opts), |
Dennis Dmitriev | 6860ba6 | 2016-11-01 21:43:46 +0200 | [diff] [blame] | 318 | ('openstack_deploy', openstack_deploy_opts), |
| 319 | ('openstack', openstack_opts), |
Dennis Dmitriev | 2cbf235 | 2016-11-11 15:34:21 +0200 | [diff] [blame] | 320 | ('opencontrail', opencontrail_opts), |
Tatyana Leontovich | c8b8ca2 | 2017-05-19 13:37:05 +0300 | [diff] [blame] | 321 | ('stack_light', sl_opts), |
| 322 | ('sl_deploy', sl_deploy_opts), |
vrovachev | bc2f5ce | 2017-05-22 19:37:24 +0400 | [diff] [blame] | 323 | ('virtlet_deploy', virtlet_deploy_opts), |
| 324 | ('virtlet', virtlet_opts), |
Artem Panchenko | edf70ef | 2017-06-13 09:14:34 +0300 | [diff] [blame] | 325 | ('k8s_deploy', k8s_deploy_opts), |
| 326 | ('k8s', k8s_opts), |
Dennis Dmitriev | 6f59add | 2016-10-18 13:45:27 +0300 | [diff] [blame] | 327 | ] |
| 328 | |
| 329 | |
| 330 | def register_opts(config): |
| 331 | config.register_group(cfg.OptGroup(name='hardware', |
| 332 | title="Hardware settings", help="")) |
| 333 | config.register_opts(group='hardware', opts=hardware_opts) |
| 334 | |
| 335 | config.register_group(cfg.OptGroup(name='underlay', |
| 336 | title="Underlay configuration", help="")) |
| 337 | config.register_opts(group='underlay', opts=underlay_opts) |
| 338 | |
Dennis Dmitriev | 6860ba6 | 2016-11-01 21:43:46 +0200 | [diff] [blame] | 339 | config.register_group(cfg.OptGroup(name='salt_deploy', |
| 340 | title="salt deploy configuration", help="")) |
| 341 | config.register_opts(group='salt_deploy', opts=salt_deploy_opts) |
Dennis Dmitriev | 6f59add | 2016-10-18 13:45:27 +0300 | [diff] [blame] | 342 | |
Dennis Dmitriev | 6860ba6 | 2016-11-01 21:43:46 +0200 | [diff] [blame] | 343 | config.register_group(cfg.OptGroup(name='salt', |
| 344 | title="salt config and credentials", help="")) |
| 345 | config.register_opts(group='salt', opts=salt_opts) |
Dennis Dmitriev | 6f59add | 2016-10-18 13:45:27 +0300 | [diff] [blame] | 346 | |
Dennis Dmitriev | 6860ba6 | 2016-11-01 21:43:46 +0200 | [diff] [blame] | 347 | config.register_group(cfg.OptGroup(name='common_services', |
| 348 | title="Common services for Openstack", help="")) |
| 349 | config.register_opts(group='common_services', opts=common_services_opts) |
| 350 | |
Dennis Dmitriev | 6f59add | 2016-10-18 13:45:27 +0300 | [diff] [blame] | 351 | config.register_group( |
Dennis Dmitriev | 6860ba6 | 2016-11-01 21:43:46 +0200 | [diff] [blame] | 352 | cfg.OptGroup(name='common_services_deploy', |
| 353 | title="Common services for Openstack deploy config", |
| 354 | help="")) |
| 355 | config.register_opts(group='common_services_deploy', |
| 356 | opts=common_services_deploy_opts) |
| 357 | |
Dennis Dmitriev | eac3aab | 2017-07-12 16:36:41 +0300 | [diff] [blame] | 358 | config.register_group(cfg.OptGroup(name='oss', |
| 359 | title="Operational Support System Tools", help="")) |
| 360 | config.register_opts(group='oss', opts=oss_opts) |
| 361 | |
| 362 | config.register_group(cfg.OptGroup(name='oss_deploy', |
| 363 | title="OSS deploy config", help="")) |
| 364 | config.register_opts(group='oss_deploy', |
| 365 | opts=oss_deploy_opts) |
| 366 | |
Dennis Dmitriev | f3f90a5 | 2017-08-10 14:37:05 +0300 | [diff] [blame] | 367 | config.register_group(cfg.OptGroup(name='decapod', |
| 368 | title="Decapod options for Ceph", help="")) |
| 369 | config.register_opts(group='decapod', opts=decapod_opts) |
| 370 | |
| 371 | config.register_group(cfg.OptGroup(name='decapod_deploy', |
| 372 | title="Decapod deploy config", help="")) |
| 373 | config.register_opts(group='decapod_deploy', |
| 374 | opts=decapod_deploy_opts) |
| 375 | |
Dennis Dmitriev | 6860ba6 | 2016-11-01 21:43:46 +0200 | [diff] [blame] | 376 | config.register_group(cfg.OptGroup(name='openstack', |
| 377 | title="Openstack config and credentials", help="")) |
| 378 | config.register_opts(group='openstack', opts=openstack_opts) |
| 379 | |
| 380 | config.register_group( |
| 381 | cfg.OptGroup(name='openstack_deploy', |
Dennis Dmitriev | 6f59add | 2016-10-18 13:45:27 +0300 | [diff] [blame] | 382 | title="Openstack deploy config and credentials", |
| 383 | help="")) |
Dennis Dmitriev | 6860ba6 | 2016-11-01 21:43:46 +0200 | [diff] [blame] | 384 | config.register_opts(group='openstack_deploy', opts=openstack_deploy_opts) |
Dennis Dmitriev | 2cbf235 | 2016-11-11 15:34:21 +0200 | [diff] [blame] | 385 | |
| 386 | config.register_group(cfg.OptGroup(name='opencontrail', |
| 387 | title="Options for Juniper contrail-tests", help="")) |
| 388 | config.register_opts(group='opencontrail', opts=opencontrail_opts) |
Dmitry Tyzhnenko | 8f6a63e | 2017-09-05 15:37:23 +0300 | [diff] [blame] | 389 | config.register_group( |
| 390 | cfg.OptGroup(name='stack_light', |
| 391 | title="StackLight config and credentials", help="")) |
Tatyana Leontovich | 5acc82a | 2017-05-23 15:41:35 +0300 | [diff] [blame] | 392 | config.register_opts(group='stack_light', opts=sl_opts) |
Tatyana Leontovich | c8b8ca2 | 2017-05-19 13:37:05 +0300 | [diff] [blame] | 393 | config.register_group( |
| 394 | cfg.OptGroup(name='sl_deploy', |
Dennis Dmitriev | f3f90a5 | 2017-08-10 14:37:05 +0300 | [diff] [blame] | 395 | title="SL deploy config and credentials", |
| 396 | help="")) |
Tatyana Leontovich | c8b8ca2 | 2017-05-19 13:37:05 +0300 | [diff] [blame] | 397 | config.register_opts(group='sl_deploy', opts=sl_deploy_opts) |
vrovachev | bc2f5ce | 2017-05-22 19:37:24 +0400 | [diff] [blame] | 398 | config.register_group(cfg.OptGroup(name='virtlet_deploy', |
| 399 | title='Virtlet deploy config', help="")) |
| 400 | config.register_opts(group='virtlet_deploy', opts=virtlet_deploy_opts) |
| 401 | config.register_group(cfg.OptGroup(name='virtlet', |
| 402 | title='Virtlet config', help="")) |
| 403 | config.register_opts(group='virtlet', opts=virtlet_opts) |
Artem Panchenko | edf70ef | 2017-06-13 09:14:34 +0300 | [diff] [blame] | 404 | |
| 405 | config.register_group(cfg.OptGroup(name='k8s_deploy', |
| 406 | title="K8s deploy configuration")) |
| 407 | config.register_opts(group='k8s_deploy', opts=k8s_deploy_opts) |
| 408 | |
| 409 | config.register_group(cfg.OptGroup(name='k8s', |
| 410 | title="K8s config and credentials")) |
| 411 | config.register_opts(group='k8s', opts=k8s_opts) |
Dennis Dmitriev | 6f59add | 2016-10-18 13:45:27 +0300 | [diff] [blame] | 412 | return config |
| 413 | |
| 414 | |
| 415 | def load_config(config_files): |
| 416 | config = cfg.CONF |
| 417 | register_opts(config) |
| 418 | config(args=[], default_config_files=config_files) |
| 419 | return config |
| 420 | |
| 421 | |
| 422 | def reload_snapshot_config(config, test_config_path): |
| 423 | """Reset config to the state from test_config file""" |
| 424 | config(args=[], default_config_files=[test_config_path]) |
| 425 | return config |
| 426 | |
| 427 | |
| 428 | def list_opts(): |
| 429 | """Return a list of oslo.config options available in the tcp_tests. |
| 430 | """ |
| 431 | return [(group, copy.deepcopy(opts)) for group, opts in _group_opts] |
| 432 | |
| 433 | |
| 434 | def list_current_opts(config): |
| 435 | """Return a list of oslo.config options available in the tcp_tests. |
| 436 | """ |
| 437 | result_opts = [] |
| 438 | for group, opts in _group_opts: |
| 439 | current_opts = copy.deepcopy(opts) |
| 440 | for opt in current_opts: |
| 441 | if hasattr(config, group): |
| 442 | if hasattr(config[group], opt.name): |
| 443 | opt.default = getattr(config[group], opt.name) |
| 444 | result_opts.append((group, current_opts)) |
| 445 | return result_opts |
| 446 | |
| 447 | |
| 448 | def save_config(config, snapshot_name, env_name=None): |
| 449 | if env_name is None: |
| 450 | env_name = 'config' |
| 451 | test_config_path = os.path.join( |
| 452 | settings.LOGS_DIR, '{0}_{1}.ini'.format(env_name, snapshot_name)) |
| 453 | |
| 454 | with open(test_config_path, 'w') as output_file: |
| 455 | formatter = generator._OptFormatter(output_file=output_file) |
| 456 | for group, opts in list_current_opts(config): |
| 457 | formatter.format_group(group) |
| 458 | for opt in opts: |
| 459 | formatter.format(opt, group, minimal=True) |
| 460 | formatter.write('\n') |
| 461 | formatter.write('\n') |