Class: Chef::Provisioning::Transport

Inherits:
Object
  • Object
show all
Defined in:
lib/chef/provisioning/transport.rb,
lib/chef/provisioning/transport/ssh.rb,
lib/chef/provisioning/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)


53
54
55
# File 'lib/chef/provisioning/transport.rb', line 53

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

#configObject

Config hash, including :log_level and :logger as keys



58
59
60
# File 'lib/chef/provisioning/transport.rb', line 58

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

#disconnectObject



49
50
51
# File 'lib/chef/provisioning/transport.rb', line 49

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

#download_file(path, local_path) ⇒ Object



37
38
39
# File 'lib/chef/provisioning/transport.rb', line 37

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)


24
25
26
# File 'lib/chef/provisioning/transport.rb', line 24

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

#make_url_available_to_remote(local_url) ⇒ Object



45
46
47
# File 'lib/chef/provisioning/transport.rb', line 45

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

#read_file(path) ⇒ Object

TODO: make exceptions for these instead of just returning nil / silently failing



29
30
31
# File 'lib/chef/provisioning/transport.rb', line 29

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

#upload_file(local_path, path) ⇒ Object



41
42
43
# File 'lib/chef/provisioning/transport.rb', line 41

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

#write_file(path, content) ⇒ Object



33
34
35
# File 'lib/chef/provisioning/transport.rb', line 33

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