mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge branch '2017.7' into fix_49566
This commit is contained in:
commit
6a5a69c8be
3 changed files with 43 additions and 43 deletions
|
@ -1,6 +1,4 @@
|
|||
# encoding: utf-8
|
||||
from __future__ import absolute_import, print_function
|
||||
|
||||
'''
|
||||
A non-blocking REST API for Salt
|
||||
================================
|
||||
|
@ -186,10 +184,11 @@ a return like::
|
|||
.. |401| replace:: authentication required
|
||||
.. |406| replace:: requested Content-Type not available
|
||||
.. |500| replace:: internal server error
|
||||
''' # pylint: disable=W0105
|
||||
# pylint: disable=W0232
|
||||
'''
|
||||
# pylint: disable=W0105,W0232
|
||||
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import, print_function
|
||||
import time
|
||||
import fnmatch
|
||||
import logging
|
||||
|
@ -608,7 +607,7 @@ class SaltAuthHandler(BaseSaltAPIHandler): # pylint: disable=W0223
|
|||
'''
|
||||
def get(self):
|
||||
'''
|
||||
All logins are done over post, this is a parked enpoint
|
||||
All logins are done over post, this is a parked endpoint
|
||||
|
||||
.. http:get:: /login
|
||||
|
||||
|
@ -621,7 +620,7 @@ class SaltAuthHandler(BaseSaltAPIHandler): # pylint: disable=W0223
|
|||
|
||||
curl -i localhost:8000/login
|
||||
|
||||
.. code-block:: http
|
||||
.. code-block:: text
|
||||
|
||||
GET /login HTTP/1.1
|
||||
Host: localhost:8000
|
||||
|
@ -629,7 +628,7 @@ class SaltAuthHandler(BaseSaltAPIHandler): # pylint: disable=W0223
|
|||
|
||||
**Example response:**
|
||||
|
||||
.. code-block:: http
|
||||
.. code-block:: text
|
||||
|
||||
HTTP/1.1 401 Unauthorized
|
||||
Content-Type: application/json
|
||||
|
@ -648,7 +647,7 @@ class SaltAuthHandler(BaseSaltAPIHandler): # pylint: disable=W0223
|
|||
# TODO: make async? Underlying library isn't... and we ARE making disk calls :(
|
||||
def post(self):
|
||||
'''
|
||||
:ref:`Authenticate <rest_tornado-auth>` against Salt's eauth system
|
||||
:ref:`Authenticate <rest_tornado-auth>` against Salt's eauth system
|
||||
|
||||
.. http:post:: /login
|
||||
|
||||
|
@ -676,7 +675,7 @@ class SaltAuthHandler(BaseSaltAPIHandler): # pylint: disable=W0223
|
|||
-d password='saltpass' \\
|
||||
-d eauth='pam'
|
||||
|
||||
.. code-block:: http
|
||||
.. code-block:: text
|
||||
|
||||
POST / HTTP/1.1
|
||||
Host: localhost:8000
|
||||
|
@ -688,7 +687,7 @@ class SaltAuthHandler(BaseSaltAPIHandler): # pylint: disable=W0223
|
|||
|
||||
**Example response:**
|
||||
|
||||
.. code-block:: http
|
||||
.. code-block:: text
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
Content-Type: application/json
|
||||
|
@ -767,7 +766,7 @@ class SaltAPIHandler(BaseSaltAPIHandler): # pylint: disable=W0223
|
|||
'''
|
||||
def get(self):
|
||||
'''
|
||||
An enpoint to determine salt-api capabilities
|
||||
An endpoint to determine salt-api capabilities
|
||||
|
||||
.. http:get:: /
|
||||
|
||||
|
@ -783,7 +782,7 @@ class SaltAPIHandler(BaseSaltAPIHandler): # pylint: disable=W0223
|
|||
|
||||
curl -i localhost:8000
|
||||
|
||||
.. code-block:: http
|
||||
.. code-block:: text
|
||||
|
||||
GET / HTTP/1.1
|
||||
Host: localhost:8000
|
||||
|
@ -791,7 +790,7 @@ class SaltAPIHandler(BaseSaltAPIHandler): # pylint: disable=W0223
|
|||
|
||||
**Example response:**
|
||||
|
||||
.. code-block:: http
|
||||
.. code-block:: text
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
Content-Type: application/json
|
||||
|
@ -835,7 +834,7 @@ class SaltAPIHandler(BaseSaltAPIHandler): # pylint: disable=W0223
|
|||
-d fun='test.ping' \\
|
||||
-d arg
|
||||
|
||||
.. code-block:: http
|
||||
.. code-block:: text
|
||||
|
||||
POST / HTTP/1.1
|
||||
Host: localhost:8000
|
||||
|
@ -847,11 +846,12 @@ class SaltAPIHandler(BaseSaltAPIHandler): # pylint: disable=W0223
|
|||
fun=test.ping&arg&client=local&tgt=*
|
||||
|
||||
**Example response:**
|
||||
|
||||
Responses are an in-order list of the lowstate's return data. In the
|
||||
event of an exception running a command the return will be a string
|
||||
instead of a mapping.
|
||||
|
||||
.. code-block:: http
|
||||
.. code-block:: text
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
Content-Length: 200
|
||||
|
@ -866,10 +866,11 @@ class SaltAPIHandler(BaseSaltAPIHandler): # pylint: disable=W0223
|
|||
ms-4: true
|
||||
|
||||
.. admonition:: multiple commands
|
||||
|
||||
Note that if multiple :term:`lowstate` structures are sent, the Salt
|
||||
API will execute them in serial, and will not stop execution upon failure
|
||||
of a previous job. If you need to have commands executed in order and
|
||||
stop on failure please use compount-command-execution.
|
||||
stop on failure please use compound-command-execution.
|
||||
|
||||
'''
|
||||
# if you aren't authenticated, redirect to login
|
||||
|
@ -970,7 +971,8 @@ class SaltAPIHandler(BaseSaltAPIHandler): # pylint: disable=W0223
|
|||
is_finished)
|
||||
|
||||
def more_todo():
|
||||
'''Check if there are any more minions we are waiting on returns from
|
||||
'''
|
||||
Check if there are any more minions we are waiting on returns from
|
||||
'''
|
||||
return any(x is False for x in six.itervalues(minions))
|
||||
|
||||
|
@ -1133,7 +1135,7 @@ class MinionSaltAPIHandler(SaltAPIHandler): # pylint: disable=W0223
|
|||
|
||||
curl -i localhost:8000/minions/ms-3
|
||||
|
||||
.. code-block:: http
|
||||
.. code-block:: text
|
||||
|
||||
GET /minions/ms-3 HTTP/1.1
|
||||
Host: localhost:8000
|
||||
|
@ -1141,7 +1143,7 @@ class MinionSaltAPIHandler(SaltAPIHandler): # pylint: disable=W0223
|
|||
|
||||
**Example response:**
|
||||
|
||||
.. code-block:: http
|
||||
.. code-block:: text
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
Content-Length: 129005
|
||||
|
@ -1194,7 +1196,7 @@ class MinionSaltAPIHandler(SaltAPIHandler): # pylint: disable=W0223
|
|||
-d tgt='*' \\
|
||||
-d fun='status.diskusage'
|
||||
|
||||
.. code-block:: http
|
||||
.. code-block:: text
|
||||
|
||||
POST /minions HTTP/1.1
|
||||
Host: localhost:8000
|
||||
|
@ -1206,7 +1208,7 @@ class MinionSaltAPIHandler(SaltAPIHandler): # pylint: disable=W0223
|
|||
|
||||
**Example response:**
|
||||
|
||||
.. code-block:: http
|
||||
.. code-block:: text
|
||||
|
||||
HTTP/1.1 202 Accepted
|
||||
Content-Length: 86
|
||||
|
@ -1261,7 +1263,7 @@ class JobsSaltAPIHandler(SaltAPIHandler): # pylint: disable=W0223
|
|||
|
||||
curl -i localhost:8000/jobs
|
||||
|
||||
.. code-block:: http
|
||||
.. code-block:: text
|
||||
|
||||
GET /jobs HTTP/1.1
|
||||
Host: localhost:8000
|
||||
|
@ -1269,7 +1271,7 @@ class JobsSaltAPIHandler(SaltAPIHandler): # pylint: disable=W0223
|
|||
|
||||
**Example response:**
|
||||
|
||||
.. code-block:: http
|
||||
.. code-block:: text
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
Content-Length: 165
|
||||
|
@ -1290,7 +1292,7 @@ class JobsSaltAPIHandler(SaltAPIHandler): # pylint: disable=W0223
|
|||
|
||||
curl -i localhost:8000/jobs/20121130104633606931
|
||||
|
||||
.. code-block:: http
|
||||
.. code-block:: text
|
||||
|
||||
GET /jobs/20121130104633606931 HTTP/1.1
|
||||
Host: localhost:8000
|
||||
|
@ -1298,7 +1300,7 @@ class JobsSaltAPIHandler(SaltAPIHandler): # pylint: disable=W0223
|
|||
|
||||
**Example response:**
|
||||
|
||||
.. code-block:: http
|
||||
.. code-block:: text
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
Content-Length: 73
|
||||
|
@ -1379,7 +1381,7 @@ class RunSaltAPIHandler(SaltAPIHandler): # pylint: disable=W0223
|
|||
-d password='saltdev' \\
|
||||
-d eauth='pam'
|
||||
|
||||
.. code-block:: http
|
||||
.. code-block:: text
|
||||
|
||||
POST /run HTTP/1.1
|
||||
Host: localhost:8000
|
||||
|
@ -1391,7 +1393,7 @@ class RunSaltAPIHandler(SaltAPIHandler): # pylint: disable=W0223
|
|||
|
||||
**Example response:**
|
||||
|
||||
.. code-block:: http
|
||||
.. code-block:: text
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
Content-Length: 73
|
||||
|
@ -1438,14 +1440,14 @@ class EventsSaltAPIHandler(SaltAPIHandler): # pylint: disable=W0223
|
|||
|
||||
curl -NsS localhost:8000/events
|
||||
|
||||
.. code-block:: http
|
||||
.. code-block:: text
|
||||
|
||||
GET /events HTTP/1.1
|
||||
Host: localhost:8000
|
||||
|
||||
**Example response:**
|
||||
|
||||
.. code-block:: http
|
||||
.. code-block:: text
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
Connection: keep-alive
|
||||
|
@ -1593,7 +1595,7 @@ class WebhookSaltAPIHandler(SaltAPIHandler): # pylint: disable=W0223
|
|||
|
||||
curl -sS localhost:8000/hook -d foo='Foo!' -d bar='Bar!'
|
||||
|
||||
.. code-block:: http
|
||||
.. code-block:: text
|
||||
|
||||
POST /hook HTTP/1.1
|
||||
Host: localhost:8000
|
||||
|
@ -1604,7 +1606,7 @@ class WebhookSaltAPIHandler(SaltAPIHandler): # pylint: disable=W0223
|
|||
|
||||
**Example response**:
|
||||
|
||||
.. code-block:: http
|
||||
.. code-block:: text
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
Content-Length: 14
|
||||
|
@ -1617,7 +1619,9 @@ class WebhookSaltAPIHandler(SaltAPIHandler): # pylint: disable=W0223
|
|||
``http://localhost:8000/hook/mycompany/build/success`` which contains
|
||||
the result of a build and the SHA of the version that was built as
|
||||
JSON. That would then produce the following event in Salt that could be
|
||||
used to kick off a deployment via Salt's Reactor::
|
||||
used to kick off a deployment via Salt's Reactor:
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
Event fired at Fri Feb 14 17:40:11 2014
|
||||
*************************
|
||||
|
@ -1642,7 +1646,7 @@ class WebhookSaltAPIHandler(SaltAPIHandler): # pylint: disable=W0223
|
|||
|
||||
And finally deploy the new build:
|
||||
|
||||
.. code-block:: yaml
|
||||
.. code-block:: jinja
|
||||
|
||||
{% set secret_key = data.get('headers', {}).get('X-My-Secret-Key') %}
|
||||
{% set build = data.get('post', {}) %}
|
||||
|
@ -1697,9 +1701,9 @@ class WebhookSaltAPIHandler(SaltAPIHandler): # pylint: disable=W0223
|
|||
|
||||
|
||||
def _check_cors_origin(origin, allowed_origins):
|
||||
"""
|
||||
'''
|
||||
Check if an origin match cors allowed origins
|
||||
"""
|
||||
'''
|
||||
if isinstance(allowed_origins, list):
|
||||
if origin in allowed_origins:
|
||||
return origin
|
||||
|
|
|
@ -49,11 +49,9 @@ from __future__ import absolute_import
|
|||
import logging
|
||||
|
||||
try:
|
||||
HAS_VARSTACK = False
|
||||
import varstack
|
||||
HAS_VARSTACK = True
|
||||
except ImportError:
|
||||
pass
|
||||
varstack = None
|
||||
|
||||
# Set up logging
|
||||
log = logging.getLogger(__name__)
|
||||
|
@ -63,10 +61,7 @@ __virtualname__ = 'varstack'
|
|||
|
||||
|
||||
def __virtual__():
|
||||
if not HAS_VARSTACK:
|
||||
log.error("Can't find varstack master_top")
|
||||
return False
|
||||
return __virtualname__
|
||||
return (False, 'varstack not installed') if varstack is None else __virtualname__
|
||||
|
||||
|
||||
def top(**kwargs):
|
||||
|
|
|
@ -669,7 +669,8 @@ class GitModuleTest(ModuleCase):
|
|||
second_rev = self.run_function(
|
||||
'git.revision',
|
||||
[self.repo],
|
||||
rev=self.branches[1]
|
||||
rev=self.branches[1],
|
||||
timeout=120
|
||||
)
|
||||
# Make sure revision is a 40-char string
|
||||
self.assertTrue(len(second_rev) == 40)
|
||||
|
|
Loading…
Add table
Reference in a new issue