Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
EOLE
Zéphir
Services
Server Manager
Commits
f2c10487
Commit
f2c10487
authored
Jun 03, 2019
by
Matthieu Lamalle
Browse files
add message server.serverselection.list
parent
acd7620f
Pipeline
#554
passed with stage
in 0 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
scripts/controller
View file @
f2c10487
...
...
@@ -382,6 +382,25 @@ class ServerRunner(ZephirCommonController):
except
ServerError
as
err
:
raise
ApplicationError
(
'server.error'
,
reason
=
str
(
err
))
@
register_wamp
(
'v1.server.serverselection.list'
,
notification_uri
=
None
,
database
=
True
)
async
def
list_server_serverselections
(
self
,
cursor
,
serverid
):
try
:
return
self
.
serverselection
.
list_server_serverselections
(
cursor
,
serverid
)
except
ServerErrorDatabaseNotAvailable
as
err
:
raise
ApplicationError
(
'server.error.database-not-available'
,
reason
=
str
(
err
))
except
ServerErrorDbConnection
as
err
:
raise
ApplicationError
(
'server.error.db-connection'
,
reason
=
str
(
err
))
except
ServerErrorInvalidServerId
as
err
:
raise
ApplicationError
(
'server.error.invalid-server-id'
,
reason
=
str
(
err
))
except
ServerErrorUnknownServerId
as
err
:
raise
ApplicationError
(
'server.error.unknown-server-id'
,
reason
=
str
(
err
))
except
ServerErrorServerNameNotProvided
as
err
:
raise
ApplicationError
(
'server.error.servername-not-provided'
,
reason
=
str
(
err
))
except
ServerError
as
err
:
raise
ApplicationError
(
'server.error'
,
reason
=
str
(
err
))
def
_list_user_servers
(
self
,
cursor
,
_session_user
):
try
:
username
=
_session_user
[
'username'
]
...
...
src/python/server/serverselection/lib.py
View file @
f2c10487
...
...
@@ -17,7 +17,8 @@ from .query import (list_all_serverselections,
fetch_serverselection_user_role
,
fetch_serverselection_user_server_role
,
erase_serverselection
,
set_list_server_serverselection
set_list_server_serverselection
,
list_server_serverselections
)
class
ServerSelection
():
...
...
@@ -179,3 +180,11 @@ class ServerSelection():
:return bool: True for addition success, False either
"""
return
fetch_serverselection_user_server_role
(
cursor
,
username
,
serverid
)
def
list_server_serverselections
(
self
,
cursor
,
serverid
):
"""List of serverselections of a server
:param int serverid: server identifier
:return: list of serverselection
"""
return
list_server_serverselections
(
cursor
,
serverid
)
src/python/server/serverselection/query.py
View file @
f2c10487
...
...
@@ -173,6 +173,14 @@ FETCH_ROLE_USER_SERVER_SERVERSELECTION = '''
AND serverselectionusers->%s IS NOT NULL
'''
"""
Fetch the selections of a server
"""
FETCH_SERVER_SERVERSELECTION_LIST
=
'''
SELECT * FROM serverselection
WHERE %s = ANY (serverselectionserversid)
'''
"""
Suppression du contenu de la table de serverselection
"""
...
...
@@ -303,6 +311,13 @@ def update_user_from_serverselection(cursor, serverselectionid, username, role):
serverselectionuserrolehstore
=
username
+
'=>'
+
role
return
serverselection_row_to_dict
(
fetchone
(
cursor
,
SERVERSELECTION_UPDATE_USER
,
(
serverselectionuserrolehstore
,
serverselectionid
),
raises
=
True
))
def
list_server_serverselections
(
cursor
,
serverid
):
cursor
.
execute
(
FETCH_SERVER_SERVERSELECTION_LIST
,
(
serverid
,))
ret
=
[]
for
serverselection
in
cursor
.
fetchall
():
ret
.
append
(
serverselection_row_to_dict
(
serverselection
))
return
ret
def
erase_serverselection
(
cursor
):
"""
Supprime le contenu de la table Serverselection
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment