Ejemplo n.º 1
0
def get_db_details(request, hostname, database_name, resource_name):
    server_info = read_server_info(hostname)
    if server_info:
        found_db = None
        for database in server_info["databases"]:
            if database["name"] == database_name:
                found_db = database
                break

        size = ""
        if found_db and "size" in found_db:
            size = found_db["size"]
        return render_to_response('platforms/postgresql/database.html', {
            "base_url": settings.BASE_URL,
            "static_url": settings.STATIC_URL,
            "db_size": size,
            "db_name": database_name,
            "hostname": hostname
        },
                                  context_instance=RequestContext(request))
    else:
        return render_to_response('platforms/postgresql/database.html', {
            "base_url": settings.BASE_URL,
            "static_url": settings.STATIC_URL,
            "hostname": hostname
        },
                                  context_instance=RequestContext(request))
Ejemplo n.º 2
0
def get_details(request, hostname, database_name, resource_name):
    server_info = read_server_info(hostname)
    if server_info:
        version = ""
        if "version" in server_info:
            version = server_info["version"]
        datadir = ""
        if "data_dir" in server_info:
            datadir = server_info["data_dir"]
        return render_to_response('platforms/postgresql/server.html', {"base_url": settings.BASE_URL, "static_url":settings.STATIC_URL, "pg_version": version, "pg_datadir": datadir, "hostname": hostname}, context_instance=RequestContext(request))
    else:
        return render_to_response('platforms/postgresql/server.html', {"base_url": settings.BASE_URL, "static_url":settings.STATIC_URL, "hostname": hostname}, context_instance=RequestContext(request))
Ejemplo n.º 3
0
def get_db_details(request, hostname, database_name, resource_name):
    server_info = read_server_info(hostname)
    if server_info:
        found_db = None
        for database in server_info["databases"]:
            if database["name"] == database_name:
                found_db = database
                break
                
        size = ""
        if found_db and "size" in found_db:
            size = found_db["size"]
        return render_to_response('platforms/postgresql/database.html', {"base_url": settings.BASE_URL, "static_url":settings.STATIC_URL, "db_size":size, "db_name":database_name, "hostname": hostname}, context_instance=RequestContext(request))
    else:
        return render_to_response('platforms/postgresql/database.html', {"base_url": settings.BASE_URL, "static_url":settings.STATIC_URL, "hostname": hostname}, context_instance=RequestContext(request))
Ejemplo n.º 4
0
def get_details(request, hostname, database_name, resource_name):
    server_info = read_server_info(hostname)
    if server_info:
        version = ""
        if "version" in server_info:
            version = server_info["version"]
        datadir = ""
        if "data_dir" in server_info:
            datadir = server_info["data_dir"]
        return render_to_response('platforms/postgresql/server.html', {
            "base_url": settings.BASE_URL,
            "static_url": settings.STATIC_URL,
            "pg_version": version,
            "pg_datadir": datadir,
            "hostname": hostname
        },
                                  context_instance=RequestContext(request))
    else:
        return render_to_response('platforms/postgresql/server.html', {
            "base_url": settings.BASE_URL,
            "static_url": settings.STATIC_URL,
            "hostname": hostname
        },
                                  context_instance=RequestContext(request))
Ejemplo n.º 5
0
 def getDetailsTree(self, hostname):
     server_info = read_server_info(hostname)
     content = {}
     #Configuring Instances
     if server_info:
         content = {"isFolder": True, "title": 'PostgreSQL', "key":'PostgreSQL', "icon":"postgresql.png", "detailsEnabled":"true", 'url': reverse('postgres_details', kwargs={'hostname':hostname, 'database_name':hostname, 'resource_name':hostname})}
         logger.debug('Configuring Databases')
         db_instances = {'title': 'Databases', 'isFolder':True, "key":"databases", "icon":"folder_database.png", "type":"databases"}
         dbs = []
         for database in server_info["databases"]:
             db = {'title':database['name'], "key":database['name'], "icon":"database.png", "type":"database", "instance":database['name'], "detailsEnabled":"true", 'url': reverse('postgres_db_details', kwargs={'hostname':hostname, 'database_name':database['name'], 'resource_name':database['name']})}
             #Configuring Applications
             logger.debug('Configuring Tables')
             tables = {'title': 'Tables', 'isFolder':True, "key":"tables", "icon":"folder_documents.png", "type":"tables"}
             tabs = []
             for table in database['tables']:
                 tab = {'title':table, "key":table, "icon":"datasource.png", "type":"table", "database":database['name']}
                 tabs.append(tab)
             tables['children'] = tabs
             
             db['children'] = [tables]
             dbs.append(db)
         db_instances['children'] = dbs
         
         users_tree = {'title': 'Users', 'isFolder':True, "key":"users", "icon":"users.png", "type":"users"}
         users = []
         for user in server_info["users"]:
             user_tree = {'title':user['username'], "key":user['username'], "icon":"user.png", "type":"user"}
             users.append(user_tree)
         users_tree['children'] = users
         
         children = []
         children.append(db_instances)
         children.append(users_tree)
         content['children'] = children 
     return content
Ejemplo n.º 6
0
    def getDetailsTree(self, hostname):
        server_info = read_server_info(hostname)
        content = {}
        #Configuring Instances
        if server_info:
            content = {
                "isFolder":
                True,
                "title":
                'PostgreSQL',
                "key":
                'PostgreSQL',
                "icon":
                "postgresql.png",
                "detailsEnabled":
                "true",
                'url':
                reverse('postgres_details',
                        kwargs={
                            'hostname': hostname,
                            'database_name': hostname,
                            'resource_name': hostname
                        })
            }
            logger.debug('Configuring Databases')
            db_instances = {
                'title': 'Databases',
                'isFolder': True,
                "key": "databases",
                "icon": "folder_database.png",
                "type": "databases"
            }
            dbs = []
            for database in server_info["databases"]:
                db = {
                    'title':
                    database['name'],
                    "key":
                    database['name'],
                    "icon":
                    "database.png",
                    "type":
                    "database",
                    "instance":
                    database['name'],
                    "detailsEnabled":
                    "true",
                    'url':
                    reverse('postgres_db_details',
                            kwargs={
                                'hostname': hostname,
                                'database_name': database['name'],
                                'resource_name': database['name']
                            })
                }
                #Configuring Applications
                logger.debug('Configuring Tables')
                tables = {
                    'title': 'Tables',
                    'isFolder': True,
                    "key": "tables",
                    "icon": "folder_documents.png",
                    "type": "tables"
                }
                tabs = []
                for table in database['tables']:
                    tab = {
                        'title': table,
                        "key": table,
                        "icon": "datasource.png",
                        "type": "table",
                        "database": database['name']
                    }
                    tabs.append(tab)
                tables['children'] = tabs

                db['children'] = [tables]
                dbs.append(db)
            db_instances['children'] = dbs

            users_tree = {
                'title': 'Users',
                'isFolder': True,
                "key": "users",
                "icon": "users.png",
                "type": "users"
            }
            users = []
            for user in server_info["users"]:
                user_tree = {
                    'title': user['username'],
                    "key": user['username'],
                    "icon": "user.png",
                    "type": "user"
                }
                users.append(user_tree)
            users_tree['children'] = users

            children = []
            children.append(db_instances)
            children.append(users_tree)
            content['children'] = children
        return content