Class: Vagrant::Cloners::Cloner

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/vagrant-cloner/cloner.rb

Overview

Cloner defines the base API that a cloner has to modify a VM or remote systems. TODO: Create a method that downloads to local and then uploads to VM?

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#enabledObject

Returns the value of attribute enabled.



14
15
16
# File 'lib/vagrant-cloner/cloner.rb', line 14

def enabled
  @enabled
end

#envObject

Returns the value of attribute env.



14
15
16
# File 'lib/vagrant-cloner/cloner.rb', line 14

def env
  @env
end

#optionsObject

Returns the value of attribute options.



14
15
16
# File 'lib/vagrant-cloner/cloner.rb', line 14

def options
  @options
end

#run_orderObject

Returns the value of attribute run_order.



14
15
16
# File 'lib/vagrant-cloner/cloner.rb', line 14

def run_order
  @run_order
end

Instance Method Details

#enabled?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/vagrant-cloner/cloner.rb', line 24

def enabled?
  @enabled.nil? ? false : @enabled
end

#nameObject



16
17
18
# File 'lib/vagrant-cloner/cloner.rb', line 16

def name
  raise "Cloner must define #name and return a string."
end

#scp(*args, &block) ⇒ Object

Opens an SCP connection to an arbitrary server, downloading or uploading to the machine currently in scope (whether the host machine or the VM). Recommended params:

remote_host, remote_user, {:password => remote_password}

See netscp documentation for further method options. github.com/net-ssh/net-scp



54
55
56
# File 'lib/vagrant-cloner/cloner.rb', line 54

def scp(*args, &block)
  Net::SCP.start(*args, &block)
end

#ssh(*args, &block) ⇒ Object

Opens an SSH connection to an arbitrary server and passes it to a supplied block.

See netssh documentation for further method options. net-ssh.github.com/net-ssh/



43
44
45
# File 'lib/vagrant-cloner/cloner.rb', line 43

def ssh(*args, &block)
  Net::SSH.start(*args, &block)
end

#validate!(env, errors) ⇒ Object



20
21
22
# File 'lib/vagrant-cloner/cloner.rb', line 20

def validate!(env, errors)
  true
end

#vmObject

Shorthand for addressing the SSH communicator to the VM. View available methods here: github.com/mitchellh/vagrant/blob/master/plugins/communicators/ssh/communicator.rb



35
36
37
# File 'lib/vagrant-cloner/cloner.rb', line 35

def vm
  env[:vm].channel
end