2011-09-16 08:57:00 -04:00
|
|
|
require 'fog/core/collection'
|
|
|
|
require 'fog/vmfusion/models/compute/server'
|
|
|
|
|
|
|
|
module Fog
|
|
|
|
module Compute
|
|
|
|
class Vmfusion
|
|
|
|
|
|
|
|
class Servers < Fog::Collection
|
|
|
|
|
|
|
|
model Fog::Compute::Vmfusion::Server
|
|
|
|
|
2011-11-22 02:21:31 -05:00
|
|
|
def all(filter = nil)
|
2011-09-16 08:57:00 -04:00
|
|
|
|
2011-11-22 02:21:31 -05:00
|
|
|
data = []
|
2011-09-16 08:57:00 -04:00
|
|
|
|
2011-11-22 02:21:31 -05:00
|
|
|
states = ::Fission::VM.all_with_status.data
|
|
|
|
|
|
|
|
filter = {} if filter.nil?
|
2011-09-16 08:57:00 -04:00
|
|
|
unless filter.has_key?(:name)
|
2011-11-22 02:21:31 -05:00
|
|
|
vms=::Fission::VM.all.data
|
2011-09-23 10:59:23 -04:00
|
|
|
vms.each do |vm|
|
2011-11-22 02:21:31 -05:00
|
|
|
data << { :raw => { :fission => vm,
|
|
|
|
:state => states[vm.name] } }
|
2011-09-16 08:57:00 -04:00
|
|
|
end
|
|
|
|
else
|
2011-11-22 02:21:31 -05:00
|
|
|
data << { :raw => { :fission => ::Fission::VM.new(filter[:name]),
|
|
|
|
:state => states[filter[:name]] } }
|
2011-09-23 10:59:23 -04:00
|
|
|
end
|
2011-09-16 08:57:00 -04:00
|
|
|
|
|
|
|
load(data)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
def get(name)
|
2011-11-22 02:21:31 -05:00
|
|
|
self.all(:name => name).first
|
2011-09-16 08:57:00 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2011-09-23 10:59:23 -04:00
|
|
|
end
|