Example #1
0
 def cli_summary_attributes(self):
     return [
         packet_common.ip_prefix_str(self.prefix),
         constants.owner_str(self.owner),
         list(map(lambda x: str(x[0]) if x[1] else "~%s" % str(x[0]),
                  self._get_nexthops_sorted()))
     ]
Example #2
0
 def __str__(self):
     all_next_hops = self._get_nexthops_sorted()
     return "%s: %s -> %s" % (constants.owner_str(self.owner),
                              packet_common.ip_prefix_str(self.prefix),
                              ", ".join(
                                  map(lambda x: str(x[0]) if x[1] else "~%s" % str(x[0]),
                                      all_next_hops)))
Example #3
0
 def cli_summary_attributes(self):
     if self.is_discard_route():
         return [
             ip_prefix_str(self.prefix),
             owner_str(self.owner), "Discard", "", "", ""
         ]
     nhops = sorted(self.next_hops)
     types = ["Negative" if nh.negative else "Positive" for nh in nhops]
     interfaces = [
         nh.interface if nh.interface is not None else "" for nh in nhops
     ]
     addresses = [
         nh.address if nh.address is not None else "" for nh in nhops
     ]
     weights = [nh.weight if nh.weight is not None else "" for nh in nhops]
     return [
         ip_prefix_str(self.prefix),
         owner_str(self.owner), types, interfaces, addresses, weights
     ]
Example #4
0
 def cli_summary_attributes(self):
     return [
         packet_common.ip_prefix_str(self.prefix),
         constants.owner_str(self.owner),
         [str(next_hop) for next_hop in sorted(self.next_hops)]
     ]
Example #5
0
 def __str__(self):
     return ("route to " + packet_common.ip_prefix_str(self.prefix) +
             " via " + ", ".join(str(nhop) for nhop in self.next_hops) +
             " owned by " + constants.owner_str(self.owner))
Example #6
0
def test_owner_str():
    assert constants.owner_str(constants.OWNER_S_SPF) == "South SPF"
    assert constants.owner_str(constants.OWNER_N_SPF) == "North SPF"
    with pytest.raises(Exception):
        constants.owner_str(999)
Example #7
0
 def __repr__(self):
     next_hops_str = ", ".join(
         [str(next_hop) for next_hop in sorted(self.next_hops)])
     return "%s: %s -> %s" % (owner_str(
         self.owner), ip_prefix_str(self.prefix), next_hops_str)