class StudioApi::Appliance::Configuration

Represent appliance configuration @example set LVM in appliance ( require rails 3 for newly initialized variables )

configuration = appliance.configuration
configuration.lvm.enabled = "true"
configuration.lvm.volume_group = "fooVG"
configuration.lvm.volumes = [ { :path => "/test", :size => "500M" } ]
configuration.save

Public Class Methods

find(id, prefix_options={}) click to toggle source
   # File lib/studio_api/appliance.rb
38 def self.find (id, prefix_options={})
39   request_str = "/appliances/#{id.to_i}/configuration"
40   response = GenericRequest.new(studio_connection).get request_str
41   Configuration.parse response
42 end

Private Class Methods

parse(response) click to toggle source
   # File lib/studio_api/appliance.rb
67 def self.parse response
68   tree = XmlSimple.xml_in(response, "ForceArray" => ["tag","user","eula","autostart","database","volume"])
69   tree["tags"] = tree["tags"]["tag"].reduce({}){ |acc,t| acc.merge :tag => t} if tree["tags"]
70   tree["users"] = tree["users"]["user"]
71   tree["eulas"] = tree["eulas"]["eula"]
72   tree["autostarts"] = tree["autostarts"]["autostart"] if tree["autostarts"]
73   if tree["databases"]
74     tree["databases"]=  tree["databases"]["database"] 
75     tree["databases"].each do |d|
76       d["users"] = d["users"]["user"] if d["users"]
77     end
78   end
79   tree["lvm"]["volumes"] = tree["lvm"]["volumes"]["volume"] if tree["lvm"] && tree["lvm"]["volumes"]
80   Firewall.studio_connection = studio_connection
81   if defined? ActiveModel #we are in rails3, so set model persistent
82     Configuration.new tree,true
83   else
84     Configuration.new tree
85   end
86 end

Public Instance Methods

update() click to toggle source
   # File lib/studio_api/appliance.rb
44 def update
45   appliance_id = id
46   attributes.delete "id"
47   rq = GenericRequest.new self.class.studio_connection
48   rq.put "/appliances/#{appliance_id.to_i}/configuration", :__raw => to_xml
49   attributes["id"] = appliance_id
50 end