예제 #1
0
파일: build.py 프로젝트: LapwingOrg/sponson
    def persist_config(self):
        """
        Write out the configuration data to a YAML file.
        """
        configfile.write_config_file(self.all_config, self.config_path)

        img_sponson_dir = os.path.join(self.image_path, "etc", "sponson")
        os.makedirs(img_sponson_dir, exist_ok=True)

        img_sponson_conf = os.path.join(
            img_sponson_dir, "{}.{}.yaml".format(self.name, self.version))
        configfile.write_config_file(self.all_config, img_sponson_conf)

        if self.is_latest:
            latest_config = os.path.join(BASE_CONF_DIR, self.name,
                                         "latest.yaml")

            if os.path.exists(latest_config):
                os.remove(latest_config)
            os.symlink(self.config_path, latest_config)
예제 #2
0
파일: new.py 프로젝트: LapwingOrg/sponson
    def _save_config(self):
        """
        Save container configuration to disk,
        both in the container and on the host.

        This is to allow the firewall setup to work later,
        and to record any mounts, slices or other changes.

        The host copy of the configuration file
        is always the last build container,
        to match what is set up in the systemd unit file.
        """
        host_conf_file = os.path.join(ETC_CONTAINER_CONF_DIR,
                                      "{}.yaml".format(self.name))
        container_conf_file = os.path.join(self.path,
                                           host_conf_file.lstrip("/"))

        conf_data = configfile.merge(self.runtime_config, self.all_config)

        conf_data["container"]["name"] = self.name
        conf_data["container"]["version"] = self.version

        configfile.write_config_file(conf_data, host_conf_file)
        configfile.write_config_file(conf_data, container_conf_file)