Commit 968e9453 authored by Matthieu Lamalle's avatar Matthieu Lamalle
Browse files

correction username

parent 858e2cc0
......@@ -260,7 +260,7 @@ class ServerRunner(ZephirCommonController):
async def exec_describe(self, job_id, automation):
if automation == 'salt':
results = await self.call('v1.execution.salt.job.describe',
jid=str(job_id))
jid=str(job_id))
else:
raise Exception(_('Automation engine not supported: {}').format(automation))
ret = []
......@@ -487,9 +487,9 @@ class ServerRunner(ZephirCommonController):
raise ApplicationError('serverselection.error', reason=str(err))
@register_wamp('v1.serverselection.user.role.get', notification_uri=None, database=True)
async def get_serverselection_user_role(self, cursor, serverselectionid, serverselectionuser):
async def get_serverselection_user_role(self, cursor, serverselectionid, username):
try:
return self.serverselection.get_serverselection_user_role(cursor, serverselectionid, serverselectionuser)
return self.serverselection.get_serverselection_user_role(cursor, serverselectionid, username)
except ServerSelectionErrorDatabaseNotAvailable as err:
raise ApplicationError('serverselection.error.database_not_available', reason=str(err))
......@@ -503,9 +503,9 @@ class ServerRunner(ZephirCommonController):
raise ApplicationError('serverselection.error', reason=str(err))
@register_wamp('v1.serverselection.user.role.server.get', notification_uri=None, database=True)
async def get_serverselection_user_server_role(self, cursor, serverid, serverselectionuser):
async def get_serverselection_user_server_role(self, cursor, serverid, username):
try:
return self.serverselection.get_serverselection_user_server_role(cursor, serverid, serverselectionuser)
return self.serverselection.get_serverselection_user_server_role(cursor, serverid, username)
except ServerSelectionErrorDatabaseNotAvailable as err:
raise ApplicationError('serverselection.error.database_not_available', reason=str(err))
......@@ -517,6 +517,35 @@ class ServerRunner(ZephirCommonController):
raise ApplicationError('serverselection.error.unknown_serverselection_id', reason=str(err))
except ServerSelectionError as err:
raise ApplicationError('serverselection.error', reason=str(err))
@register_wamp('v1.serverselection.exec.command', notification_uri=None, database=True) #FIXME notification
async def exec_cmd_on_serverserverselection(self, cursor, serverselection_id, command):
"""
Transfer command transmitted to automation (salt, ...)
"""
servers = self.serverselection.describe_serverselection(cursor, serverselection_id)['serverselectionserversid']
automation = None
servers_id = []
for server_id in servers:
if automation is None:
automation, automation_command = self.serverselection.get_automation_command(cursor, server_id)
servers_id.append(server_id)
minion_pattern = ','.join(servers_id)
if automation == 'salt':
result = await self.call('v1.execution.salt.exec',
minion_pattern=minion_pattern,
command=automation_command,
arg=command,
client_mode='local_async')
else:
raise Exception(_('Automation engine not supported: {}').format(automation))
if result['minions'] != servers_id:
raise Exception(_('Job ({}) not executed only in selected server, all client affected : {}').format(result['jid'],
result['minions']))
return {'job_id': result['jid'],
'servers_id': servers_id,
'command': command,
'automation': automation}
if __name__ == '__main__':
run(ServerRunner)
......@@ -120,6 +120,9 @@ SERVERSELECTION_UPDATE_USER = '''
RETURNING *
'''
"""
List all serverselection of a user
"""
SERVERSELECTION_USER_SERVER_LIST = '''
SELECT json_agg(c) AS serverselectionserversid
FROM (
......
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