| # Copyright 2016 Mirantis, Inc. |
| # |
| # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| # not use this file except in compliance with the License. You may obtain |
| # a copy of the License at |
| # |
| # http://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, software |
| # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| # License for the specific language governing permissions and limitations |
| # under the License. |
| import copy |
| import os |
| import pkg_resources |
| |
| from oslo_config import cfg |
| from oslo_config import generator |
| |
| from tcp_tests.helpers import ext |
| from tcp_tests.helpers import oslo_cfg_types as ct |
| from tcp_tests import settings |
| |
| print("\n" + "-" * 10 + " Initialize oslo.config variables with defaults" |
| " from environment" + "-" * 10) |
| |
| _default_conf = pkg_resources.resource_filename( |
| __name__, 'templates/{0}/underlay.yaml'.format(settings.LAB_CONFIG_NAME)) |
| |
| _default_salt_steps = pkg_resources.resource_filename( |
| __name__, 'templates/{0}/salt.yaml'.format(settings.LAB_CONFIG_NAME)) |
| _default_environment_template_dir = pkg_resources.resource_filename( |
| __name__, 'environment/') |
| _default_templates_dir = pkg_resources.resource_filename( |
| __name__, 'templates/') |
| _default_core_steps = pkg_resources.resource_filename( |
| __name__, |
| 'templates/{0}/core.yaml'.format( |
| settings.LAB_CONFIG_NAME)) |
| _default_oss_steps = pkg_resources.resource_filename( |
| __name__, |
| 'templates/{0}/oss.yaml'.format( |
| settings.LAB_CONFIG_NAME)) |
| _default_drivetrain_steps = pkg_resources.resource_filename( |
| __name__, |
| 'templates/{0}/drivetrain.yaml'.format( |
| settings.LAB_CONFIG_NAME)) |
| _default_decapod_steps = pkg_resources.resource_filename( |
| __name__, |
| 'templates/{0}/decapod.yaml'.format( |
| settings.LAB_CONFIG_NAME)) |
| _default_openstack_steps = pkg_resources.resource_filename( |
| __name__, 'templates/{0}/openstack.yaml'.format( |
| settings.LAB_CONFIG_NAME)) |
| _default_openstack_resources_steps = pkg_resources.resource_filename( |
| __name__, 'templates/{0}/post_openstack.yaml'.format( |
| settings.LAB_CONFIG_NAME)) |
| _default_opencontrail_prepare_tests_steps_path = \ |
| pkg_resources.resource_filename( |
| __name__, 'templates/{0}/opencontrail.yaml'.format( |
| settings.LAB_CONFIG_NAME)) |
| _default_sl_prepare_tests_steps_path = pkg_resources.resource_filename( |
| __name__, 'templates/{0}/sl.yaml'.format( |
| settings.LAB_CONFIG_NAME)) |
| _default_ceph_prepare_tests_steps_path = pkg_resources.resource_filename( |
| __name__, 'templates/{0}/ceph.yaml'.format( |
| settings.LAB_CONFIG_NAME)) |
| _default_k8s_steps = pkg_resources.resource_filename( |
| __name__, 'templates/{0}/k8s.yaml'.format( |
| settings.LAB_CONFIG_NAME)) |
| _default_k8s_update_steps = pkg_resources.resource_filename( |
| __name__, 'templates/{0}/k8s-update.yaml'.format( |
| settings.LAB_CONFIG_NAME)) |
| _default_net_mgm = os.environ.get("NET_MGMT", "admin-pool01") |
| _default_configure_steps = pkg_resources.resource_filename( |
| __name__, 'templates/{0}/cfg01_configure.yaml'.format( |
| settings.LAB_CONFIG_NAME)) |
| # _default_cluster_maas_config = pkg_resources.resource_filename( |
| # __name__, 'templates/{0}/cluster_infra_maas.yml'.format( |
| # settings.LAB_CONFIG_NAME)) |
| _default_cluster_maas_config = 'cluster_infra_maas.yml' |
| |
| hardware_opts = [ |
| ct.Cfg('manager', ct.String(), |
| help="Hardware manager name", default="devops"), |
| ct.Cfg('conf_path', ct.String(), |
| help="Hardware config file", default=_default_conf), |
| ct.Cfg('current_snapshot', ct.String(), |
| help="Latest environment status name", |
| default=ext.SNAPSHOT.hardware), |
| ] |
| |
| |
| underlay_opts = [ |
| ct.Cfg('ssh', ct.JSONList(), |
| help="""SSH Settings for Underlay: [{ |
| 'node_name': node1, |
| 'minion_id': node1.local, |
| 'roles': ['salt-master', 'salt-minion', ], |
| 'host': hostname, |
| 'login': login, |
| 'password': password, |
| 'address_pool': (optional), |
| 'port': (optional), |
| 'keys': [(optional)], |
| }, ...]""", default=[]), |
| ct.Cfg('roles', ct.JSONList(), |
| help="Node roles managed by underlay in the environment", |
| default=[ext.UNDERLAY_NODE_ROLES.salt_master, |
| ext.UNDERLAY_NODE_ROLES.salt_minion, |
| ext.UNDERLAY_NODE_ROLES.k8s_controller]), |
| ct.Cfg('bootstrap_timeout', ct.Integer(), |
| help="Timeout of waiting SSH for nodes with specified roles", |
| default=600), |
| ct.Cfg('nameservers', ct.JSONList(), |
| help="IP addresses of DNS servers", |
| default=[]), |
| ct.Cfg('upstream_dns_servers', ct.JSONList(), |
| help="IP addresses of upstream DNS servers (dnsmasq)", |
| default=[]), |
| ct.Cfg('address_pools', ct.JSONDict(), |
| help="""Address pools (dynamically) allocated for the environment. |
| May be used to determine CIDR for a specific network from |
| tests or during the deployment process. |
| {'pool_name1': '<cidr>', 'pool_name2': '<cidr>', ...}""", |
| default={}), |
| ct.Cfg('dhcp_ranges', ct.JSONDict(), |
| help="""DHCP ranges allocated for the address pools. |
| This is extended object comparing to 'address_pools'. |
| May be used to determine DHCP range start/end/gateway for a |
| specific network from tests or during the deployment |
| process. |
| {'pool_name1': {'cidr': 'n.n.n.n/m', |
| 'start': 'x.x.x.x', |
| 'end': 'y.y.y.y', |
| 'gateway': 'z.z.z.z'}, |
| 'pool_name2': {'cidr': 'n.n.n.n/m', |
| 'start': x.x.x.x, |
| 'end': 'y.y.y.y', |
| 'gateway': 'z.z.z.z'}, |
| ...}""", |
| default={}), |
| ct.Cfg('ssh_keys', ct.JSONList(), default=[], |
| help="SSH key pair(s) for root. If the option is left empty, " |
| "then a key pair will be generated automatically"), |
| ct.Cfg('ssh_key_file', ct.String(), default=os.path.abspath('./id_rsa'), |
| help='Path (local) to file with private key authorized on nodes'), |
| ct.Cfg('net_mgmt', ct.String(), default=_default_net_mgm) |
| ] |
| |
| |
| salt_deploy_opts = [ |
| ct.Cfg('salt_steps_path', ct.String(), |
| help="Path to YAML with steps to deploy salt", |
| default=_default_salt_steps), |
| ct.Cfg('environment_template_dir', ct.String(), |
| help="Path to directory with Environment template and inventory", |
| default=_default_environment_template_dir), |
| ct.Cfg('templates_dir', ct.String(), |
| help="Path to directory with templates", |
| default=_default_templates_dir), |
| ct.Cfg('salt_roles', ct.JSONList(), |
| help="Node roles to install salt-minions and manage by salt", |
| default=[ext.UNDERLAY_NODE_ROLES.salt_master, |
| ext.UNDERLAY_NODE_ROLES.salt_minion, |
| ext.UNDERLAY_NODE_ROLES.k8s_controller]), |
| ] |
| salt_opts = [ |
| ct.Cfg('salt_master_host', ct.IPAddress(), |
| help="", default='0.0.0.0'), |
| ct.Cfg('salt_master_port', ct.String(), |
| help="", default='6969'), |
| ] |
| |
| core_deploy_opts = [ |
| ct.Cfg('core_steps_path', ct.String(), |
| help="Path to YAML with steps to deploy common services", |
| default=_default_core_steps), |
| ] |
| |
| core_opts = [ |
| ct.Cfg('core_installed', ct.Boolean(), |
| help="", default=False), |
| ] |
| |
| oss_deploy_opts = [ |
| ct.Cfg('oss_steps_path', ct.String(), |
| help="Path to YAML with steps to deploy OSS Tools", |
| default=_default_oss_steps), |
| ] |
| |
| oss_opts = [ |
| ct.Cfg('oss_installed', ct.Boolean(), |
| help="", default=False), |
| ] |
| |
| drivetrain_deploy_opts = [ |
| ct.Cfg('drivetrain_steps_path', ct.String(), |
| help="Path to YAML with steps to deploy Drivetrain", |
| default=_default_drivetrain_steps), |
| ] |
| |
| drivetrain_opts = [ |
| ct.Cfg('drivetrain_installed', ct.Boolean(), |
| help="", default=False), |
| ] |
| |
| decapod_deploy_opts = [ |
| ct.Cfg('decapod_steps_path', ct.String(), |
| help="Path to YAML with steps to deploy Ceph with Decapod", |
| default=_default_decapod_steps), |
| ] |
| |
| decapod_opts = [ |
| ct.Cfg('decapod_installed', ct.Boolean(), |
| help="", default=False), |
| ] |
| |
| openstack_deploy_opts = [ |
| ct.Cfg('openstack_steps_path', ct.String(), |
| help="Path to YAML with steps to deploy openstack", |
| default=_default_openstack_steps), |
| ct.Cfg('openstack_resources_steps_path', ct.String(), |
| help="Path to YAML with steps to deploy openstack", |
| default=_default_openstack_resources_steps), |
| ct.Cfg('horizon_host', ct.IPAddress(), |
| help="", default='0.0.0.0'), |
| ct.Cfg('horizon_port', ct.String(), |
| help="", default='5000'), |
| ct.Cfg('horizon_user', ct.String(), |
| help="", default='admin'), |
| ct.Cfg('horizon_password', ct.String(), |
| help="", default='workshop'), |
| ] |
| openstack_opts = [ |
| ct.Cfg('openstack_installed', ct.Boolean(), |
| help="", default=False), |
| ct.Cfg('openstack_keystone_endpoint', ct.String(), |
| help="", default=''), |
| ct.Cfg('horizon_check', ct.Boolean(), |
| help="", default=False), |
| ] |
| |
| opencontrail_opts = [ |
| ct.Cfg('opencontrail_tags', ct.String(), |
| help="", default=''), |
| ct.Cfg('opencontrail_features', ct.String(), |
| help="", default=''), |
| ct.Cfg('opencontrail_prepare_tests_steps_path', ct.String(), |
| help="Path to YAML with steps to prepare contrail-tests", |
| default=_default_opencontrail_prepare_tests_steps_path), |
| ] |
| |
| sl_deploy_opts = [ |
| ct.Cfg('sl_steps_path', ct.String(), |
| help="Path to YAML with steps to deploy sl", |
| default=_default_sl_prepare_tests_steps_path), |
| ct.Cfg('docker_image_alertmanager', ct.String(), |
| default='{0}/openstack-docker/alertmanager:{1}'.format( |
| settings.DOCKER_REGISTRY, settings.DOCKER_IMAGES_SL_TAG)), |
| ct.Cfg('docker_image_alerta', ct.String(), |
| default='{0}/mirantis/external/alerta-web:{1}'.format( |
| settings.DOCKER_REGISTRY, settings.DOCKER_IMAGES_SL_TAG)), |
| ct.Cfg('docker_image_pushgateway', ct.String(), |
| default='{0}/openstack-docker/pushgateway:{1}'.format( |
| settings.DOCKER_REGISTRY, settings.DOCKER_IMAGES_SL_TAG)), |
| ct.Cfg('docker_image_prometheus', ct.String(), |
| default='{0}/openstack-docker/prometheus:{1}'.format( |
| settings.DOCKER_REGISTRY, settings.DOCKER_IMAGES_SL_TAG)), |
| ct.Cfg('docker_image_remote_agent', ct.String(), |
| default='{0}/openstack-docker/telegraf:{1}'.format( |
| settings.DOCKER_REGISTRY, settings.DOCKER_IMAGES_SL_TAG)), |
| ct.Cfg('docker_image_remote_storage_adapter', ct.String(), |
| default='{0}/openstack-docker/remote_storage_adapter:{1}'.format( |
| settings.DOCKER_REGISTRY, settings.DOCKER_IMAGES_SL_TAG)), |
| ct.Cfg('docker_image_prometheus_relay', ct.String(), |
| default='{0}/openstack-docker/prometheus_relay:{1}'.format( |
| settings.DOCKER_REGISTRY, settings.DOCKER_IMAGES_SL_TAG)), |
| ct.Cfg('docker_image_grafana', ct.String(), |
| default='{0}/mirantis/external/grafana:{1}'.format( |
| settings.DOCKER_REGISTRY, settings.DOCKER_IMAGES_SL_TAG)), |
| # SalesForce connection options for pushkin |
| ct.Cfg('sfdc_sandbox_enabled', ct.String(), default='False'), |
| ct.Cfg('sfdc_auth_url', ct.String(), default=''), |
| ct.Cfg('sfdc_username', ct.String(), default=''), |
| ct.Cfg('sfdc_password', ct.String(), default=''), |
| ct.Cfg('sfdc_consumer_key', ct.String(), default=''), |
| ct.Cfg('sfdc_consumer_secret', ct.String(), default=''), |
| ct.Cfg('sfdc_organization_id', ct.String(), default=''), |
| ] |
| |
| sl_opts = [ |
| ct.Cfg('stacklight_installed', ct.Boolean(), |
| help="", default=False), |
| ct.Cfg('sl_version', ct.String(), |
| help="StackLight version. Could be 1 or 2", default=''), |
| ct.Cfg('sl_vip_host', ct.IPAddress(), |
| help="Vip address for SL services", default='0.0.0.0'), |
| ct.Cfg('sl_prometheus_port', ct.String(), |
| help="Prometheus port", default='15010'), |
| ct.Cfg('sl_prometheus_proto', ct.String(), |
| help="Proemtheus protocol", default='http'), |
| ] |
| |
| ceph_deploy_opts = [ |
| ct.Cfg('ceph_steps_path', ct.String(), |
| help="Path to YAML with steps to deploy sl", |
| default=_default_ceph_prepare_tests_steps_path), |
| ] |
| |
| ceph_opts = [ |
| ct.Cfg('ceph_installed', ct.Boolean(), |
| help="", default=False), |
| ] |
| |
| k8s_deploy_opts = [ |
| ct.Cfg('k8s_steps_path', ct.String(), |
| help="Path to YAML with steps to deploy Kubernetes", |
| default=_default_k8s_steps), |
| ct.Cfg('k8s_update_steps_path', ct.String(), |
| help="Path to YAML with steps to update Kubernetes", |
| default=_default_k8s_update_steps), |
| ct.Cfg('kubernetes_admin_user', ct.String(), default='admin'), |
| ct.Cfg('kubernetes_admin_password', ct.String(), |
| default='sbPfel23ZigJF3Bm'), |
| ct.Cfg('kubernetes_docker_package', ct.String(), default=''), |
| ct.Cfg('kubernetes_hyperkube_image', ct.String(), |
| default='{}/mirantis/kubernetes/hyperkube-amd64:v1.11.3-2'.format( |
| settings.DOCKER_REGISTRY)), |
| ct.Cfg('kubernetes_pause_image', ct.String(), |
| default='{}/mirantis/kubernetes/pause-amd64:v1.11.3-2'.format( |
| settings.DOCKER_REGISTRY)), |
| ct.Cfg('kubernetes_calico_image', ct.String(), |
| default='{}/mirantis/projectcalico/calico/node:v3.1.3'.format( |
| settings.DOCKER_REGISTRY)), |
| ct.Cfg('kubernetes_calico_calicoctl_image', ct.String(), |
| default='{}/mirantis/projectcalico/calico/ctl:v3.1.3'.format( |
| settings.DOCKER_REGISTRY)), |
| ct.Cfg('kubernetes_calico_cni_image', ct.String(), |
| default='{}/mirantis/projectcalico/calico/cni:v3.1.3'.format( |
| settings.DOCKER_REGISTRY)), |
| ct.Cfg('kubernetes_calico_kube_controllers_image', ct.String(), |
| default='{}/mirantis/projectcalico/calico/kube-controllers:' |
| 'v3.1.3'.format(settings.DOCKER_REGISTRY)), |
| ct.Cfg('kubernetes_netchecker_enabled', ct.Boolean(), |
| help="", default=True), |
| ct.Cfg('kubernetes_netchecker_agent_image', ct.String(), |
| default='mirantis/k8s-netchecker-agent:v1.2.2'), |
| ct.Cfg('kubernetes_netchecker_server_image', ct.String(), |
| default='mirantis/k8s-netchecker-server:v1.2.2'), |
| ct.Cfg('kubernetes_calico_policy_enabled', ct.Boolean(), |
| help="", default=False), |
| ct.Cfg('kubernetes_helm_enabled', ct.Boolean(), |
| help="", default=False), |
| ct.Cfg('kubernetes_virtlet_enabled', ct.Boolean(), |
| help="", default=False), |
| ct.Cfg('kubernetes_virtlet_image', ct.String(), |
| help="", default='mirantis/virtlet:v1.4.1'), |
| ct.Cfg('kubernetes_dns', ct.Boolean(), |
| help="", default=True), |
| ct.Cfg('kubernetes_externaldns_enabled', ct.Boolean(), |
| help="", default=False), |
| ct.Cfg('kubernetes_externaldns_image', ct.String(), |
| help="", default='{}/mirantis/external-dns/external-dns:' |
| 'v0.5.6-2'.format(settings.DOCKER_REGISTRY)), |
| ct.Cfg('kubernetes_externaldns_provider', ct.String(), |
| help="", default='coredns'), |
| ct.Cfg('kubernetes_coredns_enabled', ct.Boolean(), |
| help="", default=True), |
| ct.Cfg('kubernetes_metallb_enabled', ct.Boolean(), |
| help="", default=False), |
| ct.Cfg('kubernetes_ingressnginx_enabled', ct.Boolean(), |
| help="", default=False), |
| ct.Cfg('kubelet_fail_on_swap', ct.Boolean(), |
| help="", default=False) |
| ] |
| |
| k8s_opts = [ |
| ct.Cfg('k8s_installed', ct.Boolean(), |
| help="", default=False), |
| ct.Cfg('kube_host', ct.IPAddress(), |
| help="", default='0.0.0.0'), |
| ct.Cfg('kube_apiserver_port', ct.Integer(), |
| help="", default=443), |
| ct.Cfg("k8s_conformance_run", ct.Boolean(), |
| default=False), |
| ct.Cfg("run_extended_virtlet_conformance", ct.Boolean(), |
| default=False), |
| ct.Cfg('k8s_conformance_image', ct.String(), |
| default='docker-prod-virtual.docker.mirantis.net/mirantis/' |
| 'kubernetes/k8s-conformance:v1.11.3-2'), |
| ct.Cfg('k8s_update_chain', ct.String(), |
| default='v1.9.8-4 v1.10.4-4 v1.11.3-2') |
| ] |
| |
| day1_cfg_config_opts = [ |
| ct.Cfg('configure_steps_path', ct.String(), |
| help="Path to YAML with steps to config cfg01 node", |
| default=_default_configure_steps), |
| ct.Cfg('environment_template_dir', ct.String(), |
| help="Path to directory with Environment template and inventory", |
| default=_default_environment_template_dir), |
| ct.Cfg('templates_dir', ct.String(), |
| help="Path to directory with templates", |
| default=_default_templates_dir), |
| ct.Cfg('cluster_maas_config', ct.String(), |
| help="Path to maas class yaml file for cfg node", |
| default=_default_cluster_maas_config), |
| ct.Cfg('maas_machines_macs', ct.JSONDict(), |
| help="""MAC of machines interfaces for maas config: |
| 'parameters': { |
| 'maas' : { |
| 'region' : { |
| 'machines': { |
| 'ctl01': { |
| 'interface': { |
| 'mac': 'aa:bb:cc:dd:ee:ff' |
| } |
| } |
| '...': { |
| 'interface': { |
| 'mac': 'aa:bb:cc:dd:ee:ff' |
| } |
| } |
| }}}}""", default={}), |
| ] |
| |
| _group_opts = [ |
| ('hardware', hardware_opts), |
| ('underlay', underlay_opts), |
| ('salt_deploy', salt_deploy_opts), |
| ('salt', salt_opts), |
| ('core_deploy', core_deploy_opts), |
| ('core', core_opts), |
| ('oss_deploy', oss_deploy_opts), |
| ('oss', oss_opts), |
| ('drivetrain_deploy', drivetrain_deploy_opts), |
| ('drivetrain', drivetrain_opts), |
| ('decapod_deploy', decapod_deploy_opts), |
| ('decapod', decapod_opts), |
| ('openstack_deploy', openstack_deploy_opts), |
| ('openstack', openstack_opts), |
| ('opencontrail', opencontrail_opts), |
| ('stack_light', sl_opts), |
| ('sl_deploy', sl_deploy_opts), |
| ('ceph', ceph_opts), |
| ('ceph_deploy', ceph_deploy_opts), |
| ('k8s_deploy', k8s_deploy_opts), |
| ('k8s', k8s_opts), |
| ('day1_cfg_config', day1_cfg_config_opts), |
| ('day1_underlay', underlay_opts), |
| ] |
| |
| |
| def register_opts(config): |
| config.register_group(cfg.OptGroup(name='hardware', |
| title="Hardware settings", help="")) |
| config.register_opts(group='hardware', opts=hardware_opts) |
| |
| config.register_group(cfg.OptGroup(name='underlay', |
| title="Underlay configuration", help="")) |
| config.register_opts(group='underlay', opts=underlay_opts) |
| |
| config.register_group(cfg.OptGroup(name='salt_deploy', |
| title="salt deploy configuration", help="")) |
| config.register_opts(group='salt_deploy', opts=salt_deploy_opts) |
| |
| config.register_group(cfg.OptGroup(name='salt', |
| title="salt config and credentials", help="")) |
| config.register_opts(group='salt', opts=salt_opts) |
| |
| config.register_group(cfg.OptGroup(name='core', |
| title="Common services for Openstack", help="")) |
| config.register_opts(group='core', opts=core_opts) |
| |
| config.register_group( |
| cfg.OptGroup(name='core_deploy', |
| title="Common services for Openstack deploy config", |
| help="")) |
| config.register_opts(group='core_deploy', |
| opts=core_deploy_opts) |
| |
| config.register_group(cfg.OptGroup(name='oss', |
| title="Operational Support System Tools", help="")) |
| config.register_opts(group='oss', opts=oss_opts) |
| |
| config.register_group(cfg.OptGroup(name='oss_deploy', |
| title="OSS deploy config", help="")) |
| config.register_opts(group='oss_deploy', |
| opts=oss_deploy_opts) |
| |
| config.register_group(cfg.OptGroup(name='drivetrain', |
| title="Drivetrain Tools", help="")) |
| config.register_opts(group='drivetrain', opts=drivetrain_opts) |
| |
| config.register_group(cfg.OptGroup(name='drivetrain_deploy', |
| title="Drivetrain deploy config", help="")) |
| config.register_opts(group='drivetrain_deploy', |
| opts=drivetrain_deploy_opts) |
| |
| config.register_group(cfg.OptGroup(name='decapod', |
| title="Decapod options for Ceph", help="")) |
| config.register_opts(group='decapod', opts=decapod_opts) |
| |
| config.register_group(cfg.OptGroup(name='decapod_deploy', |
| title="Decapod deploy config", help="")) |
| config.register_opts(group='decapod_deploy', |
| opts=decapod_deploy_opts) |
| |
| config.register_group(cfg.OptGroup(name='openstack', |
| title="Openstack config and credentials", help="")) |
| config.register_opts(group='openstack', opts=openstack_opts) |
| |
| config.register_group( |
| cfg.OptGroup(name='openstack_deploy', |
| title="Openstack deploy config and credentials", |
| help="")) |
| config.register_opts(group='openstack_deploy', opts=openstack_deploy_opts) |
| |
| config.register_group(cfg.OptGroup(name='opencontrail', |
| title="Options for Juniper contrail-tests", help="")) |
| config.register_opts(group='opencontrail', opts=opencontrail_opts) |
| config.register_group( |
| cfg.OptGroup(name='stack_light', |
| title="StackLight config and credentials", help="")) |
| config.register_opts(group='stack_light', opts=sl_opts) |
| config.register_group( |
| cfg.OptGroup(name='sl_deploy', |
| title="SL deploy config and credentials", |
| help="")) |
| config.register_opts(group='sl_deploy', opts=sl_deploy_opts) |
| |
| config.register_group(cfg.OptGroup(name='k8s_deploy', |
| title="K8s deploy configuration")) |
| config.register_opts(group='k8s_deploy', opts=k8s_deploy_opts) |
| |
| config.register_group(cfg.OptGroup(name='k8s', |
| title="K8s config and credentials")) |
| config.register_opts(group='k8s', opts=k8s_opts) |
| config.register_group(cfg.OptGroup(name='ceph', |
| title="ceph config", help="")) |
| config.register_opts(group='ceph', opts=ceph_opts) |
| |
| config.register_group( |
| cfg.OptGroup(name='ceph_deploy', |
| title="Ceph deploy config ", |
| help="")) |
| config.register_opts(group='ceph_deploy', opts=ceph_deploy_opts) |
| |
| config.register_group(cfg.OptGroup(name='day1_cfg_config', |
| title="Day01 config node configuration", help="")) |
| config.register_opts(group='day1_cfg_config', opts=day1_cfg_config_opts) |
| |
| config.register_group(cfg.OptGroup(name='day1_underlay', |
| title="Day01 underlay configuration", help="")) |
| config.register_opts(group='day1_underlay', opts=underlay_opts) |
| |
| return config |
| |
| |
| def load_config(config_files): |
| config = cfg.CONF |
| register_opts(config) |
| config(args=[], default_config_files=config_files) |
| return config |
| |
| |
| def reload_snapshot_config(config, test_config_path): |
| """Reset config to the state from test_config file""" |
| config(args=[], default_config_files=[test_config_path]) |
| return config |
| |
| |
| def list_opts(): |
| """Return a list of oslo.config options available in the tcp_tests. |
| """ |
| return [(group, copy.deepcopy(opts)) for group, opts in _group_opts] |
| |
| |
| def list_current_opts(config): |
| """Return a list of oslo.config options available in the tcp_tests. |
| """ |
| result_opts = [] |
| for group, opts in _group_opts: |
| current_opts = copy.deepcopy(opts) |
| for opt in current_opts: |
| if hasattr(config, group): |
| if hasattr(config[group], opt.name): |
| opt.default = getattr(config[group], opt.name) |
| result_opts.append((group, current_opts)) |
| return result_opts |
| |
| |
| def save_config(config, snapshot_name, env_name=None): |
| if env_name is None: |
| env_name = 'config' |
| test_config_path = os.path.join( |
| settings.LOGS_DIR, '{0}_{1}.ini'.format(env_name, snapshot_name)) |
| |
| with open(test_config_path, 'w') as output_file: |
| formatter = generator._OptFormatter(output_file=output_file) |
| for group, opts in list_current_opts(config): |
| formatter.format_group(group) |
| for opt in opts: |
| formatter.format(opt, group, minimal=True) |
| formatter.write('\n') |
| formatter.write('\n') |