| Tomer Filiba tomerfiliba.com |
Hi,
I would like to use RPyC service model while deploying new server via zerodeploy,
however I don't see any API available for this. Tried to add my service TestService to DeployedServer.connect() but it doesn't work.
Am I missing something?
Appreciate your help.
class TestService(Service):
def on_connect(self):
pass
def on_disconnect(self):
pass
def exposed_GetHostName(self): # this is an exposed method
with open("/etc/hostname","r") as hostnameFile:
return "Remote hostname is: "%hostnameFile.read().strip()
def get_question(self): # while this method is not exposed
return "what is the airspeed velocity of an unladen swallow?"
def connectToServer(hostName, userName):
print "Connecting to '%s' with user name '%s' ..."%(hostName, userName)
mach = SshMachine(hostName, user=userName)
print "Connected!"
print "Remote date and time: [ %s ]"%( mach["date"]().strip() )
print "Deploying RPyC..."
server = DeployedServer(mach)
print "RPyC server deployed and started. Connecting to local RPyC..."
conn1 = server.connect(TestService)
print "SSH tunnel to local RPyC server on '%s' created " % (hostName)
return server, conn1
def run():
serverConn, rpyc_conn = connectToServer(hostName="server-name", userName="user")
print "server returned:"+rpyc_conn.root.GetHostName()
if __name__ == "__main__":
run()
Error:
....
File "/tmp/tmp.LpfT7Bf2m4/rpyc/core/protocol.py", line 501, in _access_attr
return accessor(obj, name, *args)
File "/tmp/tmp.LpfT7Bf2m4/rpyc/core/service.py", line 69, in _rpyc_getattr
return getattr(self, name)
AttributeError: 'SlaveService' object has no attribute 'exposed_GetHostName'