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

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

Instance Method Summary collapse

Instance Method Details

#destroy(delete_public_ip = true) ⇒ Object



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

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

#saveObject



22
23
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
# File 'lib/fog/terremark/models/shared/internetservice.rb', line 22

def save
  requires :Name, :Protocol, :Port
  if not public_ip_address_id
    #Create the first internet service and allocate public IP
    data = service.create_internet_service(
        vdc = service.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 = service.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