Example #1
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(Node, node_id)
        data = self.checked_data()

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

        volumes_data = DisksFormatConvertor.format_disks_to_full(node, data)
        # For some reasons if we update node attributes like
        #   node.attributes.volumes = volumes_data
        # after
        #   db().commit()
        # it resets to previous state
        db().query(NodeAttributes).filter_by(node_id=node_id).update(
            {'volumes': volumes_data})
        db().flush()
        db().refresh(node)

        return DisksFormatConvertor.format_disks_to_simple(
            node.attributes.volumes)
Example #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(Node, node_id)
        data = self.checked_data()

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

        volumes_data = DisksFormatConvertor.format_disks_to_full(node, data)
        # For some reasons if we update node attributes like
        #   node.attributes.volumes = volumes_data
        # after
        #   db().commit()
        # it resets to previous state
        db().query(NodeAttributes).filter_by(node_id=node_id).update(
            {'volumes': volumes_data})
        db().commit()

        return DisksFormatConvertor.format_disks_to_simple(
            node.attributes.volumes)
Example #3
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)
Example #4
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)
Example #5
0
    def GET(self, node_id):
        node = self.get_object_or_404(Node, node_id)
        if not node.attributes:
            return web.notfound()

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

        return volumes
Example #6
0
    def PUT(self, node_id):
        node = self.get_object_or_404(Node, node_id)
        data = self.checked_data()

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

        volumes_data = DisksFormatConvertor.format_disks_to_full(node, data)
        # For some reasons if we update node attributes like
        #   node.attributes.volumes = volumes_data
        # after
        #   db().commit()
        # it resets to previous state
        db().query(NodeAttributes).filter_by(node_id=node_id).update(
            {'volumes': volumes_data})
        db().commit()

        return DisksFormatConvertor.format_disks_to_simple(
            node.attributes.volumes)
Example #7
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
Example #8
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
Example #9
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)
Example #10
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(Node, node_id)
        if not node.attributes:
            return web.notfound()

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

        return volumes
Example #11
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
Example #12
0
    def GET(self, node_id):
        node = self.get_object_or_404(Node, node_id)

        volumes_info = []
        try:
            volumes_info = DisksFormatConvertor.get_volumes_info(node)
        except errors.CannotFindVolumesInfoForRole as exc:
            logger.error(traceback.format_exc())
            raise web.notfound(
                message='Cannot calculate volumes info. '
                'Please, add node to a cluster.')

        return volumes_info
Example #13
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)
Example #14
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(Node, node_id)

        volumes_info = []
        try:
            volumes_info = DisksFormatConvertor.get_volumes_info(node)
        except errors.CannotFindVolumesInfoForRole:
            logger.error(traceback.format_exc())
            raise web.notfound(message="Cannot calculate volumes info. " "Please, add node to a cluster.")

        return volumes_info
Example #15
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(Node, node_id)

        volumes_info = []
        try:
            volumes_info = DisksFormatConvertor.get_volumes_info(node)
        except errors.CannotFindVolumesInfoForRole:
            logger.error(traceback.format_exc())
            raise web.notfound(message='Cannot calculate volumes info. '
                               'Please, add node to a cluster.')

        return volumes_info
Example #16
0
 def GET(self, node_id):
     node = self.get_object_or_404(Node, node_id)
     node_volumes = node.attributes.volumes
     return DisksFormatConvertor.format_disks_to_simple(node_volumes)