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.
351 352 353 |
# File 'lib/webee.rb', line 351 def datacenter_id @datacenter_id end |
Class Method Details
.create(datacenter_id, attributes) ⇒ Object
364 365 366 367 368 369 370 |
# File 'lib/webee.rb', line 364 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
376 377 378 |
# File 'lib/webee.rb', line 376 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
372 373 374 |
# File 'lib/webee.rb', line 372 def delete RestClient.delete(Api.url + "/admin/datacenters/#{datacenter_id}/racks/#{rack_id}", :content_type => :xml) end |
#machines ⇒ Object
380 381 382 383 384 385 386 387 |
# File 'lib/webee.rb', line 380 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 |