Exemple #1
0
    def index(self):
        c.page = int(request.params['page'])\
                if 'page' in request.params else 1
        c.title = 'Nodetraq - Groups'
        c.selected_page = 'groups'
        c.subpage = 'list'
        c.heading = "Groups"
        c.filters = [{'name': 'group', 'label': 'Group', 'type': 'text'}]
        query, c.search_fields = get_fields_and_query(Session, Group,
                                                      request.params)
        c.request_url = request.environ.get('PATH_INFO')
        if request.environ.get('QUERY_STRING'):
            c.request_url += '?' + request.environ['QUERY_STRING']
        c.group_count = query.count()

        c.link_append = '&' + urlencode(\
                [p for p in request.params.items()\
                    if p[0] != 'page'])
        if c.link_append == '&':
            c.link_append = None

        if 'show_all' in request.params:
            c.total_pages = 1
            c.current_page_count = 1
            c.groups = query.order_by('name').all()
        else:
            c.total_pages = (c.group_count + 25 - 1) / 25
            c.current_page_count = (c.page - 1) * 25
            c.groups = query.order_by('name')\
                    [c.current_page_count: c.current_page_count+25]

        c.all_groups, c.tag_sizes = self.get_tag_info()
        return render('/groups/list.mako')
Exemple #2
0
    def index(self):
        c.page = int(request.params['page'])\
                if 'page' in request.params else 1
        c.title = 'Nodetraq - Groups'
        c.selected_page = 'groups'
        c.subpage = 'list'
        c.heading = "Groups"
        c.filters = [
                { 'name': 'group', 'label': 'Group', 'type': 'text' }
            ]
        query, c.search_fields = get_fields_and_query(Session,
                Group, request.params)
        c.request_url = request.environ.get('PATH_INFO')
        if request.environ.get('QUERY_STRING'):
            c.request_url += '?' + request.environ['QUERY_STRING']
        c.group_count = query.count()

        c.link_append = '&' + urlencode(\
                [p for p in request.params.items()\
                    if p[0] != 'page'])
        if c.link_append == '&':
            c.link_append = None

        if 'show_all' in request.params:
            c.total_pages = 1
            c.current_page_count = 1
            c.groups = query.order_by('name').all()
        else:
            c.total_pages = (c.group_count+25-1)/25
            c.current_page_count = (c.page-1)*25
            c.groups = query.order_by('name')\
                    [c.current_page_count: c.current_page_count+25]

        c.all_groups, c.tag_sizes = self.get_tag_info()
        return render('/groups/list.mako')
Exemple #3
0
    def index(self, format='html'):
        c.title = 'Nodetraq - Nodes'
        c.selected_page = 'nodes'
        c.subpage = 'list'
        c.header = 'Nodes'
        c.filters = [
            { 'name': 'hostname', 'label': 'Hostname', 'type': 'text' },
            { 'name': 'groups', 'label': 'Group', 'type': 'text' },
            { 'name': 'primary_ip', 'label': 'Primary IP', 'type': 'text' },
            { 'name': 'primary_mac', 'label': 'Primary MAC', 'type': 'text' },
            { 'name': 'secondary_ip', 'label': 'Secondary IP', 'type': 'text' },
            { 'name': 'secondary_mac', 'label': 'Secondary MAC', 'type': 'text' },
            { 'name': 'location', 'label': 'Location', 'type': 'text' },
            { 'name': 'rack', 'label': 'Rack', 'type': 'integer' },
            { 'name': 'rack_u', 'label': 'Rack U', 'type': 'integer' },
            { 'name': 'service_tag', 'label': 'Service Tag', 'type': 'text' },
            { 'name': 'cpu_count', 'label': 'Cpu Count', 'type': 'integer' },
            { 'name': 'cpu_speed', 'label': 'Cpu Speed', 'type': 'integer' },
            { 'name': 'memory', 'label': 'Memory', 'type': 'integer' }, ]

        is_sorted = False
        query, c.search_fields = get_fields_and_query(Session,
                Node, request.params)
        c.request_url = request.environ.get('PATH_INFO')
        if request.environ.get('QUERY_STRING'):
            c.request_url +=  '?' + request.environ['QUERY_STRING']
        c.node_count = query.count()

        c.link_append = '&' + urlencode(
            [p for p in request.params.items()\
                 if p[0] != 'page'])

        if c.link_append == '&':
            c.link_append = None

        if 'sort' in request.params:
            sortkey, sortorder = request.params['sort'].split(':')
            is_sorted = True
            c.sort_order = sortorder
        else:
            c.sort_order = None

        if 'show_all' in request.params:
            c.page = 1
            c.total_pages = 1
            c.current_page_count = 1
            if is_sorted:
                if sortorder == 'asc':
                    c.nodes = query.order_by(asc(sortkey)).all()
                else:
                    c.nodes = query.order_by(desc(sortkey)).all()
            else:
                c.nodes = query.order_by('hostname').all()
        else:
            c.page = int(request.params['page'])\
                    if 'page' in request.params else 1
            c.total_pages = (c.node_count+25-1)/25
            c.current_page_count = (c.page-1)*25
            if is_sorted:
                if sortorder == 'asc':
                    c.nodes = query.order_by(asc(sortkey))\
                        [c.current_page_count:c.current_page_count+25]
                else:
                    c.nodes = query.order_by(desc(sortkey))\
                        [c.current_page_count:c.current_page_count+25]
            else:
                c.nodes = query.order_by('hostname')\
                    [c.current_page_count:c.current_page_count+25]

        c.group_list = [g[0] for g in Session.query(Group.name)\
                .order_by('name')]

        if format == 'html':
            return render('/nodes/list.mako')
        elif format == 'json':
            response.content_type = 'application/json'
            return render('/nodes/list.json')
        elif format == 'xml':
            response.content_type = 'application/xml'
            return render('/nodes/list.xml')
Exemple #4
0
    def index(self, format='html'):
        c.title = 'Nodetraq - Nodes'
        c.selected_page = 'nodes'
        c.subpage = 'list'
        c.header = 'Nodes'
        c.filters = [
            {
                'name': 'hostname',
                'label': 'Hostname',
                'type': 'text'
            },
            {
                'name': 'groups',
                'label': 'Group',
                'type': 'text'
            },
            {
                'name': 'primary_ip',
                'label': 'Primary IP',
                'type': 'text'
            },
            {
                'name': 'primary_mac',
                'label': 'Primary MAC',
                'type': 'text'
            },
            {
                'name': 'secondary_ip',
                'label': 'Secondary IP',
                'type': 'text'
            },
            {
                'name': 'secondary_mac',
                'label': 'Secondary MAC',
                'type': 'text'
            },
            {
                'name': 'location',
                'label': 'Location',
                'type': 'text'
            },
            {
                'name': 'rack',
                'label': 'Rack',
                'type': 'integer'
            },
            {
                'name': 'rack_u',
                'label': 'Rack U',
                'type': 'integer'
            },
            {
                'name': 'service_tag',
                'label': 'Service Tag',
                'type': 'text'
            },
            {
                'name': 'cpu_count',
                'label': 'Cpu Count',
                'type': 'integer'
            },
            {
                'name': 'cpu_speed',
                'label': 'Cpu Speed',
                'type': 'integer'
            },
            {
                'name': 'memory',
                'label': 'Memory',
                'type': 'integer'
            },
        ]

        is_sorted = False
        query, c.search_fields = get_fields_and_query(Session, Node,
                                                      request.params)
        c.request_url = request.environ.get('PATH_INFO')
        if request.environ.get('QUERY_STRING'):
            c.request_url += '?' + request.environ['QUERY_STRING']
        c.node_count = query.count()

        c.link_append = '&' + urlencode(
            [p for p in request.params.items()\
                 if p[0] != 'page'])

        if c.link_append == '&':
            c.link_append = None

        if 'sort' in request.params:
            sortkey, sortorder = request.params['sort'].split(':')
            is_sorted = True
            c.sort_order = sortorder
        else:
            c.sort_order = None

        if 'show_all' in request.params:
            c.page = 1
            c.total_pages = 1
            c.current_page_count = 1
            if is_sorted:
                if sortorder == 'asc':
                    c.nodes = query.order_by(asc(sortkey)).all()
                else:
                    c.nodes = query.order_by(desc(sortkey)).all()
            else:
                c.nodes = query.order_by('hostname').all()
        else:
            c.page = int(request.params['page'])\
                    if 'page' in request.params else 1
            c.total_pages = (c.node_count + 25 - 1) / 25
            c.current_page_count = (c.page - 1) * 25
            if is_sorted:
                if sortorder == 'asc':
                    c.nodes = query.order_by(asc(sortkey))\
                        [c.current_page_count:c.current_page_count+25]
                else:
                    c.nodes = query.order_by(desc(sortkey))\
                        [c.current_page_count:c.current_page_count+25]
            else:
                c.nodes = query.order_by('hostname')\
                    [c.current_page_count:c.current_page_count+25]

        c.group_list = [g[0] for g in Session.query(Group.name)\
                .order_by('name')]

        if format == 'html':
            return render('/nodes/list.mako')
        elif format == 'json':
            response.content_type = 'application/json'
            return render('/nodes/list.json')
        elif format == 'xml':
            response.content_type = 'application/xml'
            return render('/nodes/list.xml')