2012-11-14 08:31:02 -05:00
|
|
|
require 'fog/core/collection'
|
|
|
|
require 'fog/vsphere/models/compute/volume'
|
|
|
|
|
|
|
|
module Fog
|
|
|
|
module Compute
|
|
|
|
class Vsphere
|
|
|
|
|
|
|
|
class Volumes < Fog::Collection
|
|
|
|
|
|
|
|
model Fog::Compute::Vsphere::Volume
|
|
|
|
|
|
|
|
attr_accessor :vm
|
|
|
|
|
|
|
|
def all(filters = {})
|
|
|
|
requires :vm
|
|
|
|
case vm
|
|
|
|
when Fog::Compute::Vsphere::Server
|
2012-12-22 18:21:53 -05:00
|
|
|
load service.list_vm_volumes(vm.id)
|
2012-11-14 08:31:02 -05:00
|
|
|
when Fog::Compute::Vsphere::Template
|
2012-12-22 18:21:53 -05:00
|
|
|
load service.list_template_volumes(vm.id)
|
2012-11-14 08:31:02 -05:00
|
|
|
else
|
|
|
|
raise 'volumes should have vm or template'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def get(id)
|
2012-12-22 18:21:53 -05:00
|
|
|
new service.get_volume(id)
|
2012-11-14 08:31:02 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|