Exemple #1
0
    def construct_node(cls, node_list):
        """
        Constructs a dict of node names to TreeNodes

        :param node_list:
        :return:
        :rtype: dict[str, TreeNode]
        """
        node_map = {}
        for n in node_list.nodes:
            root_node = TreeNode(n.name, '', Color.RED)
            root_node.set_description('node')
            node_map[n.name] = root_node
        return node_map
Exemple #2
0
 def make_volume_node(self, vlm, volume_def_map):
     volume_node = TreeNode('volume' + str(vlm.vlm_nr), '', Color.DARKGREEN)
     volume_node.set_description('minor number: ' + str(vlm.vlm_minor_nr))
     volume_node.add_description(', size: ' + str(
         SizeCalc.approximate_size_string(volume_def_map[vlm.vlm_minor_nr]))
                                 )
     return volume_node
Exemple #3
0
    def make_volume_node(cls, vlm):
        """

        :param responses.Volume vlm:
        :return:
        """
        volume_node = TreeNode('volume' + str(vlm.number), '', Color.DARKGREEN)
        volume_node.set_description('minor number: ' + str(vlm.drbd_data.drbd_volume_definition.minor)
                                    if vlm.drbd_data else '')
        volume_node.add_description(
            ', size: ' + str(SizeCalc.approximate_size_string(vlm.allocated_size))
        )
        return volume_node
Exemple #4
0
 def construct_storpool(self, node_map, storage_pool_list):
     for storpool in storage_pool_list.storage_pools:
         storpool_node = TreeNode(storpool.name, '', Color.PINK)
         storpool_node.set_description('storage pool')
         node_map[storpool.node_name].add_child(storpool_node)
Exemple #5
0
    def construct_rsc(self, node_map, rsc_list):
        for rsc in rsc_list.resources:
            vlm_by_storpool = collections.defaultdict(list)
            for vlm in rsc.volumes:
                vlm_by_storpool[vlm.storage_pool_name].append(vlm)

            for (storpool_name, vlms) in vlm_by_storpool.items():
                rsc_node = TreeNode(rsc.name, '', Color.BLUE)
                rsc_node.set_description('resource')

                if storpool_name == self.DISKLESS_STORAGE_POOL:
                    storpool_node = node_map[rsc.node_name].find_child(self.DISKLESS_RESOURCE_NAME)
                    if not storpool_node:
                        storpool_node = TreeNode(self.DISKLESS_RESOURCE_NAME, '', Color.PINK)
                        storpool_node.set_description('resources may reside on other nodes')
                        node_map[rsc.node_name].add_child(storpool_node)
                else:
                    storpool_node = node_map[rsc.node_name].find_child(storpool_name)

                for vlm in vlms:
                    rsc_node.add_child(self.make_volume_node(vlm))

                storpool_node.add_child(rsc_node)