Feature #2288 » rbovirt.patch
rbovirt-0.0.15/lib/client/quota_api.rb 2013-03-08 08:49:32.853000035 -0500 | ||
---|---|---|
module OVIRT
|
||
class Client
|
||
def quota(quota_id, opts={})
|
||
q = http_get("/datacenters/%s/quotas/%s" % current_datacenter.id % quota_id)
|
||
OVIRT::Quota::new(self, q.root)
|
||
end
|
||
def quotas(opts={})
|
||
http_get("/datacenters/%s/quotas" % CGI.escape(current_datacenter.id)).xpath('/quotas/quota').collect do |q|
|
||
OVIRT::Quota::new(self, q)
|
||
end.compact
|
||
end
|
||
end
|
||
end
|
rbovirt-0.0.15/lib/client/template_api.rb 2013-03-08 07:42:06.987992454 -0500 | ||
---|---|---|
end
|
||
end
|
||
end
|
||
end
|
||
end
|
rbovirt-0.0.15/lib/ovirt/quota.rb 2013-03-08 07:27:04.575999883 -0500 | ||
---|---|---|
module OVIRT
|
||
class Quota < BaseObject
|
||
attr_reader :name, :description
|
||
def initialize(client, xml)
|
||
super(client, xml[:id], xml[:href], (xml/'name').first.text)
|
||
parse_xml_attributes!(xml)
|
||
self
|
||
end
|
||
private
|
||
def parse_xml_attributes!(xml)
|
||
@desciption = ((xml/'description').first.text rescue nil)
|
||
end
|
||
end
|
||
end
|
||
rbovirt-0.0.15/lib/ovirt/vm.rb 2013-03-08 09:50:22.034000077 -0500 | ||
---|---|---|
class VM < BaseObject
|
||
attr_reader :description, :status, :memory, :profile, :display, :host, :cluster, :template
|
||
attr_reader :storage, :cores, :creation_time, :os, :ips, :vnc
|
||
attr_reader :storage, :cores, :creation_time, :os, :ips, :vnc, :quota
|
||
attr_accessor :interfaces, :volumes
|
||
def initialize(client, xml)
|
||
... | ... | |
@interfaces ||= @client.vm_interfaces(id)
|
||
end
|
||
def quota
|
||
@quota ||= @client.quota(id)
|
||
end
|
||
def volumes
|
||
@volumes ||= @client.vm_volumes(id)
|
||
end
|
||
... | ... | |
else
|
||
template_{name_('Blank')}
|
||
end
|
||
if opts[:quota]
|
||
quota_( :id => opts[:quota])
|
||
end
|
||
if opts[:cluster]
|
||
cluster_( :id => opts[:cluster])
|
||
elsif opts[:cluster_name]
|
rbovirt-0.0.15/lib/ovirt/volume.rb 2013-03-08 17:44:34.957000083 -0500 | ||
---|---|---|
module OVIRT
|
||
class Volume < BaseObject
|
||
attr_reader :size, :disk_type, :bootable, :interface, :format, :sparse, :status, :storage_domain, :vm
|
||
attr_reader :size, :disk_type, :bootable, :interface, :format, :sparse, :status, :storage_domain, :vm, :quota
|
||
def initialize(client, xml)
|
||
super(client, xml[:id], xml[:href], (xml/'name').first.text)
|
||
... | ... | |
interface_(opts[:interface] || 'virtio')
|
||
format_(opts[:format] || 'cow')
|
||
sparse_(opts[:sparse] || 'true')
|
||
quota_( :id => opts[:quota])
|
||
}
|
||
end
|
||
Nokogiri::XML(builder.to_xml).root.to_s
|
||
... | ... | |
@format = (xml/'format').first.text
|
||
@sparse = (xml/'sparse').first.text
|
||
@status = (xml/'status').first.text
|
||
@vm = Link::new(@client, (xml/'vm').first[:id], (xml/'vm').first[:href])
|
||
@vm = Link::new(@client, (xml/'vm').first[:id], (xml/'vm').first[:href]) rescue nil
|
||
@quota = ((xml/'quota').first.text rescue nil)
|
||
end
|
||
end
|
||
end
|
||
end
|
rbovirt-0.0.15/lib/rbovirt.rb 2013-03-08 01:23:44.930000075 -0500 | ||
---|---|---|
require "ovirt/volume"
|
||
require "ovirt/interface"
|
||
require "ovirt/network"
|
||
require "ovirt/quota"
|
||
require "client/vm_api"
|
||
require "client/template_api"
|
||
... | ... | |
require "client/host_api"
|
||
require "client/datacenter_api"
|
||
require "client/storage_domain_api"
|
||
require "client/quota_api"
|
||
require "nokogiri"
|
||
require "rest_client"
|