Method: HP::Cloud::ServerHelper#initialize

Defined in:
lib/hpcloud/server_helper.rb

#initialize(connection, foggy = nil) ⇒ ServerHelper

Returns a new instance of ServerHelper.



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/hpcloud/server_helper.rb', line 36

def initialize(connection, foggy = nil)
  super(connection, foggy)
  @windows = false
  @private_image = false
  if foggy.nil?
    @meta = HP::Cloud::Metadata.new(nil)
    return
  end
  @id = foggy.id
  @name = foggy.name
  @flavor = foggy.flavor_id
  @image = foggy.image_id
  @public_ip = foggy.public_ip_address
  @private_ip = foggy.private_ip_address
  @keyname = foggy.key_name
  unless foggy.security_groups.nil?
    @security_groups = foggy.security_groups.map {|sg| sg["name"]}.join(', ')
  end
  @created = foggy.created_at
  @state = foggy.state
  @tenantid = foggy.tenant_id
  @network_name = foggy.network_name
  @networks = ""
  @ips = ""
  unless foggy.addresses.nil?
    begin
      foggy.addresses.keys.each { |x|
        @networks += "," unless @networks.empty?
        @networks += x.to_s
        foggy.addresses[x].each { |y|
          unless y["addr"].nil?
            @ips += "," unless @ips.empty?
            @ips += y["addr"].to_s
          end
        }
      }
    rescue Exception => e
      warn "Error parsing addresses: " + e.to_s
    end
  end
  @meta = HP::Cloud::Metadata.new(foggy.)
end