2012-02-10 10:10:49 -05:00
|
|
|
require 'fog/core/collection'
|
|
|
|
require 'fog/joyent/models/compute/server'
|
|
|
|
|
|
|
|
module Fog
|
|
|
|
module Compute
|
|
|
|
|
|
|
|
class Joyent
|
|
|
|
class Servers < Fog::Collection
|
|
|
|
model Fog::Compute::Joyent::Server
|
|
|
|
|
|
|
|
def all
|
2012-12-22 18:25:50 -05:00
|
|
|
load(service.list_machines().body)
|
2012-02-10 10:10:49 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def create(params = {})
|
2012-12-22 18:25:50 -05:00
|
|
|
data = service.create_machine(params).body
|
2012-02-10 10:10:49 -05:00
|
|
|
server = new(data)
|
|
|
|
server
|
|
|
|
end
|
|
|
|
|
2012-10-23 13:00:05 -04:00
|
|
|
def bootstrap(new_attributes = {})
|
|
|
|
server = create(new_attributes)
|
|
|
|
server.wait_for { ready? }
|
|
|
|
server
|
2012-02-10 10:10:49 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def get(machine_id)
|
2012-12-22 18:25:50 -05:00
|
|
|
data = service.get_machine(machine_id).body
|
2013-05-20 19:34:10 -04:00
|
|
|
server = new(data)
|
|
|
|
server.tags = server.list_tags if server.tags.nil?
|
|
|
|
server
|
2012-02-10 10:10:49 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end # Joyent
|
|
|
|
|
|
|
|
end # Compute
|
|
|
|
end # Fog
|