Merge pull request #40932 from rallytime/merge-nitrogen

[nitrogen] Merge forward from 2016.11 to nitrogen
This commit is contained in:
Nicole Thomas 2017-04-27 11:47:05 -06:00 committed by GitHub
commit abb42d1de3
6 changed files with 27 additions and 6 deletions

View File

@ -3838,6 +3838,8 @@ def get_managed(
source_sum = {'hsum': cached_sum, 'hash_type': htype} source_sum = {'hsum': cached_sum, 'hash_type': htype}
elif cached_sum != source_sum.get('hsum', __opts__['hash_type']): elif cached_sum != source_sum.get('hsum', __opts__['hash_type']):
cache_refetch = True cache_refetch = True
else:
sfn = cached_dest
# If we didn't have the template or remote file, let's get it # If we didn't have the template or remote file, let's get it
# Similarly when the file has been updated and the cache has to be refreshed # Similarly when the file has been updated and the cache has to be refreshed

View File

@ -74,6 +74,7 @@ class RunnerClient(mixins.SyncClientMixin, mixins.AsyncClientMixin, object):
reserved_kwargs = dict([(i, low.pop(i)) for i in [ reserved_kwargs = dict([(i, low.pop(i)) for i in [
'username', 'password', 'eauth', 'token', 'client', 'user', 'key', 'username', 'password', 'eauth', 'token', 'client', 'user', 'key',
'__current_eauth_groups', '__current_eauth_user',
] if i in low]) ] if i in low])
# Run name=value args through parse_input. We don't need to run kwargs # Run name=value args through parse_input. We don't need to run kwargs

View File

@ -62,7 +62,7 @@ def query(name, match=None, match_type='string', status=None, wait_for=None, **k
query_example: query_example:
http.query: http.query:
- name: 'http://example.com/' - name: 'http://example.com/'
- status: '200' - status: 200
''' '''
# Monitoring state, but changes may be made over HTTP # Monitoring state, but changes may be made over HTTP

View File

@ -62,11 +62,16 @@ def _get_changes(rsync_out):
else: else:
copied.append(line) copied.append(line)
return { ret = {
'copied': os.linesep.join(sorted(copied)) or "N/A", 'copied': os.linesep.join(sorted(copied)) or "N/A",
'deleted': os.linesep.join(sorted(deleted)) or "N/A", 'deleted': os.linesep.join(sorted(deleted)) or "N/A",
} }
# Return whether anything really changed
ret['changed'] = not ((ret['copied'] == 'N/A') and (ret['deleted'] == 'N/A'))
return ret
def synchronized(name, source, def synchronized(name, source,
delete=False, delete=False,
@ -135,12 +140,18 @@ def synchronized(name, source,
ret['comment'] = _get_summary(result['stdout']) ret['comment'] = _get_summary(result['stdout'])
return ret return ret
# Failed
if result.get('retcode'): if result.get('retcode'):
ret['result'] = False ret['result'] = False
ret['comment'] = result['stderr'] ret['comment'] = result['stderr']
ret['changes'] = result['stdout'] ret['changes'] = result['stdout']
else: # Changed
elif _get_changes(result['stdout'])['changed']:
ret['comment'] = _get_summary(result['stdout']) ret['comment'] = _get_summary(result['stdout'])
ret['changes'] = _get_changes(result['stdout']) ret['changes'] = _get_changes(result['stdout'])
del ret['changes']['changed'] # Don't need to print the boolean
# Clean
else:
ret['comment'] = _get_summary(result['stdout'])
ret['changes'] = {}
return ret return ret

View File

@ -407,7 +407,7 @@ def table_present(name, db, schema, force=False):
if len(tables) == 1: if len(tables) == 1:
sql = None sql = None
if isinstance(schema, str): if isinstance(schema, str):
sql = schema sql = schema.strip()
else: else:
sql = _get_sql_from_schema(name, schema) sql = _get_sql_from_schema(name, schema)

View File

@ -745,7 +745,14 @@ class TCPClientKeepAlive(tornado.tcpclient.TCPClient):
super(TCPClientKeepAlive, self).__init__( super(TCPClientKeepAlive, self).__init__(
resolver=resolver, io_loop=io_loop) resolver=resolver, io_loop=io_loop)
def _create_stream(self, max_buffer_size, af, addr): def _create_stream(self, max_buffer_size, af, addr, **kwargs): # pylint: disable=unused-argument
'''
Override _create_stream() in TCPClient.
Tornado 4.5 added the kwargs 'source_ip' and 'source_port'.
Due to this, use **kwargs to swallow these and any future
kwargs to maintain compatibility.
'''
# Always connect in plaintext; we'll convert to ssl if necessary # Always connect in plaintext; we'll convert to ssl if necessary
# after one connection has completed. # after one connection has completed.
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)