Class: Fog::Compute::Ecloud::InternetService

Inherits:
Ecloud::Model show all
Defined in:
lib/fog/compute/models/ecloud/internet_service.rb

Instance Attribute Summary

Attributes inherited from Ecloud::Model

#loaded

Attributes inherited from Model

#collection, #connection

Instance Method Summary collapse

Methods inherited from Ecloud::Model

#load_unless_loaded!, #reload

Methods inherited from Model

#initialize, #inspect, #reload, #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

#backup_service_uriObject



83
84
85
86
87
# File 'lib/fog/compute/models/ecloud/internet_service.rb', line 83

def backup_service_uri
  if backup_service_data
    backup_service_data[:Href]
  end
end

#backup_service_uri=(new_value) ⇒ Object



89
90
91
92
93
# File 'lib/fog/compute/models/ecloud/internet_service.rb', line 89

def backup_service_uri=(new_value)
  self.backup_service_data = {
    :Href => new_value
  }
end

#deleteObject



22
23
24
25
26
# File 'lib/fog/compute/models/ecloud/internet_service.rb', line 22

def delete
  requires :href

  connection.delete_internet_service( href )
end

#disable_monitorObject

disables monitoring for this service



38
39
40
41
42
43
44
45
# File 'lib/fog/compute/models/ecloud/internet_service.rb', line 38

def disable_monitor
  if self.monitor and self.monitor[:type] == "Disabled"
    raise RuntimeError.new("Monitoring already disabled")
  else
    self.monitor = {:type => "Disabled", :is_enabled => "true"}
    self.save
  end
end

#enable_ping_monitorObject

enable default ping monitoring, use monitor= for more exotic forms (ECV & HTTP)



48
49
50
51
# File 'lib/fog/compute/models/ecloud/internet_service.rb', line 48

def enable_ping_monitor
  self.monitor = nil
  self.save
end

#monitor=(new_monitor = {}) ⇒ Object



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/fog/compute/models/ecloud/internet_service.rb', line 53

def monitor=(new_monitor = {})
  if new_monitor.nil? || new_monitor.empty?
    attributes[:monitor] = nil
  elsif new_monitor.is_a?(Hash)
    attributes[:monitor] = {}
    attributes[:monitor][:type] = new_monitor[:MonitorType] || new_monitor[:type]
    attributes[:monitor][:url_send_string] = new_monitor[:UrlSendString] || new_monitor[:url_send_string]
    attributes[:monitor][:http_headers] = new_monitor[:HttpHeader] || new_monitor[:http_headers]
    if attributes[:monitor][:http_headers]
      if attributes[:monitor][:http_headers].is_a?(String)
        attributes[:monitor][:http_headers] = attributes[:monitor][:http_headers].split("\n")
      else
        attributes[:monitor][:http_headers] = attributes[:monitor][:http_headers]
      end
    end
    attributes[:monitor][:receive_string] = new_monitor[:ReceiveString] || new_monitor[:receive_string]
    attributes[:monitor][:interval] = new_monitor[:Interval] || new_monitor[:interval]
    attributes[:monitor][:response_timeout] = new_monitor[:ResponseTimeOut] || new_monitor[:response_timeout]
    attributes[:monitor][:downtime] = new_monitor[:DownTime] || new_monitor[:downtime]
    attributes[:monitor][:retries] = new_monitor[:Retries] || new_monitor[:retries]
    attributes[:monitor][:is_enabled] = new_monitor[:IsEnabled] || new_monitor[:is_enabled]
  else
    raise RuntimeError.new("monitor needs to either be nil or a Hash")
  end
end

#nodesObject



79
80
81
# File 'lib/fog/compute/models/ecloud/internet_service.rb', line 79

def nodes
  @nodes ||= Fog::Compute::Ecloud::Nodes.new( :connection => connection, :href => href + "/nodeServices" )
end

#saveObject



28
29
30
31
32
33
34
35
# File 'lib/fog/compute/models/ecloud/internet_service.rb', line 28

def save
  if new_record?
    result = connection.add_internet_service( collection.href, _compose_service_data )
    merge_attributes(result.body)
  else
    connection.configure_internet_service( href, _compose_service_data, _compose_ip_data )
  end
end