#NEWLINE# def _get_client( timeout = None ) : #NEWLINE# #INDENT# '\n    Get a connection to a docker API (socket or URL)\n    based on config.get mechanism (pillar -> grains)\n\n    By default it will use the base docker-py defaults which\n    at the time of writing are using the local socket and\n    the 1.4 API\n\n    Set those keys in your configuration tree somehow:\n\n        - docker.url: URL to the docker service\n        - docker.version: API version to use\n\n    ' #NEWLINE# kwargs = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# get = __salt__ [ 'config.get' ] #NEWLINE# for ( key , val ) in ( ( 'base_url' , 'docker.url' ) , ( 'version' , 'docker.version' ) ) : #NEWLINE# #INDENT# param = get ( val , NOTSET ) #NEWLINE# if ( param is not NOTSET ) : #NEWLINE# #INDENT# kwargs [ key ] = param #NEWLINE# #UNINDENT# #UNINDENT# if ( timeout is not None ) : #NEWLINE# #INDENT# kwargs [ 'timeout' ] = timeout #NEWLINE# #UNINDENT# if ( 'version' not in kwargs ) : #NEWLINE# #INDENT# kwargs [ 'version' ] = 'auto' #NEWLINE# #UNINDENT# if ( ( 'base_url' not in kwargs ) and ( 'DOCKER_HOST' in os . environ ) ) : #NEWLINE# #INDENT# kwargs [ 'base_url' ] = os . environ . get ( 'DOCKER_HOST' ) #NEWLINE# #UNINDENT# client = docker . Client ( ** kwargs ) #NEWLINE# registry_auth_config = __pillar__ . get ( 'docker-registries' , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# for ( key , data ) in six . iteritems ( __pillar__ ) : #NEWLINE# #INDENT# if key . endswith ( '-docker-registries' ) : #NEWLINE# #INDENT# registry_auth_config . update ( data ) #NEWLINE# #UNINDENT# #UNINDENT# for ( registry , creds ) in six . iteritems ( registry_auth_config ) : #NEWLINE# #INDENT# client . login ( creds [ 'username' ] , password = creds [ 'password' ] , email = creds . get ( 'email' ) , registry = registry ) #NEWLINE# #UNINDENT# return client