Adding the current user information in the server information (when

connected).
This commit is contained in:
Ashesh Vashi 2016-01-11 22:11:08 +05:30
parent c90c673900
commit 932ed358e8
2 changed files with 26 additions and 5 deletions

View File

@ -80,7 +80,9 @@ class ServerModule(sg.ServerGroupPluginModule):
self.NODE_TYPE,
connected=connected,
server_type=manager.server_type if connected else "pg",
version=manager.version
version=manager.version,
db=manager.db,
user=manager.user_info if connected else None
)
@property
@ -199,7 +201,9 @@ class ServerNode(PGChildNodeView):
self.node_type,
connected=connected,
server_type=manager.server_type if connected else 'pg',
version=manager.version
version=manager.version,
db=manager.db,
user=manager.user_info if connected else None
)
)
return make_json_response(result=res)
@ -237,7 +241,9 @@ class ServerNode(PGChildNodeView):
self.node_type,
connected=connected,
server_type=manager.server_type if connected else 'pg',
version=manager.version
version=manager.version,
db=manager.db,
user=manager.user_info if connected else None
)
)
@ -663,7 +669,8 @@ class ServerNode(PGChildNodeView):
'connected': True,
'type': manager.server_type,
'version': manager.version,
'db': manager.db
'db': manager.db,
'user': manager.user_info
}
)

View File

@ -201,7 +201,21 @@ WHERE db.datname = current_database()""")
if status:
mgr.db_info = dict()
f_row = res['rows'][0]
mgr.db_info[f_row['did']] = f_row
mgr.db_info[f_row['did']] = f_row.copy()
status, res = self.execute_dict("""
SELECT
oid as id, rolname as name, rolsuper as is_superuser,
rolcreaterole as can_create_role, rolcreatedb as can_create_db
FROM
pg_catalog.pg_roles
WHERE
rolname = current_user""")
if status:
mgr.user_info = dict()
f_row = res['rows'][0]
mgr.user_info = f_row.copy()
if 'password' in kwargs:
mgr.password = kwargs['password']