add ovirt quota support

This commit is contained in:
Jason Montleon 2013-03-08 15:42:26 -05:00
parent 62d8b31f91
commit 268f126b5f
7 changed files with 92 additions and 1 deletions

View File

@ -16,6 +16,8 @@ module Fog
collection :interfaces
model :volume
collection :volumes
model :quota
collection :quotas
request_path 'fog/ovirt/requests/compute'
@ -43,6 +45,8 @@ module Fog
request :add_volume
request :destroy_volume
request :get_api_version
request :list_quotas
request :get_quota
module Shared
# converts an OVIRT object into an hash for fog to consume.

View File

@ -0,0 +1,21 @@
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

View File

@ -0,0 +1,24 @@
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

View File

@ -27,7 +27,8 @@ module Fog
attribute :interfaces
attribute :volumes
attribute :raw
attribute :quota
def ready?
!(status =~ /down/i)
end

View File

@ -16,6 +16,7 @@ module Fog
attribute :sparse
attribute :size_gb
attribute :status
attribute :quota
def size_gb
attributes[:size_gb] ||= attributes[:size].to_i / DISK_SIZE_TO_GB if attributes[:size]

View File

@ -0,0 +1,19 @@
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

View File

@ -0,0 +1,21 @@
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