Esempio n. 1
0
 def _executeAction( self, trid, proposalTuple, clientInitArgs ):
   clientTransport = self._transportPool.get( trid )
   credDict = clientTransport.getConnectingCredentials()
   targetService = proposalTuple[0][0]
   actionType = proposalTuple[1][0]
   actionMethod = proposalTuple[1][1]
   idString = self._createIdentityString( credDict, clientTransport )
   #OOkay! Lets do the magic!
   retVal = clientTransport.receiveData()
   if not retVal[ 'OK' ]:
     gLogger.error( "Error while receiving file description", retVal[ 'Message' ] )
     clientTransport.sendData( S_ERROR( "Error while receiving file description: %s" % retVal[ 'Message' ] ) )
     return
   if actionType == "FileTransfer":
     gLogger.warn( "Received a file transfer action from %s" % idString )
     clientTransport.sendData( S_OK( "Accepted" ) )
     retVal = self.__forwardFileTransferCall( targetService, clientInitArgs,
                                               actionMethod, retVal[ 'Value' ], clientTransport )
   elif actionType == "RPC":
     gLogger.info( "Forwarding %s/%s action to %s for %s" % ( actionType, actionMethod, targetService, idString ) )
     retVal = self.__forwardRPCCall( targetService, clientInitArgs, actionMethod, retVal[ 'Value' ] )
   elif actionType == "Connection" and actionMethod == "new":
     gLogger.info( "Initiating a messaging connection to %s for %s" % ( targetService, idString ) )
     retVal = self._msgForwarder.addClient( trid, targetService, clientInitArgs, retVal[ 'Value' ] )
   else:
     gLogger.warn( "Received an invalid %s/%s action from %s" % ( actionType, actionMethod, idString ) )
     retVal = S_ERROR( "Unknown type of action (%s)" % actionType )
   #TODO: Send back the data?
   if 'rpcStub' in retVal:
     retVal.pop( 'rpcStub' )
   clientTransport.sendData( retVal )
   return retVal
Esempio n. 2
0
 def _executeAction(self, trid, proposalTuple, clientInitArgs):
     clientTransport = self._transportPool.get(trid)
     credDict = clientTransport.getConnectingCredentials()
     targetService = proposalTuple[0][0]
     actionType = proposalTuple[1][0]
     actionMethod = proposalTuple[1][1]
     idString = self._createIdentityString(credDict, clientTransport)
     # OOkay! Lets do the magic!
     retVal = clientTransport.receiveData()
     if not retVal["OK"]:
         gLogger.error("Error while receiving file description", retVal["Message"])
         clientTransport.sendData(S_ERROR("Error while receiving file description: %s" % retVal["Message"]))
         return
     if actionType == "FileTransfer":
         gLogger.warn("Received a file transfer action from %s" % idString)
         clientTransport.sendData(S_OK("Accepted"))
         retVal = self.__forwardFileTransferCall(
             targetService, clientInitArgs, actionMethod, retVal["Value"], clientTransport
         )
     elif actionType == "RPC":
         gLogger.info("Forwarding %s/%s action to %s for %s" % (actionType, actionMethod, targetService, idString))
         retVal = self.__forwardRPCCall(targetService, clientInitArgs, actionMethod, retVal["Value"])
     elif actionType == "Connection" and actionMethod == "new":
         gLogger.info("Initiating a messaging connection to %s for %s" % (targetService, idString))
         retVal = self._msgForwarder.addClient(trid, targetService, clientInitArgs, retVal["Value"])
     else:
         gLogger.warn("Received an invalid %s/%s action from %s" % (actionType, actionMethod, idString))
         retVal = S_ERROR("Unknown type of action (%s)" % actionType)
     # TODO: Send back the data?
     if "rpcStub" in retVal:
         retVal.pop("rpcStub")
     clientTransport.sendData(retVal)
     return retVal