builder.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:arouteserver 作者: pierky 项目源码 文件源码
def enrich_j2_environment(self, env):

        def convert_ext_comm(s):
            parts = s.split(":")
            return "{} {}:{}".format(
                parts[0], parts[1], parts[2]
            )

        def at_least_one_client_uses_tag_reject_policy():
            for client in self.cfg_clients.cfg["clients"]:
                policy = client["cfg"]["filtering"]["reject_policy"]["policy"]
                if policy == "tag":
                    return True
            return False

        def community_is_set(comm):
            if not comm:
                return False
            # OpenBGPD <= 6.0 does not implement large BGP communities,
            # so only standard and extended ones are considered.
            if version.parse(self.target_version or "6.0") < version.parse("6.1"):
                if not comm["std"] and not comm["ext"]:
                    return False
            else:
                if not comm["std"] and not comm["ext"] and not comm["lrg"]:
                    return False
            return True

        env.filters["convert_ext_comm"] = convert_ext_comm
        env.filters["community_is_set"] = community_is_set
        self.data["at_least_one_client_uses_tag_reject_policy"] = \
            at_least_one_client_uses_tag_reject_policy()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号