def add_inet_filter_term(self, ri_name, prefixes, inet_type):
        if inet_type == "inet6":
            prefixes = DMUtils.get_ipv6_prefixes(prefixes)
        else:
            prefixes = DMUtils.get_ipv4_prefixes(prefixes)

        from_ = From()
        for prefix in prefixes:
            from_.add_destination_address(prefix)
        then_ = Then()
        then_.add_routing_instance(ri_name)
        return Term(name=DMUtils.make_vrf_term_name(ri_name), fromxx=from_, then=then_)
Exemplo n.º 2
0
    def add_inet_filter_term(self, ri_name, prefixes, inet_type):
        if inet_type == 'inet6':
            prefixes = DMUtils.get_ipv6_prefixes(prefixes)
        else:
            prefixes = DMUtils.get_ipv4_prefixes(prefixes)

        from_ = From()
        for prefix in prefixes:
            from_.add_destination_address(self.get_subnet_for_cidr(prefix))
        then_ = Then()
        then_.add_routing_instance(ri_name)
        return Term(name=DMUtils.make_vrf_term_name(ri_name),
                    fromxx=from_, then=then_)
    def add_inet_filter_term(self, ri_name, prefixes, inet_type):
        term = etree.Element("term")
        etree.SubElement(term, "name").text = DMUtils.make_vrf_term_name(ri_name)
        from_ = etree.SubElement(term, "from")
        if inet_type == 'inet6':
            prefixes = DMUtils.get_ipv6_prefixes(prefixes)
        else:
            prefixes = DMUtils.get_ipv4_prefixes(prefixes)

        for prefix in prefixes:
            etree.SubElement(from_, "destination-address").text = prefix

        then_ = etree.SubElement(term, "then")
        etree.SubElement(then_, "routing-instance").text = ri_name
        return term
    def add_inet_filter_term(self, ri_name, prefixes, inet_type):
        term = etree.Element("term")
        etree.SubElement(term,
                         "name").text = DMUtils.make_vrf_term_name(ri_name)
        from_ = etree.SubElement(term, "from")
        if inet_type == 'inet6':
            prefixes = DMUtils.get_ipv6_prefixes(prefixes)
        else:
            prefixes = DMUtils.get_ipv4_prefixes(prefixes)

        for prefix in prefixes:
            etree.SubElement(from_, "destination-address").text = prefix

        then_ = etree.SubElement(term, "then")
        etree.SubElement(then_, "routing-instance").text = ri_name
        return term