def joinComplete(self, joinStatus, clientStatusCallback): '''This method gets called when the join is completed either successfully or failed. ''' if joinStatus == True: log.msg("JOIN WAS SUCCESSFUL") self.chordNode.addMessageObserver(self.processMessage) else: log.msg("JOIN FAILED") Utils.showError(joinStatus) # Now call the client's status callback and include the auth payload from the authentication node. if clientStatusCallback is not None: clientStatusCallback(joinStatus, self.chordNode.joinAuthPayload)
def getBootstrapEnclaves(self,bootstrapNodeIP, bootstrapNodePort): '''Ask the passed in bootstrap node what it's enclave is. If it has multiple, this will fail since we don't know the right one then.. in that case it must be specified. ''' bsNodeLocation = NodeLocation(None, bootstrapNodeIP,bootstrapNodePort ) # Get the remote reference (factory, conn) = Utils.getRemoteConnection(bsNodeLocation) bootstrapNodeRef = yield factory.getRootObject() enclaveNames = yield bootstrapNodeRef.callRemote("getEnclaveNames") # Close the connection to closerNodeLoc Utils.disconnect(None, conn) defer.returnValue(enclaveNames)
def generateNodeID(self, aString, enclaveStr='localhost'): '''Generates the node's ID from 'aString' The enclave is added on as the high order bits. The final ID looks like enclaveBits | uniq ID bits So, if the enclave is 0xFF11 and the uniq ID is 0x12345 theId=0xFF1112345 ''' return Utils.generateNodeID(aString, enclaveStr)
def getRemoteIP(self, nodeLocation): '''Ask the nodeLocation node for my IP.''' # Connect to the remote node (factory, conn) = Utils.getRemoteConnection(nodeLocation) try: nodeRef = yield factory.getRootObject() # Ask for the IP myIP = yield nodeRef.callRemote("getClientIP") except Exception, e: log.err() raise e
def isConnected(self, enclaveName='ANY'): '''Returns True | False if the node is connected to the enclave.''' # Get the enclaveID for the name if enclaveName == 'ANY': # Loop through all rc = yield self.chordNode.isConnectedToAnyEnclave() defer.returnValue(rc) else: # Get the enclaveID enclaveId = Utils.getEnclaveIDFromString(enclaveName) (madeOutgoingConnection, madeIncomingConnection) = yield self.chordNode.remote_isConnected(None, enclaveId, True) defer.returnValue(madeOutgoingConnection and madeIncomingConnection)