+ try:
+ logging.info("Writing configuration file to %s", options.CONFIG_DATA_PATH)
+ utils.WriteFile(file_name=options.CONFIG_DATA_PATH,
+ data=serializer.DumpJson(config_data),
+ mode=0600,
+ dry_run=options.dry_run,
+ backup=True)
+
+ if not options.dry_run:
+ bootstrap.GenerateClusterCrypto(False, False, False, False,
+ nodecert_file=options.SERVER_PEM_PATH,
+ rapicert_file=options.RAPI_CERT_FILE,
+ hmackey_file=options.CONFD_HMAC_KEY,
+ cds_file=options.CDS_FILE)
+
+ except Exception:
+ logging.critical("Writing configuration failed. It is probably in an"
+ " inconsistent state and needs manual intervention.")
+ raise
+
+ # test loading the config file
+ if not (options.dry_run or options.no_verify):
+ logging.info("Testing the new config file...")
+ cfg = config.ConfigWriter(cfg_file=options.CONFIG_DATA_PATH,
+ accept_foreign=options.ignore_hostname,
+ offline=True)
+ # if we reached this, it's all fine
+ vrfy = cfg.VerifyConfig()
+ if vrfy:
+ logging.error("Errors after conversion:")
+ for item in vrfy:
+ logging.error(" - %s", item)
+ del cfg
+ logging.info("File loaded successfully")