Class: Fog::Terremark::Shared::InternetService

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/terremark/models/shared/internetservice.rb

Instance Attribute Summary

Attributes inherited from Model

#collection, #connection

Instance Method Summary collapse

Methods inherited from Model

#initialize, #inspect, #reload, #symbolize_keys, #to_json, #wait_for

Methods included from Attributes::ClassMethods

#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes

Methods included from Attributes::InstanceMethods

#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #requires, #requires_one

Constructor Details

This class inherits a constructor from Fog::Model

Instance Method Details

#destroy(delete_public_ip = true) ⇒ Object



18
19
20
21
22
# File 'lib/fog/terremark/models/shared/internetservice.rb', line 18

def destroy(delete_public_ip=true)
  connection.delete_internet_service(self.Id)
  connection.delete_public_ip(self.PublicIpAddress["Id"]) if delete_public_ip
true
end

#saveObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/fog/terremark/models/shared/internetservice.rb', line 24

def save
  requires :Name, :Protocol, :Port
  if not public_ip_address_id
    #Create the first internet service and allocate public IP
    data = connection.create_internet_service(
        vdc = connection.default_vdc_id,
        name = self.Name,
        protocol = self.Protocol,
        port = self.Port,
        options = {
                'Enabled' => 'true',
                "Description" => self.Name
        }
    )
  else
    #create additional services to existing Public IP
    data = connection.add_internet_service(
              ip_id = public_ip_address_id,
              name = self.Name,
              protocol = self.Protocol,
              port = self.Port,
              options = {
                'Enabled' => 'true',
                "Description" => self.Name
                }
            )           
    end
    merge_attributes(data.body)
    true
end