17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/dimension_shell/cli.rb', line 17
def connect(servername)
_initialize_configuration
shell_user = options[:shell_user] || configatron.shell_user || 'root'
@cloud_control = CloudControl.new({
region: options[:region] || configatron.region,
organization: options[:organization] || configatron.organization,
username: options[:username] || configatron.username,
password: options[:password] || configatron.password
})
result = @cloud_control.get_server servername
if result[:reason] then
puts %Q(dsh: API access failed: #{result[:reason]})
elsif result['totalCount'] != 1 then
puts %Q(dsh: No servername matched to "#{servername}".)
else
server = result['server'].first
primary_ipv6 = server['networkInfo']['primaryNic']['ipv6']
puts "dsh: Server \"#{servername}\" found, opening secure shell to #{primary_ipv6}."
Kernel.exec("ssh #{shell_user}@#{primary_ipv6}")
end
end
|