2012-05-08 13:01:13 -04:00
|
|
|
require 'fog/core/collection'
|
|
|
|
require 'fog/cloudstack/models/compute/server'
|
|
|
|
|
|
|
|
module Fog
|
|
|
|
module Compute
|
|
|
|
class Cloudstack
|
|
|
|
|
|
|
|
class Servers < Fog::Collection
|
|
|
|
|
|
|
|
model Fog::Compute::Cloudstack::Server
|
|
|
|
|
|
|
|
def all
|
2012-12-22 18:28:53 -05:00
|
|
|
data = service.list_virtual_machines["listvirtualmachinesresponse"]["virtualmachine"] || []
|
2012-05-08 13:01:13 -04:00
|
|
|
load(data)
|
|
|
|
end
|
|
|
|
|
|
|
|
def bootstrap(new_attributes = {})
|
|
|
|
server = create(new_attributes)
|
|
|
|
server.wait_for { ready? }
|
|
|
|
server
|
|
|
|
end
|
|
|
|
|
|
|
|
def get(server_id)
|
2012-12-22 18:28:53 -05:00
|
|
|
if server = service.list_virtual_machines('id' => server_id)["listvirtualmachinesresponse"]["virtualmachine"].first
|
2012-05-08 13:01:13 -04:00
|
|
|
new(server)
|
|
|
|
end
|
|
|
|
rescue Fog::Compute::Cloudstack::BadRequest
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|