- conf = yaml.load(f, Loader=yaml.Loader)
- # Ensure all sections are not empty
- for k in (
- "global",
- "timeout",
- "RO",
- "VCA",
- "database",
- "storage",
- "message",
- ):
- if not conf.get(k):
- conf[k] = {}
-
- # read all environ that starts with OSMLCM_
- for k, v in environ.items():
- if not k.startswith("OSMLCM_"):
- continue
- subject, _, item = k[7:].lower().partition("_")
- if not item:
- continue
- if subject in ("ro", "vca"):
- # put in capital letter
- subject = subject.upper()
- try:
- if item == "port" or subject == "timeout":
- conf[subject][item] = int(v)
- else:
- conf[subject][item] = v
- except Exception as e:
- self.logger.warning(
- "skipping environ '{}' on exception '{}'".format(k, e)
- )
-
- # backward compatibility of VCA parameters
-
- if "pubkey" in conf["VCA"]:
- conf["VCA"]["public_key"] = conf["VCA"].pop("pubkey")
- if "cacert" in conf["VCA"]:
- conf["VCA"]["ca_cert"] = conf["VCA"].pop("cacert")
- if "apiproxy" in conf["VCA"]:
- conf["VCA"]["api_proxy"] = conf["VCA"].pop("apiproxy")
-
- if "enableosupgrade" in conf["VCA"]:
- conf["VCA"]["enable_os_upgrade"] = conf["VCA"].pop("enableosupgrade")
- if isinstance(conf["VCA"].get("enable_os_upgrade"), str):
- if conf["VCA"]["enable_os_upgrade"].lower() == "false":
- conf["VCA"]["enable_os_upgrade"] = False
- elif conf["VCA"]["enable_os_upgrade"].lower() == "true":
- conf["VCA"]["enable_os_upgrade"] = True
-
- if "aptmirror" in conf["VCA"]:
- conf["VCA"]["apt_mirror"] = conf["VCA"].pop("aptmirror")
-
- return conf