Пример #1
0
    def _set_all(self, request):
        site_mgmt = watolib.SiteManagementFactory().factory()

        all_sites = site_mgmt.load_sites()
        if "configuration_hash" in request:
            validate_config_hash(request["configuration_hash"], all_sites)

        for site_id, site_config in request["sites"].items():
            site_mgmt.validate_configuration(site_id, site_config, request["sites"])

        site_mgmt.save_sites(prepare_raw_site_config(request["sites"]))
Пример #2
0
    def _set(self, request):
        site_mgmt = watolib.SiteManagementFactory().factory()

        all_sites = site_mgmt.load_sites()
        existing_site = all_sites.get(request["site_id"])
        if existing_site and "configuration_hash" in request:
            validate_config_hash(request["configuration_hash"], existing_site)

        site_mgmt.validate_configuration(request["site_id"], request["site_config"], all_sites)

        sites = prepare_raw_site_config({request["site_id"]: request["site_config"]})

        all_sites.update(sites)
        site_mgmt.save_sites(all_sites)
Пример #3
0
    def load_sites(cls) -> SiteConfigurations:
        if not os.path.exists(cls._sites_mk()):
            return default_single_site_configuration()

        raw_sites = store.load_from_mk_file(cls._sites_mk(), "sites", {})
        if not raw_sites:
            return default_single_site_configuration()

        sites = prepare_raw_site_config(raw_sites)
        for site in sites.values():
            if site["proxy"] is not None:
                site["proxy"] = cls.transform_old_connection_params(site["proxy"])

        return sites