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