Class: ChefMetal::Transport

Inherits:
Object
  • Object
show all
Defined in:
lib/chef_metal/transport.rb,
lib/chef_metal/transport/ssh.rb,
lib/chef_metal/transport/winrm.rb

Direct Known Subclasses

SSH, WinRM

Defined Under Namespace

Classes: SSH, WinRM

Constant Summary collapse

DEFAULT_TIMEOUT =
15*60

Instance Method Summary collapse

Instance Method Details

#available?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/chef_metal/transport.rb', line 46

def available?
  raise "available? not overridden on #{self.class}"
end

#configObject

Config hash, including :log_level and :logger as keys



51
52
53
# File 'lib/chef_metal/transport.rb', line 51

def config
  raise "config not overridden on #{self.class}"
end

#disconnectObject



42
43
44
# File 'lib/chef_metal/transport.rb', line 42

def disconnect
  raise "disconnect not overridden on #{self.class}"
end

#download_file(path, local_path) ⇒ Object



30
31
32
# File 'lib/chef_metal/transport.rb', line 30

def download_file(path, local_path)
  IO.write(local_path, read_file(path))
end

#execute(command, options = {}) ⇒ Object

Execute a program on the remote host.

Arguments

command: command to run. May be a shell-escaped string or a pre-split array containing [PROGRAM, ARG1, ARG2, …]. options: hash of options, including but not limited to:

:timeout => NUM_SECONDS - time to wait before program finishes (throws an exception otherwise).  Set to nil or 0 to run with no timeout.  Defaults to 15 minutes.
:stream => BOOLEAN - true to stream stdout and stderr to the console.
:stream => BLOCK - block to stream stdout and stderr to (block.call(stdout_chunk, stderr_chunk))
:stream_stdout => FD - FD to stream stdout to (defaults to IO.stdout)
:stream_stderr => FD - FD to stream stderr to (defaults to IO.stderr)
:read_only => BOOLEAN - true if command is guaranteed not to change system state (useful for Docker)


18
19
20
# File 'lib/chef_metal/transport.rb', line 18

def execute(command, options = {})
  raise "execute not overridden on #{self.class}"
end

#make_url_available_to_remote(local_url) ⇒ Object



38
39
40
# File 'lib/chef_metal/transport.rb', line 38

def make_url_available_to_remote(local_url)
  raise "make_url_available_to_remote not overridden on #{self.class}"
end

#read_file(path) ⇒ Object



22
23
24
# File 'lib/chef_metal/transport.rb', line 22

def read_file(path)
  raise "read_file not overridden on #{self.class}"
end

#upload_file(local_path, path) ⇒ Object



34
35
36
# File 'lib/chef_metal/transport.rb', line 34

def upload_file(local_path, path)
  write_file(path, IO.read(local_path))
end

#write_file(path, content) ⇒ Object



26
27
28
# File 'lib/chef_metal/transport.rb', line 26

def write_file(path, content)
  raise "write_file not overridden on #{self.class}"
end