Class: HybridPlatformsConductor::HpcPlugins::Connector::Local

Inherits:
Connector
  • Object
show all
Defined in:
lib/hybrid_platforms_conductor/hpc_plugins/connector/local.rb

Overview

Connector executing remote commands on the local environment in dedicated workspaces (/tmp/hpc_local_workspaces)

Constant Summary

Constants included from LoggerHelpers

LoggerHelpers::LEVELS_MODIFIERS, LoggerHelpers::LEVELS_TO_STDERR

Instance Method Summary collapse

Methods inherited from Connector

#initialize, #prepare_for, #with_connection_to

Methods inherited from Plugin

extend_config_dsl_with, #initialize, valid?

Methods included from LoggerHelpers

#err, #init_loggers, #log_component=, #log_debug?, #log_level=, #out, #section, #set_loggers_format, #stderr_device, #stderr_device=, #stderr_displayed?, #stdout_device, #stdout_device=, #stdout_displayed?, #stdouts_to_s, #with_progress_bar

Constructor Details

This class inherits a constructor from HybridPlatformsConductor::Connector

Instance Method Details

#connectable_nodes_from(nodes) ⇒ Object

Select nodes where this connector can connect.

API
  • This method is mandatory

API
  • @cmd_runner can be used

API
  • @nodes_handler can be used

Parameters
  • nodes (Array<String>): List of candidate nodes

Result
  • Array<String>: List of nodes we can connect to from the candidates



22
23
24
25
# File 'lib/hybrid_platforms_conductor/hpc_plugins/connector/local.rb', line 22

def connectable_nodes_from(nodes)
  @nodes_handler. nodes, :local_node
  nodes.select { |node| @nodes_handler.get_local_node_of(node) }
end

#remote_bash(bash_cmds) ⇒ Object

Run bash commands on a given node.

API
  • This method is mandatory

API
  • If defined, then with_connection_to has been called before this method.

API
  • @cmd_runner can be used

API
  • @nodes_handler can be used

API
  • @node can be used to access the node on which we execute the remote bash

API
  • @timeout can be used to know when the action should fail

API
  • @stdout_io can be used to send stdout output

API
  • @stderr_io can be used to send stderr output

Parameters
  • bash_cmds (String): Bash commands to execute



39
40
41
# File 'lib/hybrid_platforms_conductor/hpc_plugins/connector/local.rb', line 39

def remote_bash(bash_cmds)
  run_cmd "cd #{workspace_for(@node)} ; #{bash_cmds}", force_bash: true
end

#remote_copy(from, to, sudo: false, owner: nil, group: nil) ⇒ Object

Copy a file to the remote node in a directory

API
  • This method is mandatory

API
  • If defined, then with_connection_to has been called before this method.

API
  • @cmd_runner can be used

API
  • @nodes_handler can be used

API
  • @node can be used to access the node on which we execute the remote bash

API
  • @timeout can be used to know when the action should fail

API
  • @stdout_io can be used to send stdout output

API
  • @stderr_io can be used to send stderr output

Parameters
  • from (String): Local file to copy

  • to (String): Remote directory to copy to

  • sudo (Boolean): Do we use sudo to copy? [default: false]

  • owner (String or nil): Owner to be used when copying the files, or nil for current one [default: nil]

  • group (String or nil): Group to be used when copying the files, or nil for current one [default: nil]



72
73
74
75
76
# File 'lib/hybrid_platforms_conductor/hpc_plugins/connector/local.rb', line 72

def remote_copy(from, to, sudo: false, owner: nil, group: nil)
  # If the destination is a relative path, prepend the workspace dir to it.
  to = "#{workspace_for(@node)}/#{to}" unless to.start_with?('/')
  FileUtils.cp_r from, to
end

#remote_interactiveObject

Execute an interactive shell on the remote node

API
  • This method is mandatory

API
  • If defined, then with_connection_to has been called before this method.

API
  • @cmd_runner can be used

API
  • @nodes_handler can be used

API
  • @node can be used to access the node on which we execute the remote bash

API
  • @timeout can be used to know when the action should fail

API
  • @stdout_io can be used to send stdout output

API
  • @stderr_io can be used to send stderr output



52
53
54
# File 'lib/hybrid_platforms_conductor/hpc_plugins/connector/local.rb', line 52

def remote_interactive
  system "cd #{workspace_for(@node)} ; /bin/bash"
end