0

I am a complete beginner with Python and fabric. I have the following code:

def initialise_clients( hostlist): 
 env.roledefs['clients']=hostlist
 print hostlist 
 print("Setting up deployment: running on %d nodes \n" % len(hostlist))
 create_jar()


def init_server(host): 
 env.roledefs['server'] = host
 print "Initialising Server " + host

Instantiated as :

 def start_experiment(nb_clients , nb_machines , nb_operations  , trx_length , nb_reads ,  nb_writes ,     
  dataset , server_host  , server_port , hostclients): 
  print("Running Experiment")
  address = server_host + ':' + server_port
  execute(init_server,address)
  execute(initialise_clients,hostclients)
  execute(create_server, server_port )

The create Server method is:

 @roles('server')
 def create_server( port): 
  print("Creating Server")
  print env.host
  print(port)
  code_dir = '/net/work/evaluation/'
  with lcd(code_dir): 
     run("java -jar server.jar " + port + " > log_server.txt ")
     print("Server Initialised - Waiting for NFS to propagate ")

The problem that I have is this: when I execute the create_server task: I have this: [t] Executing task 'create_server' My guess is that it's a string problem due to my being new to python

Fatal error: Name lookup failed for t

Underlying exception: Name or service not known

Aborting.

which corresponds to the first character of the host I pass in (as a string 't...'). Why is this the case?

I call start_experiment with server_host defined as "name.server.org"

user1018513
  • 1,682
  • 1
  • 20
  • 42

1 Answers1

0

Your issue is in the last few lines of create_server(). Take a look at these two lines from that function:

with lcd(code_dir):
    run("java -jar server.jar " + port + " > log_server.txt ")

The run() command is being executed on the remote server (specified by env.host), but the with lcd(code_dir): bit enforces a certain directory on the local machine, not on the remote server.

The error you're getting says that you're trying to use an unknown name or service. In this case, it's pretty likely the program is unable to find server.jar. The reason for this is that you haven't specified the current directory on the remote machine (where the run() command is being executed). So, changing the lcd() to a cd() should solve your problem:

with cd(code_dir):
    run("java -jar server.jar " + port + " > log_server.txt ")
mculhane
  • 923
  • 7
  • 7