Class: WeBee::Rack
Instance Attribute Summary collapse
-
#datacenter_id ⇒ Object
Returns the value of attribute datacenter_id.
Class Method Summary collapse
Instance Method Summary collapse
Methods included from SAXMachine
Instance Attribute Details
#datacenter_id ⇒ Object
Returns the value of attribute datacenter_id.
296 297 298 |
# File 'lib/webee.rb', line 296 def datacenter_id @datacenter_id end |
Class Method Details
.create(datacenter_id, attributes) ⇒ Object
309 310 311 312 313 314 315 |
# File 'lib/webee.rb', line 309 def self.create(datacenter_id, attributes) xml = attributes.to_xml(:root => 'rack') res = RestClient.post(Api.url + "/admin/datacenters/#{datacenter_id}/racks", xml, :content_type => :xml, :accept => :xml) r = Rack.parse(res) r.datacenter_id = datacenter_id r end |
Instance Method Details
#add_machine(machine) ⇒ Object
321 322 323 |
# File 'lib/webee.rb', line 321 def add_machine(machine) res = RestClient.post Api.url + "/admin/datacenters/#{datacenter_id}/racks/#{rack_id}/machines", machine.to_xml, :content_type => :xml end |
#delete ⇒ Object
317 318 319 |
# File 'lib/webee.rb', line 317 def delete RestClient.delete(Api.url + "/admin/datacenters/#{datacenter_id}/racks/#{rack_id}", :content_type => :xml) end |
#machines ⇒ Object
325 326 327 328 329 330 331 332 |
# File 'lib/webee.rb', line 325 def machines u = [] doc = Nokogiri.parse(RestClient.get(Api.url + "/admin/datacenters/#{datacenter_id}/racks/#{rack_id}/machines", :content_type => :xml)) doc.search('//machine').each do |node| u << Machine.parse(node.to_s) end u end |