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