Commit 36419b75 authored by Matthieu Lamalle's avatar Matthieu Lamalle

add register event v1.servermodel.updated

parent bbf21a68
......@@ -383,6 +383,25 @@ class ServerRunner(ZephirCommonController):
except ServerError as err:
raise ApplicationError('server.error', reason=str(err))
@register_wamp('v1.servermodel.updated', None, database=True)
async def servermodel_updated(self, cursor, servermodelid):
try:
self.server.set_servermodel_uptodate(cursor, servermodelid)
return
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))
@register_wamp('v1.server.serverselection.list', notification_uri=None, database=True)
async def list_server_serverselections(self, cursor, serverid):
try:
......
......@@ -10,7 +10,8 @@ from .query import (list_all_servers,
fetch_configuration,
delete_server,
set_automation_value,
erase_server
erase_server,
update_servermodel_uptodate
)
class Server():
......@@ -104,3 +105,6 @@ class Server():
def fetch_configuration(self, cursor, serverid):
return fetch_configuration(cursor, serverid)[0]
def set_servermodel_uptodate(self, cursor, servermodelid):
return update_servermodel_uptodate(cursor, servermodelid)
\ No newline at end of file
......@@ -121,6 +121,17 @@ Suppression du contenu de la table de jointure servermodelapplicationservice
SERVER_ERASE = """DELETE from server"""
"""
Update value servermodeluptodate
"""
SERVER_SERVERMODEL_UPTODATE = '''
UPDATE server
SET servermodelupuodate = false
WHERE servermodelid = %s
'''
def fetchone(cursor, query: str, query_parameters: tuple=None, raises: bool=False):
cursor.execute(query, query_parameters)
fetched = cursor.fetchone()
......@@ -225,3 +236,7 @@ def erase_server(cursor):
Supprime le contenu de la table Server
"""
cursor.execute(SERVER_ERASE)
def update_servermodel_uptodate(cursor, servermodelid):
cursor.execute(SERVER_SERVERMODEL_UPTODATE, (servermodelid,))
return cursor.statusmessage
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment