-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'openSUSE:openSUSE/release/3006.0' into openSUSE/release…
…/3006.0
- Loading branch information
Showing
45 changed files
with
485 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Fixed issue in salt-cloud so that multiple masters specified in the cloud | ||
are written to the minion config properly |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,27 @@ | ||
import threading | ||
import contextlib | ||
|
||
try: | ||
# Try the stdlib C extension first | ||
import _contextvars as contextvars | ||
except ImportError: | ||
# Py<3.7 | ||
import contextvars | ||
|
||
class ClassProperty(property): | ||
""" | ||
Use a classmethod as a property | ||
http://stackoverflow.com/a/1383402/1258307 | ||
""" | ||
DEFAULT_CTX_VAR = "request_ctxvar" | ||
request_ctxvar = contextvars.ContextVar(DEFAULT_CTX_VAR) | ||
|
||
def __get__(self, cls, owner): | ||
return self.fget.__get__(None, owner)() # pylint: disable=no-member | ||
|
||
|
||
class RequestContext: | ||
@contextlib.contextmanager | ||
def request_context(data): | ||
""" | ||
A context manager that saves some per-thread state globally. | ||
Intended for use with Tornado's StackContext. | ||
https://gist.github.com/simon-weber/7755289 | ||
Simply import this class into any module and access the current request handler by this | ||
class's class method property 'current'. If it returns None, there's no active request. | ||
.. code:: python | ||
from raas.utils.ctx import RequestContext | ||
current_request_handler = RequestContext.current | ||
A context manager that sets and un-sets the loader context | ||
""" | ||
tok = request_ctxvar.set(data) | ||
try: | ||
yield | ||
finally: | ||
request_ctxvar.reset(tok) | ||
|
||
_state = threading.local() | ||
_state.current_request = {} | ||
|
||
def __init__(self, current_request): | ||
self._current_request = current_request | ||
|
||
@ClassProperty | ||
@classmethod | ||
def current(cls): | ||
if not hasattr(cls._state, "current_request"): | ||
return {} | ||
return cls._state.current_request | ||
|
||
def __enter__(self): | ||
self._prev_request = self.__class__.current | ||
self.__class__._state.current_request = self._current_request | ||
|
||
def __exit__(self, *exc): | ||
self.__class__._state.current_request = self._prev_request | ||
del self._prev_request | ||
return False | ||
|
||
def __call__(self): | ||
return self | ||
def get_request_context(): | ||
return request_ctxvar.get({}) |
Oops, something went wrong.