9
10
11
12
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
|
# File 'lib/hetzner-cli/command/distributions.rb', line 9
def _distributions(ip,options)
user = options['user']
password = options['password']
robot_url = options['robot_url']
conn = Faraday.new(:url => robot_url) do |faraday|
faraday.request :url_encoded faraday.adapter Faraday.default_adapter end
conn.basic_auth(user,password)
begin
puts "[#{ip}] Available distributions:"
response = conn.get("/boot/#{ip}")
boot_info = JSON.parse(response.body)
distributions = boot_info['boot']['linux']['dist']
distributions.each do |distro|
puts "[#{ip}] - #{distro}"
end
rescue Faraday::Error::ConnectionFailed => ex
$stderr.puts "Error logging in #{ex}"
end
end
|