Class: RemotesCommand
- Inherits:
-
SSHCommand
- Object
- GenericCommand
- SSHCommand
- RemotesCommand
- Defined in:
- lib/CommandManager.rb
Constant Summary
Constants inherited from GenericCommand
GenericCommand::ERROR_CLOSE, GenericCommand::ERROR_OPEN
Instance Attribute Summary
Attributes inherited from SSHCommand
Attributes inherited from GenericCommand
#code, #command, #stderr, #stdout
Class Method Summary collapse
-
.run(command, host, remote_dir, logger = nil, stdin = nil, retries = 0, timeout = nil) ⇒ Object
Creates a command and runs it.
- .update_remotes(host, remote_dir, logger = nil) ⇒ Object
Methods inherited from SSHCommand
Methods inherited from GenericCommand
#get_error_message, #initialize, #log, #run, #to_xml
Constructor Details
This class inherits a constructor from SSHCommand
Class Method Details
.run(command, host, remote_dir, logger = nil, stdin = nil, retries = 0, timeout = nil) ⇒ Object
Creates a command and runs it
250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 |
# File 'lib/CommandManager.rb', line 250 def self.run(command, host, remote_dir, logger=nil, stdin=nil, retries=0, timeout=nil) cmd_file = command.split(' ')[0] cmd_string = "'if [ -x \"#{cmd_file}\" ]; then #{command}; else\ exit #{MAGIC_RC}; fi'" cmd = self.new(cmd_string, host, logger, stdin, timeout) cmd.run while cmd.code != 0 and retries != 0 if cmd.code == MAGIC_RC update_remotes(host, remote_dir, logger) end sleep 1 cmd.run retries = retries - 1 end cmd end |
.update_remotes(host, remote_dir, logger = nil) ⇒ Object
284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 |
# File 'lib/CommandManager.rb', line 284 def self.update_remotes(host, remote_dir, logger=nil) if logger != nil logger.call("Remote worker node files not found") logger.call("Updating remotes") end #recreate remote dir structure SSHCommand.run("mkdir -p #{remote_dir}",host,logger) # Use SCP to sync: sync_cmd = "scp -rp #{REMOTES_LOCATION}/* #{host}:#{remote_dir}" # Use rsync to sync: # sync_cmd = "rsync -Laz #{REMOTES_LOCATION} #{host}:#{@remote_dir}" LocalCommand.run(sync_cmd, logger) end |