Class: StudioApi::Appliance::Configuration::Firewall

Inherits:
ActiveResource::Base
  • Object
show all
Extended by:
StudioResource
Defined in:
lib/studio_api/appliance.rb

Instance Method Summary collapse

Methods included from StudioResource

collection_path, element_path, extended, studio_connection, studio_connection=

Instance Method Details

#to_xml(options = {}) ⇒ Object



54
55
56
57
58
59
60
61
62
63
# File 'lib/studio_api/appliance.rb', line 54

def to_xml(options={})
  if enabled == "false"
    "<firewall><enabled>false</enabled></firewall>"
  else
    #open port can be array or single string
    ports = open_port.is_a?(String) ? [open_port] : open_port
    openports_xml = ports.map{ |p| "<open_port>#{p}</open_port>" }.join("") #FIXME escape name
    "<firewall><enabled>true</enabled>#{openports_xml}</firewall>"
  end
end