Beispiel #1
0
 def GET(self, node_id):
     """:returns: JSONized node disks.
     :http: * 200 (OK)
            * 404 (node not found in db)
     """
     node = self.get_object_or_404(objects.Node, node_id)
     node_volumes = node.attributes.volumes
     return DisksFormatConvertor.format_disks_to_simple(node_volumes)
Beispiel #2
0
    def PUT(self, node_id):
        """:returns: JSONized node disks.
        :http: * 200 (OK)
               * 400 (invalid disks data specified)
               * 404 (node not found in db)
        """
        node = self.get_object_or_404(objects.Node, node_id)
        data = self.checked_data(self.validator.validate, node=node)

        if node.cluster:
            objects.Cluster.add_pending_changes(node.cluster,
                                                'disks',
                                                node_id=node.id)

        volumes_data = DisksFormatConvertor.format_disks_to_full(node, data)
        objects.Node.set_volumes(node, volumes_data)

        return DisksFormatConvertor.format_disks_to_simple(
            node.attributes.volumes)
Beispiel #3
0
 def GET(self, node_id):
     """:returns: JSONized volumes info for node.
     :http: * 200 (OK)
            * 404 (node not found in db)
     """
     node = self.get_object_or_404(objects.Node, node_id)
     if node.cluster is None:
         raise self.http(
             404, 'Cannot calculate volumes info. '
             'Please, add node to an environment.')
     volumes_info = DisksFormatConvertor.get_volumes_info(node)
     return volumes_info
Beispiel #4
0
    def GET(self, node_id):
        """:returns: JSONized node disks.
        :http: * 200 (OK)
               * 404 (node or its attributes not found in db)
        """
        node = self.get_object_or_404(objects.Node, node_id)
        if not node.attributes:
            raise self.http(404)

        volumes = DisksFormatConvertor.format_disks_to_simple(
            node.volume_manager.gen_volumes_info())

        return volumes
Beispiel #5
0
    def reserved_size(self, spaces):
        reserved_size = 0
        for disk in only_disks(spaces):
            reserved_size += DisksFormatConvertor.calculate_service_partitions_size(disk["volumes"])

        return reserved_size