91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
# File 'lib/mccloud/provider/core/vm/ssh.rb', line 91
def ssh(command=nil,options={})
extended_command="#{command}"
unless options.nil?
extended_command="screen -R \\\"#{command}\\\"" unless options[:screen].nil?
end
host_ip=self.ip_address
unless host_ip.nil? || host_ip==""
ssh_command="ssh #{ssh_commandline_options(options)} #{host_ip} \"#{extended_command}\""
unless options.nil? || options[:mute]
env.ui.info "[#{@name}] - ssh -p #{@port} #{@user}@#{host_ip} \"#{command}\""
end
if command.nil? || command==""
fg_exec(ssh_command,options)
else
unless options[:password]
bg_exec(ssh_command,options)
else
env.ui.info "[#{@name}] - attempting password login"
real_user = @user
real_user = options[:user] if options[:user]
if options[:user]
Net::SSH.start(host_ip, real_user, :password => options[:password] ) do |ssh2|
result = ssh2.exec!(command)
puts result
end
else
end
end
end
else
env.ui.error "Can't ssh into '#{@name} as we couldn't figure out it's ip-address"
end
end
|