def load_yaml_config(yaml_path, debug=None): def import_legacy(cloud, cfg): cred = cloud.setdefault("credential", {}) cred["auth_url"] = cfg.auth_url cred["username"] = cfg.user cred["password"] = cfg.password cred["region_name"] = cfg.region cred["https_insecure"] = cfg.insecure cred["https_cacert"] = cfg.cacert scope = cloud.setdefault("scope", {}) scope["project_name"] = cfg.tenant ssh = cloud.setdefault("ssh", {}) ssh["gateway"] = cfg.ssh_host ssh["username"] = cfg.ssh_user ssh["sudo_password"] = cfg.ssh_sudo_password ssh["connection_attempts"] = cfglib.CONF.migrate.ssh_connection_attempts log.configure_logging(log_config="configs/logging_config.yaml", debug=debug, forward_stdout=False) prev_legacy_config_path = None with open(yaml_path, "r") as config_file: cfg = yaml.load(config_file) clouds = cfg.setdefault("clouds", {}) for value in clouds.values(): if "legacy" not in value: continue legacy_config_path, section = value.pop("legacy").split(":") if prev_legacy_config_path != legacy_config_path: init(legacy_config_path, debug) import_legacy(value, getattr(cfglib.CONF, section)) return cfg
def load_yaml_config(yaml_path, debug=None): def import_legacy(cloud, cfg): cred = cloud.setdefault('credential', {}) cred['auth_url'] = cfg.auth_url cred['username'] = cfg.user cred['password'] = cfg.password cred['region_name'] = cfg.region cred['https_insecure'] = cfg.insecure cred['https_cacert'] = cfg.cacert scope = cloud.setdefault('scope', {}) scope['project_name'] = cfg.tenant ssh = cloud.setdefault('ssh', {}) ssh['gateway'] = cfg.ssh_host ssh['username'] = cfg.ssh_user ssh['sudo_password'] = cfg.ssh_sudo_password ssh['connection_attempts'] = \ cfglib.CONF.migrate.ssh_connection_attempts log.configure_logging(log_config='configs/logging_config.yaml', debug=debug, forward_stdout=False) prev_legacy_config_path = None with open(yaml_path, 'r') as config_file: cfg = yaml.load(config_file) clouds = cfg.setdefault('clouds', {}) for value in clouds.values(): if 'legacy' not in value: continue legacy_config_path, section = value.pop('legacy').split(':') if prev_legacy_config_path != legacy_config_path: init(legacy_config_path, debug) import_legacy(value, getattr(cfglib.CONF, section)) return cfg
def init(name_config=None, debug=None): try: cfglib.init_config(name_config) except oslo_config.cfg.Error: traceback.print_exc() sys.exit(ERROR_INVALID_CONFIGURATION) utils.init_singletones(cfglib.CONF) if cfglib.CONF.migrate.hide_ssl_warnings: warnings.simplefilter("ignore") if debug is not None: value = oslo_config.types.Boolean()(debug) cfglib.CONF.set_override("debug", value, "migrate") log.configure_logging()
def init(name_config=None, debug=None): try: cfglib.init_config(name_config) except oslo_config.cfg.Error: traceback.print_exc() sys.exit(ERROR_INVALID_CONFIGURATION) utils.init_singletones(cfglib.CONF) if cfglib.CONF.migrate.hide_ssl_warnings: warnings.simplefilter("ignore") if debug is not None: value = oslo_config.types.Boolean()(debug) cfglib.CONF.set_override('debug', value, 'migrate') log.configure_logging()