fuel-ostf/fuel_plugin/ostf_adapter/config.py
Artem Roma 50095b1bdc Disable ssl certificate verification for ostf_adapter utils
Now there is possibility to enable ssl for nginx by adding 'flat_https'
option to fuel settings (/etc/fuel/astute.yaml on the master node).
Since ostf adapter performs http requests to nailgun in order to obtain
particular info from it, ssl cerificate that is used by nginx should be
processed in the case, but since the certificate is self-signed, its
verification has to be disabled, otherwise this action will fail.

Change-Id: I98733ba57e87c3b59aeddc4f1e601a5518aeb439
Closes-Bug: #1530318
2016-01-20 15:24:47 +02:00

107 lines
3.1 KiB
Python

# Copyright 2015 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 logging
import os
from fuel_plugin.ostf_adapter import mixins
try:
from oslo.config import cfg
except ImportError:
from oslo_config import cfg
LOG = logging.getLogger(__name__)
adapter_group = cfg.OptGroup(name='adapter',
title='Adapter Options')
adapter_opts = [
cfg.StrOpt('server_host',
default='127.0.0.1',
help="adapter host"),
cfg.IntOpt('server_port',
default=8777,
help="Port number"),
cfg.StrOpt('dbpath',
default='postgresql+psycopg2://ostf:ostf@localhost/ostf',
help=""),
cfg.StrOpt('lock_dir',
default='/var/lock',
help=""),
cfg.StrOpt('nailgun_host',
default='127.0.0.1',
help=""),
cfg.StrOpt('nailgun_port',
default='8000',
help=""),
cfg.StrOpt('log_file',
default='/var/log/ostf.log',
help=""),
cfg.BoolOpt('auth_enable',
default=False,
help="Set True to enable auth."),
]
cli_opts = [
cfg.BoolOpt('debug', default=False),
cfg.BoolOpt('clear-db', default=False),
cfg.BoolOpt('after-initialization-environment-hook', default=False),
cfg.StrOpt('debug_tests')
]
cfg.CONF.register_cli_opts(cli_opts)
cfg.CONF.register_opts(adapter_opts, group='adapter')
DEFAULT_CONFIG_DIR = os.path.join(os.path.abspath(
os.path.dirname(__file__)), '/etc')
DEFAULT_CONFIG_FILE = "ostf.conf"
def init_config(args=[]):
config_files = []
failsafe_path = "/etc/ostf/" + DEFAULT_CONFIG_FILE
# Environment variables override defaults...
custom_config = os.environ.get('CUSTOM_OSTF_CONFIG')
if custom_config:
path = custom_config
else:
conf_dir = os.environ.get('OSTF_CONFIG_DIR',
DEFAULT_CONFIG_DIR)
conf_file = os.environ.get('OSTF_CONFIG', DEFAULT_CONFIG_FILE)
path = os.path.join(conf_dir, conf_file)
if not (os.path.isfile(path)
or 'OSTF_CONFIG_DIR' in os.environ
or 'OSTF_CONFIG' in os.environ):
path = failsafe_path
if not os.path.exists(path):
msg = "Config file {0} not found".format(path)
LOG.warning(msg)
# No need to fail here! If config doesnot exist defaults are used
else:
config_files.append(path)
cfg.CONF(args, project='fuel_ostf', default_config_files=config_files,
version=mixins.get_version_string())