2011-09-26 02:41:54 -04:00
|
|
|
require 'fog/core/collection'
|
|
|
|
require 'fog/openstack/models/compute/server'
|
|
|
|
|
|
|
|
module Fog
|
|
|
|
module Compute
|
|
|
|
class OpenStack
|
|
|
|
|
|
|
|
class Servers < Fog::Collection
|
|
|
|
|
2012-06-26 17:30:31 -04:00
|
|
|
attribute :filters
|
|
|
|
|
2011-09-26 02:41:54 -04:00
|
|
|
model Fog::Compute::OpenStack::Server
|
|
|
|
|
2012-06-26 17:30:31 -04:00
|
|
|
def initialize(attributes)
|
|
|
|
self.filters ||= {}
|
|
|
|
super
|
|
|
|
end
|
|
|
|
|
|
|
|
def all(filters = filters)
|
|
|
|
self.filters = filters
|
2012-12-22 18:24:36 -05:00
|
|
|
data = service.list_servers_detail(filters).body['servers']
|
2011-09-26 02:41:54 -04:00
|
|
|
load(data)
|
|
|
|
end
|
|
|
|
|
|
|
|
def bootstrap(new_attributes = {})
|
|
|
|
server = create(new_attributes)
|
|
|
|
server.wait_for { ready? }
|
|
|
|
server.setup(:password => server.password)
|
|
|
|
server
|
|
|
|
end
|
|
|
|
|
|
|
|
def get(server_id)
|
2012-12-22 18:24:36 -05:00
|
|
|
if server = service.get_server_details(server_id).body['server']
|
2011-09-26 02:41:54 -04:00
|
|
|
new(server)
|
|
|
|
end
|
|
|
|
rescue Fog::Compute::OpenStack::NotFound
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|