Exemple #1
0
    def publish(self, domain='yourdomainhere'):
        c.title = "Nodetraq -- DNS - Publish"
        c.selected_page = "dns"
        c.subpage = "publish"
        c.domain = domain

        prod = NodetraqCotendo()
        prod.GrabDNS(domain, 1)
        staging = NodetraqCotendo()
        staging.GrabDNS(domain, 1)

        results = ch.get_view('dns', 'configs')
        for r in results.rows:
            if r.value['environment'] == 'staging':
                staging.ImportDNS(r.value["config"], r.value["token"])
                break

        staging_config = staging.dns.config.splitlines(1)
        prod_config = prod.dns.config.splitlines(1)

        diff = ''.join(difflib.unified_diff(
                prod_config, staging_config, 'production', 'staging'))

        c.diff = diff
        return render('/dns/publish.mako')
Exemple #2
0
    def index(self, domain='yourdomainhere'):
        c.title = "Nodetraq -- DNS"
        c.selected_page = "dns"
        c.subpage = "list"
        c.domain = domain

        cotendo = NodetraqCotendo()
        cotendo.GrabDNS(domain, 1)
        ch.select("nodetraq")

        # Sync views
        ch.sync_view('nodetraq/model/views')

        # Update CouchDB to have a copy of the latest dns entries.
        results = ch.get_view('dns', 'configs')
        doc = None
        for r in results.rows:
            if r.value['environment'] == 'staging':
                doc = couchdb.Document(r.value)
                cotendo.ImportDNS(r.value["config"], r.value['token'])
            if doc:
                if doc["config"] != cotendo.dns.config:
                    doc["config"] = cotendo.dns.config
                    doc["token"] = cotendo.dns.token
                    ch.save(doc)
        if not doc:
            doc = couchdb.Document({"doc_type": "dns",
                     "domain": domain,
                     "environment": "staging",
                     "token": cotendo.dns.token,
                     "config": cotendo.dns.config })
            ch.save(doc)

        c.records = cotendo.dns._entries
        return render('dns/list.mako')
Exemple #3
0
    def index(self):
        c.title = 'Nodetraq -- Graphs'
        c.selected_page = 'graphs'
        c.subpage = 'index'

        c.graphs = Session.query(Graph).all()
        return render('/graphs/index.mako')
Exemple #4
0
    def edit(self, account=None):
        c.title = "Nodetraq -- Edit Users"
        c.selected_page = "users"
        c.subpage = "edit"

        dh = DirectoryHelper(
            directoryCN, directoryPassword, directoryDomain)
        try:
            c.user = dh.ldap.findUser(account, Attrs=[
                    'cn', 'uid',
                    'mail', 'loginShell', 'nsAccountLock',
                    'uidNumber', 'title', 'manager',
                    'departmentNumber', 'roomNumber',
                    'deploycode', 'orgchartmanager', 'utilityaccount'
                    ])[1]
            fix_keys = ['uidNumber', 'nsAccountLock',
                        'mail', 'loginShell']
            for key in fix_keys:
                if not c.user.has_key(key):
                    c.user[key] = ['']
        except:
            c.user = None
        groups = dh.getAllGroups()
        c.group_membership = dh.getUserGroups(account)
        c.group_membership.sort()
        c.available_groups = list(set(groups) - set(c.group_membership))
        c.available_groups.sort()
        return render('/users/edit.mako')
Exemple #5
0
 def show(self, pool):
     c.title = 'Nodetraq - Loadbalancer - Show'
     c.selected_page = 'loadbalancer'
     c.subpage = 'show'
     lb = LoadBalancer(ip='your_lb_ip')
     c.members = self.get_members_status(Session, [pool])[0]
     return render('/loadbalancer/show.mako')
Exemple #6
0
    def edit_record(self, domain='yourdomainhere', type=None, host=''):
        c.title = "Nodetraq -- DNS - Edit Record"
        c.selected_page = "dns"
        c.subpage = "edit_record"
        c.domain = domain

        cotendo = NodetraqCotendo()
        cotendo.GrabDNS(domain, 1)
        # check if record exists, if it does, update it otherwise
        results = ch.get_view('dns', 'configs')
        doc = None
        for r in results.rows:
            if r.value['environment'] == 'staging':
                cotendo.ImportDNS(r.value["config"], r.value['token'])
                doc = couchdb.Document(r.value)
                break

        c.record = cotendo.dns.get_record(type, host)
        if not c.record:
            session['flash'] = "Not a valid record"
            session.save()
            return redirect(url(controller="dns",
                                action="index", domain=domain))

        return render('/dns/edit_record.mako')
Exemple #7
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 #8
0
    def index(self):
        c.title = 'Nodetraq - Dashboard'
        c.selected_page = 'dashboard'
        c.subpage = 'index'

        c.sync_issues = self.get_sync_issues()['issues']
        return render('/dashboard/index.mako')
Exemple #9
0
 def edit_studio(self, id):
     c.studio = Session.query(Studio).filter(Studio.id == id).first()
     c.title = "Nodetraq -- Edit Studio"
     c.header = c.studio.name
     c.selected_page = "nodes"
     c.subpage = "edit_studio"
     return render('/nodes/studios/edit.mako')
Exemple #10
0
    def add(self):
        c.group = Session.query(Group).filter(Group.id == id).first()
        c.title = 'Nodetraq - Group - Add'
        c.selected_page = 'groups'
        c.subpage = 'add'

        return render('/groups/add.mako')
Exemple #11
0
 def get_new_record(self):
     json_data = json.loads(request.params.keys()[0])
     c.record_type = json_data['record_type']
     c.count = json_data['count']
     if not c.count:
         c.count = 0
     return render('/dns/new_record.mako')
Exemple #12
0
    def add_record(self, domain='yourdomainhere'):
        c.title = "Nodetraq -- DNS - Add Record"
        c.selected_page = "dns"
        c.subpage = "add_record"
        c.domain = domain

        return render('dns/add_record.mako')
Exemple #13
0
    def publish(self, domain='yourdomainhere'):
        c.title = "Nodetraq -- DNS - Publish"
        c.selected_page = "dns"
        c.subpage = "publish"
        c.domain = domain

        prod = NodetraqCotendo()
        prod.GrabDNS(domain, 1)
        staging = NodetraqCotendo()
        staging.GrabDNS(domain, 1)

        results = ch.get_view('dns', 'configs')
        for r in results.rows:
            if r.value['environment'] == 'staging':
                staging.ImportDNS(r.value["config"], r.value["token"])
                break

        staging_config = staging.dns.config.splitlines(1)
        prod_config = prod.dns.config.splitlines(1)

        diff = ''.join(
            difflib.unified_diff(prod_config, staging_config, 'production',
                                 'staging'))

        c.diff = diff
        return render('/dns/publish.mako')
Exemple #14
0
    def edit_record(self, domain='yourdomainhere', type=None, host=''):
        c.title = "Nodetraq -- DNS - Edit Record"
        c.selected_page = "dns"
        c.subpage = "edit_record"
        c.domain = domain

        cotendo = NodetraqCotendo()
        cotendo.GrabDNS(domain, 1)
        # check if record exists, if it does, update it otherwise
        results = ch.get_view('dns', 'configs')
        doc = None
        for r in results.rows:
            if r.value['environment'] == 'staging':
                cotendo.ImportDNS(r.value["config"], r.value['token'])
                doc = couchdb.Document(r.value)
                break

        c.record = cotendo.dns.get_record(type, host)
        if not c.record:
            session['flash'] = "Not a valid record"
            session.save()
            return redirect(
                url(controller="dns", action="index", domain=domain))

        return render('/dns/edit_record.mako')
Exemple #15
0
    def index(self):
        c.title = 'Nodetraq - LoadBalancer'
        c.selected_page = 'loadbalancer'
        c.subpage = 'index'
        lb = LoadBalancer(ip='lb_iphere')
        pools = lb.get_pools()
        pools.sort()
        c.pool_count = len(pools)

        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.page = 1
            c.total_pages = 1
            c.current_page_count = 1
            c.members = self.get_members_status(Session, pools)
        else:
            c.page = int(request.params['page'])\
                    if 'page' in request.params else 1
            c.total_pages = (c.pool_count + 25 - 1) / 25
            c.current_page_count = (c.page - 1) * 25
            c.members = self.get_members_status(
                Session, pools[c.current_page_count:c.current_page_count + 25])

        return render('/loadbalancer/index.mako')
Exemple #16
0
    def index(self):
        c.title = 'Nodetraq - Network'
        c.selected_page = 'network'
        c.subpage = 'index'

        c.network_devices = Session.query(NetworkDevice).all()
        return render('/network/index.mako')
Exemple #17
0
    def index(self):
        c.title = 'Nodetraq - LoadBalancer'
        c.selected_page = 'loadbalancer'
        c.subpage = 'index'
        lb = LoadBalancer(ip='lb_iphere')
        pools = lb.get_pools()
        pools.sort()
        c.pool_count = len(pools)

        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.page = 1
            c.total_pages = 1
            c.current_page_count = 1
            c.members = self.get_members_status(Session, pools)
        else:
            c.page = int(request.params['page'])\
                    if 'page' in request.params else 1
            c.total_pages = (c.pool_count+25-1)/25
            c.current_page_count = (c.page-1)*25
            c.members = self.get_members_status(Session,
                    pools[c.current_page_count:c.current_page_count+25])

        return render('/loadbalancer/index.mako')
Exemple #18
0
    def show_dbbackups(self):
        c.title = "Nodetraq -- Show Database Backups"
        c.selected_page = "nodes"
        c.subpage = "database"
        sort = None

        c.dbbackups = Session.query(NodeDatabaseBackup).all()
        if not 'sort' in request.params:
            sort = 'server'
        else:
            sort = request.params['sort']

        if sort == 'server':
            c.dbbackups = sorted(
                c.dbbackups, key=lambda backup: backup.server.hostname)
        elif sort == 'storage':
            c.dbbackups = sorted(
                c.dbbackups, key=lambda backup: backup.storage.hostname)
        elif sort == 'directory':
            c.dbbackups = sorted(
                c.dbbackups, key=lambda backup: backup.directory)
        elif sort == 'enabled':
            c.dbbackups = sorted(
                c.dbbackups, key=lambda backup: backup.enabled)

        c.sort = sort

        return render('/nodes/show_dbbackups.mako')
Exemple #19
0
 def namelist(self, format='mako'):
     c.nodes = Session.query(Node.hostname).all()
     if format == 'json':
         response.content_type = 'application/json'
     elif format == 'xml':
         response.content_type = 'application/xml'
     return render('/nodes/namelist/list.' + format)
Exemple #20
0
    def index(self):
        c.title = 'Nodetraq - Dashboard'
        c.selected_page = 'dashboard'
        c.subpage = 'index'

        c.sync_issues = self.get_sync_issues()['issues']
        return render('/dashboard/index.mako')
Exemple #21
0
 def namelist(self, format='mako'):
     c.nodes = Session.query(Node.hostname).all()
     if format == 'json':
         response.content_type = 'application/json'
     elif format == 'xml':
         response.content_type = 'application/xml'
     return render('/nodes/namelist/list.' + format)
Exemple #22
0
    def rrd_file(self, id):
        response.content_type = 'text/plain'

        if id.isdigit():
            graph_data = Session.query(Graph)\
                .filter(Graph.id == int(id)).first()
        else:
            graph_data = Session.query(Graph)\
                .filter(Graph.name == id).first()

        c.graph = graph_data.filename[1:]
        hostnames = [n.hostname for n in graph_data.get_hosts()]

        c.datasource = generate_rrd_sequence_map(
            hostnames, graph_data.get_rrds())

        c.title = graph_data.name

        if len(c.datasource) == 2:
            c.colors = ['Lime', 'Red']
            c.brmod = 2
        else:
            c.colors = ['Lime', 'Teal', 'Maroon']
            c.brmod = 3

        return render('/graphs/graph.mako')
Exemple #23
0
    def index(self):
        c.title = 'Nodetraq - Network'
        c.selected_page = 'network'
        c.subpage = 'index'

        c.network_devices = Session.query(NetworkDevice).all()
        return render('/network/index.mako')
Exemple #24
0
    def add_record(self, domain='yourdomainhere'):
        c.title = "Nodetraq -- DNS - Add Record"
        c.selected_page = "dns"
        c.subpage = "add_record"
        c.domain = domain

        return render('dns/add_record.mako')
Exemple #25
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 #26
0
 def edit_studio(self, id):
     c.studio = Session.query(Studio).filter(Studio.id == id).first()
     c.title = "Nodetraq -- Edit Studio"
     c.header = c.studio.name
     c.selected_page = "nodes"
     c.subpage = "edit_studio"
     return render('/nodes/studios/edit.mako')
Exemple #27
0
    def add(self):
        c.group = Session.query(Group).filter(Group.id == id).first()
        c.title = 'Nodetraq - Group - Add'
        c.selected_page = 'groups'
        c.subpage = 'add'

        return render('/groups/add.mako')
Exemple #28
0
    def search(self):
        c.title = "Nodetraq -- Search"
        c.selected_page = "users"
        c.subpage = "search"

        c.search_type = 'users'
        return render('/users/search.mako')
Exemple #29
0
    def show_game(self, id):
        c.game = Session.query(Game).filter(Game.id == id).first()
        c.title = "Nodetraq -- Game: %s" % c.game.name
        c.header = c.game.name
        c.selected_page = "nodes"
        c.subpage = "show_game"

        c.groups = [
            {'name': 'PE-1950', 'nodes': []},
            {'name': 'PE-2950', 'nodes': []},
            {'name': 'PE-R410', 'nodes': []},
            {'name': 'PE-R610', 'nodes': []},
            {'name': 'PE-R710', 'nodes': []},
            {'name': 'vm', 'nodes': []},
            {'name': 'unknown', 'nodes': []}
            ]

        group_list = lambda groups: [g.name for g in groups]
        for node in c.game.nodes:
            grouped = False
            for group in c.groups:
                if group['name'] in group_list(node.groups):
                    group['nodes'].append(node)
                    grouped = True

            if not grouped:
                c.groups[len(c.groups)-1]['nodes'].append(node)

        return render('/nodes/games/show.mako')
Exemple #30
0
    def show_dbbackups(self):
        c.title = "Nodetraq -- Show Database Backups"
        c.selected_page = "nodes"
        c.subpage = "database"
        sort = None

        c.dbbackups = Session.query(NodeDatabaseBackup).all()
        if not 'sort' in request.params:
            sort = 'server'
        else:
            sort = request.params['sort']

        if sort == 'server':
            c.dbbackups = sorted(c.dbbackups,
                                 key=lambda backup: backup.server.hostname)
        elif sort == 'storage':
            c.dbbackups = sorted(c.dbbackups,
                                 key=lambda backup: backup.storage.hostname)
        elif sort == 'directory':
            c.dbbackups = sorted(c.dbbackups,
                                 key=lambda backup: backup.directory)
        elif sort == 'enabled':
            c.dbbackups = sorted(c.dbbackups,
                                 key=lambda backup: backup.enabled)

        c.sort = sort

        return render('/nodes/show_dbbackups.mako')
Exemple #31
0
 def show(self, pool):
     c.title = 'Nodetraq - Loadbalancer - Show'
     c.selected_page = 'loadbalancer'
     c.subpage = 'show'
     lb = LoadBalancer(ip='your_lb_ip')
     c.members = self.get_members_status(Session, [pool])[0]
     return render('/loadbalancer/show.mako')
Exemple #32
0
 def show(self, id, vhostid=None):
     c.title = 'Nodetraq - Vhost - Edit'
     c.selected_page = 'nodes'
     c.subpage = 'vhost'
     c.header = 'Show Vhost'
     c.vhostid = vhostid
     c.node_id = id
     return render('/nodes/vhosts/show.mako')
Exemple #33
0
    def new(self, id):
        c.title = 'Nodetraq - vhosts'
        c.selected_page = 'nodes'
        c.subpage = 'vhosts'
        c.header = 'Nodes:vhosts'
        c.node_id = id

        return render('/nodes/vhosts/new.mako')
Exemple #34
0
    def show(self, id):
        c.title = 'Nodetraq - Network Devices'
        c.selected_page = 'network'
        c.subpage = 'show'

        c.network_device = Session.query(NetworkDevice).filter(
            id == NetworkDevice.id).first()
        return render('/network/show.mako')
Exemple #35
0
    def new(self, id):
        c.title = 'Nodetraq - vhosts'
        c.selected_page = 'nodes'
        c.subpage = 'vhosts'
        c.header = 'Nodes:vhosts'
        c.node_id = id

        return render('/nodes/vhosts/new.mako')
Exemple #36
0
    def show(self, id):
        c.title = 'Nodetraq - Network Devices'
        c.selected_page = 'network'
        c.subpage = 'show'

        c.network_device = Session.query(NetworkDevice).filter(
            id == NetworkDevice.id).first()
        return render('/network/show.mako')
Exemple #37
0
 def get_new_record(self):
     json_data = json.loads(
         request.params.keys()[0])
     c.record_type = json_data['record_type']
     c.count = json_data['count']
     if not c.count:
         c.count = 0
     return render('/dns/new_record.mako')
Exemple #38
0
    def info(self, id):
        c.title = "Nodetraq - Activity - Info"
        c.selected_page = "activity"
        c.subpage = "info"

        c.activity = Session.query(Activity).filter(Activity.id == id).first()
        c.Session = Session
        return render("/activity/info.mako")
Exemple #39
0
 def show(self, id, vhostid=None):
     c.title = 'Nodetraq - Vhost - Edit'
     c.selected_page = 'nodes'
     c.subpage = 'vhost'
     c.header = 'Show Vhost'
     c.vhostid = vhostid
     c.node_id = id
     return render('/nodes/vhosts/show.mako')
Exemple #40
0
    def info(self, id):
        c.title = 'Nodetraq - Activity - Info'
        c.selected_page = 'activity'
        c.subpage = 'info'

        c.activity = Session.query(Activity)\
                .filter(Activity.id == id).first()
        c.Session = Session
        return render('/activity/info.mako')
Exemple #41
0
 def atom(self):
     yesterday = now()- datetime.timedelta(hours=18)
     c.activity = Session.query(Activity)\
             .filter(Activity.created_at < now())\
             .filter(Activity.created_at > yesterday)\
             .order_by(desc(Activity.created_at))\
             .filter(Activity.parent == None)\
             .all()
     return render('/activity/atom.mako')
Exemple #42
0
    def edit_comment(self, id, commentid):
        c.title = 'Nodetraq : Comments'
        c.selected_page = 'nodes'
        c.subpage = 'editcomment'

        c.comment = Session.query(NodeComment)\
                .filter(NodeComment.id == commentid).first()
        c.node_id = id
        return render('/nodes/comments/edit.mako')
Exemple #43
0
    def edit_bulk_dbbackups(self):
        c.title = "Nodetraq -- Edit Database Backups"
        c.selected_page = "nodes"
        c.subpage = "database"

        c.dbbackups = Session.query(NodeDatabaseBackup).all()
        c.dbbackups = sorted(c.dbbackups,
                             key=lambda backup: backup.server.hostname)
        return render('/nodes/edit_bulk_dbbackups.mako')
Exemple #44
0
 def create_game(self):
     c.title = "Nodetraq -- Create Game"
     c.header = "Create Game"
     c.selected_page = "nodes"
     c.subpage = "create_game"
     c.studios = [('', '')]
     for studio in Session.query(Studio).all():
         c.studios.append((studio.id, studio.name))
     return render('/nodes/games/create.mako')
Exemple #45
0
    def index(self, id):
        c.title = 'Nodetraq - vhosts'
        c.selected_page = 'nodes'
        c.subpage = 'vhosts'
        c.header = 'Nodes : vhosts'
        c.node = Session.query(Node).filter(Node.id == id).first()
        c.node_id = c.node.id

        return render('/nodes/vhosts/index.mako')
Exemple #46
0
    def index(self, id):
        c.title = 'Nodetraq - vhosts'
        c.selected_page = 'nodes'
        c.subpage = 'vhosts'
        c.header = 'Nodes : vhosts'
        c.node = Session.query(Node).filter(Node.id == id).first()
        c.node_id = c.node.id

        return render('/nodes/vhosts/index.mako')
Exemple #47
0
 def create_game(self):
     c.title = "Nodetraq -- Create Game"
     c.header = "Create Game"
     c.selected_page = "nodes"
     c.subpage = "create_game"
     c.studios = [ ('', '') ]
     for studio in Session.query(Studio).all():
         c.studios.append((studio.id, studio.name))
     return render('/nodes/games/create.mako')
Exemple #48
0
    def edit_bulk_dbbackups(self):
        c.title = "Nodetraq -- Edit Database Backups"
        c.selected_page = "nodes"
        c.subpage = "database"

        c.dbbackups = Session.query(NodeDatabaseBackup).all()
        c.dbbackups = sorted(
            c.dbbackups, key=lambda backup: backup.server.hostname)
        return render('/nodes/edit_bulk_dbbackups.mako')
Exemple #49
0
    def edit_comment(self, id, commentid):
        c.title = 'Nodetraq : Comments'
        c.selected_page = 'nodes'
        c.subpage = 'editcomment'

        c.comment = Session.query(NodeComment)\
                .filter(NodeComment.id == commentid).first()
        c.node_id = id
        return render('/nodes/comments/edit.mako')
Exemple #50
0
    def show(self, id, format='html'):
        id = unicode(id)
        if id.isdigit():
            c.group = Session.query(Group).filter(Group.id == int(id)).first()
        else:
            c.group = Session.query(Group).filter(Group.name == id).first()
        c.group_list = [g[0] for g in Session.query(Group.name)]

        c.title = 'Nodetraq - Group - %s' % c.group.name
        c.selected_page = 'groups'
        c.subpage = 'show'
        c.header = 'Groups : %s' % c.group.name
        c.page = int(request.params['page'])\
                if 'page' in request.params else 1
        c.current_page_count = (c.page - 1) * 25
        c.node_count = len(c.group.nodes)
        c.filters = [{'name': 'group', 'label': 'Group', 'type': 'text'}]
        c.link_append = None
        is_sorted = False

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

        if is_sorted:
            if sortorder == 'asc':
                c.nodes = c.group.nodes\
                    [c.current_page_count:c.current_page_count+25]
                c.nodes = sorted(c.nodes,
                                 key=attrgetter(sortkey),
                                 reverse=False)
            else:
                c.nodes = c.group.nodes\
                    [c.current_page_count:c.current_page_count+25]
                c.nodes = sorted(c.nodes,
                                 key=attrgetter(sortkey),
                                 reverse=True)
        else:
            c.nodes = c.group.nodes[c.current_page_count:c.current_page_count +
                                    25]
        c.all_groups, c.tag_sizes = self.get_tag_info()
        c.total_pages = (c.node_count + 25 - 1) / 25

        c.request_url = request.environ.get('PATH_INFO')
        if request.environ.get('QUERY_STRING'):
            c.request_url += '?' + request.environ['QUERY_STRING']

        if format == 'html':
            return render('/nodes/list.mako')
        elif format == 'json':
            return c.group.__json__()
        elif format == 'xml':
            return c.group.__xml__()
Exemple #51
0
    def edit(self, id, vhostid=None):
        c.title = 'Nodetraq - Vhost - Edit'
        c.selected_page = 'nodes'
        c.subpage = 'vhost'
        c.header = 'Edit Vhost'
        c.vhostid = vhostid
        c.node_id = id
        c.vhost = Session.query(NodeVhost)\
                .filter(NodeVhost.id == vhostid).first()

        return render('/nodes/vhosts/edit.mako')
Exemple #52
0
    def groups(self):
        c.title = "Nodetraq -- Ldap Search"
        c.selected_page = "users"
        c.subpage = "list"

        dh = DirectoryHelper(
            directoryCN, directoryPassword, directoryDomain)
        data = dh.ldap.search_groups()
        data = [d for d in data if d[0]]
        c.users = data
        sort_type = 'cn'
        if request.params.has_key('sort'):
            sort_type = request.params['sort']

        sort_order = 'asc'
        if request.params.has_key('order'):
            sort_order = request.params['order']

        c.sort_type = sort_type
        c.sort_order = sort_order

        if sort_order == 'asc':
            sort_order = False
        else:
            sort_order = True

        c.search_type = None
        if request.params.has_key('search_type'):
            c.search_type = request.params['search_type']

        dh = DirectoryHelper(
            directoryCN, directoryPassword, directoryDomain)
        if 'search_field' in request.params:
            if request.params['search_field']:
                fltr = \
                    '(&(objectClass=groupofuniquenames)(cn=*%s*))' % \
                    request.params['search_field']
            else:
                fltr = '(&(objectClass=groupofuniquenames))'
            data = dh.ldap.search_groups(
                Filter=fltr,
                Attrs=['cn', 'description'])
        else:
            data = dh.ldap.search_groups(Attrs=['cn', 'description'])
        for item in data:
            if not item[1].has_key('description'):
                item[1]['description'] = ['']

        c.groups = data
        c.groups = sorted(c.groups,
                          key=lambda group: group[1][sort_type],
                          reverse=sort_order)

        return render('/users/groups.mako')
Exemple #53
0
    def edit(self, id):
        id = unicode(id)
        if id.isdigit():
            c.group = Session.query(Group).filter(Group.id == id).first()
        else:
            c.group = Session.query(Group).filter(Group.name == id).first()
        c.title = 'Nodetraq - Edit group %s' % c.group.name
        c.selected_page = 'groups'
        c.subpage = 'edit'

        return render('/groups/edit.mako')
Exemple #54
0
 def atom(self):
     yesterday = now() - datetime.timedelta(hours=18)
     c.activity = (
         Session.query(Activity)
         .filter(Activity.created_at < now())
         .filter(Activity.created_at > yesterday)
         .order_by(desc(Activity.created_at))
         .filter(Activity.parent == None)
         .all()
     )
     return render("/activity/atom.mako")
Exemple #55
0
    def new(self, id):
        c.title = 'Nodetraq - dbbackups'
        c.selected_page = 'nodes'
        c.subpage = 'dbbackups'
        c.header = 'Nodes : Db backups'
        c.node_id = id

        c.backup_type_list = [(t.id, t.name) for t in
                              Session.query(BackupType).all()]

        return render('/nodes/dbbackups/new.mako')
Exemple #56
0
    def show_groups(groups, is_nodehash=False):
        response.content_type = "text/plain"
        c.groups = groups
        c.nagios = None
        if 'nagios' in request.params:
            if request.params['nagios']:
                c.nagios = request.params['nagios']

        for group in c.groups:
            c.groups[group].sort(key=lambda node: node.hostname)
        return render('/hosts/dumplist.mako')
Exemple #57
0
    def show_groups(groups, is_nodehash=False):
        response.content_type = "text/plain"
        c.groups = groups
        c.nagios = None
        if 'nagios' in request.params:
            if request.params['nagios']:
                c.nagios = request.params['nagios']

        for group in c.groups:
            c.groups[group].sort(key=lambda node: node.hostname)
        return render('/hosts/dumplist.mako')
Exemple #58
0
    def edit(self, id):
        id = unicode(id)
        if id.isdigit():
            c.group = Session.query(Group).filter(Group.id == id).first()
        else:
            c.group = Session.query(Group).filter(Group.name == id).first()
        c.title = 'Nodetraq - Edit group %s' % c.group.name
        c.selected_page = 'groups'
        c.subpage = 'edit'

        return render('/groups/edit.mako')