mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
bca7179e2e
This patch has several purposes. Firstly this patch brings the Fog vmfusion provider in line with the recently released v0.4.0 version of the Fission project by aligning various method names. During this sync up servers.rb was modified to obtain all VM states and passing them to the raw object instead of doing so when attributes are obtained inside server.rb. This improves performance a lot since it reduces the need to run vmrun for every VM on the system. Other changes being made to the provider are so that it returns data and acts more similar to the vsphere provider while still keeping backward compatibility with the original implementation; which was to be more similar to various cloud providers.
41 lines
911 B
Ruby
41 lines
911 B
Ruby
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
|
|
|
|
def all(filter = nil)
|
|
|
|
data = []
|
|
|
|
states = ::Fission::VM.all_with_status.data
|
|
|
|
filter = {} if filter.nil?
|
|
unless filter.has_key?(:name)
|
|
vms=::Fission::VM.all.data
|
|
vms.each do |vm|
|
|
data << { :raw => { :fission => vm,
|
|
:state => states[vm.name] } }
|
|
end
|
|
else
|
|
data << { :raw => { :fission => ::Fission::VM.new(filter[:name]),
|
|
:state => states[filter[:name]] } }
|
|
end
|
|
|
|
load(data)
|
|
|
|
end
|
|
|
|
def get(name)
|
|
self.all(:name => name).first
|
|
end
|
|
|
|
end
|
|
end
|
|
end
|
|
end
|