Beispiel #1
0
    def systems(self, group_id=None, *args, **kw):
        try:
            group = Group.by_id(group_id)
        except DatabaseLookupError:
            log.exception('Group id %s is not a valid group id' % group_id)
            flash(_(u'Need a valid group to search on'))
            redirect('../groups/mine')

        systems = System.all(identity.current.user). \
                  filter(System.groups.contains(group)). \
                  filter(System.status != SystemStatus.removed)
        title = 'Systems in Group %s' % group.group_name
        from bkr.server.controllers import Root
        return Root()._systems(systems, title, group_id=group_id, **kw)
Beispiel #2
0
 def reserve(self, action='.', *args, **kw):
     from bkr.server.controllers import Root
     default_columns = (
         'System/Name',
         'System/Reserved',
         'System/User',
         'System/Pools',
         'System/LoanedTo',
     )
     return Root()._systems(systems=System.all(
         identity.current.user).join('open_reservation').options(
             contains_eager(System.open_reservation)),
                            title=u'Reserve Report',
                            default_result_columns=default_columns,
                            *args,
                            **kw)
Beispiel #3
0
    def process_rpc(self,method,params):
        """
        _process_rpc() handles a generic way of dissecting and calling
        methods and params with params being a list and methods being a '.'
        delimited string indicating the method to call

        """
        from bkr.server.controllers import Root
        #Is there a better way to do this?
        #I could perhaps use cherrypy.root, but this only works on prod
        obj = Root()
        # Get the function and make sure it's exposed.
        for name in method.split('.'):
            obj = getattr(obj, name, None)
            # Use the same error message to hide private method names
            if obj is None or not getattr(obj, "exposed", False):
                raise XMLRPCMethodDoesNotExist(method)

        # Call the method, convert it into a 1-element tuple
        # as expected by dumps
        response = obj(*params)
        return response