예제 #1
0
    def _remaining_blank_nets(self, ip, depth):
        if not self.show_unused_addresses:
            return []

        rows = []
        tTree = self.tree
        subtree = IPtree.getSubtree(tTree, ip)
        nets = self.generate_matrix_nets(ip)

        for net in nets:
            overlap = False
            for subnet in subtree.keys():
                if subnet.overlaps(net) == 1:
                    overlap = True
                    break

            if overlap or IPtree.search(subtree, net):
                continue
            else:
                rows.append([
                    self.Cell(
                        colspan=1,
                        color=None,
                        content='{0} {1}'.format(
                            Matrix.print_depth(depth),
                            _netlink(net))),
                    self.Cell(
                        colspan=self.num_columns,
                        color=None,
                        content=' ')
                ])
        return rows
예제 #2
0
    def _remaining_blank_nets(self, ip, depth):
        if not self.show_unused_addresses:
            return []

        rows = []
        tTree = self.tree
        subtree = IPtree.getSubtree(tTree, ip)
        nets = self.generate_matrix_nets(ip)

        for net in nets:
            overlap = False
            for subnet in subtree.keys():
                if subnet.overlaps(net) == 1:
                    overlap = True
                    break

            if overlap or IPtree.search(subtree, net):
                continue
            else:
                rows.append([
                    self.Cell(colspan=1,
                              color=None,
                              content='{0} {1}'.format(
                                  Matrix.print_depth(depth), _netlink(net))),
                    self.Cell(colspan=self.num_columns,
                              color=None,
                              content=' ')
                ])
        return rows
예제 #3
0
 def has_too_small_nets(self, net):
     """
     Returns True if argument ``net'' has too many small subnets for the
     matrix.
     """
     for net in IPtree.get_subtree(self.tree, net):
         if net.prefixlen() > self.end_net.prefixlen():
             return True
     return False
예제 #4
0
    def __init__(self, start_net, end_net=None, bits_in_matrix=3):

        if end_net is None:
            end_net = IPtools.getLastSubnet(start_net)
        self.start_net = start_net
        self.end_net = end_net
        self.bits_in_matrix = bits_in_matrix
        self.tree = IPtree.build_tree(start_net,
                                      end_net,
                                      bits_in_matrix=bits_in_matrix,
                                      add_missing_nets=True)
        self.tree_nets = self.extract_tree_nets()
        self.matrix_nets = self.extract_matrix_nets()
        self.heading_colspan = 1
        self.nodes = None
        self.num_columns = None
        self.column_headings = None
예제 #5
0
 def extract_matrix_nets(self):
     """These should be shown as horizontal rows in the matrix."""
     return IPtree.extract_subtrees_with_prefix_length(
         self.tree,
         self.end_net.prefixlen() - self.bits_in_matrix)
예제 #6
0
 def extract_tree_nets(self):
     """These should be listed vertically in the leftmost column."""
     return IPtree.remove_subnets_with_prefixlength(
         self.tree,
         self.end_net.prefixlen() - self.bits_in_matrix + 1)