Class: BBGAPI::Servers

Inherits:
Object
  • Object
show all
Defined in:
lib/bbgapi/servers.rb

Class Method Summary collapse

Class Method Details

.fulllistObject



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/bbgapi/servers.rb', line 43

def self.fulllist
  partial = '/api/servers'
  api_response = BBGAPI::Client.geturl(partial,"")
  nodes = api_response.sort_by {|var| var["hostname"]}
  nodes.each {|x|
    puts "\n"
    puts "Name:        #{x["hostname"]}"
    puts "ID:          #{x["id"]}"
    puts "Description: #{x["description"]}"
    puts "IP:          #{x["ips"].first["address"]}"
    puts "Status:      #{x["status"]}"
    puts "CPU:         #{x["cpu"]}"
    puts "Memory:      #{x["memory"]}"
    puts "Storage:     #{x["storage"]}"
    puts "Load Balancers:"
    x["lb_applications"].each {|y|
      puts y["lb_application_name"]
    }
  }
  puts "\n"

end

.listObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/bbgapi/servers.rb', line 14

def self.list
  partial = '/api/servers'
  api_response = BBGAPI::Client.geturl(partial,"")
  nodes = api_response.sort_by {|var| var["hostname"]}
  nodes.each {|x|
    puts "\n"
    puts "Name:        #{x["hostname"]}"
    puts "ID:          #{x["id"]}"
    if not x["description"].to_s.empty?
      puts "Description: #{x["description"]}"
    end
  }
  puts "\n"

  choose do |menu|
    menu.prompt = "Would you like to list extended information?"

    menu.choices(:yes) {self.fulllist}
    menu.choices(:no)
  end
end


4
5
6
7
8
9
10
11
12
# File 'lib/bbgapi/servers.rb', line 4

def self.menulist
  choose do |menu|
    puts "Servers"
    puts "----------------------------------------"
    menu.prompt = "Which Action?"

    menu.choices(:list) {self.list}
  end
end

.rawObject



36
37
38
39
40
41
# File 'lib/bbgapi/servers.rb', line 36

def self.raw
  partial = '/api/servers'
  api_response = BBGAPI::Client.geturl(partial,"")
  nodes = api_response.sort_by {|var| var["hostname"]}
  return nodes
end