parameters: (self, host, login, passwd, conn)
docstring: returns a connection object (as returned by the libvirt.open* methods) for the given host and credentials
          raises libvirtError if (re)connecting fails
docstring_summary: returns a connection object (as returned by the libvirt.open* methods) for the given host and credentials
          raises libvirtError if (re)connecting fails
docstring_tokens: returns a connection object ( as returned by the libvirt . open * methods ) for the given host and credentials raises libvirtError if ( re ) connecting fails
function: def get_connection(self, host, login, passwd, conn):
          """
          returns a connection object (as returned by the libvirt.open* methods) for the given host and credentials
          raises libvirtError if (re)connecting fails
          """
          # force all string values to unicode
          host = unicode(host)
          login = unicode(login)
          passwd = unicode(passwd) if passwd is not None else None
  
          connection = self._search_connection(host, login, passwd, conn)
  
          if (connection is None):
              self._connections_lock.acquireWrite()
              try:
                  # we have to search for the connection again after aquireing the write lock
                  # as the thread previously holding the write lock may have already added our connection
                  connection = self._search_connection(host, login, passwd, conn)
                  if (connection is None):
                      # create a new connection if a matching connection does not already exist
                      connection = wvmConnection(host, login, passwd, conn)
  
                      # add new connection to connection dict
                      if host in self._connections:
                          self._connections[host].append(connection)
                      else:
                          self._connections[host] = [connection]
              finally:
                  self._connections_lock.release()
  
          elif not connection.connected:
              # try to (re-)connect if connection is closed
              connection.connect()
  
          if connection.connected:
              # return libvirt connection object
              return connection.connection
          else:
              # raise libvirt error
              raise libvirtError(connection.last_error)
function_tokens: def get_connection ( self , host , login , passwd , conn ) : # force all string values to unicode host = unicode ( host ) login = unicode ( login ) passwd = unicode ( passwd ) if passwd is not None else None connection = self . _search_connection ( host , login , passwd , conn ) if ( connection is None ) : self . _connections_lock . acquireWrite ( ) try : # we have to search for the connection again after aquireing the write lock # as the thread previously holding the write lock may have already added our connection connection = self . _search_connection ( host , login , passwd , conn ) if ( connection is None ) : # create a new connection if a matching connection does not already exist connection = wvmConnection ( host , login , passwd , conn ) # add new connection to connection dict if host in self . _connections : self . _connections [ host ] . append ( connection ) else : self . _connections [ host ] = [ connection ] finally : self . _connections_lock . release ( ) elif not connection . connected : # try to (re-)connect if connection is closed connection . connect ( ) if connection . connected : # return libvirt connection object return connection . connection else : # raise libvirt error raise libvirtError ( connection . last_error )