Commit b0a4d430 authored by Philippe Caseiro's avatar Philippe Caseiro
Browse files

Merge branch '59_execution_commande' into 'develop'

59 execution commande

See merge request !2
parents e096b404 3c6652d1
......@@ -39,7 +39,7 @@ RUN git clone "${CONTAINERPILOT_REPO_URL}" "/tmp/orchestrate" \
# API messages description
ARG MESSAGES_API_REPO_URL=https://gitlab.mim.ovh/EOLE/Zephir/messages-api.git
ARG MESSAGES_API_REPO_REF=9f534509
ARG MESSAGES_API_REPO_REF=0.0.3-dev
RUN git clone "${MESSAGES_API_REPO_URL}" "/tmp/messages-api" \
&& cd /tmp/messages-api \
......
......@@ -51,9 +51,9 @@ class SaltRunner(ZephirCommonController):
@register_wamp('v1.execution.salt.exec', notification_uri='v1.execution.salt.exec.command-executed')
async def exec_command(self, minion_pattern, command, arg, client_mode):
async def exec_command(self, minion_pattern, command, arg, client_mode, tgt_type):
try:
ret = self.executor.exec_command(minion_pattern, command, arg, client_mode)
ret = self.executor.exec_command(minion_pattern, command, arg, client_mode, tgt_type)
return ret
except SaltExecErrorMissingMinionPattern as err:
......
......@@ -44,7 +44,7 @@ class SaltExec():
self.config = config
def exec_command(self, minion_pattern, command, arg=None, client_mode='local_async'):
def exec_command(self, minion_pattern, command, arg=None, client_mode='local_async', tgt_type='glob'):
msg = _('Salt executor : shedule execution of “{}({})” on target “{}”')
print(msg.format(command, arg or "", minion_pattern))
session = requests.Session()
......@@ -52,7 +52,7 @@ class SaltExec():
resp = session.post('http://localhost:8000/login',
json={'username': 'eole',
'password': 'eole',
'eauth': 'pam',
'eauth': 'pam'
})
assert resp.status_code == 200, resp.reason
......@@ -65,7 +65,8 @@ class SaltExec():
json_payload = {
'client': client_mode,
'tgt': minion_pattern,
'fun': command
'fun': command,
'tgt_type': tgt_type
}
if arg is not None:
......@@ -74,7 +75,9 @@ class SaltExec():
resp = session.post('http://localhost:8000', json=[json_payload])
assert resp.status_code == 200, resp.reason
print(resp.json())
ret = resp.json()['return'][0]
print(ret)
if not ret:
raise SaltExecError(_('salt did not find any server to execute the command'))
......
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