Class: Fog::Compute::Aliyun::EipAddress

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/aliyun/models/compute/eip_address.rb

Instance Method Summary collapse

Instance Method Details

#associate(new_server, options = {}) ⇒ Object



41
42
43
44
45
46
47
48
49
# File 'lib/fog/aliyun/models/compute/eip_address.rb', line 41

def associate(new_server, options = {})
  if persisted?
    @server = nil
    self.server_id = new_server.id
    service.associate_eip_address(server_id, id, options)
  else
    @server = new_server
  end
end

#destroyObject



19
20
21
22
23
# File 'lib/fog/aliyun/models/compute/eip_address.rb', line 19

def destroy
  requires :id
  service.release_eip_address(id)
  true
end

#disassociate(new_server, options = {}) ⇒ Object



51
52
53
54
55
# File 'lib/fog/aliyun/models/compute/eip_address.rb', line 51

def disassociate(new_server, options = {})
  @server = nil
  self.server_id = new_server.id
  service.unassociate_eip_address(server_id, id, options) if persisted?
end

#ready?Boolean

Returns:

  • (Boolean)


25
26
27
28
# File 'lib/fog/aliyun/models/compute/eip_address.rb', line 25

def ready?
  requires :state
  state == 'Available'
end

#save(options = {}) ⇒ Object



30
31
32
33
34
35
36
37
38
39
# File 'lib/fog/aliyun/models/compute/eip_address.rb', line 30

def save(options = {})
  # raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if persisted?
  # requires :availability_zone
  options[:bandwidth] = bandwidth if bandwidth
  options[:internet_charge_type] = charge_type if charge_type

  data = Fog::JSON.decode(service.allocate_eip_address(options).body)
  merge_attributes(data)
  true
end