lib/fog/vcloud/terremark/ecloud/models/internet_service.rb in fog-0.5.2 vs lib/fog/vcloud/terremark/ecloud/models/internet_service.rb in fog-0.5.3

- old
+ new

@@ -33,18 +33,40 @@ else connection.configure_internet_service( href, _compose_service_data, _compose_ip_data ) end end + # disables monitoring for this service + 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 default ping monitoring, use monitor= for more exotic forms (ECV & HTTP) + def enable_ping_monitor + self.monitor = nil + self.save + end + 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] - attributes[:monitor][:http_headers] = attributes[:monitor][:http_headers].split("\n") unless attributes[:monitor][:http_headers].is_a?(Array) + 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]