Class: HP::Cloud::AddressHelper

Inherits:
BaseHelper show all
Defined in:
lib/hpcloud/address_helper.rb

Instance Attribute Summary collapse

Attributes inherited from BaseHelper

#connection, #cstatus, #fog

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseHelper

#destroy, #is_valid?, #set_error, #to_hash

Constructor Details

#initialize(connection, foggy = nil) ⇒ AddressHelper

Returns a new instance of AddressHelper.



31
32
33
34
35
36
37
38
# File 'lib/hpcloud/address_helper.rb', line 31

def initialize(connection, foggy = nil)
  super(connection, foggy)
  return if foggy.nil?
  @id = foggy.id
  @ip = foggy.ip
  @fixed_ip = foggy.fixed_ip
  @instance_id = foggy.instance_id
end

Instance Attribute Details

#fixed_ipObject

Returns the value of attribute fixed_ip.



25
26
27
# File 'lib/hpcloud/address_helper.rb', line 25

def fixed_ip
  @fixed_ip
end

#idObject

Returns the value of attribute id.



25
26
27
# File 'lib/hpcloud/address_helper.rb', line 25

def id
  @id
end

#instance_idObject

Returns the value of attribute instance_id.



25
26
27
# File 'lib/hpcloud/address_helper.rb', line 25

def instance_id
  @instance_id
end

#ipObject

Returns the value of attribute ip.



25
26
27
# File 'lib/hpcloud/address_helper.rb', line 25

def ip
  @ip
end

Class Method Details

.get_keysObject



27
28
29
# File 'lib/hpcloud/address_helper.rb', line 27

def self.get_keys()
  return [ "id", "ip", "fixed_ip", "instance_id" ]
end

Instance Method Details

#name=(value) ⇒ Object



58
59
60
# File 'lib/hpcloud/address_helper.rb', line 58

def name=(value)
  ip = value
end

#saveObject



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/hpcloud/address_helper.rb', line 40

def save
  return false if is_valid? == false
  if @fog.nil?
    address = @connection.compute.addresses.create
    if address.nil?
      set_error("Error creating ip address")
      return false
    end
    @id = address.id
    @ip = address.ip
    @fixed_ip = address.fixed_ip
    @fog = address
    return true
  else
    raise "Update not implemented"
  end
end