2 # This file contains functions to perform the
3 # functionalities of trivial paralllization
8 # The following library are REQUIRED!
9 # Read the README file for more info.
15 # function downloads files from the cluster machines to a
16 # designated location on the local machine
17 def download (addr, login, passwd, from)
21 # Checking if the location exists
22 while check_status == 0
23 puts "Where do you want to save the files to?"
24 puts "You are currently in #{Dir.getwd}"
27 save_path = gets.chomp
28 data_file_path = from + "/data/."
30 if File.directory?(save_path) then
31 # You are set to donwload
35 puts "Error!: #{save_path} does not exist!"
36 puts "Try again?(y/n)"
38 if ans == "y" || ans == "Y" then
41 puts "Error!: Could not find the save path: #{save_path}"
46 Net::SCP.start( addr, login, :password => passwd ) do |scp|
47 channel = scp.download( data_file_path , save_path, :recursive => true )
48 puts "Downloading ..."
50 puts "Download Complete!"
57 # uploads files from a user specified path, to a default remote location on
59 def upload (addr, login, passwd, to)
63 while check_status == 0
64 # ask for the file to upload
65 puts "Where is the file you wish to upload?"
66 puts "****************************************************"
67 puts "* REMEMBER TO PUT THE FULL OR RELATIVE PATH *"
68 puts "****************************************************"
69 puts "You are currently in #{Dir.getwd}"
70 puts "Here are the contents of the dir:"
72 Dir.glob("*") do |f| puts f end
74 local_path = gets.chomp
76 # check if the file exists
77 if File.exists?(local_path) then
78 # you are set to upload
82 # if the file doesn't exist ask again
83 puts "Error!: #{local_path} does not exist!"
84 puts "Try again?(y/n)"
86 if ans == "y" || ans == "Y" then
89 puts "Error!: Could not find the file: #{local_path}"
94 # if file is found, we are ready to upload
96 Net::SCP.start( addr, login, :password => passwd) do |scp|
97 channel = scp.upload( local_path, to)
100 puts "Upload Complete"
108 def exejob( addr, login, passwd, path_of_exe)
109 puts "Have you uploaded the job file?(y/n)"
117 if ans == "y" || ans == "Y" then
118 puts "OK! starting the job"
119 # ssh into the gateway and start the "executer!"
120 Net::SSH.start( addr, login, :password => passwd) do |ssh|
121 # the following passes a bash command to start the executer,
122 # it takes argumenst of username, password, and job file
123 ssh.exec("ruby #{path_of_exe} #{login} #{passwd} job.xml")
128 puts "Where is the job file you wish to start processing?"
129 puts "You are currently in #{Dir.getwd}"
130 puts "Here are the contents of the dir:"
132 jobfile_path = gets.chomp
134 # Checking if the file exists
135 while check_status == 0
136 if File.exists?(jobfile_path) then
137 # You are set to upload
140 puts "Error!: #{jobfile_path} does not exist!"
141 puts "Try again?(y/n)"
143 if ans == "y" || ans == "Y" then
146 puts "Error!: Could not find the job file: #{jobfile_path}"
150 end # end of 2nd while loop (check if jobfile exists on local)
151 end # end of if else in 1st while loop
152 end # end of 1st while loop (check if exejob is done)