Feature #2288 » fog.patch
fog-1.9.0/lib/fog/ovirt/compute.rb 2013-03-08 18:07:36.542000080 -0500 | ||
---|---|---|
collection :interfaces
|
||
model :volume
|
||
collection :volumes
|
||
model :quota
|
||
collection :quotas
|
||
request_path 'fog/ovirt/requests/compute'
|
||
... | ... | |
request :list_template_volumes
|
||
request :add_volume
|
||
request :destroy_volume
|
||
request :list_quotas
|
||
request :get_quota
|
||
module Shared
|
||
# converts an OVIRT object into an hash for fog to consume.
|
fog-1.9.0/lib/fog/ovirt/models/compute/quota.rb 2013-03-08 03:26:52.040002152 -0500 | ||
---|---|---|
module Fog
|
||
module Compute
|
||
class Ovirt
|
||
class Quota < Fog::Model
|
||
identity :id
|
||
attribute :name
|
||
attribute :description
|
||
def to_s
|
||
name
|
||
end
|
||
end
|
||
end
|
||
end
|
||
end
|
||
fog-1.9.0/lib/fog/ovirt/models/compute/quotas.rb 2013-03-08 03:40:57.589999878 -0500 | ||
---|---|---|
require 'fog/core/collection'
|
||
require 'fog/ovirt/models/compute/quota'
|
||
module Fog
|
||
module Compute
|
||
class Ovirt
|
||
class Quotas < Fog::Collection
|
||
model Fog::Compute::Ovirt::Quota
|
||
def all(filters = {})
|
||
load service.list_quotas(filters)
|
||
end
|
||
def get(id)
|
||
new service.get_quota(id)
|
||
end
|
||
end
|
||
end
|
||
end
|
||
end
|
||
fog-1.9.0/lib/fog/ovirt/models/compute/server.rb 2013-03-08 02:25:00.999998447 -0500 | ||
---|---|---|
attribute :interfaces
|
||
attribute :volumes
|
||
attribute :raw
|
||
attribute :quota
|
||
|
||
def ready?
|
||
!(status =~ /down/i)
|
||
end
|
fog-1.9.0/lib/fog/ovirt/models/compute/volume.rb 2013-03-08 18:04:16.406000061 -0500 | ||
---|---|---|
attribute :format
|
||
attribute :sparse
|
||
attribute :size_gb
|
||
attribute :quota
|
||
def size_gb
|
||
attributes[:size_gb] ||= attributes[:size].to_i / DISK_SIZE_TO_GB if attributes[:size]
|
fog-1.9.0/lib/fog/ovirt/requests/compute/get_quota.rb 2013-03-08 01:24:51.570004916 -0500 | ||
---|---|---|
module Fog
|
||
module Compute
|
||
class Ovirt
|
||
class Real
|
||
def get_quota(id)
|
||
ovirt_attrs client.quota(id)
|
||
end
|
||
end
|
||
class Mock
|
||
def get_quota(id)
|
||
xml = read_xml('quota.xml')
|
||
ovirt_attrs OVIRT::Quota::new(self, Nokogiri::XML(xml).root)
|
||
end
|
||
end
|
||
end
|
||
end
|
||
end
|
||
fog-1.9.0/lib/fog/ovirt/requests/compute/list_quotas.rb 2013-03-08 01:25:18.186000764 -0500 | ||
---|---|---|
module Fog
|
||
module Compute
|
||
class Ovirt
|
||
class Real
|
||
def list_quotas(filters = {})
|
||
client.quotas(filters).map {|ovirt_obj| ovirt_attrs ovirt_obj}
|
||
end
|
||
end
|
||
class Mock
|
||
def list_quotas(filters = {})
|
||
xml = read_xml 'quotas.xml'
|
||
Nokogiri::XML(xml).xpath('/quotas/quota').collect do |q|
|
||
ovirt_attrs OVIRT::Quotas::new(self, q)
|
||
end
|
||
end
|
||
end
|
||
end
|
||
end
|
||
end
|
||