Class: VagrantPlugins::SecuredCloud::Command::SshConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/secured-cloud-vagrant/commands/ssh_config.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.synopsisObject



9
10
11
# File 'lib/secured-cloud-vagrant/commands/ssh_config.rb', line 9

def self.synopsis
	"Outputs OpenSSH valid configuration to connect to the machine"
end

Instance Method Details

#executeObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/secured-cloud-vagrant/commands/ssh_config.rb', line 13

def execute
	options = {}
  
	opts = OptionParser.new do |o|
		o.banner = "Usage: vagrant ssh-config [vm-name] [--host name]"
		o.separator ""
  
		o.on("--host COMMAND", "Name the host for the config..") do |h|
			options[:host] = h
		end
	end
  
	argv = parse_options(opts)
	return if !argv
  
	with_target_vms(argv, :single_target => true) do |machine|
		env = machine.action(:read_ssh_info)
		
		unless env[:vm_conn_info].nil? then
		   env[:ui].info(I18n.t('secured_cloud_vagrant.commands.vm-config', :host_name => env[:vm_conn_info][:host], 
             :port => env[:vm_conn_info][:port], :username => env[:vm_conn_info][:username]))
       end 
	end
  
	# Success, exit status 0
	0
end