mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
add ovirt quota support
This commit is contained in:
parent
62d8b31f91
commit
268f126b5f
7 changed files with 92 additions and 1 deletions
lib/fog/ovirt
|
@ -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.
|
||||
|
|
21
lib/fog/ovirt/models/compute/quota.rb
Normal file
21
lib/fog/ovirt/models/compute/quota.rb
Normal 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
|
||||
|
24
lib/fog/ovirt/models/compute/quotas.rb
Normal file
24
lib/fog/ovirt/models/compute/quotas.rb
Normal 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
|
||||
|
|
@ -27,7 +27,8 @@ module Fog
|
|||
attribute :interfaces
|
||||
attribute :volumes
|
||||
attribute :raw
|
||||
|
||||
attribute :quota
|
||||
|
||||
def ready?
|
||||
!(status =~ /down/i)
|
||||
end
|
||||
|
|
|
@ -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]
|
||||
|
|
19
lib/fog/ovirt/requests/compute/get_quota.rb
Normal file
19
lib/fog/ovirt/requests/compute/get_quota.rb
Normal 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
|
||||
|
21
lib/fog/ovirt/requests/compute/list_quotas.rb
Normal file
21
lib/fog/ovirt/requests/compute/list_quotas.rb
Normal 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
|
||||
|
Loading…
Add table
Reference in a new issue