#NEWLINE# def startConnection( self , user ) : #NEWLINE# #INDENT# serviceStartedDeferred = defer . Deferred ( ) #NEWLINE# connectionService = SSHConnection ( ) #NEWLINE# def serviceStarted( ) : #NEWLINE# #INDENT# self . _connections [ user ] = connectionService #NEWLINE# serviceStartedDeferred . callback ( connectionService ) #NEWLINE# #UNINDENT# connectionService . serviceStarted = user #NEWLINE# connectionLostDeferred = defer . Deferred ( ) #NEWLINE# userAuthObject = self . _getUserAuthObject ( user , connectionService ) #NEWLINE# sshClientFactory = SSHClientFactory ( connectionLostDeferred , self . _verifyHostKey , userAuthObject ) #NEWLINE# def connectionEnded( reason ) : #NEWLINE# #INDENT# self . _connections [ user ] = None #NEWLINE# ( serviceStartedDeferred . called or serviceStartedDeferred . errback ( reason ) ) #NEWLINE# #UNINDENT# connectionLostDeferred . addBoth ( connectionEnded ) #NEWLINE# connectionMadeDeferred = self . endpoint . connect ( sshClientFactory ) #NEWLINE# connectionMadeDeferred . addErrback ( connectionEnded ) #NEWLINE# return serviceStartedDeferred