Class: WeBee::Rack

Inherits:
Object
  • Object
show all
Includes:
SAXMachine
Defined in:
lib/webee.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from SAXMachine

#old_parse, #parse

Instance Attribute Details

#datacenter_idObject

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

#deleteObject



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

#machinesObject



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